From e9eb22f8f0a8667873e13cafca87723002a28d0d Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 10 Jan 2025 11:17:06 +0100 Subject: [PATCH 01/10] zero could be a value --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 9d265d0240d..3536ec55be5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2076,7 +2076,7 @@ if ($id > 0) { //var_dump($fieldlist); $class = ''; $showfield = 1; - $valuetoshow = empty($obj->$value) ? '' : $obj->$value; + $valuetoshow = !isset($obj->$value) ? '' : $obj->$value; $titletoshow = ''; if ($value == 'entity') { From a34d760a88cfd7a96b00864180aed06cde2d4c5c Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 10 Jan 2025 11:28:46 +0100 Subject: [PATCH 02/10] fix edit : display zero value instead of nothing --- htdocs/admin/dict.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 3536ec55be5..e1a38d4c750 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2445,7 +2445,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && isset($obj->$value) && in_array($obj->type, array('system', 'systemauto'))) { - $hidden = (!empty($obj->{$value}) ? $obj->{$value}:''); + $hidden = (isset($obj->{$value}) ? $obj->{$value}:''); print ''; print ''; print $langs->trans($hidden); @@ -2558,7 +2558,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } elseif ($value == 'price' || preg_match('/^amount/i', $value)) { print ''; } elseif ($value == 'code' && isset($obj->{$value})) { - print ''; + print ''; } elseif ($value == 'unit') { print ''; $units = array( From dd40aea3803251c57f84213eb134ebc68bc5fd49 Mon Sep 17 00:00:00 2001 From: tnegre Date: Tue, 28 Jan 2025 14:18:26 +0100 Subject: [PATCH 03/10] Add hook PrintFieldListFrom on actions list --- htdocs/comm/action/list.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index d3d1ecfb833..18cd89caa2c 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -454,6 +454,12 @@ if ($filtert > 0 || $usergroup > 0) { if ($usergroup > 0) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; } + +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= " WHERE c.id = a.fk_action"; $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode From d288fe74a2372afe67268473fbc8a6d9610cbb1f Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 7 Feb 2025 15:05:49 +0100 Subject: [PATCH 04/10] fk_user_author instead of user_author into update --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1c02a897a14..4f95b29cfa8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2551,7 +2551,7 @@ class Facture extends CommonInvoice $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").","; $sql .= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '') ? $this->db->escape($this->revenuestamp) : "null").","; $sql .= " fk_statut=".(isset($this->statut) ? $this->db->escape($this->statut) : "null").","; - $sql .= " fk_user_author=".(isset($this->user_author) ? $this->db->escape($this->user_author) : "null").","; + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->db->escape($this->fk_user_author) : "null").","; $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->db->escape($this->fk_user_valid) : "null").","; $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? $this->db->escape($this->fk_facture_source) : "null").","; $sql .= " fk_projet=".(isset($this->fk_project) ? $this->db->escape($this->fk_project) : "null").","; From 03340d601622e791b9b00094ce0980e1d70f82ba Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 7 Feb 2025 15:13:20 +0100 Subject: [PATCH 05/10] in case of old code in other part makes a direct assignation --- htdocs/compta/facture/class/facture.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4f95b29cfa8..5011753c47f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2522,6 +2522,9 @@ class Facture extends CommonInvoice if (isset($this->retained_warranty)) { $this->retained_warranty = floatval($this->retained_warranty); } + if (!isset($this->fk_user_author) && isset($this->user_author) ) { + $this->fk_user_author = $this->user_author; + } // Check parameters From 7eba8832e683f4cb4cecdf928427f8ff40622f9e Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Fri, 7 Feb 2025 15:47:36 +0100 Subject: [PATCH 06/10] FIX bad dispatched quantities for batches on shipment card --- htdocs/expedition/dispatch.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index fd9f2f7f1b9..53ac2ff3cc6 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -765,14 +765,14 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; // Dispatch column print ''; // Warehouse column - /*$sql = "SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; - $sql .= " WHERE cfd.fk_commandefourndet = ".(int) $objp->rowid;*/ - - $sql = "SELECT ed.rowid, ed.qty, ed.fk_entrepot, eb.batch, eb.eatby, eb.sellby, cd.fk_product"; - $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as eb on ed.rowid = eb.fk_expeditiondet"; - $sql .= " JOIN ".MAIN_DB_PREFIX."commandedet as cd on ed.fk_origin_line = cd.rowid"; + $sql = "SELECT ed.rowid"; + $sql .= ", cd.fk_product"; + $sql .= ", ".$db->ifsql('eb.rowid IS NULL', 'ed.qty', 'eb.qty')." as qty"; + $sql .= ", ed.fk_entrepot"; + $sql .= ", eb.batch, eb.eatby, eb.sellby"; + $sql .= " FROM ".$db->prefix()."expeditiondet as ed"; + $sql .= " LEFT JOIN ".$db->prefix()."expeditiondet_batch as eb on ed.rowid = eb.fk_expeditiondet"; + $sql .= " INNER JOIN ".$db->prefix()."commandedet as cd on ed.fk_origin_line = cd.rowid"; $sql .= " WHERE ed.fk_origin_line =".(int) $objp->rowid; $sql .= " AND ed.fk_expedition =".(int) $object->id; $sql .= " ORDER BY ed.rowid, ed.fk_origin_line"; From 47f10cdc297433548eb34e35039556e5851d13d7 Mon Sep 17 00:00:00 2001 From: ulysse-vldn Date: Mon, 10 Feb 2025 09:55:47 +0100 Subject: [PATCH 07/10] Fix missing unset post fourn_ref --- htdocs/fourn/facture/card-rec.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index ae26587c6bc..4ef17a83632 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -717,6 +717,7 @@ if (empty($reshook)) { unset($_POST['date_end_fill']); unset($_POST['situations']); unset($_POST['progress']); + unset($_POST['fourn_ref']); } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -859,6 +860,7 @@ if (empty($reshook)) { unset($_POST['date_endyear']); unset($_POST['situations']); unset($_POST['progress']); + unset($_POST['fourn_ref']); } else { setEventMessages($object->error, $object->errors, 'errors'); } From d04ac67ecdc70fa84189ade0490560598840d65a Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 11 Feb 2025 00:31:59 +0100 Subject: [PATCH 08/10] backport 20.0 solution --- htdocs/admin/dict.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e1a38d4c750..c9f44885d2c 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2004,6 +2004,11 @@ if ($id > 0) { $canbemodified = 1; } + if ($tabname[$id] == "c_product_nature" && in_array($obj->code, array(0, 1))) { + $canbedisabled = 0; + $canbemodified = 0; + $iserasable = 0; + } // Build Url. The table is id=, the id of line is rowid= $rowidcol = $tabrowid[$id]; // If rowidcol not defined From 94eaf5d0891320bbf94a975295ff8fc7fe946f23 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 11 Feb 2025 00:32:57 +0100 Subject: [PATCH 09/10] cancel first idea --- htdocs/admin/dict.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index c9f44885d2c..859ef271a85 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2081,7 +2081,7 @@ if ($id > 0) { //var_dump($fieldlist); $class = ''; $showfield = 1; - $valuetoshow = !isset($obj->$value) ? '' : $obj->$value; + $valuetoshow = empty($obj->$value) ? '' : $obj->$value; $titletoshow = ''; if ($value == 'entity') { @@ -2450,7 +2450,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && isset($obj->$value) && in_array($obj->type, array('system', 'systemauto'))) { - $hidden = (isset($obj->{$value}) ? $obj->{$value}:''); + $hidden = (!empty($obj->{$value}) ? $obj->{$value}:''); print ''; print ''; print $langs->trans($hidden); @@ -2563,7 +2563,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') } elseif ($value == 'price' || preg_match('/^amount/i', $value)) { print ''; } elseif ($value == 'code' && isset($obj->{$value})) { - print ''; + print ''; } elseif ($value == 'unit') { print ''; $units = array( From edea44bccba3e580950b1f8310891b416bef3c68 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 11 Feb 2025 17:12:15 +0100 Subject: [PATCH 10/10] FIX display full tree on shipment card when a kit contains a same component in other sub-kit --- htdocs/product/class/product.class.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4860fe9c34a..7f8de67a96a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4966,8 +4966,6 @@ class Product extends CommonObject */ public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = array()) { - global $alreadyfound; - if (empty($id)) { return array(); } @@ -4984,9 +4982,6 @@ class Product extends CommonObject dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.(is_array($parents)?implode(',', $parents):$parents), LOG_DEBUG); - if ($level == 1) { - $alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly - } // Protection against infinite loop if ($level > 30) { return array(); @@ -4995,14 +4990,16 @@ class Product extends CommonObject $res = $this->db->query($sql); if ($res) { $prods = array(); + if ($this->db->num_rows($res) > 0) { + $parents[] = $id; + } + while ($rec = $this->db->fetch_array($res)) { - if (!empty($alreadyfound[$rec['rowid']])) { + if (in_array($rec['id'], $parents)) { dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); - if (in_array($rec['id'], $parents)) { - continue; // We discard this child if it is already found at a higher level in tree in the same branch. - } + continue; // We discard this child if it is already found at a higher level in tree in the same branch. } - $alreadyfound[$rec['rowid']] = 1; + $prods[$rec['rowid']] = array( 0=>$rec['rowid'], 1=>$rec['qty'], @@ -5016,7 +5013,6 @@ class Product extends CommonObject //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - $parents[] = $rec['rowid']; $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, $parents); foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild;