From e9eb22f8f0a8667873e13cafca87723002a28d0d Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 10 Jan 2025 11:17:06 +0100 Subject: [PATCH 01/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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; From f7bd03fb751d611aee6e8483e29c1b8eaaa779e2 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 12 Feb 2025 16:02:00 +0100 Subject: [PATCH 11/51] FIX #33038 drag and drop files are not prefixed with object reference --- htdocs/core/class/fileupload.class.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index ec6465e42f2..c2d44f8b496 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -58,6 +58,7 @@ class FileUpload $pathname = str_replace('/class', '', $element_prop['classpath']); $filename = $element_prop['classfile']; $dir_output = $element_prop['dir_output']; + $savingDocMask = ''; //print 'fileupload.class.php: element='.$element.' pathname='.$pathname.' filename='.$filename.' dir_output='.$dir_output."\n"; @@ -73,6 +74,11 @@ class FileUpload $object_ref = dol_sanitizeFileName($object->ref); + // add object reference as file name prefix if const MAIN_DISABLE_SUGGEST_REF_AS_PREFIX is not enabled + if (!getDolGlobalInt('MAIN_DISABLE_SUGGEST_REF_AS_PREFIX')) { + $savingDocMask = $object_ref.'-__file__'; + } + // Special cases to forge $object_ref used to forge $upload_dir if ($element == 'invoice_supplier') { $object_ref = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object_ref; @@ -98,6 +104,7 @@ class FileUpload 'script_url' => $_SERVER['PHP_SELF'], 'upload_dir' => $dir_output.'/'.$object_ref.'/', 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object_ref.'/', + 'saving_doc_mask' => $savingDocMask, 'param_name' => 'files', // Set the following option to 'POST', if your server does not support // DELETE requests. This is a parameter sent to the client: @@ -417,6 +424,14 @@ class FileUpload if ($validate) { if (dol_mkdir($this->options['upload_dir']) >= 0) { + // add object reference as file name prefix if const MAIN_DISABLE_SUGGEST_REF_AS_PREFIX is not enabled + $fileNameWithoutExt = preg_replace('/\.[^\.]+$/', '', $file->name); + $savingDocMask = $this->options['saving_doc_mask']; + if ($savingDocMask && strpos($savingDocMask, $fileNameWithoutExt) !== 0) { + $fileNameWithPrefix = preg_replace('/__file__/', $file->name, $savingDocMask); + $file->name = $fileNameWithPrefix; + } + $file_path = $this->options['upload_dir'].$file->name; $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); From 0ef79d47d89e044a86d6a093ffd4c9edef737c85 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 12 Feb 2025 22:43:01 +0100 Subject: [PATCH 12/51] Fix warning --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e6198c8bb6e..32796db2147 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -701,7 +701,7 @@ abstract class CommonObject public $user_creation; /** - * @var int User id author/creation + * @var int|null User id author/creation */ public $user_creation_id; From f2f1f5eeddba6c782e52cad322ffe3600adbbe74 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 13 Feb 2025 10:28:19 +0100 Subject: [PATCH 13/51] Fix phpunit --- htdocs/compta/facture/class/facture.class.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 163e1903e71..ed1a480794d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2496,13 +2496,12 @@ class Facture extends CommonInvoice if (isset($this->retained_warranty)) { $this->retained_warranty = (float) $this->retained_warranty; } - if (!isset($this->fk_user_author) && isset($this->user_author) ) { - $this->fk_user_author = $this->user_author; + if (!isset($this->user_creation_id) && isset($this->fk_user_author) ) { + $this->user_creation_id = $this->fk_user_author; + } + if (!isset($this->user_validation_id) && isset($this->fk_user_valid) ) { + $this->user_validation_id = $this->fk_user_valid; } - - - // Check parameters - // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; @@ -2527,8 +2526,8 @@ class Facture extends CommonInvoice $sql .= " total_ttc=".(isset($this->total_ttc) ? (float) $this->total_ttc : "null").","; $sql .= " revenuestamp=".((isset($this->revenuestamp) && $this->revenuestamp != '') ? (float) $this->revenuestamp : "null").","; $sql .= " fk_statut=".(isset($this->status) ? (int) $this->status : "null").","; - $sql .= " fk_user_author=".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null").","; - $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? (int) $this->fk_user_valid : "null").","; + $sql .= " fk_user_author=".(isset($this->user_creation_id) ? ((int) $this->user_creation_id) : "null").","; + $sql .= " fk_user_valid=".(isset($this->user_validation_id) ? (int) $this->user_validation_id : "null").","; $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? (int) $this->fk_facture_source : "null").","; $sql .= " fk_projet=".(isset($this->fk_project) ? (int) $this->fk_project : "null").","; $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? (int) $this->cond_reglement_id : "null").","; From e0370a514369a5480198f0ec15f49e3084817bc2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 13 Feb 2025 11:00:22 +0100 Subject: [PATCH 14/51] FIX sql "order by" is defined twice --- htdocs/contrat/services_list.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 4a2fa3fb219..2a871d7a486 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -395,10 +395,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - -//print $sql; - // Count total nb of records $nbtotalofrecords = ''; if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { @@ -410,7 +406,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { } } -// Complete request and execute it with limit +// Complete request and execute it with order and limit $sql .= $db->order($sortfield, $sortorder); if ($limit) { $sql .= $db->plimit($limit + 1, $offset); From 7997e927a03c51abbc7776c21b7dfc6f0500b5c9 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 13 Feb 2025 14:59:15 +0100 Subject: [PATCH 15/51] fix: On Supplier Order create, if insertExtrafield failed, Dolibarr do not return error and continue --- htdocs/fourn/class/fournisseur.commande.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4f72be4c417..de27129124a 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1610,8 +1610,13 @@ class CommandeFournisseur extends CommonOrder // End call triggers } - $this->db->commit(); - return $this->id; + if (!$error) { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -4; + } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); From c55eb6773ceb969a476058c8350b873fcb48e511 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 13 Feb 2025 17:16:35 +0100 Subject: [PATCH 16/51] FIX wrong path for odt models --- htdocs/compta/facture/class/facture.class.php | 3 ++- htdocs/core/modules/modCommande.class.php | 4 ++-- htdocs/core/modules/modFacture.class.php | 4 ++-- htdocs/core/modules/modPropale.class.php | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ed1a480794d..5c2ae3b38af 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5064,11 +5064,12 @@ class Facture extends CommonInvoice //Avoid php warning Warning: mt_rand(): max(0) is smaller than min(1) when no product exists if (empty($num_prods)) { $num_prods = 1; + $prodids[$num_prods] = 1; } // Initialize parameters $this->id = 0; - $this->entity = 1; + $this->entity = $conf->entity; $this->ref = 'SPECIMEN'; $this->specimen = 1; $this->socid = 1; diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 88fdc6d8abc..276ff239f75 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -94,7 +94,7 @@ class modCommande extends DolibarrModules $r++; $this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/orders"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/orders"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; @@ -459,7 +459,7 @@ class modCommande extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/orders'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/orders'; $dest = $dirodt.'/template_order.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 16c8e983673..62402977443 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -95,7 +95,7 @@ class modFacture extends DolibarrModules $this->const[$r][0] = "FACTURE_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/invoices"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/invoices"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -773,7 +773,7 @@ class modFacture extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/invoices'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/invoices'; $dest = $dirodt.'/template_invoice.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 2e99a82acde..8bac74cc3b8 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -99,7 +99,7 @@ class modPropale extends DolibarrModules $this->const[$r][0] = "PROPALE_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/proposals"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/proposals"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -489,7 +489,7 @@ class modPropale extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/proposals'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/proposals'; $dest = $dirodt.'/template_proposal.odt'; if (file_exists($src) && !file_exists($dest)) { From 8150cc615986cea0ffe7ed4c0e2658b1993bad51 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 13 Feb 2025 18:20:47 +0100 Subject: [PATCH 17/51] FIX wrong ODT path for multicompany --- htdocs/core/modules/modAdherent.class.php | 6 +++--- htdocs/core/modules/modBom.class.php | 4 ++-- htdocs/core/modules/modContrat.class.php | 4 ++-- htdocs/core/modules/modExpedition.class.php | 6 +++--- htdocs/core/modules/modFournisseur.class.php | 8 ++++---- htdocs/core/modules/modHoliday.class.php | 4 ++-- htdocs/core/modules/modMrp.class.php | 4 ++-- htdocs/core/modules/modProjet.class.php | 8 ++++---- htdocs/core/modules/modReception.class.php | 4 ++-- htdocs/core/modules/modSociete.class.php | 4 ++-- htdocs/core/modules/modStock.class.php | 6 +++--- htdocs/core/modules/modSupplierProposal.class.php | 4 ++-- htdocs/core/modules/modTicket.class.php | 4 ++-- .../template/core/modules/modMyModule.class.php | 2 +- 14 files changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 51dd74cc117..2445000cee1 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -182,7 +182,7 @@ class modAdherent extends DolibarrModules $this->const[$r][0] = "MEMBER_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/members"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/members"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -438,8 +438,8 @@ class modAdherent extends DolibarrModules // ODT template /* - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/members/template_member.odt'; + $dirodt=DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/members'; $dest=$dirodt.'/template_order.odt'; if (file_exists($src) && ! file_exists($dest)) { diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index c08828442c9..748332a744c 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -127,7 +127,7 @@ class modBom extends DolibarrModules $this->const = array( 1 => array('BOM_ADDON_PDF', 'chaine', 'generic_bom_odt', 'Name of PDF model of BOM', 0), 2 => array('BOM_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0), - 3 => array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0) + 3 => array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT'.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/boms', '', 0) ); // Some keys to add into the overwriting translation tables @@ -479,7 +479,7 @@ class modBom extends DolibarrModules // ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/boms/template_bom.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/boms'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/boms'; $dest = $dirodt.'/template_bom.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 8154c3f8902..a6bab80e3be 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -87,7 +87,7 @@ class modContrat extends DolibarrModules $this->const[$r][0] = "CONTRACT_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/contracts"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/contracts"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -230,7 +230,7 @@ class modContrat extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/contracts/template_contract.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/contracts'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/contracts'; $dest = $dirodt.'/template_contract.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 0448e1a8f11..aadfda78a18 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -99,7 +99,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "EXPEDITION_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipments"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/shipments"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -120,7 +120,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "DELIVERY_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/deliveries"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/deliveries"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -343,7 +343,7 @@ class modExpedition extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipments/template_shipment.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/shipments'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/shipments'; $dest = $dirodt.'/template_shipment.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 5e7a31b3d77..6a2dacb6bcc 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -117,7 +117,7 @@ class modFournisseur extends DolibarrModules // Add ability ODT for Supplier orders $this->const[$r][0] = "SUPPLIER_ORDER_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_orders"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/supplier_orders"; $this->const[$r][3] = ''; $this->const[$r][4] = 0; $r++; @@ -125,7 +125,7 @@ class modFournisseur extends DolibarrModules // Add ability ODT for Supplier Invoices $this->const[$r][0] = "SUPPLIER_INVOICE_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = ""; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/supplier_invoices"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -972,7 +972,7 @@ class modFournisseur extends DolibarrModules //ODT template for Supplier Orders $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_orders'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/supplier_orders'; $dest = $dirodt.'/template_supplier_order.odt'; if (file_exists($src) && !file_exists($dest)) { @@ -993,7 +993,7 @@ class modFournisseur extends DolibarrModules //ODT template for Supplier Invoice $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_invoices/template_supplier_invoices.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_invoices'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/supplier_invoices'; $dest = $dirodt.'/template_supplier_invoices.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 5e4002b26a4..453bb966a06 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -111,7 +111,7 @@ class modHoliday extends DolibarrModules $this->const[$r][0] = "HOLIDAY_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/holiday"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/holiday"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -308,7 +308,7 @@ class modHoliday extends DolibarrModules //ODT template /*$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/holiday/template_holiday.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/holiday'; + $dirodt=DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/holiday'; $dest=$dirodt.'/template_order.odt'; if (file_exists($src) && ! file_exists($dest)) diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index 08456a9f99c..5b6289c8f10 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -138,7 +138,7 @@ class modMrp extends DolibarrModules $this->const = array( //1=>array('MRP_MO_ADDON_PDF', 'chaine', 'vinci', 'Name of default PDF model of MO', 0), 2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0), - 3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/mrps', '', 0) + 3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT'.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/mrps', '', 0) ); // Some keys to add into the overwriting translation tables @@ -442,7 +442,7 @@ class modMrp extends DolibarrModules // ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/mrps'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/mrps'; $dest = $dirodt.'/template_mo.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index bed2e414cc6..0508a540ce8 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -92,7 +92,7 @@ class modProjet extends DolibarrModules $this->const[$r][0] = "PROJECT_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/projects"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/projects"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -113,7 +113,7 @@ class modProjet extends DolibarrModules $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/tasks"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/tasks"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -379,7 +379,7 @@ class modProjet extends DolibarrModules //ODT template for project $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/projects'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/projects'; $dest = $dirodt.'/template_project.odt'; if (file_exists($src) && !file_exists($dest)) { @@ -395,7 +395,7 @@ class modProjet extends DolibarrModules //ODT template for tasks $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/tasks'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/tasks'; $dest = $dirodt.'/template_task_summary.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index e424325734e..e76ce8b8b78 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -91,7 +91,7 @@ class modReception extends DolibarrModules $this->const[$r][0] = "RECEPTION_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/receptions"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/receptions"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -266,7 +266,7 @@ class modReception extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/reception/template_reception.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/reception'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/reception'; $dest = $dirodt.'/template_reception.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 0c075298d3a..43d8a9ac94b 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -101,7 +101,7 @@ class modSociete extends DolibarrModules $this->const[$r][0] = "COMPANY_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/thirdparties"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/thirdparties"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -947,7 +947,7 @@ class modSociete extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/thirdparties'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/thirdparties'; $dest = $dirodt.'/template_thirdparty.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index c55ad96883c..640300b9479 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -96,14 +96,14 @@ class modStock extends DolibarrModules $r++; $this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/stocks"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; $this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/movements"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/stocks/movements"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; @@ -538,7 +538,7 @@ class modStock extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/stocks/template_warehouse.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/stocks'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/stocks'; $dest = $dirodt.'/template_warehouse.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index d7c7941d08b..4dacfc3ed09 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -92,7 +92,7 @@ class modSupplierProposal extends DolibarrModules $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposals"; + $this->const[$r][2] = "DOL_DATA_ROOT".($conf->entity > 1 ? '/'.$conf->entity : '')."/doctemplates/supplier_proposals"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; @@ -163,7 +163,7 @@ class modSupplierProposal extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposals/template_supplier_proposal.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_proposals'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/supplier_proposals'; $dest = $dirodt.'/template_supplier_proposal.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 17e6ecc9430..4fd1a842ed6 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -110,7 +110,7 @@ class modTicket extends DolibarrModules $this->const = array( 1 => array('TICKET_ENABLE_PUBLIC_INTERFACE', 'chaine', '0', 'Enable ticket public interface', 0), 2 => array('TICKET_ADDON', 'chaine', 'mod_ticket_simple', 'Ticket ref module', 0), - 3 => array('TICKET_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/tickets', 'Ticket templates ODT/ODS directory for templates', 0), + 3 => array('TICKET_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT'.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/tickets', 'Ticket templates ODT/ODS directory for templates', 0), 4 => array('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'chaine', 0, 'Automatically mark ticket as read when created from backend', 0), 5 => array('TICKET_DELAY_BEFORE_FIRST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time before a first answer to a ticket (in hours). Display a warning in tickets list if not respected.', 0), 6 => array('TICKET_DELAY_SINCE_LAST_RESPONSE', 'chaine', '0', 'Maximum wanted elapsed time between two answers on the same ticket (in hours). Display a warning in tickets list if not respected.', 0), @@ -414,7 +414,7 @@ class modTicket extends DolibarrModules //ODT template $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tickets/template_ticket.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/tickets'; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/tickets'; $dest = $dirodt.'/template_ticket.odt'; if (file_exists($src) && !file_exists($dest)) { diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index c79c226fc6f..f7f6805d64a 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -496,7 +496,7 @@ class modMyModule extends DolibarrModules } if ($myTmpObjectArray['includerefgeneration']) { $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_myobjects.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir; + $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/'.$moduledir; $dest = $dirodt.'/template_myobjects.odt'; if (file_exists($src) && !file_exists($dest)) { From 36fd5b7b264d09a6ca69e9e3b4bbd9c840caf7fa Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 13 Feb 2025 20:29:25 +0100 Subject: [PATCH 18/51] FIX #CVE-2024-34051 --- htdocs/main.inc.php | 8 ++++---- test/phpunit/SecurityTest.php | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 88264cf918b..991e73c7ec7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -170,25 +170,25 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/=data:/si', $val); // List of dom events is on https://www.w3schools.com/jsref/dom_obj_event.asp and https://developer.mozilla.org/en-US/docs/Web/Events $inj += preg_match('/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $val); // onmousexxx can be set on img or any html tag like - $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $val); + $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|bounce|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $val); $inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $val); $inj += preg_match('/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $val); $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $val); $inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $val); // More not into the previous list - $inj += preg_match('/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $val); + $inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $val); // We refuse html into html because some hacks try to obfuscate evil strings by inserting HTML into HTML. Example: error=alert(1) to bypass test on onerror $tmpval = preg_replace('/<[^<]+>/', '', $val); // List of dom events is on https://www.w3schools.com/jsref/dom_obj_event.asp and https://developer.mozilla.org/en-US/docs/Web/Events $inj += preg_match('/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $tmpval); // onmousexxx can be set on img or any html tag like - $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|bounce|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $tmpval); // More not into the previous list - $inj += preg_match('/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $tmpval); //$inj += preg_match('/on[A-Z][a-z]+\*=/', $val); // To lock event handlers onAbort(), ... $inj += preg_match('/:|:|:/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...' diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 4fee9d64026..c10a1f5af7c 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -280,6 +280,14 @@ class SecurityTest extends PHPUnit\Framework\TestCase $result=testSqlAndScriptInject($test, 0); $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7'); + $test=''; + $result=testSqlAndScriptInject($test, 0); + $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject onbeforeintput'); + $test=''; + $result=testSqlAndScriptInject($test, 0); + $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject onbounce'); + + $test=''; $result=testSqlAndScriptInject($test, 0); $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb'); From 054010f8ecd55d426c2ac1e5cd5a8bb87e2f83cd Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 13 Feb 2025 20:34:55 +0100 Subject: [PATCH 19/51] Fix test --- test/phpunit/SecurityTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index c10a1f5af7c..f4b2f3e25a3 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -1149,6 +1149,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $this->assertEquals('358080.38', $result); global $leftmenu; // Used into strings to eval + $conf->global->MAIN_FEATURES_LEVEL = 1; $leftmenu = 'AAA'; $result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); @@ -1171,7 +1172,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase print "result16 = ".$result."\n"; $this->assertFalse($result); - $string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)'; + $string = '(isModEnabled("user") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)'; $result=dol_eval($string, 1, 1, '1'); print "result17 = ".$result."\n"; $this->assertTrue($result); From 5fd5eae3b1c2b481cbb55c26409ab236e18261eb Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 14 Feb 2025 09:35:57 +0100 Subject: [PATCH 20/51] set deposit percent to zero on change --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 67a8dab7845..880c450f798 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4332,7 +4332,7 @@ class Form if (depositPercent.length > 0) { $("#' . $htmlname . '_deposit_percent_container").show().find("#' . $htmlname . '_deposit_percent").val(depositPercent); } else { - $("#' . $htmlname . '_deposit_percent_container").hide(); + $("#' . $htmlname . '_deposit_percent_container").hide().find("#' . $htmlname . '_deposit_percent").val(0); } return true; From cb18bebb87d06dc3ecbbf367ad645171ad85c70f Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 14:23:16 +0100 Subject: [PATCH 21/51] Fix warning on date --- htdocs/core/class/commonobject.class.php | 7 ++++--- htdocs/projet/class/task.class.php | 5 ++--- htdocs/projet/tasks/time.php | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 32796db2147..200c6222a3e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -10059,9 +10059,9 @@ abstract class CommonObject /** * Create object in the database * - * @param User $user User that creates - * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers - * @return int<-1,max> Return integer <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int<-1,max> Return integer <0 if KO, Id of created object if OK */ public function createCommon(User $user, $notrigger = 0) { @@ -10080,6 +10080,7 @@ abstract class CommonObject if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) { $fieldvalues['date_creation'] = $this->db->idate($now); } + // For backward compatibility, if a property ->fk_user_creat exists and not filled. if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) { $fieldvalues['fk_user_creat'] = $user->id; $this->fk_user_creat = $user->id; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 83b9b1e55a8..9a32ee96f96 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -139,7 +139,7 @@ class Task extends CommonObjectLine public $timespent_old_duration; public $timespent_date; public $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds) - public $timespent_withhour; // 1 = we entered also start hours for timesheet line + public $timespent_withhour; // 0 or 1 = we have entered also start hours for timesheet line public $timespent_fk_user; public $timespent_thm; public $timespent_note; @@ -1467,10 +1467,9 @@ class Task extends CommonObjectLine $timespent->fk_user = $this->timespent_fk_user; $timespent->fk_product = $this->timespent_fk_product; $timespent->note = $this->timespent_note; - $timespent->datec = $this->db->idate($now); + $timespent->datec = $now; $result = $timespent->create($user); - if ($result > 0) { $ret = $result; $this->timespent_id = $result; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 4f7541724fc..00c4a8e8053 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -175,7 +175,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_year = ''; $search_note = ''; $search_duration = ''; - $search_value = ''; $search_date_startday = ''; $search_date_startmonth = ''; $search_date_startyear = ''; @@ -249,6 +248,7 @@ if ($action == 'addtimespent' && $user->hasRight('projet', 'time')) { $object->timespent_withhour = 1; } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOSTINT("timemonth"), GETPOSTINT("timeday"), GETPOSTINT("timeyear")); + $object->timespent_withhour = 0; } $object->timespent_fk_user = GETPOSTINT("userid"); $object->timespent_fk_product = GETPOSTINT("fk_product"); @@ -299,6 +299,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_withhour = 1; } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); + $object->timespent_withhour = 0; } $object->timespent_fk_user = GETPOSTINT("userid_line"); $object->timespent_fk_product = GETPOSTINT("fk_product"); @@ -328,6 +329,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_withhour = 1; } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOSTINT("timelinemonth"), GETPOSTINT("timelineday"), GETPOSTINT("timelineyear")); + $object->timespent_withhour = 0; } $object->timespent_fk_user = GETPOSTINT("userid_line"); $object->timespent_fk_product = GETPOSTINT("fk_product"); From 7a23905a1d4911acb5e161487f785376bba33392 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 16 Feb 2025 15:03:30 +0100 Subject: [PATCH 22/51] More generic example --- build/makepack-dolibarr.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 020caba8398..2e4652f4970 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -85,8 +85,8 @@ if (! $ENV{"DESTIBETARC"} || ! $ENV{"DESTISTABLE"}) print "set DESTIBETARC=c:/tmp\n"; print "set DESTISTABLE=c:/tmp\n"; print "\n"; - print "Example: DESTIBETARC='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/lastbuild'\n"; - print "Example: DESTISTABLE='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/stable'\n"; + print "Example: DESTIBETARC='/media/HDDATA1_LD/Mes Archives/Doli/dolibarr/files/lastbuild'\n"; + print "Example: DESTISTABLE='/media/HDDATA1_LD/Mes Archives/Doli/dolibarr/files/stable'\n"; sleep 2; exit 1; } From eead065990752a744746ea77421f3c256b2bbfd4 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 15:10:34 +0100 Subject: [PATCH 23/51] More generic example --- build/makepack-dolibarr.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 2e4652f4970..d31e27a223a 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -85,8 +85,9 @@ if (! $ENV{"DESTIBETARC"} || ! $ENV{"DESTISTABLE"}) print "set DESTIBETARC=c:/tmp\n"; print "set DESTISTABLE=c:/tmp\n"; print "\n"; - print "Example: DESTIBETARC='/media/HDDATA1_LD/Mes Archives/Doli/dolibarr/files/lastbuild'\n"; - print "Example: DESTISTABLE='/media/HDDATA1_LD/Mes Archives/Doli/dolibarr/files/stable'\n"; + print "Example in .bashrc:\n"; + print "export DESTIBETARC='/mnt/HDDATA1_LD/Mes Archives/Doli/dolibarr/lastbuild'\n"; + print "export DESTISTABLE='/mnt/HDDATA1_LD/Mes Archives/Doli/dolibarr/stable'\n"; sleep 2; exit 1; } From 7b9dddcfc95ae4032f99f355c1b38f4b04e52bc8 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 15:17:06 +0100 Subject: [PATCH 24/51] Prepare 20.0.4 --- ChangeLog | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/ChangeLog b/ChangeLog index b6d139108ee..823aa8cb42f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,109 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 20.0.4 compared to 20.0.2 ***** +FIX: $this->origin_object can not be instance of CommandeFournisseur if it is already an instanceof CommonObject +FIX: 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237 +FIX: 17.0 - collisions in cache for dol_getIdFromCode +FIX: #18713 +FIX: 20.0 - PHP8 fatal when creating a reception unless corresponding PDF model is enabled +FIX: #21294 Stock import sql query +FIX: #26250 fatal error on kit +FIX: #28702 +FIX: #29624 - substitution of __DATE_DELIVERY__ +FIX: #32113 +FIX: #32186 +FIX: #32339 Delete a loan settlement is partial +FIX: #32387 +FIX: #32477 Loan - Insurance amount need decimals +FIX: #32611 +FIX: #32736 + avoid php warning +FIX: #32743 +FIX: #32765 JS Error: Uncaught TypeError +FIX: #32801 VAT type is inverted in form VAT selector +FIX: #32840 +FIX: #32843 +FIX: #32880 - Tags are using a special rendering. +FIX: add other fields +FIX: autofill price with multicurrency on supplier doc +FIX: avoid phan error +FIX: avoid php8 warnings +FIX: avoid warning with the new Dolistore website +FIX: backport from develop to avoid php warning +FIX: Bad calculation of the theoretical stock. Did not take into account +FIX: bad dispatched quantities for batches on shipment card +FIX: Brian is in the kitchen +FIX: broken feature, compatibility with "Default search filters" +FIX: broken feature with check $pa_ht_isemptystring +FIX: Bug on select user on time.php (all project list) +FIX: can not delete files in task card +FIX: Check "$search_sale" only if it's an internal user +FIX: clean unique extrafields when create product combination +FIX: code not visible correctly into view of dictionary +FIX: compatibility between next_prev_filter and hook return +FIX: compatibility with multicompany +FIX: Complete path was started in #17243 for pdf_cannelle +FIX: Continue for eagle_proforma +FIX: country id is not saved when we provide country_code only +FIX: #CVE-2024-34051 +FIX: delete supplier order when at least one line linked to customer order line +FIX: display error when loan can't be deleted +FIX: display full tree on shipment card when a kit contains a same component in other sub-kit +FIX: DROP INDEX IF EXISTS is not possible ! +FIX: extrafields lost during creation from rec invoice +FIX: FEC import +FIX: Fiscal year - missing translation on status +FIX: Fix return value of hook sendMail when hook return -1 who must be return false in sendfile() function +FIX: GETPOST('private_message') +FIX: glob is better for search files with wildcard + avoid warning +FIX: if $force_entity = 0 ($force_entity != 'default') = false +FIX: Loan - Insurance amount need decimals +FIX: Many status on invoice linked object block +FIX: merge problem +FIX: missing company name if dontaion is linked to third party +FIX: missing default values if $objsrc or $soc fields are empty +FIX: missing edit extrafields inline for member card +FIX: missing quick edit for extrafields +FIX: more bugs and warnings +FIX: Multilangs : PDF lines description +FIX: Must not have both thirdparty and member. +FIX: ODT substitution when many HTML tags in string +FIX: on the road again +FIX: pdf_cannelle (supplier_invoice) add background - Complete #17243 +FIX: Prices didn't update when clone a propale with update prices +FIX: product variants copy: also copy multiprice variations +FIX: refactorize (maybe broken feature for not received completely) +FIX: remove debug trace +FIX: remove socid when cloning a project without third parties +FIX: removes traces of << Date: Sun, 16 Feb 2025 15:25:18 +0100 Subject: [PATCH 25/51] Add missing dpendency to po2debconf --- build/makepack-dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index d31e27a223a..83e1c693d1e 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -36,7 +36,7 @@ $PUBLISHBETARC="dolibarr\@vmprod1.dolibarr.org:/home/dolibarr/asso.dolibarr.org/ "RPM_FEDORA"=>"rpmbuild", "RPM_MANDRIVA"=>"rpmbuild", "RPM_OPENSUSE"=>"rpmbuild", -"DEB"=>"dpkg", +"DEB"=>"dpkg,po2debconf", "FLATPACK"=>"flatpack", "EXEDOLIWAMP"=>"ISCC.exe", "SNAPSHOT"=>"tar" From 030357e87be3d076eefea2a8f9999bc0afa0ee47 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 15:29:01 +0100 Subject: [PATCH 26/51] Fix missing dependency --- build/makepack-dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 83e1c693d1e..c15e79b5947 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -36,7 +36,7 @@ $PUBLISHBETARC="dolibarr\@vmprod1.dolibarr.org:/home/dolibarr/asso.dolibarr.org/ "RPM_FEDORA"=>"rpmbuild", "RPM_MANDRIVA"=>"rpmbuild", "RPM_OPENSUSE"=>"rpmbuild", -"DEB"=>"dpkg,po2debconf", +"DEB"=>"dpkg,po2debconf", # need also debhelper "FLATPACK"=>"flatpack", "EXEDOLIWAMP"=>"ISCC.exe", "SNAPSHOT"=>"tar" From c404b0702e81aabda19e45e9a90f9a664acfdd01 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 15:41:23 +0100 Subject: [PATCH 27/51] Prepare 20.0.5 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 4e38fe07568..388e1d7b5c5 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -35,7 +35,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '20.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '20.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { From 66b767d024cc35ed906ab98a38bee42ebd81d50e Mon Sep 17 00:00:00 2001 From: iLLixM <162678117+iLLixM@users.noreply.github.com> Date: Sun, 16 Feb 2025 18:22:33 +0100 Subject: [PATCH 28/51] Typo in Update ChangeLog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 823aa8cb42f..87f353f6cd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 20.0.4 compared to 20.0.2 ***** +***** ChangeLog for 20.0.4 compared to 20.0.3 ***** FIX: $this->origin_object can not be instance of CommandeFournisseur if it is already an instanceof CommonObject FIX: 17.0 API endpoints "PUT": prevent overwriting all extrafields if only some are supplied in the request cf. PR #29237 FIX: 17.0 - collisions in cache for dol_getIdFromCode From bd9bf8b5a8c9ebebfb09265beea8832b05588d79 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 13 Feb 2025 20:29:25 +0100 Subject: [PATCH 29/51] FIX #CVE-2024-34051 --- htdocs/main.inc.php | 8 ++++---- test/phpunit/SecurityTest.php | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e4e85ad053e..264bd10a07c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -170,25 +170,25 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/=data:/si', $val); // List of dom events is on https://www.w3schools.com/jsref/dom_obj_event.asp and https://developer.mozilla.org/en-US/docs/Web/Events $inj += preg_match('/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $val); // onmousexxx can be set on img or any html tag like - $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $val); + $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|bounce|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $val); $inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $val); $inj += preg_match('/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $val); $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $val); $inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $val); // More not into the previous list - $inj += preg_match('/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $val); + $inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $val); // We refuse html into html because some hacks try to obfuscate evil strings by inserting HTML into HTML. Example: error=alert(1) to bypass test on onerror $tmpval = preg_replace('/<[^<]+>/', '', $val); // List of dom events is on https://www.w3schools.com/jsref/dom_obj_event.asp and https://developer.mozilla.org/en-US/docs/Web/Events $inj += preg_match('/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $tmpval); // onmousexxx can be set on img or any html tag like - $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|bounce|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $tmpval); $inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $tmpval); // More not into the previous list - $inj += preg_match('/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $tmpval); //$inj += preg_match('/on[A-Z][a-z]+\*=/', $val); // To lock event handlers onAbort(), ... $inj += preg_match('/:|:|:/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...' diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index fb3132a17ff..410371f46d2 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -276,6 +276,14 @@ class SecurityTest extends PHPUnit\Framework\TestCase $result=testSqlAndScriptInject($test, 0); $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7'); + $test=''; + $result=testSqlAndScriptInject($test, 0); + $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject onbeforeintput'); + $test=''; + $result=testSqlAndScriptInject($test, 0); + $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject onbounce'); + + $test=''; $result=testSqlAndScriptInject($test, 0); $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb'); From bfa5aaf9ac6a5d30012390fb84b67f972f24326e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 17 Feb 2025 16:01:22 +0100 Subject: [PATCH 30/51] FIX php warning + look and feel --- htdocs/product/admin/product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 82759e7a8d5..e016add79f0 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -657,7 +657,7 @@ if (empty($conf->use_javascript_ajax)) { '2' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', '3' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', ); - print $form->selectarray("activate_usesearchtoselectproduct", $arrval, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); + print $form->selectarray("activate_usesearchtoselectproduct", $arrval, getDolGlobalString('PRODUIT_USE_SEARCH_TO_SELECT'), 0, 0, 0, '', 0, 0, 0, '', 'minwidth400'); print ''; } print ''; From 1904d4da6e6918857d789ca5b11dc4168f55c86c Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 16:42:11 +0100 Subject: [PATCH 31/51] FIX harmless PHP warnings --- htdocs/compta/bank/class/paymentvarious.class.php | 3 ++- htdocs/compta/bank/various_payment/document.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index c42bc942479..1a2bfe8076e 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -767,7 +767,7 @@ class PaymentVarious extends CommonObject */ public function info($id) { - $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; + $sql = 'SELECT v.rowid, v.datec, v.fk_user_author, fk_user_modif, tms'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $sql .= ' WHERE v.rowid = '.((int) $id); @@ -780,6 +780,7 @@ class PaymentVarious extends CommonObject $this->id = $obj->rowid; $this->user_creation = $obj->fk_user_author; + $this->user_creation_id = $obj->fk_user_author; $this->user_modification_id = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 7c717d7ede0..3ee2fbd77e9 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -129,7 +129,7 @@ if ($object->id) { $morehtmlref .= ''; $linkback = ''.$langs->trans("BackToList").''; - $morehtmlstatus = $morehtmlright; + $morehtmlstatus = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus); print '
'; From 9d9d890c974939ffc175565f0de74534579a4ed5 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 18 Feb 2025 12:07:19 +0100 Subject: [PATCH 32/51] FIX accountancy export Quadratus when doc ref is less than 10 char --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index d986e5c0d56..472f5b5ce38 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -966,7 +966,7 @@ class AccountancyExport // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part // $tab['num_piece3'] = str_pad(self::trunc($line->piece_num, 10), 10); - $tab['num_piece3'] = substr(self::trunc($line->doc_ref, 20), -10); + $tab['num_piece3'] = str_pad(substr(self::trunc($line->doc_ref, 20), -10), 10); $tab['reserved'] = str_repeat(' ', 10); // position 159 $tab['currency_amount'] = str_repeat(' ', 13); // position 169 // get document file From f89aff96f7aed4967221242795977c4c1643bcb8 Mon Sep 17 00:00:00 2001 From: tnegre Date: Wed, 19 Feb 2025 11:25:26 +0100 Subject: [PATCH 33/51] FIX invoice creation : use dol_include_once instead of require_once to allow external modules --- htdocs/fourn/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d2699019a63..b09244a027d 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1042,7 +1042,7 @@ if (empty($reshook)) { $object->origin_id = GETPOST('originid', 'int'); - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; @@ -1070,7 +1070,7 @@ if (empty($reshook)) { // Add lines if ($id > 0) { - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; @@ -2026,7 +2026,7 @@ if ($action == 'create') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; From 41e54529b0e6b54bf08878a94928e8d721a23587 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 19 Feb 2025 17:26:54 +0100 Subject: [PATCH 34/51] FIX #33145 wrong label status buy on prodcut tooltip --- htdocs/core/class/commonobject.class.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cf013497aec..807c5f37bfc 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5213,14 +5213,10 @@ abstract class CommonObject $discount->fk_soc = $this->socid; $this->tpl['label'] .= $discount->getNomUrl(0, 'discount'); } elseif (!empty($line->fk_product)) { - $productstatic = new Product($this->db); - $productstatic->id = $line->fk_product; - $productstatic->ref = $line->ref; - $productstatic->type = $line->fk_product_type; - if (empty($productstatic->ref)) { + if (empty($line->product)) { $line->fetch_product(); - $productstatic = $line->product; } + $productstatic = $line->product; $this->tpl['label'] .= $productstatic->getNomUrl(1); $this->tpl['label'] .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); From 5911d7d0c00aad720b22928789e3d8432c9aa6b3 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 20 Feb 2025 08:21:50 +0100 Subject: [PATCH 35/51] Protect product object for line label --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 807c5f37bfc..085b77dd532 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5218,7 +5218,7 @@ abstract class CommonObject } $productstatic = $line->product; - $this->tpl['label'] .= $productstatic->getNomUrl(1); + $this->tpl['label'] .= (is_object($productstatic) ? $productstatic->getNomUrl(1) : $line->ref); $this->tpl['label'] .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); // Dates if ($line->product_type == 1 && ($date_start || $date_end)) { From 0846a1de2e7801b860b5917f6ee0d96d341ad983 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 20 Feb 2025 12:42:53 +0100 Subject: [PATCH 36/51] FIX Corna PDF : error break page --- .../supplier_order/doc/pdf_cornas.modules.php | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 885a25b84b5..8951e69b861 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -269,13 +269,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part + $pdf->SetAutoPageBreak(1, 0); + + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { $heightforfooter += 6; } - $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -328,6 +329,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $nexY = $tab_top - 1; + // Incoterm $height_incoterms = 0; if (isModEnabled('incoterm')) { @@ -337,7 +340,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $nexY); $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter @@ -360,6 +363,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pagenb = $pdf->getPage(); if (!empty($notetoshow)) { + $tab_top -= 2; + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $pageposbeforenote = $pagenb; @@ -368,8 +373,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - $tab_top -= 2; - $pdf->startTransaction(); $pdf->SetFont('', '', $default_font_size - 1); @@ -484,21 +487,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); + $nexY = $tab_top + $this->tabTitleHeight; $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; - // Show square - if ($pagenb == $pageposbeforeprintlines) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } - - $nexY = $tab_top + $this->tabTitleHeight; - // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; @@ -547,20 +540,20 @@ class pdf_cornas extends ModelePDFSuppliersOrders } // Description of product line - $curX = $this->posxdesc - 1; $showpricebeforepagebreak = 1; if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); - $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); + $pageposafter = $pageposbefore; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); - $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text @@ -587,8 +580,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders $posYAfterDescription = $pdf->GetY(); } - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $posYAfterImage); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -790,6 +785,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders } } + // Show square + if ($pagenb == $pageposbeforeprintlines) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis); + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis); + } + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + // Affiche zone infos $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); From db8df90ea8452752272d1418ee2e30d0b773896d Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 20 Feb 2025 14:46:02 +0100 Subject: [PATCH 37/51] Fix #33160 dol_check_secure_access_document bad value for productlot --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 24d223c02cc..6f1fe961852 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3296,7 +3296,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } elseif (isModEnabled("service")) { $original_file = $conf->service->multidir_output[$entity].'/'.$original_file; } - } elseif ($modulepart == 'product_batch' || $modulepart == 'produitlot') { + } elseif ($modulepart == 'product_batch' || $modulepart == 'productlot') { // Wrapping pour les lots produits if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) { return array('accessallowed' => 0, 'error' => 'Value entity must be provided'); From 431a9de17ab26318257137e5da72d9260839e9e4 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Fri, 21 Feb 2025 08:21:17 +0100 Subject: [PATCH 38/51] fix(fourn): use float for multicurrency tx --- htdocs/fourn/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a7d7df70c25..a37b6c7dbbd 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -910,7 +910,7 @@ if (empty($reshook)) { $object->fk_incoterms = GETPOSTINT('incoterm_id'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx'); + $object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx'); $object->transport_mode_id = GETPOSTINT('transport_mode_id'); // Proprietes particulieres a facture avoir @@ -1013,7 +1013,7 @@ if (empty($reshook)) { $object->fk_incoterms = GETPOSTINT('incoterm_id'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx'); + $object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx'); // Source facture $object->fac_rec = $fac_recid; @@ -1080,7 +1080,7 @@ if (empty($reshook)) { $object->fk_incoterms = GETPOSTINT('incoterm_id'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx'); + $object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx'); $object->transport_mode_id = GETPOSTINT('transport_mode_id'); // Auto calculation of date due if not filled by user From 0759814b22b03797609130dbc260940ca761079e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Fri, 21 Feb 2025 11:33:43 +0100 Subject: [PATCH 39/51] Doc --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 87f353f6cd2..3c52f18a9e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -61,7 +61,7 @@ FIX: if $force_entity = 0 ($force_entity != 'default') = false FIX: Loan - Insurance amount need decimals FIX: Many status on invoice linked object block FIX: merge problem -FIX: missing company name if dontaion is linked to third party +FIX: missing company name if donation is linked to third party FIX: missing default values if $objsrc or $soc fields are empty FIX: missing edit extrafields inline for member card FIX: missing quick edit for extrafields From 0dd57bdada4f2026f00e93649d63735931ebd64b Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 21 Feb 2025 11:53:57 +0100 Subject: [PATCH 40/51] Fix signature --- htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php | 3 ++- .../core/modules/supplier_order/doc/pdf_muscadet.modules.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 885a25b84b5..f760deb2dc7 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1143,9 +1143,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders * @param int $hidetop Hide top bar of array * @param int $hidebottom Hide bottom bar of array * @param string $currency Currency code + * @param Translate $outputlangsbis Langs object bis * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null) { global $conf; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 9fd63c8ce7e..93aea2559f5 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -998,9 +998,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param int $hidetop Hide top bar of array * @param int $hidebottom Hide bottom bar of array * @param string $currency Currency code + * @param Translate $outputlangsbis Langs object bis * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null) { global $conf; From 2e0a29d28e17a73f6f9967b0a89271becd3ee407 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Fri, 21 Feb 2025 13:21:51 +0100 Subject: [PATCH 41/51] FIX Missing quotes when using __NOW__ --- htdocs/core/lib/functions.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index cb6b009f99f..95f69e8e3fe 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13502,7 +13502,7 @@ function forgeSQLFromUniversalSearchCriteria($filter, &$errorstr = '', $noand = $ret = ($noand ? "" : " AND ").($nopar ? "" : '(').preg_replace_callback('/'.$regexstring.'/i', 'dolForgeCriteriaCallback', $filter).($nopar ? "" : ')'); if (is_object($db)) { - $ret = str_replace('__NOW__', $db->idate(dol_now()), $ret); + $ret = str_replace('__NOW__', "'".$db->idate(dol_now())."'", $ret); } if (is_object($user)) { $ret = str_replace('__USER_ID__', (string) $user->id, $ret); @@ -13733,8 +13733,10 @@ function dolForgeCriteriaCallback($matches) $tmpescaped = 'NULL'; } elseif (is_int($tmpescaped)) { $tmpescaped = (int) $tmpescaped; - } else { + } elseif (is_numeric((string) $tmpescaped)) { // it can be a float with a . $tmpescaped = (float) $tmpescaped; + } else { + $tmpescaped = preg_replace('/[^a-z0-9_]/i', '', $tmpescaped); // it can be a name of field or a substitution variable like '__NOW__' } } From 6acbaf81f22f0dd12805c77bf0f20766893af104 Mon Sep 17 00:00:00 2001 From: Pratush Raj Date: Fri, 21 Feb 2025 19:05:08 +0530 Subject: [PATCH 42/51] Fixed: 33178 --- htdocs/bom/class/bom.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 1099a9d0ff7..9952525b258 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -292,7 +292,7 @@ class BOM extends CommonObject * @param int $notrigger false=launch triggers after, true=disable triggers * @return int Return integer <0 if KO, Id of created object if OK */ - public function create(User $user, $notrigger = 1) + public function create(User $user, $notrigger = 0) { if ($this->efficiency <= 0 || $this->efficiency > 1) { $this->efficiency = 1; @@ -546,7 +546,7 @@ class BOM extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function update(User $user, $notrigger = 1) + public function update(User $user, $notrigger = 0) { if ($this->efficiency <= 0 || $this->efficiency > 1) { $this->efficiency = 1; From 7cc16734f946c72c70d14ec4d6d9566ddc0bdc9b Mon Sep 17 00:00:00 2001 From: Quentin VIAL--GOUTEYRON Date: Fri, 21 Feb 2025 16:25:28 +0100 Subject: [PATCH 43/51] Missing filter for skill tab --- htdocs/hrm/skill_tab.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/hrm/skill_tab.php b/htdocs/hrm/skill_tab.php index 8f700a087cd..85338f7e486 100644 --- a/htdocs/hrm/skill_tab.php +++ b/htdocs/hrm/skill_tab.php @@ -283,6 +283,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql_skill .=" FROM ".MAIN_DB_PREFIX."hrm_skillrank AS sr"; $sql_skill .=" JOIN ".MAIN_DB_PREFIX."hrm_skill AS s ON sr.fk_skill = s.rowid"; $sql_skill .= " AND sr.fk_object = ".((int) $id); + $sql_skill .= " AND sr.objecttype = '".$db->escape($objecttype)."'"; $result = $db->query($sql_skill); $numSkills = $db->num_rows($result); for ($i=0; $i < $numSkills; $i++) { From c295314edcfe1d0998b27efd743acba9ae082237 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Sat, 22 Feb 2025 02:00:19 +0100 Subject: [PATCH 44/51] FIX - Warehouse default --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a9a84415f4b..b343affbd48 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1922,7 +1922,7 @@ if ($action == 'create') { if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE')) { $warehouse_id = getDolGlobalString('MAIN_DEFAULT_WAREHOUSE'); } - if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE_USER') && !empty($user->warehouse_id)) { + if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE_USER') && !empty($user->fk_warehouse)) { $warehouse_id = $user->fk_warehouse; } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 586eb8bcbaa..db21f28fd8a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1836,7 +1836,7 @@ if ($action == 'create' && $usercancreate) { if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE')) { $warehouse_id = getDolGlobalString('MAIN_DEFAULT_WAREHOUSE'); } - if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE_USER') && !empty($user->warehouse_id)) { + if (empty($object->warehouse_id) && getDolGlobalString('MAIN_DEFAULT_WAREHOUSE_USER') && !empty($user->fk_warehouse)) { $warehouse_id = $user->fk_warehouse; } } From 51e96dfb608e848ebf452aa52b0ca3c137022bc1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 23 Feb 2025 14:16:20 +0100 Subject: [PATCH 45/51] FIX wrong object and avoid warnings --- htdocs/core/lib/signature.lib.php | 2 +- htdocs/fourn/commande/card.php | 1 + htdocs/reception/list.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 4c2e13693ec..d07b2a410f2 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -176,7 +176,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o if ($mode == 1) { $out .= "hash('".$securekeyseed."' + '".$type."' + $type + '_ref)"; } else { - $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0'); + $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $obj->entity), '0'); } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8f3041a20ec..0f23e7776a6 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1962,6 +1962,7 @@ if ($action == 'create') { $formconfirm = ''; + $text = ''; // Confirmation de la suppression de la commande if ($action == 'delete') { diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 13f20113775..b8334a9c729 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -1441,7 +1441,7 @@ print ''; $db->free($resql); $hidegeneratedfilelistifempty = 1; -if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { +if ($massaction == 'builddoc' || $action == 'remove_file' || !empty($show_files)) { $hidegeneratedfilelistifempty = 0; } From 1a55de511ac1f922a64592a7ca216f2207926391 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 23 Feb 2025 22:26:38 +0100 Subject: [PATCH 46/51] FIX Cancel button on edit line must go back to card --- htdocs/compta/facture/card-rec.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 8e996becd5c..292d092bc85 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -145,10 +145,13 @@ $result = restrictedArea($user, 'facture', $object->id, $objecttype); /* * Actions */ - if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; + if ($action != 'updateline') { + $action = 'list'; + $massaction = ''; + } else { + $cancel = ''; + } } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; From d375a4b7940a331f8ad24fbea935f55da4c5757f Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 24 Feb 2025 12:40:04 +0100 Subject: [PATCH 47/51] Doc --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index b4bc00f68ca..ef0a83fa579 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -614,7 +614,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled $deschelp .= '
'.$desc."
\n"; } - if (getDolGlobalString('MAIN_SETUP_MODULES_INFO')) { // Show a custom message + if (getDolGlobalString('MAIN_SETUP_MODULES_INFO')) { // Show a custom message. A good usage for SaaS with option MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING. $deschelp .= '
'.$langs->trans(getDolGlobalString('MAIN_SETUP_MODULES_INFO'))."
\n"; } if ($deschelp) { From 70422e891cd18ef3b7a08650afc66d3a0147700b Mon Sep 17 00:00:00 2001 From: tnegre Date: Wed, 19 Feb 2025 11:25:26 +0100 Subject: [PATCH 48/51] FIX invoice creation : use dol_include_once instead of require_once to allow external modules --- htdocs/fourn/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 01f43d6dc45..6791444e8b2 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1111,7 +1111,7 @@ if (empty($reshook)) { $object->origin_id = GETPOST('originid', 'int'); - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; @@ -1139,7 +1139,7 @@ if (empty($reshook)) { // Add lines if ($id > 0) { - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; @@ -2097,7 +2097,7 @@ if ($action == 'create') { $subelement = 'fournisseur.commande'; } - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; From c8cfb5ae90571043f2e8ffa57af4d94104f2d246 Mon Sep 17 00:00:00 2001 From: tnegre Date: Wed, 19 Feb 2025 11:25:26 +0100 Subject: [PATCH 49/51] FIX invoice creation : use dol_include_once instead of require_once to allow external modules --- htdocs/fourn/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a37b6c7dbbd..f1ab09df0d6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1122,7 +1122,7 @@ if (empty($reshook)) { $object->origin_id = GETPOSTINT('originid'); - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; @@ -1150,7 +1150,7 @@ if (empty($reshook)) { // Add lines if ($id > 0) { - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; @@ -2121,7 +2121,7 @@ if ($action == 'create') { $subelement = 'fournisseur.commande'; } - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); if ($classname == 'Fournisseur.commande') { $classname = 'CommandeFournisseur'; From 950d7259f0da0035400ed186e44e3fd5507249f6 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 25 Feb 2025 15:20:25 +0100 Subject: [PATCH 50/51] Fix Situation Percent with USE_INVOICE_SITUATION = 2 --- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cc0460ffead..2df00a8f637 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2006,7 +2006,7 @@ if (empty($reshook)) { $line->fk_prev_id = $line->id; $line->fetch_optionals(); if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) { - $line->situation_percent = $line->get_allprev_progress($object->id);; // get good progress including credit note + $line->situation_percent = 0; // New situation percent must be 0 (No cumulative) } else { $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5c2ae3b38af..9772c590d85 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3874,7 +3874,12 @@ class Facture extends CommonInvoice $fk_prev_id = 'null'; } if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '' || $situation_percent == null) { - $situation_percent = 100; + // INVOICE_USE_SITUATION = 2 - Lines situation percent on new lines must be 0 (No cumulative) + if ($this->type == Facture::TYPE_SITUATION && getDolGlobalInt('INVOICE_USE_SITUATION') == 2 && (int) $situation_percent < 100) { + $situation_percent = 0; + } else { + $situation_percent = 100; + } } if (empty($ref_ext)) { $ref_ext = ''; From 4f0b90950845abd13bc7b73175f4777c6d294280 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 26 Feb 2025 09:30:37 +0100 Subject: [PATCH 51/51] FIX Stats Supplier turnover by thirdparty - Problem on search --- .../stats/supplier_turnover_by_thirdparty.php | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 367666b0692..1c21c1e2303 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -1,6 +1,7 @@ - * Copyright (C) 2023 Ferran Marcet +/* Copyright (C) 2020 Maxime Kohlhaas + * Copyright (C) 2023 Ferran Marcet + * Copyright (C) 2025 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,11 +57,25 @@ $socid = GETPOSTINT('socid'); // Category $selected_cat = GETPOSTINT('search_categ'); +if ($selected_cat == -1) { + $selected_cat = 0; +} $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; } +// Security check +if ($user->socid > 0) { + $socid = $user->socid; +} +if (isModEnabled('comptabilite')) { + $result = restrictedArea($user, 'compta', '', '', 'resultat'); +} +if (isModEnabled('accounting')) { + $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); +} + // Hook $hookmanager->initHooks(array('supplierturnoverbythirdpartylist')); @@ -148,12 +163,24 @@ $commonparams['sortorder'] = $sortorder; $commonparams['sortfield'] = $sortfield; $headerparams = array(); -$headerparams['date_startyear'] = $date_startyear; -$headerparams['date_startmonth'] = $date_startmonth; -$headerparams['date_startday'] = $date_startday; -$headerparams['date_endyear'] = $date_endyear; -$headerparams['date_endmonth'] = $date_endmonth; -$headerparams['date_endday'] = $date_endday; +if (!empty($date_startyear)) { + $headerparams['date_startyear'] = $date_startyear; +} +if (!empty($date_startmonth)) { + $headerparams['date_startmonth'] = $date_startmonth; +} +if (!empty($date_startday)) { + $headerparams['date_startday'] = $date_startday; +} +if (!empty($date_endyear)) { + $headerparams['date_endyear'] = $date_endyear; +} +if (!empty($date_endmonth)) { + $headerparams['date_endmonth'] = $date_endmonth; +} +if (!empty($date_endday)) { + $headerparams['date_endday'] = $date_endday; +} $tableparams = array(); $tableparams['search_categ'] = $selected_cat; @@ -173,16 +200,7 @@ foreach ($allparams as $key => $value) { $paramslink .= '&'.$key.'='.$value; } -// Security check -if ($user->socid > 0) { - $socid = $user->socid; -} -if (isModEnabled('comptabilite')) { - $result = restrictedArea($user, 'compta', '', '', 'resultat'); -} -if (isModEnabled('accounting')) { - $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); -} + /* @@ -203,6 +221,9 @@ if ($modecompta == "BOOKKEEPINGCOLLECTED") { $modecompta = "RECETTES-DEPENSES"; } +$namelink = ''; +$builddate = dol_now(); + // Show report header if ($modecompta == "CREANCES-DETTES") { $name = $langs->trans("PurchaseTurnover").', '.$langs->trans("ByThirdParties"); @@ -223,7 +244,6 @@ if ($modecompta == "CREANCES-DETTES") { // TODO } -$builddate = dol_now(); $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $period .= ' - '; $period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); @@ -235,7 +255,7 @@ if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $exportlink = ''; -report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode); +report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode); if (isModEnabled('accounting')) { if ($modecompta != 'BOOKKEEPING') {