From d59391aaf2d74ee7ebf0a08e498bb8f54a208b47 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 23 Nov 2022 13:08:09 +0100 Subject: [PATCH 01/17] NEW: Add Customer Order delivered (ORDER_CLOSE) in module Notification --- htdocs/core/class/notify.class.php | 1 + htdocs/langs/en_US/other.lang | 1 + htdocs/langs/fr_FR/other.lang | 1 + 3 files changed, 3 insertions(+) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 2a6fdf8def7..d9f5b610877 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -69,6 +69,7 @@ class Notify 'BILL_PAYED', 'ORDER_CREATE', 'ORDER_VALIDATE', + 'ORDER_CLOSE', 'PROPAL_VALIDATE', 'PROPAL_CLOSE_SIGNED', 'FICHINTER_VALIDATE', diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index d5701ba2224..899cd74a79d 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -40,6 +40,7 @@ notiftofixedemail=To fixed mail notiftouserandtofixedemail=To user and fixed mail Notify_ORDER_VALIDATE=Sales order validated Notify_ORDER_SENTBYMAIL=Sales order sent by mail +Notify_ORDER_CLOSE=Sales order delivered Notify_ORDER_SUPPLIER_SENTBYMAIL=Purchase order sent by email Notify_ORDER_SUPPLIER_VALIDATE=Purchase order recorded Notify_ORDER_SUPPLIER_APPROVE=Purchase order approved diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 6c714be2c4d..dc5bae1efa9 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -40,6 +40,7 @@ notiftofixedemail=aux e-mails définis notiftouserandtofixedemail=Aux utilisateurs et e-mails définis Notify_ORDER_VALIDATE=Validation commande client Notify_ORDER_SENTBYMAIL=Envoi commande client par email +Notify_ORDER_CLOSE=Commande client livrée Notify_ORDER_SUPPLIER_SENTBYMAIL=Envoi commande fournisseur par email Notify_ORDER_SUPPLIER_VALIDATE=Commande fournisseur enregistrée Notify_ORDER_SUPPLIER_APPROVE=Commande fournisseur approuvée From 0b4d8775b484014972ffaae732439c4ffb70fcd7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 23 Nov 2022 14:00:24 +0100 Subject: [PATCH 02/17] add good text --- htdocs/core/class/notify.class.php | 13 +++++++++++++ htdocs/langs/en_US/other.lang | 1 + htdocs/langs/fr_FR/other.lang | 1 + 3 files changed, 15 insertions(+) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index d9f5b610877..ad0cd6a50a9 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -496,6 +496,13 @@ class Notify $labeltouse = $conf->global->ORDER_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; + case 'ORDER_CLOSE': + $link = ''.$newref.''; + $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); + $object_type = 'order'; + $labeltouse = $conf->global->ORDER_CLOSE_TEMPLATE; + $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderClose", $link); + break; case 'PROPAL_VALIDATE': $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); @@ -740,6 +747,12 @@ class Notify $object_type = 'order'; $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; + case 'ORDER_CLOSE': + $link = ''.$newref.''; + $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); + $object_type = 'order'; + $mesg = $langs->transnoentitiesnoconv("EMailTextOrderClose", $link); + break; case 'PROPAL_VALIDATE': $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 899cd74a79d..008333b8c0b 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -213,6 +213,7 @@ EMailTextInvoicePayed=Invoice %s has been paid. EMailTextProposalValidated=Proposal %s has been validated. EMailTextProposalClosedSigned=Proposal %s has been closed signed. EMailTextOrderValidated=Order %s has been validated. +EMailTextOrderClose=Order %s has been delivered. EMailTextOrderApproved=Order %s has been approved. EMailTextOrderValidatedBy=Order %s has been recorded by %s. EMailTextOrderApprovedBy=Order %s has been approved by %s. diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index dc5bae1efa9..e16102d4c5b 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -212,6 +212,7 @@ EMailTextInvoicePayed=La facture %s a été payée. EMailTextProposalValidated=La proposition commerciale %s vous concernant a été validée. EMailTextProposalClosedSigned=La proposition %s a été clôturée signée. EMailTextOrderValidated=La commande %s a été validée. +EMailTextOrderClose=La commande %s a été livrée. EMailTextOrderApproved=La commande %s a été approuvée. EMailTextOrderValidatedBy=La commande %s a été enregistrée par %s EMailTextOrderApprovedBy=La commande %s a été approuvée par %s. From 483e9814f9ae4d646d1361c3bf4706aa5659c9e9 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 1 Dec 2022 14:33:35 +0100 Subject: [PATCH 03/17] NEW filter on entity in import --- htdocs/core/modules/import/import_csv.modules.php | 12 ++++++++++++ htdocs/core/modules/import/import_xlsx.modules.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 22c12024c2b..0fc2a6609cb 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -870,6 +870,10 @@ class ImportCsv extends ModeleImports $filters[] = $col.' = '.$data[$key]; } } + if (!empty($tablewithentity_cache[$tablename])) { + $where[] = "entity = ".((int) $conf->entity); + $filters[] = "entity = ".((int) $conf->entity); + } $sqlSelect .= " WHERE ".implode(' AND ', $where); $resql = $this->db->query($sqlSelect); @@ -906,6 +910,10 @@ class ImportCsv extends ModeleImports } $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); + if (!empty($tablewithentity_cache[$tablename])) { + $sqlSelect .= " AND entity = ".((int) $conf->entity); + } + $resql = $this->db->query($sqlSelect); if ($resql) { $res = $this->db->fetch_object($resql); @@ -951,6 +959,10 @@ class ImportCsv extends ModeleImports $sqlend = " WHERE " . implode(' AND ', $where); } + if (!empty($tablewithentity_cache[$tablename])) { + $sqlend .= " AND entity = ".((int) $conf->entity); + } + $sql = $sqlstart.$sqlend; // Run update request diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 35adc4476a0..ebfce90c26e 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -916,6 +916,10 @@ class ImportXlsx extends ModeleImports $filters[] = $col.' = '.$data[$key]; } } + if (!empty($tablewithentity_cache[$tablename])) { + $where[] = "entity = ".((int) $conf->entity); + $filters[] = "entity = ".((int) $conf->entity); + } $sqlSelect .= " WHERE " . implode(' AND ', $where); $resql = $this->db->query($sqlSelect); @@ -953,6 +957,10 @@ class ImportXlsx extends ModeleImports } $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); + if (!empty($tablewithentity_cache[$tablename])) { + $sqlSelect .= " AND entity = ".((int) $conf->entity); + } + $resql = $this->db->query($sqlSelect); if ($resql) { $res = $this->db->fetch_object($resql); @@ -998,6 +1006,10 @@ class ImportXlsx extends ModeleImports $sqlend = " WHERE " . implode(' AND ', $where); } + if (!empty($tablewithentity_cache[$tablename])) { + $sqlend .= " AND entity = ".((int) $conf->entity); + } + $sql = $sqlstart . $sqlend; // Run update request From e6606f3b366dfd8e973f3e08748cc80bc7a9d57c Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 18 Jan 2023 11:22:52 +0100 Subject: [PATCH 04/17] NEW map table to element for get entity in import --- .../modules/import/import_csv.modules.php | 10 ++-- .../modules/import/import_xlsx.modules.php | 10 ++-- htdocs/core/modules/import/modules_import.php | 59 ++++++++++++++++++- 3 files changed, 70 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 0fc2a6609cb..393e3c54cee 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -96,6 +96,8 @@ class ImportCsv extends ModeleImports public function __construct($db, $datatoimport) { global $conf, $langs; + + parent::__construct(); $this->db = $db; $this->separator = (GETPOST('separator') ?GETPOST('separator') : (empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->IMPORT_CSV_SEPARATOR_TO_USE)); @@ -871,8 +873,8 @@ class ImportCsv extends ModeleImports } } if (!empty($tablewithentity_cache[$tablename])) { - $where[] = "entity = ".((int) $conf->entity); - $filters[] = "entity = ".((int) $conf->entity); + $where[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + $filters[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; } $sqlSelect .= " WHERE ".implode(' AND ', $where); @@ -911,7 +913,7 @@ class ImportCsv extends ModeleImports $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); if (!empty($tablewithentity_cache[$tablename])) { - $sqlSelect .= " AND entity = ".((int) $conf->entity); + $sqlSelect .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; } $resql = $this->db->query($sqlSelect); @@ -960,7 +962,7 @@ class ImportCsv extends ModeleImports } if (!empty($tablewithentity_cache[$tablename])) { - $sqlend .= " AND entity = ".((int) $conf->entity); + $sqlend .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; } $sql = $sqlstart.$sqlend; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index ebfce90c26e..acd2a10b040 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -106,6 +106,8 @@ class ImportXlsx extends ModeleImports public function __construct($db, $datatoimport) { global $conf, $langs; + + parent::__construct(); $this->db = $db; // this is used as an extension from the example file code, so we have to put xlsx here !!! @@ -917,8 +919,8 @@ class ImportXlsx extends ModeleImports } } if (!empty($tablewithentity_cache[$tablename])) { - $where[] = "entity = ".((int) $conf->entity); - $filters[] = "entity = ".((int) $conf->entity); + $where[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; + $filters[] = "entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; } $sqlSelect .= " WHERE " . implode(' AND ', $where); @@ -958,7 +960,7 @@ class ImportXlsx extends ModeleImports $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); if (!empty($tablewithentity_cache[$tablename])) { - $sqlSelect .= " AND entity = ".((int) $conf->entity); + $sqlSelect .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; } $resql = $this->db->query($sqlSelect); @@ -1007,7 +1009,7 @@ class ImportXlsx extends ModeleImports } if (!empty($tablewithentity_cache[$tablename])) { - $sqlend .= " AND entity = ".((int) $conf->entity); + $sqlend .= " AND entity IN (".getEntity($this->getElementFromTableWithPrefix($tablename)).")"; } $sql = $sqlstart . $sqlend; diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index d875afc5c4f..73e36bf246c 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -75,14 +75,53 @@ class ModeleImports public $libversion = array(); + /** + * @var array Element mapping from table name + */ + public static $mapTableToElement = array( + 'actioncomm' => 'agenda', + 'adherent' => 'member', + 'adherent_type' => 'member_type', + 'bank_account' => 'bank_account', + 'categorie' => 'category', + 'commande' => 'commande', + 'commande_fournisseur' => 'commande_fournisseur', + 'contrat' => 'contract', + 'entrepot' => 'stock', + 'expensereport' => 'expensereport', + 'facture' => 'invoice', + 'facture_fourn' => 'facture_fourn', + 'fichinter' => 'intervention', + 'holiday' => 'holiday', + 'product' => 'product', + 'productprice' => 'productprice', + 'product_fournisseur_price' => 'productsupplierprice', + 'projet' => 'project', + 'propal' => 'propal', + 'societe' => 'societe', + 'socpeople' => 'contact', + 'supplier_proposal' => 'supplier_proposal', + 'ticket' => 'ticket', + ); /** * Constructor */ public function __construct() { - } + global $hookmanager; + if (is_object($hookmanager)) { + $hookmanager->initHooks(array('import')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('constructModeleImports', $parameters, $this); + if ($reshook >= 0 && !empty($hookmanager->resArray)) { + foreach ($hookmanager->resArray as $mapList) { + self::$mapTableToElement[$mapList['table']] = $mapList['element']; + } + } + } + } /** * getDriverId @@ -269,4 +308,22 @@ class ModeleImports { return $this->libversion[$key]; } + + /** + * Get element from table name with prefix + * + * @param string $tableNameWithPrefix Table name with prefix + * @return string Element name or '' if not found + */ + public function getElementFromTableWithPrefix($tableNameWithPrefix) + { + $element = ''; + + $tableElement = preg_replace('/^'.preg_quote($this->db->prefix(), '/').'/', '', $tableNameWithPrefix); + if (isset(self::$mapTableToElement[$tableElement])) { + $element = self::$mapTableToElement[$tableElement]; + } + + return $element; + } } From 1e8dc90b41dcbd0d1cbc46f614dd28d3cddff5f4 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Fri, 20 Jan 2023 10:39:02 +0100 Subject: [PATCH 05/17] Update modules_import.php --- htdocs/core/modules/import/modules_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 73e36bf246c..5904af215d0 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -94,7 +94,7 @@ class ModeleImports 'fichinter' => 'intervention', 'holiday' => 'holiday', 'product' => 'product', - 'productprice' => 'productprice', + 'product_price' => 'productprice', 'product_fournisseur_price' => 'productsupplierprice', 'projet' => 'project', 'propal' => 'propal', From f3f840f7e81e2466421cfda22eb39c2a7cd3d20e Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 26 Jan 2023 15:05:59 +0100 Subject: [PATCH 06/17] NEW remove keys whose table element is the same as element in map list --- htdocs/core/modules/import/modules_import.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 5904af215d0..0c31f95ce66 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -82,26 +82,26 @@ class ModeleImports 'actioncomm' => 'agenda', 'adherent' => 'member', 'adherent_type' => 'member_type', - 'bank_account' => 'bank_account', + //'bank_account' => 'bank_account', 'categorie' => 'category', - 'commande' => 'commande', - 'commande_fournisseur' => 'commande_fournisseur', + //'commande' => 'commande', + //'commande_fournisseur' => 'commande_fournisseur', 'contrat' => 'contract', 'entrepot' => 'stock', - 'expensereport' => 'expensereport', + //'expensereport' => 'expensereport', 'facture' => 'invoice', - 'facture_fourn' => 'facture_fourn', + //'facture_fourn' => 'facture_fourn', 'fichinter' => 'intervention', - 'holiday' => 'holiday', - 'product' => 'product', + //'holiday' => 'holiday', + //'product' => 'product', 'product_price' => 'productprice', 'product_fournisseur_price' => 'productsupplierprice', 'projet' => 'project', - 'propal' => 'propal', - 'societe' => 'societe', + //'propal' => 'propal', + //'societe' => 'societe', 'socpeople' => 'contact', - 'supplier_proposal' => 'supplier_proposal', - 'ticket' => 'ticket', + //'supplier_proposal' => 'supplier_proposal', + //'ticket' => 'ticket', ); /** @@ -313,13 +313,13 @@ class ModeleImports * Get element from table name with prefix * * @param string $tableNameWithPrefix Table name with prefix - * @return string Element name or '' if not found + * @return string Element name or table element as default */ public function getElementFromTableWithPrefix($tableNameWithPrefix) { - $element = ''; - $tableElement = preg_replace('/^'.preg_quote($this->db->prefix(), '/').'/', '', $tableNameWithPrefix); + $element = $tableElement; + if (isset(self::$mapTableToElement[$tableElement])) { $element = self::$mapTableToElement[$tableElement]; } From aad63c5f033f23733c92604f2905678a14cdf475 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Wed, 8 Feb 2023 15:35:45 +0100 Subject: [PATCH 07/17] In addition to the hook selectProductsListWhere in the function select_produits_list, added the hooks selectProductsListSelect, selectProductsListFrom, and constructProductListOption. --- htdocs/core/class/html.form.class.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c6cf71fbe44..47c03958a74 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2542,6 +2542,10 @@ class Form global $langs, $conf; global $hookmanager; + if (empty($hookmanager->hooks)) { + $hookmanager->initHooks(array('commonobject')); + } + $out = ''; $outarray = array(); @@ -2572,7 +2576,10 @@ class Form } $sql = "SELECT "; - $sql .= $selectFields.$selectFieldsGrouped; + // Add select from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectProductsListSelect', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint; if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) { //Product category @@ -2619,6 +2626,10 @@ class Form $selectFields .= ", price_rowid, price_by_qty"; } $sql .= " FROM ".$this->db->prefix()."product as p"; + // Add from (left join) from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('selectProductsListFrom', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; if (count($warehouseStatusArray)) { $sql .= " LEFT JOIN ".$this->db->prefix()."product_stock as ps on ps.fk_product = p.rowid"; $sql .= " LEFT JOIN ".$this->db->prefix()."entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".getEntity('stock').")"; @@ -2890,6 +2901,11 @@ class Form protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { global $langs, $conf, $user; + global $hookmanager; + + if (empty($hookmanager->hooks)) { + $hookmanager->initHooks(array('commonobject')); + } $outkey = ''; $outval = ''; @@ -3175,6 +3191,14 @@ class Form } } + $parameters = array('objp'=>$objp); + $reshook = $hookmanager->executeHooks('constructProductListOption', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($reshook)) { + $opt = $hookmanager->resPrint; + } else { + $opt .= $hookmanager->resPrint; + } + $opt .= "\n"; $optJson = array( 'key'=>$outkey, From 894caf1ada419e127ae8adc106f734c5ea476677 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 9 Feb 2023 09:10:38 +0100 Subject: [PATCH 08/17] Corrected Stickler CI errors. --- htdocs/core/class/html.form.class.php | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 47c03958a74..f8c04c562af 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2542,9 +2542,9 @@ class Form global $langs, $conf; global $hookmanager; - if (empty($hookmanager->hooks)) { - $hookmanager->initHooks(array('commonobject')); - } + if (empty($hookmanager->hooks)) { + $hookmanager->initHooks(array('commonobject')); + } $out = ''; $outarray = array(); @@ -2901,11 +2901,11 @@ class Form protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { global $langs, $conf, $user; - global $hookmanager; + global $hookmanager; - if (empty($hookmanager->hooks)) { - $hookmanager->initHooks(array('commonobject')); - } + if (empty($hookmanager->hooks)) { + $hookmanager->initHooks(array('commonobject')); + } $outkey = ''; $outval = ''; @@ -3191,13 +3191,13 @@ class Form } } - $parameters = array('objp'=>$objp); - $reshook = $hookmanager->executeHooks('constructProductListOption', $parameters); // Note that $action and $object may have been modified by hook - if (!empty($reshook)) { - $opt = $hookmanager->resPrint; - } else { - $opt .= $hookmanager->resPrint; - } + $parameters = array('objp'=>$objp); + $reshook = $hookmanager->executeHooks('constructProductListOption', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($reshook)) { + $opt = $hookmanager->resPrint; + } else { + $opt .= $hookmanager->resPrint; + } $opt .= "\n"; $optJson = array( From 2629eb5bb80f393dcf1184788e9af85c9033282c Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 9 Feb 2023 10:02:24 +0100 Subject: [PATCH 09/17] Corrected Stickler CI errors once again by setting a proper PHP indentation style. --- htdocs/core/class/html.form.class.php | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f8c04c562af..1db337166ad 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2542,9 +2542,9 @@ class Form global $langs, $conf; global $hookmanager; - if (empty($hookmanager->hooks)) { - $hookmanager->initHooks(array('commonobject')); - } + if (empty($hookmanager->hooks)) { + $hookmanager->initHooks(array('commonobject')); + } $out = ''; $outarray = array(); @@ -2901,11 +2901,11 @@ class Form protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { global $langs, $conf, $user; - global $hookmanager; + global $hookmanager; - if (empty($hookmanager->hooks)) { - $hookmanager->initHooks(array('commonobject')); - } + if (empty($hookmanager->hooks)) { + $hookmanager->initHooks(array('commonobject')); + } $outkey = ''; $outval = ''; @@ -3191,13 +3191,13 @@ class Form } } - $parameters = array('objp'=>$objp); - $reshook = $hookmanager->executeHooks('constructProductListOption', $parameters); // Note that $action and $object may have been modified by hook - if (!empty($reshook)) { - $opt = $hookmanager->resPrint; - } else { - $opt .= $hookmanager->resPrint; - } + $parameters = array('objp'=>$objp); + $reshook = $hookmanager->executeHooks('constructProductListOption', $parameters); // Note that $action and $object may have been modified by hook + if (!empty($reshook)) { + $opt = $hookmanager->resPrint; + } else { + $opt .= $hookmanager->resPrint; + } $opt .= "\n"; $optJson = array( From c9369415a226b681783f5b906f783b0a41d05249 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Wed, 15 Feb 2023 15:15:57 +0100 Subject: [PATCH 10/17] Removed not necessary 'if (empty(->hooks)) { ... } block. --- htdocs/core/class/html.form.class.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5e5b1920b6b..eb0cfed4fea 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2546,10 +2546,6 @@ class Form global $langs, $conf; global $hookmanager; - if (empty($hookmanager->hooks)) { - $hookmanager->initHooks(array('commonobject')); - } - $out = ''; $outarray = array(); @@ -2907,10 +2903,6 @@ class Form global $langs, $conf, $user; global $hookmanager; - if (empty($hookmanager->hooks)) { - $hookmanager->initHooks(array('commonobject')); - } - $outkey = ''; $outval = ''; $outref = ''; From 581b8df8ce89118114bbc47d8f47b919ba6453db Mon Sep 17 00:00:00 2001 From: mgabriel Date: Wed, 15 Feb 2023 15:40:30 +0100 Subject: [PATCH 11/17] Resolved merge conflict. --- htdocs/langs/fr_FR/errors.lang | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 803bebf310e..939c070008d 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -348,11 +348,7 @@ WarningPaypalPaymentNotCompatibleWithStrict=La valeur 'Strict' fait que les fonc WarningThemeForcedTo=Attention, le choix du thème a été forcé à %s par la constante cachée MAIN_FORCETHEME WarningPagesWillBeDeleted=Attention, cela supprimera également toutes les pages/conteneurs existants du site. Vous devriez exporter votre site Web avant, afin d'avoir une sauvegarde pour le réimporter plus tard. WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal=La validation automatique est désactivée lorsque l'option de diminution du stock est définie sur "Validation de la facture". -<<<<<<< HEAD -WarningModuleNeedRefrech = Module %s desactivé. N'oublier pas de le réactivé -======= WarningModuleNeedRefrech = Le module %s a été désactivé. N'oubliez pas de le réactiver ->>>>>>> branch '17.0' of git@github.com:Dolibarr/dolibarr.git # Validate RequireValidValue = Valeur non valide From 86d9fda87e1b63daabd459533ae2d138f7a38c35 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Wed, 15 Mar 2023 09:19:10 +0100 Subject: [PATCH 12/17] Corrected sticler-ci errors. --- htdocs/core/class/html.form.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 14abaeeaff2..ab5bb032837 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2609,11 +2609,11 @@ class Form // Add select from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('selectProductsListSelect', $parameters); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { - $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint; - } else { - $sql .= $hookmanager->resPrint; - } + if ($reshook > 0) { + $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint; + } else { + $sql .= $hookmanager->resPrint; + } if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) { //Product category From 7086b2dab9f98f35b97c858b35067d7421cc3184 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Tue, 21 Mar 2023 08:59:39 +0100 Subject: [PATCH 13/17] Corrected $reshook check which was incorrect. --- htdocs/core/class/html.form.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 322337b30f5..b1fd401f277 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2605,11 +2605,10 @@ class Form $sql = "SELECT "; - // Add select from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('selectProductsListSelect', $parameters); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { + if (empty($reshook)) { $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint; } else { $sql .= $hookmanager->resPrint; From 6f68380efe72e0ab45235ae8b3d834e1d529e782 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Tue, 21 Mar 2023 09:22:35 +0100 Subject: [PATCH 14/17] Changed $reshook check to be like the Dolibarr documentation. --- htdocs/core/class/html.form.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b1fd401f277..022b2f40914 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3224,10 +3224,10 @@ class Form $parameters = array('objp'=>$objp); $reshook = $hookmanager->executeHooks('constructProductListOption', $parameters); // Note that $action and $object may have been modified by hook - if (!empty($reshook)) { - $opt = $hookmanager->resPrint; - } else { + if (empty($reshook)) { $opt .= $hookmanager->resPrint; + } else { + $opt = $hookmanager->resPrint; } $opt .= "\n"; From 57156dd022ed6ac7007edae36935546a7a9f744e Mon Sep 17 00:00:00 2001 From: BadPixxel Date: Fri, 31 Mar 2023 13:15:44 +0200 Subject: [PATCH 15/17] FIX: Invoice Thirdparty never loaded at this point Attempt to read property "default_lang" on null in /var/www/html/fourn/class/paiementfourn.class.php on line 353 --- htdocs/fourn/class/paiementfourn.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index e3b7be2c42a..b587922b71d 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -362,6 +362,7 @@ class PaiementFourn extends Paiement $newlang = ''; $outputlangs = $langs; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + $invoice->fetch_thirdparty(); $newlang = $invoice->thirdparty->default_lang; } if (!empty($newlang)) { From 3f4879d494a50c261f526651b5328afed4c2da00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20de=20Grandpr=C3=A9?= Date: Fri, 31 Mar 2023 13:41:29 -0400 Subject: [PATCH 16/17] Read of correct global variable --- htdocs/adherents/admin/member.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index f9e15e88fca..5a562fec537 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -511,7 +511,7 @@ foreach ($dirmodels as $reldir) { // Defaut print ''; - if (getDolGlobalString('MEMBER_ADDON_PDF') == $name) { + if (getDolGlobalString('MEMBER_ADDON_PDF_ODT') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir) ? $module->scandir : '').'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; From ae7b31e71627f4206317be91a44427cd05b34668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20de=20Grandpr=C3=A9?= Date: Fri, 31 Mar 2023 17:31:20 -0400 Subject: [PATCH 17/17] Fix #24410 - No $resql overwrite --- htdocs/core/lib/functions2.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 2eda8cbbdcc..ce639624f1a 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1936,14 +1936,14 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) $sql .= " ORDER BY description DESC"; dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); + $resql_models = $db->query($sql); + if ($resql_models) { + $num = $db->num_rows($resql_models); $i = 0; while ($i < $num) { $found = 1; - $obj = $db->fetch_object($resql); + $obj = $db->fetch_object($resql_models); // If this generation module needs to scan a directory, then description field is filled // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).