From 089d24bef01ec864cd31cdb979fb0f26ed71cfb1 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 21 Sep 2023 14:30:37 +0200 Subject: [PATCH 1/2] FIX sql to create batch from shipping line --- .../expedition/class/expeditionlinebatch.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index 10f13d8439c..fbf6564616f 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -125,13 +125,13 @@ class ExpeditionLineBatch extends CommonObject $sql .= ", fk_origin_stock"; $sql .= ", fk_warehouse"; $sql .= ") VALUES ("; - $sql .= $id_line_expdet.","; - $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'").","; - $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : ("'".$this->db->idate($this->eatby))."'").","; - $sql .= " ".(!isset($this->batch) ? 'NULL' : ("'".$this->db->escape($this->batch)."'")).","; - $sql .= " ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ? 'NULL' : $this->dluo_qty) : $this->qty).","; // dluo_qty deprecated, use qty - $sql .= " ".(!isset($this->fk_origin_stock) ? 'NULL' : $this->fk_origin_stock); - $sql .= " ".(!isset($this->fk_warehouse) ? 'NULL' : $this->fk_warehouse); + $sql .= $id_line_expdet; + $sql .= ", ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : ("'".$this->db->idate($this->sellby))."'"); + $sql .= ", ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : ("'".$this->db->idate($this->eatby))."'"); + $sql .= ", ".(!isset($this->batch) ? 'NULL' : ("'".$this->db->escape($this->batch)."'")); + $sql .= ", ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ? 'NULL' : $this->dluo_qty) : $this->qty); // dluo_qty deprecated, use qty + $sql .= ", ".(!isset($this->fk_origin_stock) ? 'NULL' : $this->fk_origin_stock); + $sql .= ", ".(!isset($this->fk_warehouse) ? 'NULL' : $this->fk_warehouse); $sql .= ")"; dol_syslog(__METHOD__, LOG_DEBUG); From 8d38378d3b7fb06153eb84c46788f1c151312c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 21 Sep 2023 16:52:06 +0200 Subject: [PATCH 2/2] NEW: Add preselected update keys attribute to import class and select it by default if filled --- htdocs/imports/class/import.class.php | 3 +++ htdocs/imports/import.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index b5dff8e94c7..97988a1a475 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -61,6 +61,7 @@ class Import public $array_import_entities; public $array_import_regex; public $array_import_updatekeys; + public $array_import_preselected_updatekeys; public $array_import_examplevalues; public $array_import_convertvalue; public $array_import_run_sql_after; @@ -191,6 +192,8 @@ class Import $this->array_import_regex[$i] = (isset($module->import_regex_array[$r]) ? $module->import_regex_array[$r] : ''); // Array of columns allowed as UPDATE options $this->array_import_updatekeys[$i] = (isset($module->import_updatekeys_array[$r]) ? $module->import_updatekeys_array[$r] : ''); + // Array of columns preselected as UPDATE options + $this->array_import_preselected_updatekeys[$i] = (isset($module->import_preselected_updatekeys_array[$r]) ? $module->import_preselected_updatekeys_array[$r] : ''); // Array of examples $this->array_import_examplevalues[$i] = (isset($module->import_examplevalues_array[$r]) ? $module->import_examplevalues_array[$r] : ''); // Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 16160cbffa1..9d5045ecefb 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -153,6 +153,10 @@ $hookmanager->initHooks(array('imports')); $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); +if (empty($updatekeys) && !empty($objimport->array_import_preselected_updatekeys[0])) { + $updatekeys = array_keys($objimport->array_import_preselected_updatekeys[0]); +} + $objmodelimport = new ModeleImports(); $form = new Form($db);