26 require_once
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/imports/class/import.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/modules/import/modules_import.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/import.lib.php';
36 $langs->loadLangs(array(
'exports',
'compta',
'errors'));
42 $entitytoicon = array(
44 'invoice_line' =>
'bill',
46 'order_line' =>
'order',
48 'propal_line' =>
'propal',
49 'intervention' =>
'intervention',
50 'inter_line' =>
'intervention',
52 'member_type' =>
'group',
53 'subscription' =>
'payment',
54 'payment' =>
'payment',
56 'tax_type' =>
'generic',
58 'account' =>
'account',
59 'product' =>
'product',
60 'virtualproduct'=>
'product',
61 'subproduct' =>
'product',
62 'product_supplier_ref' =>
'product',
64 'warehouse' =>
'stock',
66 'stockbatch' =>
'stock',
67 'category' =>
'category',
68 'shipment' =>
'sending',
69 'shipment_line'=>
'sending',
70 'reception'=>
'sending',
71 'reception_line'=>
'sending',
72 'expensereport'=>
'trip',
73 'expensereport_line'=>
'trip',
74 'holiday' =>
'holiday',
75 'contract_line' =>
'contract',
76 'translation' =>
'generic',
82 $entitytolang = array(
84 'company' =>
'Company',
85 'contact' =>
'Contact',
87 'invoice_line' =>
'InvoiceLine',
89 'order_line' =>
'OrderLine',
90 'propal' =>
'Proposal',
91 'propal_line' =>
'ProposalLine',
92 'intervention' =>
'Intervention',
93 'inter_line' =>
'InterLine',
95 'member_type' =>
'MemberType',
96 'subscription' =>
'Subscription',
97 'tax' =>
'SocialContribution',
98 'tax_type' =>
'DictionarySocialContributions',
99 'account' =>
'BankTransactions',
100 'payment' =>
'Payment',
101 'product' =>
'Product',
102 'virtualproduct' =>
'AssociatedProducts',
103 'subproduct' =>
'SubProduct',
104 'product_supplier_ref' =>
'SupplierPrices',
105 'service' =>
'Service',
107 'movement' =>
'StockMovement',
109 'stockbatch' =>
'StockDetailPerBatch',
110 'warehouse' =>
'Warehouse',
111 'category' =>
'Category',
113 'trip' =>
'TripsAndExpenses',
114 'shipment' =>
'Shipments',
115 'shipment_line'=>
'ShipmentLine',
116 'project' =>
'Projects',
117 'projecttask' =>
'Tasks',
118 'task_time' =>
'TaskTimeSpent',
120 'expensereport'=>
'ExpenseReport',
121 'expensereport_line'=>
'ExpenseReportLine',
122 'holiday' =>
'TitreRequestCP',
123 'contract' =>
'Contract',
124 'contract_line'=>
'ContractLine',
125 'translation' =>
'Translation',
127 'bomline' =>
'BOMLine'
130 $datatoimport =
GETPOST(
'datatoimport');
132 $filetoimport =
GETPOST(
'filetoimport');
133 $action =
GETPOST(
'action',
'alpha');
134 $confirm =
GETPOST(
'confirm',
'alpha');
136 $import_name =
GETPOST(
'import_name');
138 $importmodelid =
GETPOST(
'importmodelid');
139 $excludefirstline = (
GETPOST(
'excludefirstline') ?
GETPOST(
'excludefirstline') : 1);
140 $endatlinenb = (
GETPOST(
'endatlinenb') ?
GETPOST(
'endatlinenb') :
'');
141 $updatekeys = (
GETPOST(
'updatekeys',
'array') ?
GETPOST(
'updatekeys',
'array') : array());
142 $separator = (
GETPOST(
'separator',
'nohtml') ?
GETPOST(
'separator',
'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE :
','));
143 $enclosure = (
GETPOST(
'enclosure',
'nohtml') ?
GETPOST(
'enclosure',
'nohtml') :
'"');
145 $objimport =
new Import($db);
146 $objimport->load_arrays($user, ($step == 1 ?
'' : $datatoimport));
150 $form =
new Form($db);
155 $serialized_array_match_file_to_database = isset($_SESSION[
"dol_array_match_file_to_database"]) ? $_SESSION[
"dol_array_match_file_to_database"] :
'';
156 $array_match_file_to_database = array();
157 $fieldsarray = explode(
',', $serialized_array_match_file_to_database);
158 foreach ($fieldsarray as $elem)
160 $tabelem = explode(
'=', $elem, 2);
162 $val = (isset($tabelem[1]) ? $tabelem[1] :
'');
165 $array_match_file_to_database[$key] = $val;
199 if ($action ==
'builddoc')
202 $result = $objimport->build_file($user,
GETPOST(
'model',
'alpha'), $datatoimport, $array_match_file_to_database);
211 if ($action ==
'deleteprof')
215 $objimport->fetch(
GETPOST(
"id",
'int'));
216 $result = $objimport->delete($user);
221 if ($action ==
'add_import_model')
227 foreach ($array_match_file_to_database as $key=>$val)
229 if ($hexa) $hexa .=
',';
230 $hexa .= $key.
'='.$val;
233 $objimport->model_name = $import_name;
234 $objimport->datatoimport = $datatoimport;
235 $objimport->hexa = $hexa;
237 $result = $objimport->create($user);
240 setEventMessages($langs->trans(
"ImportModelSaved", $objimport->model_name), null,
'mesgs');
242 $langs->load(
"errors");
243 if ($objimport->errno ==
'DB_ERROR_RECORD_ALREADY_EXISTS')
245 setEventMessages($langs->trans(
"ErrorImportDuplicateProfil"), null,
'errors');
251 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ImportModelName")), null,
'errors');
255 if ($step == 3 && $datatoimport)
257 if (
GETPOST(
'sendit') && !empty($conf->global->MAIN_UPLOAD_DOC))
262 $fullpath = $conf->import->dir_temp.
"/".$nowyearmonth.
'-'.$_FILES[
'userfile'][
'name'];
265 dol_syslog(
"File ".$fullpath.
" was added for import");
267 $langs->load(
"errors");
273 if ($action ==
'confirm_deletefile' && $confirm ==
'yes')
275 $langs->load(
"other");
277 $param =
'&datatoimport='.urlencode($datatoimport).
'&format='.urlencode($format);
278 if ($excludefirstline) $param .=
'&excludefirstline='.urlencode($excludefirstline);
279 if ($endatlinenb) $param .=
'&endatlinenb='.urlencode($endatlinenb);
281 $file = $conf->import->dir_temp.
'/'.
GETPOST(
'urlfile');
285 Header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?step='.$step.$param);
290 if ($step == 4 && $action ==
'select_model')
293 $_SESSION[
"dol_array_match_file_to_database"] =
'';
294 $serialized_array_match_file_to_database =
'';
295 $array_match_file_to_database = array();
299 $result = $objimport->fetch($importmodelid);
302 $serialized_array_match_file_to_database = $objimport->hexa;
303 $fieldsarray = explode(
',', $serialized_array_match_file_to_database);
304 foreach ($fieldsarray as $elem)
306 $tabelem = explode(
'=', $elem);
311 $array_match_file_to_database[$key] = $val;
314 $_SESSION[
"dol_array_match_file_to_database"] = $serialized_array_match_file_to_database;
318 if ($action ==
'saveorder')
321 dol_syslog(
"boxorder=".$_GET[
'boxorder'].
" datatoimport=".$_GET[
"datatoimport"], LOG_DEBUG);
322 $part = explode(
':', $_GET[
'boxorder']);
325 dol_syslog(
'column='.$colonne.
' list='.$list);
328 $fieldstarget = $objimport->array_import_fields[0];
331 $serialized_array_match_file_to_database =
'';
332 $array_match_file_to_database = array();
333 $fieldsarray = explode(
',', $list);
335 foreach ($fieldsarray as $fieldnb)
338 $posbis = 0; $namefield =
'';
339 foreach ($fieldstarget as $key => $val)
354 if ($fieldnb && $namefield)
356 $array_match_file_to_database[$fieldnb] = $namefield;
357 if ($serialized_array_match_file_to_database) $serialized_array_match_file_to_database .=
',';
358 $serialized_array_match_file_to_database .= ($fieldnb.
'='.$namefield);
365 $_SESSION[
"dol_array_match_file_to_database"] = $serialized_array_match_file_to_database;
366 dol_syslog(
'dol_array_match_file_to_database='.$serialized_array_match_file_to_database);
378 if ($step == 1 || !$datatoimport)
381 $serialized_array_match_file_to_database =
'';
382 $array_match_file_to_database = array();
383 $_SESSION[
"dol_array_match_file_to_database"] =
'';
386 if ($excludefirstline) $param .=
'&excludefirstline='.urlencode($excludefirstline);
387 if ($endatlinenb) $param .=
'&endatlinenb='.urlencode($endatlinenb);
388 if ($separator) $param .=
'&separator='.urlencode($separator);
389 if ($enclosure) $param .=
'&enclosure='.urlencode($enclosure);
391 llxHeader(
'', $langs->trans(
"NewImport"),
'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
393 $head = import_prepare_head($param, 1);
397 print '<div class="opacitymedium">'.$langs->trans(
"SelectImportDataSet").
'</div><br>';
400 print '<div class="div-table-responsive-no-min">';
401 print '<table class="noborder centpercent">';
402 print '<tr class="liste_titre">';
403 print '<td>'.$langs->trans(
"Module").
'</td>';
404 print '<td>'.$langs->trans(
"ImportableDatas").
'</td>';
405 print '<td> </td>';
408 if (count($objimport->array_import_module))
410 $sortedarrayofmodules =
dol_sort_array($objimport->array_import_module,
'position_of_profile',
'asc', 0, 0, 1);
411 foreach ($sortedarrayofmodules as $key => $value)
414 print '<tr class="oddeven"><td>';
415 $titleofmodule = $objimport->array_import_module[$key][
'module']->getName();
417 if (in_array($objimport->array_import_code[$key], array(
'produit_supplierprices',
'produit_multiprice',
'produit_languages'))) $titleofmodule = $langs->trans(
"ProductOrService");
418 print $titleofmodule;
420 $entity = preg_replace(
'/:.*$/',
'', $objimport->array_import_icon[$key]);
421 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
422 print img_object($objimport->array_import_module[$key][
'module']->getName(), $entityicon).
' ';
423 print $objimport->array_import_label[$key];
424 print '</td><td style="text-align: right">';
425 if ($objimport->array_import_perms[$key])
427 print '<a href="'.DOL_URL_ROOT.
'/imports/import.php?step=2&datatoimport='.$objimport->array_import_code[$key].$param.
'">'.
img_picto($langs->trans(
"NewImport"),
'next',
'class="fa-15x"').
'</a>';
429 print $langs->trans(
"NotEnoughPermissions");
434 print '<tr><td class="oddeven" colspan="3">'.$langs->trans(
"NoImportableData").
'</td></tr>';
444 if ($step == 2 && $datatoimport)
446 $param =
'&datatoimport='.urlencode($datatoimport);
447 if ($excludefirstline) $param .=
'&excludefirstline='.urlencode($excludefirstline);
448 if ($endatlinenb) $param .=
'&endatlinenb='.urlencode($endatlinenb);
449 if ($separator) $param .=
'&separator='.urlencode($separator);
450 if ($enclosure) $param .=
'&enclosure='.urlencode($enclosure);
452 llxHeader(
'', $langs->trans(
"NewImport"),
'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
454 $head = import_prepare_head($param, 2);
458 print '<div class="underbanner clearboth"></div>';
459 print '<div class="fichecenter">';
461 print '<table width="100%" class="border tableforfield">';
464 print '<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
466 $titleofmodule = $objimport->array_import_module[0][
'module']->getName();
468 if (in_array($objimport->array_import_code[0], array(
'produit_supplierprices',
'produit_multiprice',
'produit_languages'))) $titleofmodule = $langs->trans(
"ProductOrService");
469 print $titleofmodule;
473 print '<tr><td>'.$langs->trans(
"DatasetToImport").
'</td>';
475 $entity = preg_replace(
'/:.*$/',
'', $objimport->array_import_icon[0]);
476 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
477 print img_object($objimport->array_import_module[0][
'module']->getName(), $entityicon).
' ';
478 print $objimport->array_import_label[0];
486 print '<form name="userfile" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" METHOD="POST">';
487 print '<input type="hidden" name="token" value="'.newToken().
'">';
488 print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.
'">';
490 print '<span class="opacitymedium">';
491 $s = $langs->trans(
"ChooseFormatOfFileToImport",
'{s1}');
492 $s = str_replace(
'{s1}',
img_picto(
'',
'next'), $s);
494 print '</span><br><br>';
496 print '<div class="div-table-responsive-no-min">';
497 print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
502 print '<tr class="liste_titre"><td colspan="6">';
503 print $langs->trans(
"FileMustHaveOneOfFollowingFormat");
505 $liste = $objmodelimport->liste_modeles($db);
506 foreach ($liste as $key)
508 print '<tr class="oddeven">';
509 print '<td width="16">'.img_picto_common($key, $objmodelimport->getPictoForKey($key)).
'</td>';
510 $text = $objmodelimport->getDriverDescForKey($key);
511 print '<td>'.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).
'</td>';
512 print '<td style="text-align:center"><a href="'.DOL_URL_ROOT.
'/imports/emptyexample.php?format='.$key.$param.
'" target="_blank">'.$langs->trans(
"DownloadEmptyExample").
'</a></td>';
514 print '<td style="text-align:right">';
515 print '<a href="'.DOL_URL_ROOT.
'/imports/import.php?step=3&format='.$key.$param.
'">'.
img_picto($langs->trans(
"SelectFormat"),
'next',
'class="fa-15x"').
'</a>';
528 if ($step == 3 && $datatoimport)
530 $param =
'&datatoimport='.urlencode($datatoimport).
'&format='.urlencode($format);
531 if ($excludefirstline) $param .=
'&excludefirstline='.urlencode($excludefirstline);
532 if ($endatlinenb) $param .=
'&endatlinenb='.urlencode($endatlinenb);
533 if ($separator) $param .=
'&separator='.urlencode($separator);
534 if ($enclosure) $param .=
'&enclosure='.urlencode($enclosure);
536 $liste = $objmodelimport->liste_modeles($db);
538 llxHeader(
'', $langs->trans(
"NewImport"),
'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
540 $head = import_prepare_head($param, 3);
547 if ($action ==
'delete')
549 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?urlfile='.urlencode(
GETPOST(
'urlfile')).
'&step=3'.$param, $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'', 0, 1);
552 print '<div class="underbanner clearboth"></div>';
553 print '<div class="fichecenter">';
555 print '<table width="100%" class="border tableforfield">';
558 print '<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
560 $titleofmodule = $objimport->array_import_module[0][
'module']->getName();
562 if (in_array($objimport->array_import_code[0], array(
'produit_supplierprices',
'produit_multiprice',
'produit_languages'))) $titleofmodule = $langs->trans(
"ProductOrService");
563 print $titleofmodule;
567 print '<tr><td>'.$langs->trans(
"DatasetToImport").
'</td>';
569 $entity = preg_replace(
'/:.*$/',
'', $objimport->array_import_icon[0]);
570 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
571 print img_object($objimport->array_import_module[0][
'module']->getName(), $entityicon).
' ';
572 print $objimport->array_import_label[0];
580 print '<div class="underbanner clearboth"></div>';
581 print
'<div class="fichecenter">';
582 print
'<table width="100%" class="border tableforfield">';
585 print
'<tr><td class="titlefield">'.$langs->trans(
"SourceFileFormat").
'</td>';
587 $text = $objmodelimport->getDriverDescForKey($format);
588 print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
589 print
'</td><td style="text-align:right" class="nowrap"><a href="'.DOL_URL_ROOT.
'/imports/emptyexample.php?format='.$format.$param.
'" target="_blank">'.$langs->trans(
"DownloadEmptyExample").
'</a>';
599 if ($format ==
'xlsx' && !class_exists(
'XMLWriter')) {
600 $langs->load(
"install");
601 print
info_admin($langs->trans(
"ErrorPHPDoesNotSupport",
'php-xml'), 0, 0, 1,
'error');
607 print
'<form name="userfile" action="'.$_SERVER[
"PHP_SELF"].
'" enctype="multipart/form-data" METHOD="POST">';
608 print
'<input type="hidden" name="token" value="'.newToken().
'">';
609 print
'<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.
'">';
611 print
'<input type="hidden" value="'.$step.
'" name="step">';
612 print
'<input type="hidden" value="'.dol_escape_htmltag($format).
'" name="format">';
613 print
'<input type="hidden" value="'.$excludefirstline.
'" name="excludefirstline">';
614 print
'<input type="hidden" value="'.$endatlinenb.
'" name="endatlinenb">';
615 print
'<input type="hidden" value="'.dol_escape_htmltag($separator).
'" name="separator">';
616 print
'<input type="hidden" value="'.dol_escape_htmltag($enclosure).
'" name="enclosure">';
617 print
'<input type="hidden" value="'.dol_escape_htmltag($datatoimport).
'" name="datatoimport">';
619 print
'<span class="opacitymedium">';
620 $s = $langs->trans(
"ChooseFileToImport",
'{s1}');
621 $s = str_replace(
'{s1}',
img_picto(
'',
'next'), $s);
623 print
'</span><br><br>';
625 print
'<div class="div-table-responsive-no-min">';
626 print
'<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
633 print
'<tr class="oddeven nohover"><td colspan="6">';
634 print
'<input type="file" name="userfile" size="20" maxlength="80"> ';
635 $out = (empty($conf->global->MAIN_UPLOAD_DOC) ?
' disabled' :
'');
636 print
'<input type="submit" class="button" value="'.$langs->trans(
"AddFile").
'"'.$out.
' name="sendit">';
638 if (!empty($conf->global->MAIN_UPLOAD_DOC))
640 $max = $conf->global->MAIN_UPLOAD_DOC;
641 $maxphp = @ini_get(
'upload_max_filesize');
642 if (preg_match(
'/k$/i', $maxphp)) $maxphp = $maxphp * 1;
643 if (preg_match(
'/m$/i', $maxphp)) $maxphp = $maxphp * 1024;
644 if (preg_match(
'/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024;
645 if (preg_match(
'/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024;
646 $maxphp2 = @ini_get(
'post_max_size');
647 if (preg_match(
'/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1;
648 if (preg_match(
'/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024;
649 if (preg_match(
'/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024;
650 if (preg_match(
'/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
653 $maxphptoshow = $maxphptoshowparam =
'';
656 $maxmin = min($max, $maxphp);
657 $maxphptoshow = $maxphp;
658 $maxphptoshowparam =
'upload_max_filesize';
662 $maxmin = min($max, $maxphp2);
663 if ($maxphp2 < $maxphp)
665 $maxphptoshow = $maxphp2;
666 $maxphptoshowparam =
'post_max_size';
670 $langs->load(
'other');
672 $out .=
info_admin($langs->trans(
"ThisLimitIsDefinedInSetup", $max, $maxphptoshow), 1);
674 $out .=
' ('.$langs->trans(
"UploadDisabled").
')';
681 $filearray =
dol_dir_list($conf->import->dir_temp,
'files', 0,
'',
'',
'name', SORT_DESC);
682 if (count($filearray) > 0)
684 $dir = $conf->import->dir_temp;
688 foreach ($filearray as $key => $val)
690 $file = $val[
'name'];
693 if (!
utf8_check($file)) $file = utf8_encode($file);
695 if (preg_match(
'/^\./', $file))
continue;
697 $modulepart =
'import';
698 $urlsource =
$_SERVER[
"PHP_SELF"].
'?step='.$step.$param.
'&filetoimport='.urlencode($filetoimport);
699 $relativepath = $file;
701 print
'<tr class="oddeven">';
702 print
'<td width="16">'.img_mime($file).
'</td>';
704 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'&step=3'.$param.
'" target="_blank">';
709 print
'<td style="text-align:right">'.dol_print_size(
dol_filesize($dir.
'/'.$file)).
'</td>';
711 print
'<td style="text-align:right">'.dol_print_date(
dol_filemtime($dir.
'/'.$file),
'dayhour').
'</td>';
713 print
'<td style="text-align:right"><a href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&step=3'.$param.
'&urlfile='.urlencode($relativepath);
714 print
'">'.img_delete().
'</a></td>';
716 print
'<td style="text-align:right">';
717 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?step=4'.$param.
'&filetoimport='.urlencode($relativepath).
'">'.
img_picto($langs->trans(
"NewImport"),
'next',
'class="fa-15x"').
'</a>';
731 if ($step == 4 && $datatoimport)
734 $liste = $objmodelimport->liste_modeles($db);
737 $dir = DOL_DOCUMENT_ROOT.
"/core/modules/import/";
738 $file =
"import_".$model.
".modules.php";
739 $classname =
"Import".ucfirst($model);
740 require_once $dir.$file;
741 $obj =
new $classname($db, $datatoimport);
744 $obj->separator = $separator;
745 $obj->enclosure = $enclosure;
747 if ($model ==
'xlsx') {
748 if (!preg_match(
'/\.xlsx$/i', $filetoimport))
750 $langs->load(
"errors");
751 $param =
'&datatoimport='.$datatoimport.
'&format='.$format;
752 setEventMessages($langs->trans(
"ErrorFileMustHaveFormat", $model), null,
'errors');
753 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?step=3'.$param.
'&filetoimport='.urlencode($relativepath));
759 $array_match_file_to_database = array();
763 $fieldssource = array();
764 $result = $obj->import_open_file($conf->import->dir_temp.
'/'.$filetoimport, $langs);
768 $arrayrecord = $obj->import_read_record();
771 foreach ($arrayrecord as $key => $val)
773 $fieldssource[$i][
'example1'] =
dol_trunc($val[
'val'], 24);
776 $obj->import_close_file();
780 $fieldstarget = $objimport->array_import_fields[0];
782 $maxpos = max(count($fieldssource), count($fieldstarget));
787 if (count($array_match_file_to_database) == 0)
794 $num = count($fieldssource);
797 if ($num >= 1 && $pos <= $num)
800 foreach ($fieldstarget as $key => $val)
808 $array_match_file_to_database[$pos] = $key;
809 if ($serialized_array_match_file_to_database) $serialized_array_match_file_to_database .=
',';
810 $serialized_array_match_file_to_database .= ($pos.
'='.$key);
817 $_SESSION[
"dol_array_match_file_to_database"] = $serialized_array_match_file_to_database;
819 $array_match_database_to_file = array_flip($array_match_file_to_database);
827 $param =
'&format='.$format.
'&datatoimport='.urlencode($datatoimport).
'&filetoimport='.urlencode($filetoimport);
828 if ($excludefirstline) $param .=
'&excludefirstline='.urlencode($excludefirstline);
829 if ($endatlinenb) $param .=
'&endatlinenb='.urlencode($endatlinenb);
830 if ($separator) $param .=
'&separator='.urlencode($separator);
831 if ($enclosure) $param .=
'&enclosure='.urlencode($enclosure);
833 llxHeader(
'', $langs->trans(
"NewImport"),
'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
835 $head = import_prepare_head($param, 4);
839 print
'<div class="underbanner clearboth"></div>';
840 print
'<div class="fichecenter">';
842 print
'<table width="100%" class="border tableforfield">';
845 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
847 $titleofmodule = $objimport->array_import_module[0][
'module']->getName();
849 if (in_array($objimport->array_import_code[0], array(
'produit_supplierprices',
'produit_multiprice',
'produit_languages'))) $titleofmodule = $langs->trans(
"ProductOrService");
850 print $titleofmodule;
854 print
'<tr><td>'.$langs->trans(
"DatasetToImport").
'</td>';
856 $entity = preg_replace(
'/:.*$/',
'', $objimport->array_import_icon[0]);
857 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
858 print
img_object($objimport->array_import_module[0][
'module']->getName(), $entityicon).
' ';
859 print $objimport->array_import_label[0];
867 print
'<div class="underbanner clearboth"></div>';
868 print
'<div class="fichecenter">';
869 print
'<table width="100%" class="border tableforfield">';
872 print
'<tr><td class="titlefield">'.$langs->trans(
"SourceFileFormat").
'</td>';
874 $text = $objmodelimport->getDriverDescForKey($format);
875 print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
879 if ($model ==
'csv') {
880 print
'<tr><td>'.$langs->trans(
"CsvOptions").
'</td>';
883 print
'<input type="hidden" name="token" value="'.newToken().
'">';
884 print
'<input type="hidden" value="'.$step.
'" name="step">';
885 print
'<input type="hidden" value="'.$format.
'" name="format">';
886 print
'<input type="hidden" value="'.$excludefirstline.
'" name="excludefirstline">';
887 print
'<input type="hidden" value="'.$endatlinenb.
'" name="endatlinenb">';
888 print
'<input type="hidden" value="'.$datatoimport.
'" name="datatoimport">';
889 print
'<input type="hidden" value="'.$filetoimport.
'" name="filetoimport">';
890 print $langs->trans(
"Separator").
' : ';
891 print
'<input type="text" size="1" name="separator" value="'.dol_escape_htmltag($separator).
'"/>';
892 print
' '.$langs->trans(
"Enclosure").
' : ';
893 print
'<input type="text" size="1" name="enclosure" value="'.dol_escape_htmltag($enclosure).
'"/>';
894 print
'<input name="update" type="submit" value="'.$langs->trans(
'Update').
'" class="button" />';
900 print
'<tr><td>'.$langs->trans(
"FileToImport").
'</td>';
902 $modulepart =
'import';
903 $relativepath =
GETPOST(
'filetoimport');
904 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'&step=4'.$param.
'" target="_blank">';
918 print
'<!-- List of source fields -->'.
"\n";
919 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
920 print
'<input type="hidden" name="token" value="'.newToken().
'">';
921 print
'<input type="hidden" name="action" value="select_model">';
922 print
'<input type="hidden" name="step" value="4">';
923 print
'<input type="hidden" name="format" value="'.$format.
'">';
924 print
'<input type="hidden" name="datatoimport" value="'.$datatoimport.
'">';
925 print
'<input type="hidden" name="filetoimport" value="'.$filetoimport.
'">';
926 print
'<input type="hidden" name="excludefirstline" value="'.$excludefirstline.
'">';
927 print
'<input type="hidden" name="endatlinenb" value="'.$endatlinenb.
'">';
928 print
'<input type="hidden" name="separator" value="'.dol_escape_htmltag($separator).
'">';
929 print
'<input type="hidden" name="enclosure" value="'.dol_escape_htmltag($enclosure).
'">';
931 print
'<div class="marginbottomonly">';
932 print
'<span class="opacitymedium">';
933 $s = $langs->trans(
"SelectImportFields",
'{s1}');
934 $s = str_replace(
'{s1}',
img_picto(
'',
'grip_title',
'',
false, 0, 0,
'',
'', 0), $s);
937 $htmlother->select_import_model($importmodelid,
'importmodelid', $datatoimport, 1);
938 print
'<input type="submit" class="button" value="'.$langs->trans(
"Select").
'">';
943 print
'<div class="div-table-responsive-no-min">';
944 print
'<table class="noborder centpercent">';
945 print
'<tr class="liste_titre">';
946 print
'<td>'.$langs->trans(
"FieldsInSourceFile").
'</td>';
947 print
'<td>'.$langs->trans(
"FieldsInTargetDatabase").
'</td>';
952 print
'<tr valign="top"><td width="50%">';
954 $fieldsplaced = array();
955 $valforsourcefieldnb = array();
956 $listofkeys = array();
957 foreach ($array_match_file_to_database as $key => $val)
959 $listofkeys[$key] = 1;
962 print
"\n<!-- Box left container -->\n";
963 print
'<div id="left" class="connectedSortable">'.
"\n";
968 foreach ($array_match_file_to_database as $key => $val)
971 show_elem($fieldssource, $key, $val, $var);
973 $listofkeys[$key] = 1;
974 $fieldsplaced[$key] = 1;
975 $valforsourcefieldnb[$lefti] = $key;
978 if ($lefti > count($fieldstarget))
break;
984 $num = count($fieldssource);
985 while ($lefti <= $num)
988 $newkey =
getnewkey($fieldssource, $listofkeys);
989 show_elem($fieldssource, $newkey,
'', $var);
991 $listofkeys[$key] = 1;
997 print
"<!-- End box left container -->\n";
1000 print
'</td><td width="50%">';
1005 $mandatoryfieldshavesource =
true;
1007 print
'<table width="100%" class="nobordernopadding">';
1008 foreach ($fieldstarget as $code=>$label)
1010 print
'<tr class="oddeven" style="height:'.$height.
'">';
1013 $entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]);
1015 $tablealias = preg_replace(
'/(\..*)$/i',
'', $code);
1016 $tablename = $objimport->array_import_tables[0][$tablealias];
1018 $entityicon = $entitytoicon[$entity] ? $entitytoicon[$entity] : $entity;
1019 $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0];
1021 print
'<td class="nowrap" style="font-weight: normal">=>'.img_object(
'', $entityicon).
' '.$langs->trans($entitylang).
'</td>';
1022 print
'<td style="font-weight: normal">';
1023 $newlabel = preg_replace(
'/\*$/',
'', $label);
1024 $text = $langs->trans($newlabel);
1026 if (preg_match(
'/\*$/', $label))
1028 $text =
'<span class="fieldrequired">'.$text.
'</span>';
1029 $more = ((!empty($valforsourcefieldnb[$i]) && $valforsourcefieldnb[$i] <= count($fieldssource)) ?
'' :
img_warning($langs->trans(
"FieldNeedSource")));
1030 if ($mandatoryfieldshavesource) $mandatoryfieldshavesource = (!empty($valforsourcefieldnb[$i]) && ($valforsourcefieldnb[$i] <= count($fieldssource)));
1036 print
'<td style="font-weight:normal; text-align:right">';
1037 $filecolumn = $array_match_database_to_file[$code];
1039 $htmltext =
'<b><u>'.$langs->trans(
"FieldSource").
'</u></b><br>';
1040 if ($filecolumn > count($fieldssource)) $htmltext .= $langs->trans(
"DataComeFromNoWhere").
'<br>';
1042 if (empty($objimport->array_import_convertvalue[0][$code]))
1044 $filecolumntoshow = $filecolumn;
1045 $htmltext .= $langs->trans(
"DataComeFromFileFieldNb", $filecolumntoshow).
'<br>';
1047 if ($objimport->array_import_convertvalue[0][$code][
'rule'] ==
'fetchidfromref') $htmltext .= $langs->trans(
"DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).
'<br>';
1048 if ($objimport->array_import_convertvalue[0][$code][
'rule'] ==
'fetchidfromcodeid') $htmltext .= $langs->trans(
"DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code][
'dict'])).
'<br>';
1052 $htmltext .= $langs->trans(
"SourceRequired").
': <b>'.
yn(preg_match(
'/\*$/', $label)).
'</b><br>';
1053 $example = $objimport->array_import_examplevalues[0][$code];
1055 if (empty($objimport->array_import_convertvalue[0][$code]))
1057 if ($example) $htmltext .= $langs->trans(
"SourceExample").
': <b>'.$example.
'</b><br>';
1059 if ($objimport->array_import_convertvalue[0][$code][
'rule'] ==
'fetchidfromref') $htmltext .= $langs->trans(
"SourceExample").
': <b>'.$langs->transnoentitiesnoconv(
"ExampleAnyRefFoundIntoElement", $entitylang).($example ?
' ('.$langs->transnoentitiesnoconv(
"Example").
': '.$example.
')' :
'').
'</b><br>';
1060 elseif ($objimport->array_import_convertvalue[0][$code][
'rule'] ==
'fetchidfromcodeid') $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>';
1061 elseif ($example) $htmltext .= $langs->trans("SourceExample").': <b>'.$example.'</b><br>';
1064 if (!empty($objimport->array_import_regex[0][$code]))
1066 $htmltext .= $langs->trans(
"FormatControlRule").
': <b>'.$objimport->array_import_regex[0][$code].
'</b><br>';
1068 $htmltext .=
'<br>';
1070 $htmltext .=
'<b><u>'.$langs->trans(
"FieldTarget").
'</u></b><br>';
1071 if (empty($objimport->array_import_convertvalue[0][$code]))
1073 $htmltext .= $langs->trans(
"DataIsInsertedInto").
'<br>';
1075 if ($objimport->array_import_convertvalue[0][$code][
'rule'] ==
'fetchidfromref') $htmltext .= $langs->trans(
"DataIDSourceIsInsertedInto").
'<br>';
1076 if ($objimport->array_import_convertvalue[0][$code][
'rule'] ==
'fetchidfromcodeid') $htmltext .= $langs->trans(
"DataCodeIDSourceIsInsertedInto").
'<br>';
1078 $htmltext .= $langs->trans(
"FieldTitle").
": <b>".$langs->trans($newlabel).
"</b><br>";
1079 $htmltext .= $langs->trans(
"Table").
" -> ".$langs->trans(
"Field").
': <b>'.$tablename.
" -> ".preg_replace(
'/^.*\./',
'', $code).
"</b><br>";
1080 print $form->textwithpicto($more, $htmltext);
1084 $save_select .= $bit;
1091 print
'<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"NotImportedFields").
'</td></tr>';
1093 print
'<tr valign="top"><td width="50%">';
1095 print
"\n<!-- Box ignore container -->\n";
1096 print
'<div id="right" class="connectedSortable">'.
"\n";
1098 $nbofnotimportedfields = 0;
1099 foreach ($fieldssource as $key => $val)
1101 if (empty($fieldsplaced[$key]))
1104 $nbofnotimportedfields++;
1105 show_elem($fieldssource, $key,
'', $var,
'nostyle');
1107 $listofkeys[$key] = 1;
1113 $newkey =
getnewkey($fieldssource, $listofkeys);
1114 show_elem($fieldssource, $newkey,
'', $var,
'nostyle');
1116 $listofkeys[$newkey] = 1;
1117 $nbofnotimportedfields++;
1120 print
"<!-- End box ignore container -->\n";
1123 print
'<td width="50%">';
1125 while ($i < $nbofnotimportedfields)
1128 show_elem(
'',
'',
'none', $var,
'nostyle');
1137 if ($conf->use_javascript_ajax)
1139 print
'<script type="text/javascript" language="javascript">';
1140 print
'jQuery(function() {
1141 jQuery("#left, #right").sortable({
1142 /* placeholder: \'ui-state-highlight\', */
1143 handle: \'.boxhandle\',
1144 revert: \'invalid\',
1146 containment: \'.fiche\',
1147 connectWith: \'.connectedSortable\',
1148 stop: function(event, ui) {
1155 print
'function updateOrder(){'.
"\n";
1156 print
'var left_list = cleanSerialize(jQuery("#left").sortable("serialize" ));'.
"\n";
1158 print
'var boxorder = \'A:\' + left_list;'.
"\n";
1167 print
'var newlocation= \''.$_SERVER[
"PHP_SELF"].
'?step=4'.$param.
'&action=saveorder&boxorder=\' + boxorder;'.
"\n";
1169 print
'window.location.href=newlocation;'.
"\n";
1171 print
'</script>'.
"\n";
1177 print
'<div class="tabsAction">';
1179 if (count($array_match_file_to_database))
1181 if ($mandatoryfieldshavesource)
1183 print
'<a class="butAction" href="import.php?step=5'.$param.
'&filetoimport='.urlencode($filetoimport).
'">'.$langs->trans(
"NextStep").
'</a>';
1185 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"SomeMandatoryFieldHaveNoSource")).
'">'.$langs->trans(
"NextStep").
'</a>';
1193 if (count($array_match_file_to_database))
1196 print
'<!-- Area to add new import profile -->'.
"\n";
1197 print
'<div class="marginbottomonly"><span class="opacitymedium">'.$langs->trans(
"SaveImportModel").
'</span></div>';
1199 print
'<form class="nocellnopadd" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1200 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1201 print
'<input type="hidden" name="action" value="add_import_model">';
1202 print
'<input type="hidden" name="step" value="'.$step.
'">';
1203 print
'<input type="hidden" name="format" value="'.$format.
'">';
1204 print
'<input type="hidden" name="datatoimport" value="'.$datatoimport.
'">';
1205 print
'<input type="hidden" name="filetoimport" value="'.$filetoimport.
'">';
1206 print
'<input type="hidden" name="hexa" value="'.$hexa.
'">';
1207 print
'<input type="hidden" name="excludefirstline" value="'.$excludefirstline.
'">';
1208 print
'<input type="hidden" name="endatlinenb" value="'.$endatlinenb.
'">';
1209 print
'<input type="hidden" value="'.dol_escape_htmltag($separator).
'" name="separator">';
1210 print
'<input type="hidden" value="'.dol_escape_htmltag($enclosure).
'" name="enclosure">';
1212 print
'<table summary="selectofimportprofil" class="noborder centpercent">';
1213 print
'<tr class="liste_titre">';
1214 print
'<td>'.$langs->trans(
"ImportModelName").
'</td>';
1215 print
'<td> </td>';
1218 print
'<tr class="oddeven">';
1219 print
'<td><input name="import_name" size="48" value=""></td><td style="text-align:right">';
1220 print
'<input type="submit" class="button" value="'.$langs->trans(
"SaveImportProfile").
'">';
1224 $sql =
"SELECT rowid, label";
1225 $sql .=
" FROM ".MAIN_DB_PREFIX.
"import_model";
1226 $sql .=
" WHERE type = '".$db->escape($datatoimport).
"'";
1227 $sql .=
" ORDER BY rowid";
1228 $resql = $db->query($sql);
1231 $num = $db->num_rows(
$resql);
1235 $obj = $db->fetch_object(
$resql);
1236 print
'<tr class="oddeven"><td>';
1238 print
'</td><td style="text-align:right">';
1239 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?step='.$step.$param.
'&action=deleteprof&token='.
newToken().
'&id='.$obj->rowid.
'&filetoimport='.urlencode($filetoimport).
'">';
1256 if ($step == 5 && $datatoimport)
1258 $max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME);
1259 $max_time = @ini_get(
"max_execution_time");
1260 if ($max_time && $max_time < $max_execution_time_for_importexport)
1262 dol_syslog(
"max_execution_time=".$max_time.
" is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.
". We try to increase it dynamically.");
1263 @ini_set(
"max_execution_time", $max_execution_time_for_importexport);
1267 $liste = $objmodelimport->liste_modeles($db);
1270 $dir = DOL_DOCUMENT_ROOT.
"/core/modules/import/";
1271 $file =
"import_".$model.
".modules.php";
1272 $classname =
"Import".ucfirst($model);
1273 require_once $dir.$file;
1274 $obj =
new $classname($db, $datatoimport);
1275 if ($model ==
'csv') {
1276 $obj->separator = $separator;
1277 $obj->enclosure = $enclosure;
1281 $fieldssource = array();
1282 $result = $obj->import_open_file($conf->import->dir_temp.
'/'.$filetoimport, $langs);
1287 $arrayrecord = $obj->import_read_record();
1290 foreach ($arrayrecord as $key => $val)
1292 $fieldssource[$i][
'example1'] =
dol_trunc($val[
'val'], 24);
1295 $obj->import_close_file();
1298 $nboflines = $obj->import_get_nb_of_lines($conf->import->dir_temp.
'/'.$filetoimport);
1300 $param =
'&leftmenu=import&format='.urlencode($format).
'&datatoimport='.urlencode($datatoimport).
'&filetoimport='.urlencode($filetoimport).
'&nboflines='.urlencode($nboflines).
'&separator='.urlencode($separator).
'&enclosure='.urlencode($enclosure);
1302 if ($excludefirstline) $param .=
'&excludefirstline='.urlencode($excludefirstline);
1303 if ($endatlinenb) $param .=
'&endatlinenb='.urlencode($endatlinenb);
1304 if (!empty($updatekeys)) $param .=
'&updatekeys[]='.implode(
'&updatekeys[]=', $updatekeys);
1306 llxHeader(
'', $langs->trans(
"NewImport"),
'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
1308 $head = import_prepare_head($param, 5);
1311 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?'.$param2.
'" method="POST">';
1312 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1313 print
'<input type="hidden" name="step" value="5">';
1314 print
'<input type="hidden" name="action" value="launchsimu">';
1318 print
'<div class="underbanner clearboth"></div>';
1319 print
'<div class="fichecenter">';
1321 print
'<table width="100%" class="border tableforfield">';
1324 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
1326 $titleofmodule = $objimport->array_import_module[0][
'module']->getName();
1328 if (in_array($objimport->array_import_code[0], array(
'produit_supplierprices',
'produit_multiprice',
'produit_languages'))) $titleofmodule = $langs->trans(
"ProductOrService");
1329 print $titleofmodule;
1333 print
'<tr><td>'.$langs->trans(
"DatasetToImport").
'</td>';
1335 $entity = preg_replace(
'/:.*$/',
'', $objimport->array_import_icon[0]);
1336 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
1337 print
img_object($objimport->array_import_module[0][
'module']->getName(), $entityicon).
' ';
1338 print $objimport->array_import_label[0];
1346 print
'<div class="underbanner clearboth"></div>';
1347 print
'<div class="fichecenter">';
1348 print
'<table width="100%" class="border tableforfield">';
1351 print
'<tr><td class="titlefield">'.$langs->trans(
"SourceFileFormat").
'</td>';
1353 $text = $objmodelimport->getDriverDescForKey($format);
1354 print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
1358 if ($model ==
'csv') {
1359 print
'<tr><td>'.$langs->trans(
"CsvOptions").
'</td>';
1362 print
' '.$langs->trans(
"Enclosure").
' : '.
dol_escape_htmltag($enclosure);
1367 print
'<tr><td>'.$langs->trans(
"FileToImport").
'</td>';
1369 $modulepart =
'import';
1370 $relativepath =
GETPOST(
'filetoimport');
1371 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'&step=4'.$param.
'" target="_blank">';
1372 print $filetoimport;
1378 print $langs->trans(
"NbOfSourceLines");
1385 print $langs->trans(
"ImportFromToLine");
1387 if ($action ==
'launchsimu')
1389 print
'<input type="number" class="maxwidth50" name="excludefirstlinebis" disabled="disabled" value="'.$excludefirstline.
'">';
1390 print
'<input type="hidden" name="excludefirstline" value="'.$excludefirstline.
'">';
1392 print
'<input type="number" class="maxwidth50" name="excludefirstline" value="'.$excludefirstline.
'">';
1393 print $form->textwithpicto(
"", $langs->trans(
"SetThisValueTo2ToExcludeFirstLine"));
1396 if ($action ==
'launchsimu')
1398 print
'<input type="text" class="maxwidth50" name="endatlinenbbis" disabled="disabled" value="'.$endatlinenb.
'">';
1399 print
'<input type="hidden" name="endatlinenb" value="'.$endatlinenb.
'">';
1401 print
'<input type="text" class="maxwidth50" name="endatlinenb" value="'.$endatlinenb.
'">';
1402 print $form->textwithpicto(
"", $langs->trans(
"KeepEmptyToGoToEndOfFile"));
1404 if ($action ==
'launchsimu') print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?step=5'.$param.
'">'.$langs->trans(
"Modify").
'</a>';
1409 print $langs->trans(
"KeysToUseForUpdates");
1411 if ($action ==
'launchsimu') {
1412 if (count($updatekeys))
1414 print $form->multiselectarray(
'updatekeysbis', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0,
'', 1,
'80%',
'disabled');
1416 print
'<span class="opacitymedium">'.$langs->trans(
"NoUpdateAttempt").
'</span> -';
1418 foreach ($updatekeys as $val) {
1419 print
'<input type="hidden" name="updatekeys[]" value="'.$val.
'">';
1421 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?step=5'.$param.
'">'.$langs->trans(
"Modify").
'</a>';
1423 if (is_array($objimport->array_import_updatekeys[0]) && count($objimport->array_import_updatekeys[0]))
1425 print $form->multiselectarray(
'updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0,
'', 1,
'80%');
1426 print $form->textwithpicto(
"", $langs->trans(
"SelectPrimaryColumnsForUpdateAttempt"));
1428 print
'<span class="opacitymedium">'.$langs->trans(
"UpdateNotYetSupportedForThisImport").
'</span>';
1440 print
load_fiche_titre($langs->trans(
"InformationOnTargetTables"),
'',
'');
1442 print
'<div class="underbanner clearboth"></div>';
1443 print
'<div class="fichecenter">';
1445 print
'<table width="100%" class="border tableforfield">';
1448 print
'<tr><td class="titlefield">';
1449 print $langs->trans(
"TablesTarget");
1451 $listtables = array();
1452 $sort_array_match_file_to_database = $array_match_file_to_database;
1453 foreach ($array_match_file_to_database as $code=>$label)
1456 if ($code > count($fieldssource))
continue;
1458 $alias = preg_replace(
'/(\..*)$/i',
'', $label);
1459 $listtables[$alias] = $objimport->array_import_tables[0][$alias];
1461 if (count($listtables))
1465 foreach ($listtables as $val)
1467 if ($newval) print
', ';
1482 }
else print $langs->trans(
"Error");
1487 print $langs->trans(
"FieldsTarget").
'</td><td>';
1488 $listfields = array();
1491 $sort_array_match_file_to_database = $array_match_file_to_database;
1492 ksort($sort_array_match_file_to_database);
1494 foreach ($sort_array_match_file_to_database as $code=>$label)
1498 if ($code > count($fieldssource))
continue;
1500 $alias = preg_replace(
'/(\..*)$/i',
'', $label);
1501 $listfields[$i] = $langs->trans(
"Field").
' '.$code.
'->'.$label;
1503 print count($listfields) ? (join(
', ', $listfields)) : $langs->trans(
"Error");
1512 if ($action !=
'launchsimu')
1515 print
'<br><span class="opacitymedium">';
1516 print $langs->trans(
"NowClickToTestTheImport", $langs->transnoentitiesnoconv(
"RunSimulateImportFile")).
'</span><br>';
1520 print
'<div class="center">';
1521 if ($user->rights->import->run)
1523 print
'<input type="submit" class="butAction" value="'.$langs->trans(
"RunSimulateImportFile").
'">';
1525 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"RunSimulateImportFile").
'</a>';
1530 $arrayoferrors = array();
1531 $arrayofwarnings = array();
1532 $maxnboferrors = empty($conf->global->IMPORT_MAX_NB_OF_ERRORS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_ERRORS;
1533 $maxnbofwarnings = empty($conf->global->IMPORT_MAX_NB_OF_WARNINGS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_WARNINGS;
1545 $pathfile = $conf->import->dir_temp.
'/'.$filetoimport;
1546 $result = $obj->import_open_file($pathfile, $langs);
1549 global $tablewithentity_cache;
1550 $tablewithentity_cache = array();
1551 $sourcelinenb = 0; $endoffile = 0;
1554 while (($sourcelinenb < $nboflines) && !$endoffile)
1559 $arrayrecord = $obj->import_read_record();
1560 if ($arrayrecord ===
false)
1562 $arrayofwarnings[$sourcelinenb][0] = array(
'lib'=>
'File has '.$nboflines.
' lines. However we reach end of file after record '.$sourcelinenb.
'. This may occurs when some records are split onto several lines. Ensure the complete string is delimited correctly when there is a separator character in the text string.',
'type'=>
'EOF_RECORD_ON_SEVERAL_LINES');
1566 if ($excludefirstline && ($sourcelinenb < $excludefirstline))
continue;
1567 if ($endatlinenb && ($sourcelinenb > $endatlinenb))
break;
1570 $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys);
1572 if (count($obj->errors)) $arrayoferrors[$sourcelinenb] = $obj->errors;
1573 if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb] = $obj->warnings;
1574 if (!count($obj->errors) && !count($obj->warnings)) $nbok++;
1577 $obj->import_close_file();
1579 print $langs->trans(
"ErrorFailedToOpenFile", $pathfile);
1586 if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
1589 foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport)
1592 $resqlafterimport = $db->query($sqlafterimport);
1593 if (!$resqlafterimport)
1595 $arrayoferrors[
'none'][] = array(
'lib'=>$langs->trans(
"Error running final request: ".$sqlafterimport));
1604 if (!count($arrayoferrors) && !count($arrayofwarnings)) {
1605 print
'<div class="center">'.img_picto($langs->trans(
"OK"),
'tick').
' <b>'.$langs->trans(
"NoError").
'</b></div><br><br>';
1606 print
'<div class="ok">';
1607 print $langs->trans(
"NbInsert", empty($obj->nbinsert) ? 0 : $obj->nbinsert).
'<br>';
1608 print $langs->trans(
"NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).
'<br><br>';
1610 }
else print $langs->trans(
"NbOfLinesOK", $nbok).
'<br><br>';
1614 if (count($arrayoferrors))
1616 print
img_error().
' <b>'.$langs->trans(
"ErrorsOnXLines", count($arrayoferrors)).
'</b><br>';
1617 print
'<table width="100%" class="border"><tr><td>';
1618 foreach ($arrayoferrors as $key => $val)
1621 if ($nboferrors > $maxnboferrors)
1623 print $langs->trans(
"TooMuchErrors", (count($arrayoferrors) - $nboferrors)).
"<br>";
1626 print
'* '.$langs->trans(
"Line").
' '.$key.
'<br>';
1627 foreach ($val as $i => $err)
1629 print
' > '.$err[
'lib'].
'<br>';
1632 print
'</td></tr></table>';
1638 if (count($arrayofwarnings))
1640 print
img_warning().
' <b>'.$langs->trans(
"WarningsOnXLines", count($arrayofwarnings)).
'</b><br>';
1641 print
'<table width="100%" class="border"><tr><td>';
1642 foreach ($arrayofwarnings as $key => $val)
1645 if ($nbofwarnings > $maxnbofwarnings)
1647 print $langs->trans(
"TooMuchWarnings", (count($arrayofwarnings) - $nbofwarnings)).
"<br>";
1650 print
' * '.$langs->trans(
"Line").
' '.$key.
'<br>';
1651 foreach ($val as $i => $err)
1653 print
' > '.$err[
'lib'].
'<br>';
1656 print
'</td></tr></table>';
1663 print
'<div class="center">';
1664 print
'<span class="opacitymedium">'.$langs->trans(
"NowClickToRunTheImport", $langs->transnoentitiesnoconv(
"RunImportFile")).
'</span><br>';
1665 if (empty($nboferrors)) print $langs->trans(
"DataLoadedWithId", $importid).
'<br>';
1671 print
'<div class="center">';
1672 if ($user->rights->import->run)
1674 if (empty($nboferrors))
1676 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/imports/import.php?leftmenu=import&step=6&importid='.$importid.$param.
'">'.$langs->trans(
"RunImportFile").
'</a>';
1680 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"CorrectErrorBeforeRunningImport")).
'">'.$langs->trans(
"RunImportFile").
'</a>';
1683 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"RunSimulateImportFile").
'</a>';
1685 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"RunImportFile").
'</a>';
1695 if ($step == 6 && $datatoimport)
1697 $max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME);
1698 $max_time = @ini_get(
"max_execution_time");
1699 if ($max_time && $max_time < $max_execution_time_for_importexport)
1701 dol_syslog(
"max_execution_time=".$max_time.
" is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.
". We try to increase it dynamically.");
1702 @ini_set(
"max_execution_time", $max_execution_time_for_importexport);
1706 $liste = $objmodelimport->liste_modeles($db);
1707 $importid =
GETPOST(
"importid",
'alphanohtml');
1711 $dir = DOL_DOCUMENT_ROOT.
"/core/modules/import/";
1712 $file =
"import_".$model.
".modules.php";
1713 $classname =
"Import".ucfirst($model);
1714 require_once $dir.$file;
1715 $obj =
new $classname($db, $datatoimport);
1716 if ($model ==
'csv') {
1717 $obj->separator = $separator;
1718 $obj->enclosure = $enclosure;
1722 $fieldssource = array();
1723 $result = $obj->import_open_file($conf->import->dir_temp.
'/'.$filetoimport, $langs);
1727 $arrayrecord = $obj->import_read_record();
1730 foreach ($arrayrecord as $key => $val)
1732 $fieldssource[$i][
'example1'] =
dol_trunc($val[
'val'], 24);
1735 $obj->import_close_file();
1738 $nboflines = (!empty($_GET[
"nboflines"]) ? $_GET[
"nboflines"] :
dol_count_nb_of_line($conf->import->dir_temp.
'/'.$filetoimport));
1740 $param =
'&format='.$format.
'&datatoimport='.urlencode($datatoimport).
'&filetoimport='.urlencode($filetoimport).
'&nboflines='.urlencode($nboflines);
1741 if ($excludefirstline) $param .=
'&excludefirstline='.urlencode($excludefirstline);
1742 if ($endatlinenb) $param .=
'&endatlinenb='.urlencode($endatlinenb);
1743 if ($separator) $param .=
'&separator='.urlencode($separator);
1744 if ($enclosure) $param .=
'&enclosure='.urlencode($enclosure);
1746 llxHeader(
'', $langs->trans(
"NewImport"),
'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
1748 $head = import_prepare_head($param, 6);
1752 print
'<div class="underbanner clearboth"></div>';
1753 print
'<div class="fichecenter">';
1755 print
'<table width="100%" class="border">';
1758 print
'<tr><td class="titlefield">'.$langs->trans(
"Module").
'</td>';
1760 $titleofmodule = $objimport->array_import_module[0][
'module']->getName();
1762 if (in_array($objimport->array_import_code[0], array(
'produit_supplierprices',
'produit_multiprice',
'produit_languages'))) $titleofmodule = $langs->trans(
"ProductOrService");
1763 print $titleofmodule;
1767 print
'<tr><td>'.$langs->trans(
"DatasetToImport").
'</td>';
1769 $entity = preg_replace(
'/:.*$/',
'', $objimport->array_import_icon[0]);
1770 $entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
1771 print
img_object($objimport->array_import_module[0][
'module']->getName(), $entityicon).
' ';
1772 print $objimport->array_import_label[0];
1780 print
'<div class="underbanner clearboth"></div>';
1781 print
'<div class="fichecenter">';
1782 print
'<table width="100%" class="border">';
1785 print
'<tr><td class="titlefield">'.$langs->trans(
"SourceFileFormat").
'</td>';
1787 $text = $objmodelimport->getDriverDescForKey($format);
1788 print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
1792 if ($model ==
'csv') {
1793 print
'<tr><td>'.$langs->trans(
"CsvOptions").
'</td>';
1795 print $langs->trans(
"Separator").
' : ';
1796 print htmlentities($separator);
1797 print
' '.$langs->trans(
"Enclosure").
' : ';
1798 print htmlentities($enclosure);
1803 print
'<tr><td>'.$langs->trans(
"FileToImport").
'</td>';
1805 $modulepart =
'import';
1806 $relativepath =
GETPOST(
'filetoimport');
1807 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'&step=4'.$param.
'" target="_blank">';
1808 print $filetoimport;
1814 print $langs->trans(
"NbOfSourceLines");
1821 print $langs->trans(
"ImportFromLine");
1823 print
'<input type="text" size="4" name="excludefirstline" disabled="disabled" value="'.$excludefirstline.
'">';
1828 print $langs->trans(
"EndAtLineNb");
1830 print
'<input type="text" size="4" name="endatlinenb" disabled="disabled" value="'.$endatlinenb.
'">';
1838 print
'<b>'.$langs->trans(
"InformationOnTargetTables").
'</b>';
1839 print
'<div class="underbanner clearboth"></div>';
1840 print
'<div class="fichecenter">';
1841 print
'<table width="100%" class="border">';
1845 print
'<tr><td width="25%">';
1846 print $langs->trans(
"TablesTarget");
1848 $listtables = array();
1849 foreach ($array_match_file_to_database as $code=>$label)
1852 if ($code > count($fieldssource))
continue;
1854 $alias = preg_replace(
'/(\..*)$/i',
'', $label);
1855 $listtables[$alias] = $objimport->array_import_tables[0][$alias];
1857 if (count($listtables))
1860 foreach ($listtables as $val)
1862 if ($newval) print
', ';
1877 }
else print $langs->trans(
"Error");
1882 print $langs->trans(
"FieldsTarget").
'</td><td>';
1883 $listfields = array();
1885 $sort_array_match_file_to_database = $array_match_file_to_database;
1886 ksort($sort_array_match_file_to_database);
1888 foreach ($sort_array_match_file_to_database as $code=>$label)
1892 if ($code > count($fieldssource))
continue;
1894 $alias = preg_replace(
'/(\..*)$/i',
'', $label);
1895 $listfields[$i] = $langs->trans(
"Field").
' '.$code.
'->'.$label;
1897 print count($listfields) ? (join(
', ', $listfields)) : $langs->trans(
"Error");
1904 $arrayoferrors = array();
1905 $arrayofwarnings = array();
1906 $maxnboferrors = empty($conf->global->IMPORT_MAX_NB_OF_ERRORS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_ERRORS;
1907 $maxnbofwarnings = empty($conf->global->IMPORT_MAX_NB_OF_WARNINGS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_WARNINGS;
1919 $pathfile = $conf->import->dir_temp.
'/'.$filetoimport;
1920 $result = $obj->import_open_file($pathfile, $langs);
1923 global $tablewithentity_cache;
1924 $tablewithentity_cache = array();
1925 $sourcelinenb = 0; $endoffile = 0;
1927 while ($sourcelinenb < $nboflines && !$endoffile)
1930 $arrayrecord = $obj->import_read_record();
1931 if ($arrayrecord ===
false)
1933 $arrayofwarnings[$sourcelinenb][0] = array(
'lib'=>
'File has '.$nboflines.
' lines. However we reach end of file after record '.$sourcelinenb.
'. This may occurs when some records are split onto several lines.',
'type'=>
'EOF_RECORD_ON_SEVERAL_LINES');
1937 if ($excludefirstline && ($sourcelinenb < $excludefirstline))
continue;
1938 if ($endatlinenb && ($sourcelinenb > $endatlinenb))
break;
1941 $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys);
1943 if (count($obj->errors)) $arrayoferrors[$sourcelinenb] = $obj->errors;
1944 if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb] = $obj->warnings;
1945 if (!count($obj->errors) && !count($obj->warnings)) $nbok++;
1948 $obj->import_close_file();
1950 print $langs->trans(
"ErrorFailedToOpenFile", $pathfile);
1953 if (count($arrayoferrors) > 0) $db->rollback();
1959 if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
1962 foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport)
1965 $resqlafterimport = $db->query($sqlafterimport);
1966 if (!$resqlafterimport)
1968 $arrayoferrors[
'none'][] = array(
'lib'=>$langs->trans(
"Error running final request: ".$sqlafterimport));
1974 if (!$error) $db->commit();
1975 else $db->rollback();
1983 print
'<div class="ok">';
1984 print $langs->trans(
"NbOfLinesImported", $nbok).
'</b><br>';
1985 print $langs->trans(
"NbInsert", empty($obj->nbinsert) ? 0 : $obj->nbinsert).
'<br>';
1986 print $langs->trans(
"NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).
'<br><br>';
1988 print
'<div class="center">';
1989 print $langs->trans(
"FileWasImported", $importid).
'<br>';
1990 print
'<span class="opacitymedium">'.$langs->trans(
"YouCanUseImportIdToFindRecord", $importid).
'</span><br>';
2013 function show_elem($fieldssource, $pos, $key, $var, $nostyle =
'')
2019 if ($key ==
'none') {
2021 print
"\n\n<!-- Box_no-key start-->\n";
2022 print
'<div class="box boximport" style="padding:0;">'.
"\n";
2023 print
'<table summary="boxtable_no-key" width="100%" class="nobordernopadding">'.
"\n";
2025 print
"\n\n<!-- Box ".$pos.
" start -->\n";
2026 print
'<div class="box boximport" style="padding: 0;" id="boxto_'.$pos.
'">'.
"\n";
2028 print
'<table summary="boxtable'.$pos.
'" width="100%" class="nobordernopadding">'.
"\n";
2031 if ($pos && $pos > count($fieldssource))
2033 print
'<tr'.($nostyle ?
'' :
' '.$bc[$var]).
' style="height:'.$height.
'">';
2034 print
'<td class="nocellnopadding" width="16" style="font-weight: normal">';
2035 print
img_picto(($pos > 0 ? $langs->trans(
"MoveField", $pos) :
''),
'grip_title',
'class="boxhandle" style="cursor:move;"');
2037 print
'<td style="font-weight: normal">';
2038 print $langs->trans(
"NoFields");
2041 } elseif ($key ==
'none')
2043 print
'<tr'.($nostyle ?
'' :
' '.$bc[$var]).
' style="height:'.$height.
'">';
2044 print
'<td class="nocellnopadding" width="16" style="font-weight: normal">';
2047 print
'<td style="font-weight: normal">';
2053 print
'<tr'.($nostyle ?
'' :
' '.$bc[$var]).
' style="height:'.$height.
'">';
2054 print
'<td class="nocellnopadding" width="16" style="font-weight: normal">';
2056 print
img_picto($langs->trans(
"MoveField", $pos),
'grip_title',
'class="boxhandle" style="cursor:move;"');
2058 print
'<td style="font-weight: normal">';
2059 print $langs->trans(
"Field").
' '.$pos;
2060 $example = $fieldssource[$pos][
'example1'];
2063 if (!
utf8_check($example)) $example = utf8_encode($example);
2064 print
' (<i>'.$example.
'</i>)';
2073 print
"<!-- Box end -->\n\n";
2086 $i = count($fieldssource) + 1;
2089 foreach ($listofkey as $key=>$val)
2091 $maxkey = max($maxkey, $key);
2094 while ($i <= $maxkey)
2096 if (empty($listofkey[$i]))
break;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getnewkey(&$fieldssource, &$listofkey)
Return not used field number.
dol_now($mode= 'auto')
Return date for now.
dol_filesize($pathoffile)
Return size of a file.
show_elem($fieldssource, $pos, $key, $var, $nostyle= '')
Function to put the movable box of a source field.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
img_error($titlealt= 'default')
Show error logo.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
utf8_check($str)
Check if a string is in UTF8.
dol_count_nb_of_line($file)
Count number of lines in a file.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles= 'addedfile', $upload_dir= '')
Make control on an uploaded file from an GUI page and move it to final destination.
print $_SERVER["PHP_SELF"]
Edit parameters.
Parent class for import file readers.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_filemtime($pathoffile)
Return time of a file.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...