28 use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
29 use PhpOffice\PhpSpreadsheet\Spreadsheet;
30 use PhpOffice\PhpSpreadsheet\Style\Alignment;
32 require_once DOL_DOCUMENT_ROOT .
'/core/modules/import/modules_import.php';
55 public $errors = array();
73 public $version =
'dolibarr';
85 public $cacheconvert = array();
87 public $cachefieldtable = array();
104 global $conf, $langs;
109 $this->label =
'Excel 2007';
110 $this->desc = $langs->trans(
"Excel2007FormatDesc");
111 $this->extension =
'xlsx';
112 $this->picto =
'mime/xls';
113 $this->version =
'1.0';
115 require_once DOL_DOCUMENT_ROOT .
'/includes/phpoffice/autoloader.php';
116 require_once DOL_DOCUMENT_ROOT .
'/includes/Psr/autoloader.php';
117 require_once PHPEXCELNEW_PATH .
'Spreadsheet.php';
118 $this->workbook =
new Spreadsheet();
122 if (!class_exists(
'ZipArchive'))
124 $langs->load(
"errors");
125 $this->error = $langs->trans(
'ErrorPHPNeedModule',
'zip');
129 $this->label_lib =
'PhpSpreadSheet';
130 $this->version_lib =
'1.8.0';
132 $this->datatoimport = $datatoimport;
133 if (preg_match(
'/^societe_/', $datatoimport)) $this->thirpartyobject =
new Societe($this->
db);
147 global $user, $conf, $langs, $file;
149 $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs) .
' - Dolibarr ' . DOL_VERSION);
150 $this->workbook->getProperties()->setTitle($outputlangs->trans(
"Import") .
' - ' . $file);
151 $this->workbook->getProperties()->setSubject($outputlangs->trans(
"Import") .
' - ' . $file);
152 $this->workbook->getProperties()->setDescription($outputlangs->trans(
"Import") .
' - ' . $file);
154 $this->workbook->setActiveSheetIndex(0);
155 $this->workbook->getActiveSheet()->setTitle($outputlangs->trans(
"Sheet"));
156 $this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
173 $this->workbook->getActiveSheet()->getStyle(
'1')->getFont()->setBold(
true);
174 $this->workbook->getActiveSheet()->getStyle(
'1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
177 foreach ($headerlinefields as $field) {
178 $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field));
200 foreach ($contentlinevalues as $cell) {
201 $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, $row, $cell);
219 $tempfile = tempnam(sys_get_temp_dir(),
'dol');
220 $objWriter =
new PhpOffice\PhpSpreadsheet\Writer\Xlsx($this->workbook);
221 $objWriter->save($tempfile);
222 $this->workbook->disconnectWorksheets();
223 unset($this->workbook);
225 $content = file_get_contents($tempfile);
245 dol_syslog(get_class($this) .
"::open_file file=" . $file);
247 $reader =
new Xlsx();
248 $this->workbook = $reader->load($file);
266 $reader =
new Xlsx();
267 $this->workbook = $reader->load($file);
269 $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow();
271 $this->workbook->disconnectWorksheets();
272 unset($this->workbook);
288 $this->headers = array();
290 $info = $xlsx->listWorksheetinfo($this->file);
291 $countcolumns = $info[0][
'totalColumns'];
292 for ($col = 1; $col <= $countcolumns; $col++) {
293 $this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue();
310 $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow();
311 if ($this->record > $rowcount)
315 $info = $xlsx->listWorksheetinfo($this->file);
316 $countcolumns = $info[0][
'totalColumns'];
317 for ($col = 1; $col <= $countcolumns; $col++) {
318 $val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue();
319 $array[$col][
'val'] = $val;
320 $array[$col][
'type'] = (
dol_strlen($val) ? 1 : -1);
335 $this->workbook->disconnectWorksheets();
336 unset($this->workbook);
353 public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys)
356 global $langs, $conf, $user;
357 global $thirdparty_static;
358 global $tablewithentity_cache;
362 $this->errors = array();
363 $this->warnings = array();
369 $array_match_database_to_file = array_flip($array_match_file_to_database);
370 $sort_array_match_file_to_database = $array_match_file_to_database;
371 ksort($sort_array_match_file_to_database);
375 if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[1][
'val']))) {
377 $this->warnings[$warning][
'lib'] = $langs->trans(
'EmptyLine');
378 $this->warnings[$warning][
'type'] =
'EMPTY';
381 $last_insert_id_array = array();
385 foreach ($objimport->array_import_tables[0] as $alias => $tablename) {
388 $listfields = array();
389 $listvalues = array();
391 $errorforthistable = 0;
394 if (!isset($tablewithentity_cache[$tablename]))
396 dol_syslog(
"Check if table " . $tablename .
" has an entity field");
397 $resql = $this->
db->DDLDescTable($tablename,
'entity');
399 $obj = $this->
db->fetch_object(
$resql);
400 if ($obj) $tablewithentity_cache[$tablename] = 1;
401 else $tablewithentity_cache[$tablename] = 0;
408 $arrayfield = array();
409 foreach ($sort_array_match_file_to_database as $key => $val) {
410 $arrayfield[$val] = ($key - 1);
414 foreach ($sort_array_match_file_to_database as $key => $val) {
415 $fieldalias = preg_replace(
'/\..*$/i',
'', $val);
416 $fieldname = preg_replace(
'/^.*\./i',
'', $val);
418 if ($alias != $fieldalias)
continue;
420 if ($key <= $maxfields) {
423 if ($arrayrecord[($key)][
'type'] > 0) $newval = $arrayrecord[($key)][
'val'];
428 if (preg_match(
'/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval ==
'')) {
429 $this->errors[$error][
'lib'] = $langs->trans(
'ErrorMissingMandatoryValue', $key);
430 $this->errors[$error][
'type'] =
'NOTNULL';
431 $errorforthistable++;
437 if (!empty($objimport->array_import_convertvalue[0][$val])) {
440 $objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchidfromcodeid'
441 || $objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchidfromref'
442 || $objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchidfromcodeorlabel'
446 if (!is_numeric($newval) && $newval !=
'' && !preg_match(
'/^id:/i', $newval)) $isidorref =
'ref';
447 $newval = preg_replace(
'/^(id|ref):/i',
'', $newval);
450 if ($isidorref ==
'ref') {
451 $file = (empty($objimport->array_import_convertvalue[0][$val][
'classfile']) ? $objimport->array_import_convertvalue[0][$val][
'file'] : $objimport->array_import_convertvalue[0][$val][
'classfile']);
452 $class = $objimport->array_import_convertvalue[0][$val][
'class'];
453 $method = $objimport->array_import_convertvalue[0][$val][
'method'];
454 if ($this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_'][$newval] !=
'') {
455 $newval = $this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_'][$newval];
458 if (empty($resultload)) {
459 dol_print_error(
'',
'Error trying to call file=' . $file .
', class=' . $class .
', method=' . $method);
462 $classinstance =
new $class($this->
db);
464 $param_array = array(
'', $newval);
465 if ($class ==
'AccountingAccount') {
478 $param_array = array(
'', $newval, 0, $arrayrecord[0][
'val']);
480 call_user_func_array(array($classinstance, $method), $param_array);
482 if (!($classinstance->id !=
'') && $objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchidfromcodeorlabel') {
483 $param_array = array(
'',
'', $newval);
484 call_user_func_array(array($classinstance, $method), $param_array);
486 $this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_'][$newval] = $classinstance->id;
488 if ($classinstance->id !=
'')
490 $newval = $classinstance->id;
492 if (!empty($objimport->array_import_convertvalue[0][$val][
'dict'])) $this->errors[$error][
'lib'] = $langs->trans(
'ErrorFieldValueNotIn', $key, $newval,
'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val][
'dict']));
493 elseif (!empty($objimport->array_import_convertvalue[0][$val][
'element'])) $this->errors[$error][
'lib'] = $langs->trans(
'ErrorFieldRefNotIn', $key, $newval, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val][
'element']));
494 else $this->errors[$error][
'lib'] =
'ErrorBadDefinitionOfImportProfile';
495 $this->errors[$error][
'type'] =
'FOREIGNKEY';
496 $errorforthistable++;
501 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchidfromcodeandlabel') {
503 if (!is_numeric($newval) && $newval !=
'' && !preg_match(
'/^id:/i', $newval)) $isidorref =
'ref';
504 $newval = preg_replace(
'/^(id|ref):/i',
'', $newval);
506 if ($isidorref ==
'ref') {
507 $file = (empty($objimport->array_import_convertvalue[0][$val][
'classfile']) ? $objimport->array_import_convertvalue[0][$val][
'file'] : $objimport->array_import_convertvalue[0][$val][
'classfile']);
508 $class = $objimport->array_import_convertvalue[0][$val][
'class'];
509 $method = $objimport->array_import_convertvalue[0][$val][
'method'];
510 $codefromfield = $objimport->array_import_convertvalue[0][$val][
'codefromfield'];
511 $code = $arrayrecord[$arrayfield[$codefromfield]][
'val'];
512 if ($this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_' . $code][$newval] !=
'') {
513 $newval = $this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_' . $code][$newval];
516 if (empty($resultload)) {
517 dol_print_error(
'',
'Error trying to call file=' . $file .
', class=' . $class .
', method=' . $method .
', code=' . $code);
520 $classinstance =
new $class($this->
db);
522 $param_array = array(
'', $newval, $code);
523 call_user_func_array(array($classinstance, $method), $param_array);
524 $this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_' . $code][$newval] = $classinstance->id;
525 if ($classinstance->id > 0)
527 $newval = $classinstance->id;
529 if (!empty($objimport->array_import_convertvalue[0][$val][
'dict'])) $this->errors[$error][
'lib'] = $langs->trans(
'ErrorFieldValueNotIn', $key, $newval,
'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val][
'dict']));
530 else $this->errors[$error][
'lib'] =
'ErrorFieldValueNotIn';
531 $this->errors[$error][
'type'] =
'FOREIGNKEY';
532 $errorforthistable++;
537 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'zeroifnull') {
538 if (empty($newval)) $newval =
'0';
539 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchscalefromcodeunits') {
540 $file = (empty($objimport->array_import_convertvalue[0][$val][
'classfile']) ? $objimport->array_import_convertvalue[0][$val][
'file'] : $objimport->array_import_convertvalue[0][$val][
'classfile']);
541 $class = $objimport->array_import_convertvalue[0][$val][
'class'];
542 $method = $objimport->array_import_convertvalue[0][$val][
'method'];
543 $units = $objimport->array_import_convertvalue[0][$val][
'units'];
544 if ($this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_' . $units][$newval] !=
'') {
545 $newval = $this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_' . $units][$newval];
548 if (empty($resultload)) {
549 dol_print_error(
'',
'Error trying to call file=' . $file .
', class=' . $class .
', method=' . $method .
', units=' . $units);
552 $classinstance =
new $class($this->
db);
554 call_user_func_array(array($classinstance, $method), array(
'',
'', $newval, $units));
555 $scaleorid = (($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale);
556 $this->cacheconvert[$file .
'_' . $class .
'_' . $method .
'_' . $units][$newval] = $scaleorid;
558 if ($classinstance->id > 0)
560 $newval = $scaleorid ? $scaleorid : 0;
562 if (!empty($objimport->array_import_convertvalue[0][$val][
'dict'])) $this->errors[$error][
'lib'] = $langs->trans(
'ErrorFieldValueNotIn', $key, $newval,
'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val][
'dict']));
563 else $this->errors[$error][
'lib'] =
'ErrorFieldValueNotIn';
564 $this->errors[$error][
'type'] =
'FOREIGNKEY';
565 $errorforthistable++;
569 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'getcustomercodeifauto') {
570 if (strtolower($newval) ==
'auto') {
571 $this->thirpartyobject->get_codeclient(0, 0);
572 $newval = $this->thirpartyobject->code_client;
575 if (empty($newval)) $arrayrecord[($key)][
'type'] = -1;
576 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'getsuppliercodeifauto') {
577 if (strtolower($newval) ==
'auto') {
578 $newval = $this->thirpartyobject->get_codefournisseur(0, 1);
579 $newval = $this->thirpartyobject->code_fournisseur;
582 if (empty($newval)) $arrayrecord[($key)][
'type'] = -1;
583 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'getcustomeraccountancycodeifauto') {
584 if (strtolower($newval) ==
'auto') {
585 $this->thirpartyobject->get_codecompta(
'customer');
586 $newval = $this->thirpartyobject->code_compta;
589 if (empty($newval)) $arrayrecord[($key)][
'type'] = -1;
590 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'getsupplieraccountancycodeifauto') {
591 if (strtolower($newval) ==
'auto') {
592 $this->thirpartyobject->get_codecompta(
'supplier');
593 $newval = $this->thirpartyobject->code_compta_fournisseur;
594 if (empty($newval)) $arrayrecord[($key - 1)][
'type'] = -1;
597 if (empty($newval)) $arrayrecord[($key)][
'type'] = -1;
598 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'getrefifauto') {
601 $obj = empty($conf->global->PROJECT_TASK_ADDON) ?
'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
602 if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON .
".php")) {
603 require_once DOL_DOCUMENT_ROOT .
"/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON .
'.php';
605 $defaultref = $modTask->getNextValue(null, null);
607 if (is_numeric($defaultref) && $defaultref <= 0) $defaultref =
'';
608 $newval = $defaultref;
609 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'compute') {
610 $file = (empty($objimport->array_import_convertvalue[0][$val][
'classfile']) ? $objimport->array_import_convertvalue[0][$val][
'file'] : $objimport->array_import_convertvalue[0][$val][
'classfile']);
611 $class = $objimport->array_import_convertvalue[0][$val][
'class'];
612 $method = $objimport->array_import_convertvalue[0][$val][
'method'];
614 if (empty($resultload)) {
615 dol_print_error(
'',
'Error trying to call file=' . $file .
', class=' . $class .
', method=' . $method);
618 $classinstance =
new $class($this->
db);
619 $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
621 if (!empty($objimport->array_import_convertvalue[0][$val][
'dict'])) $this->errors[$error][
'lib'] = $langs->trans(
'ErrorFieldValueNotIn', $key, $newval,
'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val][
'dict']));
622 else $this->errors[$error][
'lib'] =
'ErrorFieldValueNotIn';
623 $this->errors[$error][
'type'] =
'FOREIGNKEY';
624 $errorforthistable++;
627 $newval = $arrayrecord[($key)][
'val'];
629 } elseif ($objimport->array_import_convertvalue[0][$val][
'rule'] ==
'numeric') {
637 if (!empty($objimport->array_import_regex[0][$val]) && ($newval !=
'')) {
640 if (preg_match(
'/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) {
643 $filter = !empty($reg[3]) ? substr($reg[3], 1) :
'';
645 $cachekey = $field .
'@' . $table;
646 if (!empty($filter)) $cachekey .=
':' . $filter;
649 if (!is_array($this->cachefieldtable[$cachekey]))
651 $sql =
"SELECT " . $field .
" as aliasfield FROM " . $table;
652 if (!empty($filter)) {
653 $sql .=
' WHERE ' . $filter;
661 $obj = $this->
db->fetch_object(
$resql);
662 if ($obj) $this->cachefieldtable[$cachekey][] = $obj->aliasfield;
671 if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) {
672 $tableforerror = $table;
673 if (!empty($filter)) $tableforerror .=
':' . $filter;
674 $this->errors[$error][
'lib'] = $langs->transnoentitiesnoconv(
'ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror);
675 $this->errors[$error][
'type'] =
'FOREIGNKEY';
676 $errorforthistable++;
681 elseif (!preg_match(
'/' . $objimport->array_import_regex[0][$val] .
'/i', $newval)) {
683 $this->errors[$error][
'lib'] = $langs->transnoentitiesnoconv(
'ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]);
684 $this->errors[$error][
'type'] =
'REGEX';
685 $errorforthistable++;
695 $listfields[] = $fieldname;
698 if (empty($newval) && $arrayrecord[($key)][
'type'] < 0) $listvalues[] = ($newval ==
'0' ? $newval :
"null");
699 elseif (empty($newval) && $arrayrecord[($key)][
'type'] == 0) $listvalues[] =
"''";
700 else $listvalues[] =
"'" . $this->
db->escape($newval) .
"'";
706 if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) {
708 foreach ($objimport->array_import_fieldshidden[0] as $key => $val) {
709 if (!preg_match(
'/^' . preg_quote($alias,
'/') .
'\./', $key))
continue;
710 if ($val ==
'user->id') {
711 $listfields[] = preg_replace(
'/^' . preg_quote($alias,
'/') .
'\./',
'', $key);
712 $listvalues[] = $user->id;
713 } elseif (preg_match(
'/^lastrowid-/', $val)) {
714 $tmp = explode(
'-', $val);
715 $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0;
716 $keyfield = preg_replace(
'/^' . preg_quote($alias,
'/') .
'\./',
'', $key);
717 $listfields[] = $keyfield;
718 $listvalues[] = $lastinsertid;
720 } elseif (preg_match(
'/^const-/', $val)) {
721 $tmp = explode(
'-', $val, 2);
722 $listfields[] = preg_replace(
'/^' . preg_quote($alias,
'/') .
'\./',
'', $key);
723 $listvalues[] =
"'" . $tmp[1] .
"'";
725 $this->errors[$error][
'lib'] =
'Bad value of profile setup ' . $val .
' for array_import_fieldshidden';
726 $this->errors[$error][
'type'] =
'Import profile setup';
735 if (!$errorforthistable) {
737 if (!empty($listfields)) {
740 if (!empty($updatekeys)) {
743 if (empty($lastinsertid)) {
744 $sqlSelect =
'SELECT rowid FROM ' . $tablename;
746 $data = array_combine($listfields, $listvalues);
749 foreach ($updatekeys as $key) {
750 $col = $objimport->array_import_updatekeys[0][$key];
751 $key = preg_replace(
'/^.*\./i',
'', $key);
752 $where[] = $key .
' = ' . $data[$key];
753 $filters[] = $col .
' = ' . $data[$key];
755 $sqlSelect .=
' WHERE ' . implode(
' AND ', $where);
757 $resql = $this->
db->query($sqlSelect);
759 $res = $this->
db->fetch_object(
$resql);
760 if (
$resql->num_rows == 1) {
761 $lastinsertid = $res->rowid;
762 $last_insert_id_array[$tablename] = $lastinsertid;
763 } elseif (
$resql->num_rows > 1) {
764 $this->errors[$error][
'lib'] = $langs->trans(
'MultipleRecordFoundWithTheseFilters', implode(
', ', $filters));
765 $this->errors[$error][
'type'] =
'SQL';
772 $this->errors[$error][
'lib'] = $this->
db->lasterror();
773 $this->errors[$error][
'type'] =
'SQL';
782 $sqlSelect =
'SELECT rowid FROM ' . $tablename;
784 if (empty($keyfield)) $keyfield =
'rowid';
785 $sqlSelect .=
' WHERE ' . $keyfield .
' = ' . $lastinsertid;
787 $resql = $this->
db->query($sqlSelect);
789 $res = $this->
db->fetch_object(
$resql);
790 if (
$resql->num_rows == 1) {
799 $this->errors[$error][
'lib'] = $this->
db->lasterror();
800 $this->errors[$error][
'type'] =
'SQL';
805 if (!empty($lastinsertid)) {
807 $sqlstart =
'UPDATE ' . $tablename;
809 $data = array_combine($listfields, $listvalues);
811 foreach ($data as $key => $val) {
812 $set[] = $key .
' = ' . $val;
814 $sqlstart .=
' SET ' . implode(
', ', $set);
816 if (empty($keyfield)) $keyfield =
'rowid';
817 $sqlend =
' WHERE ' . $keyfield .
' = ' . $lastinsertid;
819 $sql = $sqlstart . $sqlend;
828 $this->errors[$error][
'lib'] = $this->
db->lasterror();
829 $this->errors[$error][
'type'] =
'SQL';
836 if (!$error && !$updatedone) {
838 $sqlstart =
'INSERT INTO ' . $tablename .
'(' . implode(
', ', $listfields) .
', import_key';
839 $sqlend =
') VALUES(' . implode(
', ', $listvalues) .
", '" . $this->
db->escape($importid) .
"'";
840 if (!empty($tablewithentity_cache[$tablename])) {
841 $sqlstart .=
', entity';
842 $sqlend .=
', ' . $conf->entity;
844 if (!empty($objimport->array_import_tables_creator[0][$alias])) {
845 $sqlstart .=
', ' . $objimport->array_import_tables_creator[0][$alias];
846 $sqlend .=
', ' . $user->id;
848 $sql = $sqlstart . $sqlend .
')';
855 $last_insert_id_array[$tablename] = $this->
db->last_insert_id($tablename);
859 $this->errors[$error][
'lib'] = $this->
db->lasterror();
860 $this->errors[$error][
'type'] =
'SQL';
875 if ($updatedone) $this->nbupdate++;
876 if ($insertdone) $this->nbinsert++;
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
import_open_file($file)
Open input file.
import_read_header()
Input header line from file.
Class to import Excel files.
write_footer_example($outputlangs)
Output footer of an example file for this format.
import_get_nb_of_lines($file)
Return nb of records.
$conf db
API class for accounts.
import_read_record()
Return array of next record in input file.
write_record_example($outputlangs, $contentlinevalues)
Output record of an example file for this format.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
__construct($db, $datatoimport)
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys)
Insert a record into database.
write_header_example($outputlangs)
Output header of an example file for this format.
write_title_example($outputlangs, $headerlinefields)
Output title line of an example file for this format.
Parent class for import file readers.
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...
import_close_file()
Close file handle.