From 115323dec8e079da7768549da0189ed1e9b5d24c Mon Sep 17 00:00:00 2001 From: alkaan Date: Wed, 20 Nov 2024 20:57:22 +0100 Subject: [PATCH 01/25] FIX : removes traces of << --- htdocs/core/class/commonobject.class.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5333a0b6f17..b81688307b9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2156,12 +2156,7 @@ abstract class CommonObject if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) { $sql .= " AND te.entity IS NOT NULL"; // Show all users } else { -<<<<<<< HEAD - $sql .= " AND ug.fk_user = te.rowid"; - $sql .= " AND ug.entity IN (".getEntity('usergroup').")"; -======= $sql .= " AND ug.entity IN (".getEntity($this->element).")"; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git } } else { $sql .= ' AND te.entity IN ('.getEntity($this->element).')'; From 04b7fdd4c442cc99edef6d04153e66ab1a631f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 19 Dec 2024 18:32:16 +0100 Subject: [PATCH 02/25] fix CI --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c340cbd5d20..39009d1301e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3834,7 +3834,7 @@ abstract class CommonObject $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); if ($justsource || $justtarget) { if ($justsource) { $this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target; @@ -3894,11 +3894,11 @@ abstract class CommonObject $classpath = 'adherents/class'; $module = 'adherent'; } elseif ($objecttype == 'contact') { - $module = 'societe'; - } elseif ($objecttype == 'action') { - $module = 'agenda'; - $subelement = 'actionComm'; - } + $module = 'societe'; + } elseif ($objecttype == 'action') { + $module = 'agenda'; + $subelement = 'actionComm'; + } // Set classfile $classfile = strtolower($subelement); From cd2f211652f09e6991a609b2625ae4deec6b4110 Mon Sep 17 00:00:00 2001 From: PsyCrow <93346975+PsyCrow-code@users.noreply.github.com> Date: Sun, 29 Dec 2024 12:10:26 -0600 Subject: [PATCH 03/25] Error on function purgeSessions() at admin.lib.php Error on function purgeSessions() incorrect evaluation of dol_entity so never purge sessions --- htdocs/core/lib/admin.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 705cf304460..cf3b925b771 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1087,7 +1087,7 @@ function purgeSessions($mysessionid) $sessValues = file_get_contents($fullpath); // get raw session data if (preg_match('/dol_login/i', $sessValues) && // limit to dolibarr session - preg_match('/dol_entity\|s:([0-9]+):"('.$conf->entity.')"/i', $sessValues) && // limit to current entity + (preg_match('/dol_entity\|i:('.$conf->entity.')/', $sessValues) || preg_match('/dol_entity\|s:([0-9]+):"('.$conf->entity.')"/i', $sessValues)) && // limit to current entity preg_match('/dol_company\|s:([0-9]+):"(' . getDolGlobalString('MAIN_INFO_SOCIETE_NOM').')"/i', $sessValues)) { // limit to company name $tmp = explode('_', $file); $idsess = $tmp[1]; From 8416557e083a52aafadd08e192e43ada1ca2cfb1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 4 Jan 2025 10:43:01 +0100 Subject: [PATCH 04/25] FIX $this->origin_object can not be instance of CommandeFournisseur here --- htdocs/reception/class/reception.class.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index ea5794ed324..b85696b9cad 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -729,11 +729,7 @@ class Reception extends CommonObject $this->fetch_origin(); if ($this->origin_object instanceof CommonObject && empty($this->origin_object->lines)) { $res = $this->origin_object->fetch_lines(); - if ($this->origin_object instanceof CommandeFournisseur) { - $this->commandeFournisseur = $this->origin_object; // deprecated - } else { - $this->commandeFournisseur = null; // deprecated - } + $this->commandeFournisseur = null; // deprecated if ($res < 0) { return $res; } From 3e952e76946dd29649366aa58272b7e8a7825510 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 17:47:24 +0100 Subject: [PATCH 05/25] FIX refactorize (maybe broken feature for not received completely) --- htdocs/reception/class/reception.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index b85696b9cad..8478ac2a85b 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -733,6 +733,12 @@ class Reception extends CommonObject if ($res < 0) { return $res; } + } elseif ($this->origin_object instanceof CommandeFournisseur && empty($this->origin_object->lines)) { + $res = $this->origin_object->fetch_lines(); + $this->commandeFournisseur = $this->origin_object; // deprecated + if ($res < 0) { + return $res; + } } } From 584a0a8afe911fd82cf186d57f7ba603f657aca3 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Mon, 6 Jan 2025 15:28:46 +0100 Subject: [PATCH 06/25] Empty child warehouse sql error --- htdocs/product/inventory/class/inventory.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index c1c7772f37a..a1e9da17a1c 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -297,7 +297,9 @@ class Inventory extends CommonObject if (!empty($include_sub_warehouse) && getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE')) { $TChildWarehouses = array(); $this->getChildWarehouse($this->fk_warehouse, $TChildWarehouses); - $sql .= " OR ps.fk_entrepot IN (".$this->db->sanitize(implode(',', $TChildWarehouses)).")"; + if (!empty($TChildWarehouses)){ + $sql .= " OR ps.fk_entrepot IN (".$this->db->sanitize(implode(',', $TChildWarehouses)).")"; + } } $sql .= ')'; } From 39108e70c49b6ac9c2dadd312bb6eee64dcb9798 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Mon, 6 Jan 2025 15:36:56 +0100 Subject: [PATCH 07/25] php error --- htdocs/product/inventory/class/inventory.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index a1e9da17a1c..890bce9870c 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -297,8 +297,8 @@ class Inventory extends CommonObject if (!empty($include_sub_warehouse) && getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE')) { $TChildWarehouses = array(); $this->getChildWarehouse($this->fk_warehouse, $TChildWarehouses); - if (!empty($TChildWarehouses)){ - $sql .= " OR ps.fk_entrepot IN (".$this->db->sanitize(implode(',', $TChildWarehouses)).")"; + if (!empty($TChildWarehouses)) { + $sql .= " OR ps.fk_entrepot IN (" . $this->db->sanitize(implode(',', $TChildWarehouses)) . ")"; } } $sql .= ')'; From 40e59d853bfcc1ccec46928ca89248a8279a9629 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 6 Jan 2025 16:07:15 +0100 Subject: [PATCH 08/25] FIX: switch on/off status of a page of the second website. --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d2ffdb68c48..b17f0e6f92c 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3295,7 +3295,7 @@ if (!GETPOST('hide_websitemenu')) { print ''.img_picto($langs->trans($text_off), 'switch_on').''; } } else { - print ajax_object_onoff($websitepage, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle inline-block'.(empty($websitepage->id) ? ' opacitymedium disabled' : ''), 'statuswebsitepage', 1, 'pageid='.$websitepage->id); + print ajax_object_onoff($websitepage, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle inline-block'.(empty($websitepage->id) ? ' opacitymedium disabled' : ''), 'statuswebsitepage', 1, 'website='.urlencode($website->ref).'&pageid='.((int) $websitepage->id)); } //print ''; print ''; From b4848d90f6e0083ff8134eba8cccf894c0a58727 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Mon, 6 Jan 2025 17:14:50 +0100 Subject: [PATCH 09/25] Doc --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cca97eb20d4..b6d139108ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -441,7 +441,7 @@ WARNING: -------- The following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* If a filter is defined into and extrafields "Select from a table", this filter MUST use the Universai Search Filter syntax (field:=:value) instead of field=value. +* If a filter is defined into an extrafield, this filter MUST use the Universai Search Filter syntax (field:=:value) instead of th eunsecured SQL code field=value. See https://wiki.dolibarr.org/index.php?title=Universal_Search_Filter_Syntax * The parameter $filter of methods fetchAll() does not accept array of SQL commands but must be a string of an Universal Search Filter syntax. See https://wiki.dolibarr.org/index.php?title=Universal_Search_Filter_Syntax From daa18360d7263a7594198ab2a94172a9992d6492 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jan 2025 13:16:32 +0100 Subject: [PATCH 10/25] fix: manage error in Notification triggers --- .../interface_50_modNotification_Notification.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index b9a009f7c0a..3ef8a86ab25 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -94,7 +94,11 @@ class InterfaceNotification extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id); $notify = new Notify($this->db); - $notify->send($action, $object); + $resultSend = $notify->send($action, $object); + if ($resultSend<0) { + $this->errors=array_merge($this->errors, $notify->errors); + return $resultSend; + } return 1; } From 74881ae25125a53396a5ce363e4aa19d67c6e6b9 Mon Sep 17 00:00:00 2001 From: uvaldenaire-opendsi Date: Tue, 7 Jan 2025 12:10:40 +0100 Subject: [PATCH 11/25] fix join societe_commerciaux in societe list --- htdocs/societe/list.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7f978829b91..512b7878a10 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -507,7 +507,7 @@ if ($search_sale == -2) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux AS sc ON s.rowid = sc.fk_soc"; } // Add table from hooks $parameters = array(); @@ -518,9 +518,6 @@ $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } -if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { - $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale -} if (!$user->rights->fournisseur->lire) { $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible } From fc54c837fa899eaa1fed016373972435eacad0f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jan 2025 15:59:07 +0100 Subject: [PATCH 12/25] Update interface_50_modNotification_Notification.class.php --- .../interface_50_modNotification_Notification.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 3ef8a86ab25..18e1dd246ca 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -95,7 +95,7 @@ class InterfaceNotification extends DolibarrTriggers $notify = new Notify($this->db); $resultSend = $notify->send($action, $object); - if ($resultSend<0) { + if ($resultSend < 0) { $this->errors=array_merge($this->errors, $notify->errors); return $resultSend; } From 1d8f9fd24b33e36745e9a6fc018df2775636827b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jan 2025 16:00:31 +0100 Subject: [PATCH 13/25] Update interface_50_modNotification_Notification.class.php --- .../interface_50_modNotification_Notification.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 18e1dd246ca..8fceee8e47a 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -96,7 +96,7 @@ class InterfaceNotification extends DolibarrTriggers $notify = new Notify($this->db); $resultSend = $notify->send($action, $object); if ($resultSend < 0) { - $this->errors=array_merge($this->errors, $notify->errors); + $this->errors = array_merge($this->errors, $notify->errors); return $resultSend; } From 7b08a99cf61c634fb35f8582087b82f4f5ff43db Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jan 2025 17:23:10 +0100 Subject: [PATCH 14/25] fix: remove list mass action update price wihen price mode is not uniq price --- htdocs/product/list.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index f4dbed9b156..c485cdfd3b4 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -829,7 +829,10 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if ($user->hasRight($rightskey, 'creer')) { - $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice"); + if (getDolGlobalString('PRODUCT_PRICE_UNIQ')) { + $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice"); + } + $arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus"); $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus"); } From 9f25fc0c8a03ca3f0357552f51f30ec30b060095 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jan 2025 17:27:11 +0100 Subject: [PATCH 15/25] fix: remove list mass action update price wihen price mode is not uniq price --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index c485cdfd3b4..4d817250cbe 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -829,7 +829,7 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if ($user->hasRight($rightskey, 'creer')) { - if (getDolGlobalString('PRODUCT_PRICE_UNIQ')) { + if (getDolGlobalString('PRODUCT_PRICE_UNIQ') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) { $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice"); } From d711ec05d42c9a6f352c255c820844be7691168e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 7 Jan 2025 18:10:47 +0100 Subject: [PATCH 16/25] FIX broken feature, hook removed --- htdocs/accountancy/admin/account.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 2eea530e96e..df139d5d60d 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -450,6 +450,10 @@ if ($resql) { print '
'; + $parameters = array('chartofaccounts' => $chartofaccounts, 'permissiontoadd' => $permissiontoadd, 'permissiontodelete' => $permissiontodelete); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $accounting, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; From 273ec857a3b0dd60b8ff49dc50ada418ef69d0fd Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 7 Jan 2025 18:35:58 +0100 Subject: [PATCH 17/25] Fix : cron job user rights force reload --- scripts/cron/cron_run_jobs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index ec8abcdea80..3174b0eae7f 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -210,7 +210,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { exit(-1); } } - $user->getrights(); + $user->getrights('', 1); // We force rights reload to have the correct permissions for user in the entity we just switched in } // Reload langs From c130c292ed15e33e319122d643b12761b08e2f5e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jan 2025 19:07:40 +0100 Subject: [PATCH 18/25] fix: undefined variable and bad error messages --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 95b66d2551e..58819af096f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2873,7 +2873,7 @@ if (empty($reshook)) { $percent = $line->get_prev_progress($object->id); } if ((float) $all_progress < (float) $percent) { - $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); + $mesg = $langs->trans("Line").' '.$line->rang.' : '.$langs->trans("CantBeLessThanMinPercent"); setEventMessages($mesg, null, 'warnings'); $result = -1; } else { From dd7b7a8584f96c37dd8c02605f324f5e4816e7be Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Tue, 7 Jan 2025 20:58:16 +0100 Subject: [PATCH 19/25] FIX Bad calculation of the theoretical stock. Did not take into account the inc/dec stock option. --- htdocs/product/class/product.class.php | 32 ++++++++++++++++++++------ htdocs/product/stock/product.php | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index faa655b9bdc..a3096d3bda8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3154,7 +3154,7 @@ class Product extends CommonObject $sql .= " AND c.fk_soc = ".((int) $socid); } if ($filtrestatut != '') { - $sql .= " AND c.fk_statut in (".$this->db->sanitize($filtrestatut).")"; + $sql .= " AND c.fk_statut IN (".$this->db->sanitize($filtrestatut).")"; } $result = $this->db->query($sql); @@ -3187,7 +3187,7 @@ class Product extends CommonObject } // If stock decrease is on invoice validation, the theorical stock continue to - // count the orders to ship in theorical stock when some are already removed by invoice validation. + // count the orders lines in theoretical stock when some are already removed by invoice validation. if ($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_ON_BILL')) { if (getDolGlobalString('DECREASE_ONLY_UNINVOICEDPRODUCTS')) { // If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice. @@ -5841,22 +5841,40 @@ class Product extends CommonObject $this->stock_theorique = $this->stock_reel + $stock_inproduction; + // $weBillOrderOrShipmentReception is set to 'order' or 'shipmentreception'. it will be used to know how to make virtual stock + // calculation when we have a stock increase or decrease on billing. Do we have to count orders to bill or shipment/reception to bill ? + $weBillOrderOrShipmentReception = getDolGlobalString('STOCK_DO_WE_BILL_ORDER_OR_SHIPMENTECEPTION_FOR_VIRTUALSTOCK', 'order'); + // Stock decrease mode if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') || getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { $this->stock_theorique -= ($stock_commande_client - $stock_sending_client); } elseif (getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER')) { - $this->stock_theorique += 0; - } elseif (getDolGlobalString('STOCK_CALCULATE_ON_BILL')) { + if (getDolGlobalString('STOCK_CALCULATE_ON_VALIDATE_ORDER_INCLUDE_DRAFT')) { // By default, draft means "does not exist", so we do not include them by default, except if option is on + $tmpnewprod = dol_clone($this, 1); + $result = $tmpnewprod->load_stats_commande(0, '0', 1); // Get qty in draft orders + $this->stock_theorique += $tmpnewprod->stats_commande['qty']; + } + } elseif (getDolGlobalString('STOCK_CALCULATE_ON_BILL') && $weBillOrderOrShipmentReception == 'order') { $this->stock_theorique -= $stock_commande_client; + } elseif (getDolGlobalString('STOCK_CALCULATE_ON_BILL') && $weBillOrderOrShipmentReception == 'shipmentreception') { + $this->stock_theorique -= ($stock_commande_client - $stock_sending_client); } + // Stock Increase mode if (getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION') || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE')) { $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); - } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')) { + } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')) { // This option is similar to STOCK_CALCULATE_ON_RECEPTION_CLOSE but when module Reception is not enabled $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); - } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')) { + } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER')) { // Warning: stock change "on approval", not on validation ! + if (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER_INCLUDE_DRAFT')) { // By default, draft means "does not exist", so we do not include them by default, except if option is on + $tmpnewprod = dol_clone($this, 1); + $result = $tmpnewprod->load_stats_commande_fournisseur(0, '0', 1); // Get qty in draft orders + $this->stock_theorique += $this->stats_commande_fournisseur['qty']; + } $this->stock_theorique -= $stock_reception_fournisseur; - } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL')) { + } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL') && $weBillOrderOrShipmentReception == 'order') { + $this->stock_theorique += $stock_commande_fournisseur; + } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_BILL') && $weBillOrderOrShipmentReception == 'shipmentreception') { $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 3edb2745d31..0aa66433fc7 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -541,7 +541,7 @@ if ($id > 0 || $ref) { $variants = $object->hasVariants(); - $object->load_stock(); + $object->load_stock(); // This include the load_virtual_stock() $title = $langs->trans('ProductServiceCard'); $helpurl = ''; From ea94370486b052bf53e232023d3063174a276f93 Mon Sep 17 00:00:00 2001 From: Amael-PE Date: Wed, 8 Jan 2025 17:03:15 +0100 Subject: [PATCH 20/25] FIX Complete wath was started in #17243 for pdf_cannelle --- .../core/modules/asset/doc/pdf_standard_asset.modules.php | 6 +++++- .../modules/supplier_invoice/doc/pdf_canelle.modules.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index c28c033b1bb..ae5823861c4 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -286,7 +286,11 @@ class pdf_standard_asset extends ModelePDFAsset // Set path to the background PDF File if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity]; + } + $pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index a6bdd688a07..388b81de18f 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -250,7 +250,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity]; + } + $pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } From 21e997acd79b1d07a6dfb4cfb69a09c99e173e37 Mon Sep 17 00:00:00 2001 From: Amael-PE Date: Wed, 8 Jan 2025 17:06:19 +0100 Subject: [PATCH 21/25] FIX Continue for eagle_proforma --- .../stocktransfer/doc/pdf_eagle_proforma.modules.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 9c6ceccf901..c8982040b2c 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -275,7 +275,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); + $logodir = $conf->mycompany->dir_output; + if (!empty($conf->mycompany->multidir_output[$object->entity])) { + $logodir = $conf->mycompany->multidir_output[$object->entity]; + } + $pagecount = $pdf->setSourceFile($logodir .'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } From 539c8b3e7450d86f402c6f77086a562099b450c6 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Thu, 9 Jan 2025 02:28:00 +0100 Subject: [PATCH 22/25] Fix remove tables not into project --- dev/initdemo/mysqldump_dolibarr_3.5.0.sql | 94 ----------------------- 1 file changed, 94 deletions(-) diff --git a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql index f94c3238db3..8e257afddb4 100644 --- a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql @@ -393,100 +393,6 @@ LOCK TABLES `llx_adherent_type_extrafields` WRITE; /*!40000 ALTER TABLE `llx_adherent_type_extrafields` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `llx_advanced_extrafields` --- - -DROP TABLE IF EXISTS `llx_advanced_extrafields`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_advanced_extrafields` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `entity` int(11) NOT NULL DEFAULT '1', - `elementtype` varchar(64) NOT NULL, - `name` varchar(64) NOT NULL, - `label` varchar(64) NOT NULL, - `format` varchar(8) NOT NULL, - `fieldsize` int(11) DEFAULT NULL, - `maxlength` int(11) DEFAULT NULL, - `options` varchar(255) DEFAULT NULL, - `rang` int(11) DEFAULT NULL, - PRIMARY KEY (`rowid`), - UNIQUE KEY `idx_advanced_extrafields_name` (`elementtype`,`entity`,`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_advanced_extrafields` --- - -LOCK TABLES `llx_advanced_extrafields` WRITE; -/*!40000 ALTER TABLE `llx_advanced_extrafields` DISABLE KEYS */; -/*!40000 ALTER TABLE `llx_advanced_extrafields` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_advanced_extrafields_options` --- - -DROP TABLE IF EXISTS `llx_advanced_extrafields_options`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_advanced_extrafields_options` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `fk_extrafields` int(11) NOT NULL, - `value` varchar(255) NOT NULL, - `rang` int(11) DEFAULT NULL, - PRIMARY KEY (`rowid`), - KEY `idx_advanced_extrafields_options_fk_advanced_extrafields` (`fk_extrafields`), - CONSTRAINT `fk_advanced_extrafields_options_fk_advanced_extrafields` FOREIGN KEY (`fk_extrafields`) REFERENCES `llx_advanced_extrafields` (`rowid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_advanced_extrafields_options` --- - -LOCK TABLES `llx_advanced_extrafields_options` WRITE; -/*!40000 ALTER TABLE `llx_advanced_extrafields_options` DISABLE KEYS */; -/*!40000 ALTER TABLE `llx_advanced_extrafields_options` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_advanced_extrafields_values` --- - -DROP TABLE IF EXISTS `llx_advanced_extrafields_values`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_advanced_extrafields_values` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `entity` int(11) NOT NULL DEFAULT '1', - `datec` datetime DEFAULT NULL, - `datem` datetime DEFAULT NULL, - `fk_element` int(11) NOT NULL, - `fk_extrafields` int(11) NOT NULL, - `value` varchar(255) DEFAULT NULL, - `fk_user_create` int(11) DEFAULT NULL, - `fk_user_modif` int(11) DEFAULT NULL, - PRIMARY KEY (`rowid`), - KEY `idx_advanced_extrafields_values_fk_advanced_extrafields` (`fk_extrafields`,`entity`), - CONSTRAINT `fk_advanced_extrafields_values_fk_advanced_extrafields` FOREIGN KEY (`fk_extrafields`) REFERENCES `llx_advanced_extrafields` (`rowid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_advanced_extrafields_values` --- - -LOCK TABLES `llx_advanced_extrafields_values` WRITE; -/*!40000 ALTER TABLE `llx_advanced_extrafields_values` DISABLE KEYS */; -/*!40000 ALTER TABLE `llx_advanced_extrafields_values` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `llx_bank` -- From f0449e349f0adb37cdea60f1268b93232386f93a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 9 Jan 2025 09:59:23 +0100 Subject: [PATCH 23/25] fix: php warning --- htdocs/core/modules/commande/mod_commande_marbre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index e5e2e525342..e229e17f89e 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -57,7 +57,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes { global $conf, $mysoc; - if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 16.0 && $mysoc->country_code != 'FR') { + if ((float) getDolGlobalString('MAIN_VERSION_LAST_INSTALL') >= 16.0 && $mysoc->country_code != 'FR') { $this->prefix = 'SO'; // We use correct standard code "SO = Sale Order" } } From 90713d7773ed8cf46592f26c2e6c757a5fbf865a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Jan 2025 12:07:03 +0100 Subject: [PATCH 24/25] FIX wrong alias table --- htdocs/compta/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index e5119d46c56..9968411c62e 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -444,7 +444,7 @@ if (isModEnabled('don') && $user->hasRight('don', 'lire')) { print ''; print ''; print ''; print ''; print ''; From aa438e29be1e4cd58ea5224b6f758c3729f3b524 Mon Sep 17 00:00:00 2001 From: tnegre Date: Thu, 9 Jan 2025 17:30:07 +0100 Subject: [PATCH 25/25] fix: avoid duplicate lines in inventory --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 890bce9870c..559ac2cd859 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -274,7 +274,7 @@ class Inventory extends CommonObject // Scan existing stock to prefill the inventory $sql = "SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product, ps.reel,"; if (isModEnabled('productbatch')) { - $sql .= " pb.batch as batch, pb.qty as qty,"; + $sql .= " COALESCE(pb.batch, '') as batch, pb.qty as qty,"; } else { $sql .= " '' as batch, 0 as qty,"; }
'.$langs->trans("BoxTitleLastModifiedDonations", $max); - print '...'; + print '...'; print ''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").'