From 9bfeb5e4245243539bcc3f4794e6712938b2601d Mon Sep 17 00:00:00 2001 From: atm-lena <52402938+atm-lena@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:13:36 +0200 Subject: [PATCH 1/5] Add Hook "printFieldListFrom" in supplier order list (#26376) Co-authored-by: atm-lena --- htdocs/fourn/commande/list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 4b2d08f18d8..7c8cdeb2dfd 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -531,6 +531,9 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet"; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= ' WHERE cf.fk_soc = s.rowid'; $sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; From 2ce3ececfb3de20220a2a9c02d43b210a2c00d54 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 2 Nov 2023 01:33:46 +0100 Subject: [PATCH 2/5] Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 17.0 --- htdocs/adherents/subscription.php | 8 +++++--- htdocs/public/payment/paymentok.php | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 93b57a630e1..1a6925951a6 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -80,9 +80,6 @@ $extrafields->fetch_name_optionals_label($object->table_element); $errmsg = ''; -$defaultdelay = 1; -$defaultdelayunit = 'y'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('subscription')); @@ -212,6 +209,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! // Subscription informations $datesubscription = 0; $datesubend = 0; + $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; + $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; $paymentdate = ''; // Do not use 0 here, default value is '' that means not filled where 0 means 1970-01-01 if (GETPOST("reyear", "int") && GETPOST("remonth", "int") && GETPOST("reday", "int")) { $datesubscription = dol_mktime(0, 0, 0, GETPOST("remonth", "int"), GETPOST("reday", "int"), GETPOST("reyear", "int")); @@ -470,6 +469,9 @@ if ($rowid > 0) { $adht->fetch($object->typeid); + $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; + $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; + $head = member_prepare_head($object); $rowspan = 10; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index e19fd856f23..7b605be02ed 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -398,9 +398,6 @@ if ($ispaymentok) { // Create complementary actions (this include creation of thirdparty) // Send confirmation email - $defaultdelay = 1; - $defaultdelayunit = 'y'; - // Record subscription include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; @@ -411,6 +408,9 @@ if ($ispaymentok) { $result1 = $object->fetch((int) $tmptag['MEM']); $result2 = $adht->fetch($object->typeid); + $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; + $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; + dol_syslog("We have to process member with id=".$tmptag['MEM']." result1=".$result1." result2=".$result2, LOG_DEBUG, 0, '_payment'); if ($result1 > 0 && $result2 > 0) { From 301064afb610e73c836753ff3220c89315849620 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 2 Nov 2023 01:33:46 +0100 Subject: [PATCH 3/5] Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 17.0 --- htdocs/adherents/subscription.php | 8 +++++--- htdocs/public/payment/paymentok.php | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index cf0ad445c92..54ea3ebe998 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -79,9 +79,6 @@ $extrafields->fetch_name_optionals_label($object->table_element); $errmsg = ''; -$defaultdelay = 1; -$defaultdelayunit = 'y'; - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('subscription')); @@ -211,6 +208,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! // Subscription informations $datesubscription = 0; $datesubend = 0; + $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; + $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; $paymentdate = ''; // Do not use 0 here, default value is '' that means not filled where 0 means 1970-01-01 if (GETPOST("reyear", "int") && GETPOST("remonth", "int") && GETPOST("reday", "int")) { $datesubscription = dol_mktime(0, 0, 0, GETPOST("remonth", "int"), GETPOST("reday", "int"), GETPOST("reyear", "int")); @@ -469,6 +468,9 @@ if ($rowid > 0) { $adht->fetch($object->typeid); + $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; + $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; + $head = member_prepare_head($object); $rowspan = 10; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 241fa09dabc..44411db975d 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -386,9 +386,6 @@ if ($ispaymentok) { // Create complementary actions (this include creation of thirdparty) // Send confirmation email - $defaultdelay = 1; - $defaultdelayunit = 'y'; - // Record subscription include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; @@ -399,6 +396,9 @@ if ($ispaymentok) { $result1 = $object->fetch((int) $tmptag['MEM']); $result2 = $adht->fetch($object->typeid); + $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; + $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; + dol_syslog("We have to process member with id=".$tmptag['MEM']." result1=".$result1." result2=".$result2, LOG_DEBUG, 0, '_payment'); if ($result1 > 0 && $result2 > 0) { From 35a25599e58c0c48861d813b368e3fbd1a18da3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Nov 2023 19:28:04 +0100 Subject: [PATCH 4/5] FIX Backport memory fix for fatal error when +100000 products --- htdocs/product/list.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b3b4e3be2dd..30131312903 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -328,10 +328,14 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; if (!empty($searchCategoryProductList) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; +$linktopfp = " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; +$sql .= $linktopfp; // multilang if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang()."'"; @@ -426,8 +430,24 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/'.preg_quote($linktopfp, '/').'/', '', $sqlforcount); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + /* $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + */ + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { $page = 0; From 9c7381601fa4b2a63de38e32ce657f9eb9094cea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Nov 2023 19:35:34 +0100 Subject: [PATCH 5/5] Backport or better module compatibility --- htdocs/core/lib/functions.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0084a4a33c8..ab396c5ed26 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -64,6 +64,17 @@ function getDolGlobalInt($key) return (int) (empty($conf->global->$key) ? 0 : $conf->global->$key); } +/** + * Is Dolibarr module enabled + * @param string $module module name to check + * @return int + */ +function isModEnabled($module) +{ + global $conf; + return !empty($conf->$module->enabled); +} + /** * Return a DoliDB instance (database handler). *