From 9f7be989c2f4150ec5327a5ae784fe69fb609884 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Tue, 6 Jul 2021 17:38:37 +0200 Subject: [PATCH 01/47] FIX 13.0 - fatal - missing inclusion of ajax.lib.php for calling `ajax_autocompleter()` --- htdocs/core/class/html.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 945897856f2..1019e9623e4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1118,6 +1118,7 @@ class Form if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && !$forcecombo) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; // No immediate load of all database $placeholder = ''; if ($selected && empty($selected_input_value)) From 2f250799813e7e4faa65cde9e137b420a6ece1e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Jul 2021 14:38:52 +0200 Subject: [PATCH 02/47] Fix CSRF token generation must be fast, can have low entropy. --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2301ca75161..df61e752f5c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -420,7 +420,7 @@ if (!defined('NOTOKENRENEWAL')) { if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] - $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number + $token = dol_hash(uniqid(mt_rand(), false), 'md5'); // Generates a hash of a random number. We don't need a secured hash, just a changing random value. $_SESSION['newtoken'] = $token; dol_syslog("NEW TOKEN generated by : " . $_SERVER['PHP_SELF'], LOG_DEBUG); } From 4e77a0d16a4b46314fc13a6c5d70d7cd179a162b Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 8 Jul 2021 15:55:07 +0200 Subject: [PATCH 03/47] don't display custom masks if they are not used --- htdocs/product/card.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 3d5afd1b16c..5b8c431d65d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1649,21 +1649,30 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''."\n"; + print ''."\n"; } else { - print ''."\n"; + print ''."\n"; } } } From 12b1f5b23b4b712f851ad6b90d32e382a27744b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 21:05:56 +0200 Subject: [PATCH 12/47] Fix sql --- htdocs/core/class/dolgraph.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 17dcdd557a4..a1725526898 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -611,7 +611,7 @@ class DolGraph $nbseries = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1); - foreach($this->data as $x) { // Loop on each x + foreach ($this->data as $x) { // Loop on each x for ($i = 0; $i < $nbseries; $i++) { // Loop on each serie if (is_null($max)) { $max = $x[$i + 1]; // $i+1 because the index 0 is the legend @@ -641,7 +641,7 @@ class DolGraph $nbseries = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1); - foreach($this->data as $x) { // Loop on each x + foreach ($this->data as $x) { // Loop on each x for ($i = 0; $i < $nbseries; $i++) { // Loop on each serie if (is_null($min)) { $min = $x[$i + 1]; // $i+1 because the index 0 is the legend From cd215cda17f3e2c41f25de8304f207a13615e8f9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 8 Jul 2021 21:49:53 +0200 Subject: [PATCH 13/47] FIX Accountancy - if we define a date start, automatic binding try to solve old binding --- htdocs/accountancy/customer/index.php | 3 +++ htdocs/accountancy/supplier/index.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 1a5098bda38..943d914a980 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -136,6 +136,9 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; + if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { + $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + } dol_syslog('htdocs/accountancy/customer/index.php'); $result = $db->query($sql); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 0dbe09fa468..f20c238514a 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -133,6 +133,9 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; + if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { + $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; + } dol_syslog('htdocs/accountancy/supplier/index.php'); From d6be3808166ef6c4bc57b2f1c5e43125e1d4ab05 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 8 Jul 2021 21:35:25 +0200 Subject: [PATCH 14/47] FIX Accountancy - constant ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY --- htdocs/accountancy/customer/index.php | 12 ++++--- htdocs/accountancy/supplier/index.php | 12 ++++--- htdocs/societe/card.php | 48 +++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index dde599a1462..e6b4e95df07 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -201,11 +201,13 @@ if ($action == 'validatehistory') { } } - // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) - if (!empty($objp->company_code_sell)) { - $objp->code_sell_t = $objp->company_code_sell; - $objp->aarowid_suggest = $objp->aarowid_thirdparty; - $suggestedaccountingaccountfor = ''; + if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_sell)) { + $objp->code_sell_t = $objp->company_code_sell; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } } if ($objp->aarowid_suggest > 0) { diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index b5c6804c7d6..818455ce979 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -202,11 +202,13 @@ if ($action == 'validatehistory') { } } - // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) - if (!empty($objp->company_code_buy)) { - $objp->code_buy_t = $objp->company_code_buy; - $objp->aarowid_suggest = $objp->aarowid_thirdparty; - $suggestedaccountingaccountfor = ''; + if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($objp->company_code_buy)) { + $objp->code_buy_t = $objp->company_code_buy; + $objp->aarowid_suggest = $objp->aarowid_thirdparty; + $suggestedaccountingaccountfor = ''; + } } if ($objp->aarowid_suggest > 0) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ba4023dbba9..53efb132352 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -495,10 +495,22 @@ if (empty($reshook)) { $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); if (GETPOSTISSET('accountancy_code_sell')) { - $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } } if (GETPOSTISSET('accountancy_code_buy')) { - $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } } // Incoterms @@ -1058,10 +1070,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->default_lang = GETPOST('default_lang'); if (GETPOSTISSET('accountancy_code_sell')) { - $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } } if (GETPOSTISSET('accountancy_code_buy')) { - $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } } $object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : ''); @@ -1785,10 +1809,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); if (GETPOSTISSET('accountancy_code_sell')) { - $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + + if ($accountancy_code_sell <= 0) { + $object->accountancy_code_sell = ''; + } else { + $object->accountancy_code_sell = $accountancy_code_sell; + } } if (GETPOSTISSET('accountancy_code_buy')) { - $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + + if ($accountancy_code_buy <= 0) { + $object->accountancy_code_buy = ''; + } else { + $object->accountancy_code_buy = $accountancy_code_buy; + } } //Incoterms From 5c8ac0cb9da016e6e865f3c2c80c51971ffad4f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 21:53:24 +0200 Subject: [PATCH 15/47] Update card.php --- htdocs/societe/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 53efb132352..475c1c57082 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -497,7 +497,7 @@ if (empty($reshook)) { if (GETPOSTISSET('accountancy_code_sell')) { $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; @@ -506,7 +506,7 @@ if (empty($reshook)) { if (GETPOSTISSET('accountancy_code_buy')) { $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; @@ -1072,7 +1072,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_sell')) { $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; @@ -1081,7 +1081,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_buy')) { $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; From 6539961d58784be1eb921a3a03825229da7e7538 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 21:55:35 +0200 Subject: [PATCH 16/47] Update card.php --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 475c1c57082..76ae78fdb51 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1811,7 +1811,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_sell')) { $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; @@ -1820,7 +1820,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('accountancy_code_buy')) { $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; From be62c2f7f44cd8852f9204301bffbebc7bb814a9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 8 Jul 2021 22:11:41 +0200 Subject: [PATCH 17/47] FIX Problem of z-index with popup and top menu --- htdocs/theme/eldy/global.inc.php | 3 +++ htdocs/theme/md/style.css.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e5db84f9719..61cddc1f5a8 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4108,6 +4108,9 @@ div#card-errors { .ui-dialog-content { } +.ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-dialog-buttons.ui-draggable { + z-index: 1002 !important; /* Default 101 with jquery, top menu have a z-index of 1000 */ +} /* ============================================================================== */ /* For content of image preview */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 3b690993c5d..0912fe2d38b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4025,6 +4025,9 @@ div#card-errors { font-size: px !important; } +.ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-dialog-buttons.ui-draggable { + z-index: 1002 !important; /* Default 101 with jquery, top menu have a z-index of 1000 */ +} /* ============================================================================== */ /* For content of image preview */ From a916f668f97c615145f4e0e5880e0270d7fac4c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 22:16:47 +0200 Subject: [PATCH 18/47] Fix param of include js --- htdocs/main.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2647cba166c..99cfe360f9f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1689,7 +1689,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr // Global js function print ''."\n"; - print ''."\n"; + print ''."\n"; // JS forced by modules (relative url starting with /) if (!empty($conf->modules_parts['js'])) { // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) @@ -1698,7 +1698,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr $filesjs = (array) $filesjs; // To be sure filejs is an array foreach ($filesjs as $jsfile) { // jsfile is a relative path - print ''."\n".''."\n"; + print ''."\n".''."\n"; } } } @@ -1707,9 +1707,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; foreach ($arrayofjs as $jsfile) { if (preg_match('/^(http|\/\/)/i', $jsfile)) { - print ''."\n"; + print ''."\n"; } else { - print ''."\n"; + print ''."\n"; } } } From f4005cd7a7b32b656d599eb82aa30a67e5c040dc Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 8 Jul 2021 22:24:20 +0200 Subject: [PATCH 19/47] Update product/card.php --- htdocs/product/card.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 3d5afd1b16c..1e1a365ead1 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -383,32 +383,32 @@ if (empty($reshook)) { $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } - if ($accountancy_code_sell_intra <= 0) { + if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra == '-1') { $object->accountancy_code_sell_intra = ''; } else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; } - if ($accountancy_code_sell_export <= 0) { + if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export == '-1') { $object->accountancy_code_sell_export = ''; } else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; } - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } - if ($accountancy_code_buy_intra <= 0) { + if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra == '-1') { $object->accountancy_code_buy_intra = ''; } else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; } - if ($accountancy_code_buy_export <= 0) { + if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export == '-1') { $object->accountancy_code_buy_export = ''; } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; @@ -552,32 +552,32 @@ if (empty($reshook)) { $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); - if ($accountancy_code_sell <= 0) { + if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } - if ($accountancy_code_sell_intra <= 0) { + if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra == '-1') { $object->accountancy_code_sell_intra = ''; } else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; } - if ($accountancy_code_sell_export <= 0) { + if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export == '-1') { $object->accountancy_code_sell_export = ''; } else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; } - if ($accountancy_code_buy <= 0) { + if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } - if ($accountancy_code_buy_intra <= 0) { + if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra == '-1') { $object->accountancy_code_buy_intra = ''; } else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; } - if ($accountancy_code_buy_export <= 0) { + if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export == '-1') { $object->accountancy_code_buy_export = ''; } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; From aa9d98a336842dd1980be0f425357d59b68d2be4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jul 2021 23:19:43 +0200 Subject: [PATCH 20/47] Clean code of lib_notification. Now use cache like other js. --- htdocs/core/js/lib_foot.js.php | 5 + htdocs/core/js/lib_head.js.php | 5 + htdocs/core/js/lib_notification.js.php | 237 +++++++++++++------------ htdocs/core/js/timepicker.js.php | 4 + 4 files changed, 140 insertions(+), 111 deletions(-) diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index dce74d93653..764fde5097e 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -47,6 +47,11 @@ session_cache_limiter('public'); require_once '../../main.inc.php'; + +/* + * View + */ + // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index a56084d0f32..db63b1a75d4 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -50,6 +50,11 @@ session_cache_limiter('public'); require_once '../../main.inc.php'; + +/* + * View + */ + // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index dc46a5e2072..616463b944d 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -41,132 +41,147 @@ if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', 1); } +session_cache_limiter('public'); + require_once '../../main.inc.php'; -if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/index.php' - || preg_match('/getmenu_div\.php/', $_SERVER['HTTP_REFERER']))) { - global $langs, $conf; - top_httphead('text/javascript; charset=UTF-8'); +/* + * View + */ - print 'var login = \''.$_SESSION['dol_login'].'\';'."\n"; - print 'var nowtime = Date.now();'; - print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined - print 'var time_js_next_test;'."\n"; - ?> - - /* Check if permission ok */ - if (Notification.permission !== "granted") { - console.log("Ask Notification.permission"); - Notification.requestPermission() - } - - /* Launch timer */ - // We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. - //var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds - var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION) ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; - if (login != '') { - setTimeout(first_execution, time_first_execution * 1000); - time_js_next_test = nowtime + time_first_execution; - console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" time_js_next_check = "+time_js_next_test); - } //first run auto check +top_httphead('text/javascript; charset=UTF-8'); +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} - function first_execution() { - console.log("Call first_execution then set repeat time to time_auto_update = MAIN_BROWSER_NOTIFICATION_FREQUENCY = "+time_auto_update); - check_events(); //one check before setting the new time for other checks - setInterval(check_events, time_auto_update * 1000); // Set new time to run next check events - } +print "jQuery(document).ready(function () {\n"; - function check_events() { - if (Notification.permission === "granted") - { - time_js_next_test += time_auto_update; - console.log("Call ajax to check_events with time_js_next_test = "+time_js_next_test); +//print " console.log('referrer=".dol_escape_js($_SERVER['HTTP_REFERER'])."');\n"; - $.ajax("", { - type: "post", // Usually post or get - async: true, - data: { time_js_next_test: time_js_next_test, forcechecknow: 1, token: 'notrequired' }, - dataType: "json", - success: function (result) { - //console.log(result); - var arrayofpastreminders = Object.values(result.pastreminders); - if (arrayofpastreminders && arrayofpastreminders.length > 0) { - console.log("Retrieved "+arrayofpastreminders.length+" reminders to do."); - var audio = null; - global->AGENDA_REMINDER_BROWSER_SOUND)) { - print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav\');'; +print ' var nowtime = Date.now();'; +print ' var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined +print ' var time_js_next_test;'."\n"; +?> + +/* Check if permission ok */ +if (Notification.permission !== "granted") { + console.log("Ask Notification.permission"); + Notification.requestPermission() +} + +/* Launch timer */ + +// We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. +//var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds +var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION) ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; + +setTimeout(first_execution, time_first_execution * 1000); +time_js_next_test = nowtime + time_first_execution; +console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" time_js_next_check = "+time_js_next_test); + + +function first_execution() { + console.log("Call first_execution then set repeat time to time_auto_update = MAIN_BROWSER_NOTIFICATION_FREQUENCY = "+time_auto_update); + check_events(); //one check before setting the new time for other checks + setInterval(check_events, time_auto_update * 1000); // Set new time to run next check events +} + +function check_events() { + if (Notification.permission === "granted") + { + time_js_next_test += time_auto_update; + console.log("Call ajax to check_events with time_js_next_test = "+time_js_next_test); + + $.ajax("", { + type: "post", // Usually post or get + async: true, + data: { time_js_next_test: time_js_next_test, forcechecknow: 1, token: 'notrequired' }, + dataType: "json", + success: function (result) { + //console.log(result); + var arrayofpastreminders = Object.values(result.pastreminders); + if (arrayofpastreminders && arrayofpastreminders.length > 0) { + console.log("Retrieved "+arrayofpastreminders.length+" reminders to do."); + var audio = null; + global->AGENDA_REMINDER_BROWSER_SOUND)) { + print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav\');'; + } + ?> + var listofreminderids = ''; + var noti = [] + + $.each(arrayofpastreminders, function (index, value) { + console.log(value); + var url = "notdefined"; + var title = "Not defined"; + var body = value.label; + if (value.type == 'agenda' && value.location != null && value.location != '') { + body += '\n' + value.location; } - ?> - var listofreminderids = ''; - var noti = [] - $.each(arrayofpastreminders, function (index, value) { - console.log(value); - var url = "notdefined"; - var title = "Not defined"; - var body = value.label; - if (value.type == 'agenda' && value.location != null && value.location != '') { - body += '\n' + value.location; - } + if (value.type == 'agenda' && (value.event_date_start_formated != null || value.event_date_start_formated['event_date_start'] != '')) { + body += '\n' + value.event_date_start_formated; + } - if (value.type == 'agenda' && (value.event_date_start_formated != null || value.event_date_start_formated['event_date_start'] != '')) { - body += '\n' + value.event_date_start_formated; - } + if (value.type == 'agenda') + { + url = '' + value.id_agenda; + title = 'trans('EventReminder')) ?>'; + } + var extra = { + icon: '', + //image: '', + body: body, + tag: value.id_agenda, + requireInteraction: true + }; - if (value.type == 'agenda') - { - url = '' + value.id_agenda; - title = 'trans('EventReminder')) ?>'; - } - var extra = { - icon: '', - //image: '', - body: body, - tag: value.id_agenda, - requireInteraction: true + // We release the notify + console.log("Send notification on browser"); + noti[index] = new Notification(title, extra); + if (index==0 && audio) + { + audio.play(); + } + + if (noti[index]) { + noti[index].onclick = function (event) { + console.log("A click on notification on browser has been done"); + event.preventDefault(); // prevent the browser from focusing the Notification's tab + window.focus(); + window.open(url, '_blank'); + noti[index].close(); }; - // We release the notify - console.log("Send notification on browser"); - noti[index] = new Notification(title, extra); - if (index==0 && audio) - { - audio.play(); - } + listofreminderids = (listofreminderids == '' ? '' : listofreminderids + ',') + value.id_reminder + } + }); - if (noti[index]) { - noti[index].onclick = function (event) { - console.log("A click on notification on browser has been done"); - event.preventDefault(); // prevent the browser from focusing the Notification's tab - window.focus(); - window.open(url, '_blank'); - noti[index].close(); - }; - - listofreminderids = (listofreminderids == '' ? '' : listofreminderids + ',') + value.id_reminder - } - }); - - // Update status of all notifications we sent on browser (listofreminderids) - console.log("Flag notification as done for listofreminderids="+listofreminderids); - $.ajax(""+listofreminderids, { - type: "POST", // Usually post or get - async: true, - data: { time_js_next_test: time_js_next_test, token: 'notrequired' } - }); - } else { - console.log("No reminder to do found, next search at "+time_js_next_test); - } + // Update status of all notifications we sent on browser (listofreminderids) + console.log("Flag notification as done for listofreminderids="+listofreminderids); + $.ajax(""+listofreminderids, { + type: "POST", // Usually post or get + async: true, + data: { time_js_next_test: time_js_next_test, token: 'notrequired' } + }); + } else { + console.log("No reminder to do found, next search at "+time_js_next_test); } - }); - } - else - { - console.log("Cancel check_events. Useless because javascript Notification.permission is "+Notification.permission+" (blocked manualy or web site is not https)."); - } + } + }); + } + else + { + console.log("Cancel check_events. Useless because javascript Notification.permission is "+Notification.permission+" (blocked manualy or web site is not https)."); } - Date: Fri, 9 Jul 2021 12:15:43 +0200 Subject: [PATCH 21/47] Fix reposition --- htdocs/admin/ihm.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index f4ea09966fc..cf4c250a678 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -255,7 +255,7 @@ if ($action == 'update') { $_SESSION["mainmenu"] = ""; // Le gestionnaire de menu a pu changer - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(GETPOSTISSET('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); exit; } @@ -281,6 +281,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; print '
'; print ''; print ''; +print ''; clearstatcache(); @@ -292,8 +293,9 @@ print ''; // Default language print ''.$langs->trans("DefaultLanguage").''; +print img_picto('', 'language', 'class="pictofixedwidth"'); print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, null, '', 0, 0, 'minwidth300', 2); -print ''; +//print ''; print ''; print ''; @@ -303,12 +305,24 @@ print ajax_constantonoff("MAIN_MULTILANGS", array(), $conf->entity, 0, 0, 1, 0); print ''; print ''; -print '
'."\n"; +print ''."\n"; print ''; +print '
'; +print '
'; +print ''; +print '
'; + +print '

'; + // Themes and themes options showSkins(null, 1); print '
'; +print '
'; +print ''; +print '
'; + +print '

'; // Other print '
'; @@ -440,6 +454,12 @@ print '
'; print '
'; +print '
'; +print ''; +print '
'; + +print '

'; + // Other print '
'; print ''; @@ -497,7 +517,7 @@ print ''; print '
'; print '
'; -print ''; +print ''; print '
'; print ''; From 2bef8a27c8cb871a46a6cc9b56184e8337151ced Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jul 2021 12:34:51 +0200 Subject: [PATCH 22/47] Trans --- htdocs/fourn/ajax/getSupplierPrices.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index e0cd9beff0c..889484cec44 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -43,7 +43,7 @@ $idprod = GETPOST('idprod', 'int'); $prices = array(); // Load translation files required by the page -$langs->loadLangs(array("stocks", "margins")); +$langs->loadLangs(array("stocks", "margins", "products")); /* From b7c42c70ef05f16913e50907612acd1dd66b4099 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jul 2021 13:33:37 +0200 Subject: [PATCH 23/47] Fix date for planned entries --- htdocs/compta/bank/treso.php | 140 ++++++++++++++++++---------------- htdocs/fourn/facture/card.php | 43 ++++++----- 2 files changed, 96 insertions(+), 87 deletions(-) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index d9b54ad1c3d..98a51947c0e 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -98,44 +98,6 @@ if (GETPOST("account") || GETPOST("ref")) { print dol_get_fiche_end(); - print '
'; - - $solde = $object->solde(0); - if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { - $colspan = 6; - } else { - $colspan = 5; - } - - // Show next coming entries - print '
'; - print '
'; - - // Ligne de titre tableau des ecritures - print ''; - print ''; - print ''; - if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - - // Current balance - print ''; - print ''; - print ''; - print ''; - - - print ''; - print ''; - print ''; - print ''; - // Remainder to pay in future $sqls = array(); @@ -183,10 +145,12 @@ if (GETPOST("account") || GETPOST("ref")) { $error = 0; $tab_sqlobjOrder = array(); $tab_sqlobj = array(); + $nbtotalofrecords = 0; foreach ($sqls as $sql) { $resql = $db->query($sql); if ($resql) { + $nbtotalofrecords += $db->num_rows($resql); while ($sqlobj = $db->fetch_object($resql)) { $tmpobj = new stdClass(); $tmpobj->family = $sqlobj->family; @@ -194,7 +158,7 @@ if (GETPOST("account") || GETPOST("ref")) { $tmpobj->ref = $sqlobj->ref; $tmpobj->total_ttc = $sqlobj->total_ttc; $tmpobj->type = $sqlobj->type; - $tmpobj->dlt = $sqlobj->dlr; + $tmpobj->dlr = $db->jdate($sqlobj->dlr); $tmpobj->socid = $sqlobj->socid; $tmpobj->name = $sqlobj->name; $tmpobj->fournisseur = $sqlobj->fournisseur; @@ -208,6 +172,48 @@ if (GETPOST("account") || GETPOST("ref")) { } } + $param = ''; + $sortfield = ''; + $sortorder = ''; + $massactionbutton = ''; + $num = 0; + $picto = ''; + $morehtml = ''; + $limit = 0; + + print_barre_liste($langs->trans("RemainderToPay"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit, 0, 0, 1); + + + $solde = $object->solde(0); + if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { + $colspan = 6; + } else { + $colspan = 5; + } + + // Show next coming entries + print '
'; + print '
'.$langs->trans("DateDue").''.$langs->trans("Description").''.$langs->trans("Entity").''.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").'
'.$langs->trans("CurrentBalance").''.price($solde).'
'.$langs->trans("RemainderToPay").' 
'; + + // Ligne de titre tableau des ecritures + print ''; + print ''; + print ''; + if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + + // Current balance + print ''; + print ''; + print ''; + print ''; + // Sort array if (!$error) { array_multisort($tab_sqlobjOrder, $tab_sqlobj); @@ -220,60 +226,60 @@ if (GETPOST("account") || GETPOST("ref")) { $refcomp = ''; $totalpayment = ''; - $obj = array_shift($tab_sqlobj); + $tmpobj = array_shift($tab_sqlobj); - if ($obj->family == 'invoice_supplier') { + if ($tmpobj->family == 'invoice_supplier') { $showline = 1; // Uncomment this line to avoid to count suppliers credit note (ff.type = 2) - //$showline=(($obj->total_ttc < 0 && $obj->type != 2) || ($obj->total_ttc > 0 && $obj->type == 2)) + //$showline=(($tmpobj->total_ttc < 0 && $tmpobj->type != 2) || ($tmpobj->total_ttc > 0 && $tmpobj->type == 2)) if ($showline) { - $ref = $obj->ref; + $ref = $tmpobj->ref; $facturefournstatic->ref = $ref; - $facturefournstatic->id = $obj->objid; - $facturefournstatic->type = $obj->type; + $facturefournstatic->id = $tmpobj->objid; + $facturefournstatic->type = $tmpobj->type; $ref = $facturefournstatic->getNomUrl(1, ''); - $societestatic->id = $obj->socid; - $societestatic->name = $obj->name; + $societestatic->id = $tmpobj->socid; + $societestatic->name = $tmpobj->name; $refcomp = $societestatic->getNomUrl(1, '', 24); $totalpayment = -1 * $facturefournstatic->getSommePaiement(); // Payment already done } } - if ($obj->family == 'invoice') { - $facturestatic->ref = $obj->ref; - $facturestatic->id = $obj->objid; - $facturestatic->type = $obj->type; + if ($tmpobj->family == 'invoice') { + $facturestatic->ref = $tmpobj->ref; + $facturestatic->id = $tmpobj->objid; + $facturestatic->type = $tmpobj->type; $ref = $facturestatic->getNomUrl(1, ''); - $societestatic->id = $obj->socid; - $societestatic->name = $obj->name; + $societestatic->id = $tmpobj->socid; + $societestatic->name = $tmpobj->name; $refcomp = $societestatic->getNomUrl(1, '', 24); $totalpayment = $facturestatic->getSommePaiement(); // Payment already done $totalpayment += $facturestatic->getSumDepositsUsed(); $totalpayment += $facturestatic->getSumCreditNotesUsed(); } - if ($obj->family == 'social_contribution') { - $socialcontribstatic->ref = $obj->ref; - $socialcontribstatic->id = $obj->objid; - $socialcontribstatic->label = $obj->type; + if ($tmpobj->family == 'social_contribution') { + $socialcontribstatic->ref = $tmpobj->ref; + $socialcontribstatic->id = $tmpobj->objid; + $socialcontribstatic->label = $tmpobj->type; $ref = $socialcontribstatic->getNomUrl(1, 24); $totalpayment = -1 * $socialcontribstatic->getSommePaiement(); // Payment already done } - $parameters = array('obj' => $obj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment); - $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('obj' => $tmpobj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment); + $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $tmpobject, $action); // Note that $action and $tmpobject may have been modified by hook if (empty($reshook)) { $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : $ref; $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : $refcomp; $totalpayment = isset($hookmanager->resArray['totalpayment']) ? $hookmanager->resArray['totalpayment'] : $totalpayment; } - $total_ttc = $obj->total_ttc; + $total_ttc = $tmpobj->total_ttc; if ($totalpayment) { - $total_ttc = $obj->total_ttc - $totalpayment; + $total_ttc = $tmpobj->total_ttc - $totalpayment; } $solde += $total_ttc; @@ -282,26 +288,26 @@ if (GETPOST("account") || GETPOST("ref")) { // Show line print ''; print '"; print ""; if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { - if ($obj->family == 'invoice') { - $mc->getInfo($obj->entity); + if ($tmpobj->family == 'invoice') { + $mc->getInfo($tmpobj->entity); print ""; } else { print ""; } } print ""; - if ($obj->total_ttc < 0) { + if ($tmpobj->total_ttc < 0) { print '"; }; - if ($obj->total_ttc >= 0) { + if ($tmpobj->total_ttc >= 0) { print '"; }; print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 7d8d29b307c..6b67d0a2dcf 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2739,14 +2739,17 @@ if ($action == 'create') { // Label print ''; - print ''; - print ''; + print ''; + print ''; print ''; $form_permission = ($object->statut < FactureFournisseur::STATUS_CLOSED) && $usercancreate && ($object->getSommePaiement() <= 0); + $form_permission2 = ($object->statut < FactureFournisseur::STATUS_CLOSED) && $usercancreate; // Date - print ''; @@ -2756,11 +2759,11 @@ if ($action == 'create') { print '
'.$langs->trans("DateDue").''.$langs->trans("Description").''.$langs->trans("Entity").''.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").'
'.$langs->trans("CurrentBalance").''.price($solde).'
'; - if ($obj->dlr) { - print dol_print_date($db->jdate($obj->dlr), "day"); + if ($tmpobj->dlr) { + print dol_print_date($tmpobj->dlr, "day"); } else { print $langs->trans("NotDefined"); } print "".$ref."".$mc->label."".$refcomp."'.price(abs($total_ttc))."  '.price($total_ttc)."'.price($solde).'
'.$form->editfieldkey("Label", 'label', $object->label, $object, ($usercancreate)).''.$form->editfieldval("Label", 'label', $object->label, $object, ($usercancreate)).''.$form->editfieldkey("Label", 'label', $object->label, $object, $usercancreate).''.$form->editfieldval("Label", 'label', $object->label, $object, $usercancreate).'
'.$form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker').''; + print '
'; + print $form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker'); + print ''; print $form->editfieldval("Date", 'datef', $object->datep, $object, $form_permission, 'datepicker'); print '
'; } print '
'; print $langs->trans('PaymentConditions'); print ''; - if ($action != 'editconditions' && $usercancreate) { + if ($action != 'editconditions' && $form_permission) { print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; - print ''; + print ''; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { @@ -2770,8 +2773,10 @@ if ($action == 'create') { print ''; // Due date - print ''.$form->editfieldkey("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission, 'datepicker').''; - print $form->editfieldval("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission, 'datepicker'); + print ''; + print $form->editfieldkey("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission2, 'datepicker'); + print ''; + print $form->editfieldval("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission2, 'datepicker'); if ($action != 'editdate_lim_reglement' && $object->hasDelay()) { print img_warning($langs->trans('Late')); } @@ -2783,11 +2788,11 @@ if ($action == 'create') { print ''; - if ($action != 'editmode' && $usercancreate) { + if ($action != 'editmode' && $form_permission2) { print ''; } print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; - print ''; + print ''; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); } else { @@ -2807,7 +2812,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -2819,14 +2824,14 @@ if ($action == 'create') { if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print ''; print ''; - print ''; } print '
'; + print ''; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print ''; } print '
'; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; - print '
'; + print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); @@ -2854,7 +2859,7 @@ if ($action == 'create') { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; - print ''; + print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -2877,7 +2882,7 @@ if ($action == 'create') { } print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { @@ -2898,7 +2903,6 @@ if ($action == 'create') { } print ''; print ''; - print ''; if ($action == 'editmode') { $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'transport_mode_id', 1, 1); @@ -2913,8 +2917,8 @@ if ($action == 'create') { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; - print '
'; + print '
'; print '
'; print '
'; @@ -2933,7 +2937,7 @@ if ($action == 'create') { print ''; // Multicurrency Amount TTC - print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; + print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; } @@ -2977,9 +2981,8 @@ if ($action == 'create') { print ''; - /* - * List of payments - */ + + // List of payments $totalpaye = 0; From ec6fadf196a73ac8b5313a97a81437e3e71781f1 Mon Sep 17 00:00:00 2001 From: kamel Date: Fri, 9 Jul 2021 15:29:39 +0200 Subject: [PATCH 24/47] Fix hook constructCategory when several new categories is added by several modules --- htdocs/categories/class/categorie.class.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b98cff5b3a5..3144f1f98c3 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -263,15 +263,16 @@ class Categorie extends CommonObject $parameters = array(); $reshook = $hookmanager->executeHooks('constructCategory', $parameters, $this); // Note that $action and $object may have been modified by some hooks if ($reshook >= 0 && !empty($hookmanager->resArray)) { - $mapList = $hookmanager->resArray; - $mapId = $mapList['id']; - $mapCode = $mapList['code']; - self::$MAP_ID_TO_CODE[$mapId] = $mapCode; - $this->MAP_ID[$mapCode] = $mapId; - $this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk']; - $this->MAP_CAT_TABLE[$mapCode] = $mapList['cat_table']; - $this->MAP_OBJ_CLASS[$mapCode] = $mapList['obj_class']; - $this->MAP_OBJ_TABLE[$mapCode] = $mapList['obj_table']; + foreach ($hookmanager->resArray as $mapList) { + $mapId = $mapList['id']; + $mapCode = $mapList['code']; + self::$MAP_ID_TO_CODE[$mapId] = $mapCode; + $this->MAP_ID[$mapCode] = $mapId; + $this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk']; + $this->MAP_CAT_TABLE[$mapCode] = $mapList['cat_table']; + $this->MAP_OBJ_CLASS[$mapCode] = $mapList['obj_class']; + $this->MAP_OBJ_TABLE[$mapCode] = $mapList['obj_table']; + } } } } From 073ace3a9e48c60d90b25717819d4b1ac3636a41 Mon Sep 17 00:00:00 2001 From: kamel Date: Fri, 9 Jul 2021 16:23:46 +0200 Subject: [PATCH 25/47] FIX get categories linked to another object type --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b98cff5b3a5..5bcfa903f75 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1497,7 +1497,7 @@ class Categorie extends CommonObject } else { $sql = "SELECT ct.fk_categorie, c.label, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as ct, ".MAIN_DB_PREFIX."categorie as c"; - $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type]; + $sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id; $sql .= " AND c.entity IN (".getEntity('category').")"; $res = $this->db->query($sql); From 9e9af8548d0d607a1db79b7c1b5df8b7ec9b0b5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jul 2021 18:47:34 +0200 Subject: [PATCH 26/47] Responsive --- htdocs/admin/oauth.php | 2 ++ htdocs/admin/oauthlogintokens.php | 13 +++++++++---- htdocs/includes/.htaccess | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 htdocs/includes/.htaccess diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 079e55cb523..e2f123f627c 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -91,6 +91,7 @@ print dol_get_fiche_head($head, 'services', '', -1, 'technic'); print ''.$langs->trans("ListOfSupportedOauthProviders").'

'; +print '
'; print ''; $i = 0; @@ -145,6 +146,7 @@ foreach ($list as $key) { } print '
'."\n"; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 1b2886cd8ef..998b6c39c0f 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -230,7 +230,7 @@ if ($mode == 'setup' && $user->admin) { print ''; print ''; - + print '
'; print ''."\n"; print ''; @@ -262,15 +262,15 @@ if ($mode == 'setup' && $user->admin) { print $langs->trans("NoAccessToken"); } print ''; - print '
'; + print ''; // Links to delete/checks token if (is_object($tokenobj)) { //test on $storage->hasAccessToken($OAUTH_SERVICENAME) ? - print ''.$langs->trans('DeleteAccess').'
'; + print ''.$langs->trans('DeleteAccess').'
'; } // Request remote token if ($urltorenew) { - print ''.$langs->trans('RequestAccess').'
'; + print ''.$langs->trans('RequestAccess').'
'; } // Check remote access if ($urltocheckperms) { @@ -330,6 +330,7 @@ if ($mode == 'setup' && $user->admin) { } print '
'; + print '
'; if (!empty($driver)) { if ($submit_enabled) { @@ -345,6 +346,7 @@ if ($mode == 'setup' && $user->admin) { if ($mode == 'test' && $user->admin) { print $langs->trans('PrintTestDesc'.$driver)."

\n"; + print '
'; print ''; if (!empty($driver)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; @@ -364,11 +366,13 @@ if ($mode == 'test' && $user->admin) { } print '
'; + print '
'; } if ($mode == 'userconf' && $user->admin) { print $langs->trans('PrintUserConfDesc'.$driver)."

\n"; + print '
'; print ''; print ''; print ''; @@ -395,6 +399,7 @@ if ($mode == 'userconf' && $user->admin) { print "\n"; } print '
'.$langs->trans("User").'
'; + print '
'; } print dol_get_fiche_end(); diff --git a/htdocs/includes/.htaccess b/htdocs/includes/.htaccess new file mode 100644 index 00000000000..c15ce44a5e1 --- /dev/null +++ b/htdocs/includes/.htaccess @@ -0,0 +1,16 @@ +# htaccess file to clock +# The virtual host must have AllowOverride FileInfo to have this file used. +# You can achieve the same effect by adding a definition to +# +# +#RewriteRule \.php$ - [F,L] +# + + +#RewriteRule \.php$ - [F,L] + +# If there is no directory with AllowOveride FileInfo, you will get error 500. But +# we got what we want, php file into external libraries can't be executed directly. + + SetHandler ! + From 97ac547fe230d4773f295ff9d68c91f272c11e86 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jul 2021 00:44:36 +0200 Subject: [PATCH 27/47] Fix/debug the numbering module to autocalculate a new lot. --- htdocs/core/modules/modProductBatch.class.php | 4 +- .../product_batch/mod_lot_advanced.php | 10 +- .../product_batch/mod_lot_standard.php | 27 +- .../modules/product_batch/mod_sn_advanced.php | 6 +- .../modules/product_batch/mod_sn_standard.php | 31 +- htdocs/langs/en_US/productbatch.lang | 8 +- htdocs/product/admin/product_lot.php | 287 +++++++++--------- .../product/stock/class/productlot.class.php | 2 +- 8 files changed, 198 insertions(+), 177 deletions(-) diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 79529898bb0..4b508d79d7c 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -84,14 +84,14 @@ class modProductBatch extends DolibarrModules $this->const[$r][0] = "PRODUCTBATCH_LOT_ADDON"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "mod_lot_free"; - $this->const[$r][3] = 'Module to control product codes'; + $this->const[$r][3] = 'Module to control lot number'; $this->const[$r][4] = 0; $r++; $this->const[$r][0] = "PRODUCTBATCH_SN_ADDON"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "mod_sn_free"; - $this->const[$r][3] = 'Module to control product codes'; + $this->const[$r][3] = 'Module to control serial number'; $this->const[$r][4] = 0; $r++; diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php index 0bbb124d14b..8ee857bfbea 100644 --- a/htdocs/core/modules/product_batch/mod_lot_advanced.php +++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php @@ -128,27 +128,27 @@ class mod_lot_advanced extends ModeleNumRefBatch /** * Return next free value * - * @param Product $objprod Object product + * @param Societe $objsoc Object Societe * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objprod, $object) + public function getNextValue($objsoc, $object) { global $db, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask = $conf->global->BATCH_ADVANCED_MASK; + $mask = $conf->global->LOT_ADVANCED_MASK; if (!$mask) { $this->error = 'NotConfigured'; return 0; } - $date = $object->date; + $date = dol_now(); - $numFinal = get_next_value($db, $mask, 'product_lot', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'product_lot', 'batch', '', null, $date); return $numFinal; } diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index 0d2b5a55139..59de1965a6e 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -85,17 +85,21 @@ class mod_lot_standard extends ModeleNumRefBatch $coyymm = ''; $max = ''; $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(batch FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " WHERE batch LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } + $obj = $db->fetch_object($resql); + if ($obj) { + $max = intval($obj->max); + } else { + $max = 0; + } } - if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { + if ($max && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $max)) { $langs->load("errors"); $this->error = $langs->trans('ErrorNumRefModel', $max); return false; @@ -117,23 +121,26 @@ class mod_lot_standard extends ModeleNumRefBatch // First, we get the max value $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(batch FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " WHERE batch LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = intval($obj->max); - else $max = 0; + if ($obj) { + $max = intval($obj->max); + } else { + $max = 0; + } } else { dol_syslog("mod_lot_standard::getNextValue", LOG_DEBUG); return -1; } //$date=time(); - $date = $object->date_creation; + $date = dol_now(); $yymm = strftime("%y%m", $date); if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php index 8117b9e6c6e..54c67291d9a 100644 --- a/htdocs/core/modules/product_batch/mod_sn_advanced.php +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -139,16 +139,16 @@ class mod_sn_advanced extends ModeleNumRefBatch require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask = $conf->global->BATCH_ADVANCED_MASK; + $mask = $conf->global->SN_ADVANCED_MASK; if (!$mask) { $this->error = 'NotConfigured'; return 0; } - $date = $object->date; + $date = dol_now(); - $numFinal = get_next_value($db, $mask, 'product_sn', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'product_lot', 'batch', '', null, $date); return $numFinal; } diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index bef5efcd9f8..845044c39f3 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -85,17 +85,21 @@ class mod_sn_standard extends ModeleNumRefBatch $coyymm = ''; $max = ''; $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(batch FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " WHERE batch LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } + $obj = $db->fetch_object($resql); + if ($obj) { + $max = intval($obj->max); + } else { + $max = 0; + } } - if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { + if ($max && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $max)) { $langs->load("errors"); $this->error = $langs->trans('ErrorNumRefModel', $max); return false; @@ -107,33 +111,36 @@ class mod_sn_standard extends ModeleNumRefBatch /** * Return next free value * - * @param Product $objprod Object product + * @param Societe $objsoc Object product * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - public function getNextValue($objprod, $object) + public function getNextValue($objsoc, $object) { global $db, $conf; // First, we get the max value $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql = "SELECT MAX(CAST(SUBSTRING(batch FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " WHERE batch LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $max = intval($obj->max); - else $max = 0; + if ($obj) { + $max = intval($obj->max); + } else { + $max = 0; + } } else { dol_syslog("mod_sn_standard::getNextValue", LOG_DEBUG); return -1; } //$date=time(); - $date = $object->date_creation; + $date = dol_now(); $yymm = strftime("%y%m", $date); if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 450d0285819..763af20c6b4 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -26,12 +26,10 @@ ShowLogOfMovementIfLot=Show log of movements for couple product/lot StockDetailPerBatch=Stock detail per lot SerialNumberAlreadyInUse=Serial number %s is already used for product %s TooManyQtyForSerialNumber=You can only have one product %s for serial number %s -BatchLotNumberingModules=Options for automatic generation of batch products managed by lots -BatchSerialNumberingModules=Options for automatic generation of batch products managed by serial numbers ManageLotMask=Custom mask -CustomMasks=Adds an option to define mask in the product card -LotProductTooltip=Adds an option in the product card to define a dedicated batch number mask -SNProductTooltip=Adds an option in the product card to define a dedicated serial number mask +CustomMasks=Option to define a different numbering mask for each product +BatchLotNumberingModules=Numbering rule for automatic generation of lot number +BatchSerialNumberingModules=Numbering rule for automatic generation of serial number (for products with property 1 unique lot/serial for each product) QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned LifeTime=Life span (in days) EndOfLife=End of life diff --git a/htdocs/product/admin/product_lot.php b/htdocs/product/admin/product_lot.php index 8cafa97e077..3f4fd636de4 100644 --- a/htdocs/product/admin/product_lot.php +++ b/htdocs/product/admin/product_lot.php @@ -101,188 +101,197 @@ $head = product_lot_admin_prepare_head(); print dol_get_fiche_head($head, 'settings', $langs->trans("Batch"), -1, 'lot'); -/* - * Lot Numbering models - */ -print load_fiche_titre($langs->trans("BatchLotNumberingModules"), '', ''); +if ($conf->global->MAIN_FEATURES_LEVEL < 2) { + // The feature to define the numbering module of lot or serial is no enabled bcause it is not used anywhere in Dolibarr code: You can set it + // but the numbering module is not used. + // TODO Use it on lot creation page, when you create a lot and when the lot number is kept empty to define the lot according + // to the selected product. + print $langs->trans("NothingToSetup"); +} else { + /* + * Lot Numbering models + */ -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''."\n"; + print load_fiche_titre($langs->trans("BatchLotNumberingModules"), '', ''); -clearstatcache(); + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; -foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/product_batch/"); + clearstatcache(); - if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 8) == 'mod_lot_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file) - 4); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/product_batch/"); - require_once $dir.$file.'.php'; + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 8) == 'mod_lot_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); - $module = new $file($db); + require_once $dir.$file.'.php'; - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $module = new $file($db); - if ($module->isEnabled()) { - print ''; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - // Show example of numbering model - print ''."\n"; + if ($module->isEnabled()) { + print ''; - print ''; + // Show example of numbering model + print ''."\n"; - $batch = new Productlot($db); - $batch->initAsSpecimen(); - - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $batch); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; + print ''; + + $batch = new Productlot($db); + $batch->initAsSpecimen(); + + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $batch); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; } - - print ''; - - print "\n"; } } + closedir($handle); } - closedir($handle); } } -} -print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->name."\n"; - print $module->info(); - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'.$module->name."\n"; + print $module->info(); + print ''; - if ($conf->global->PRODUCTBATCH_LOT_ADDON == $file) { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->PRODUCTBATCH_LOT_ADDON == $file) { + print img_picto($langs->trans("Activated"), 'switch_on'); } else { - $htmltooltip .= $langs->trans($module->error).'
'; + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } + print '
'; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '
'; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print '

\n"; + print "
\n"; -/* - * Serials Numbering models - */ + /* + * Serials Numbering models + */ -print load_fiche_titre($langs->trans("BatchSerialNumberingModules"), '', ''); + print load_fiche_titre($langs->trans("BatchSerialNumberingModules"), '', ''); -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''."\n"; + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; -clearstatcache(); + clearstatcache(); -foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/product_batch/"); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/product_batch/"); - if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 7) == 'mod_sn_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 7) == 'mod_sn_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.$file.'.php'; + require_once $dir.$file.'.php'; - $module = new $file($db); + $module = new $file($db); - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - if ($module->isEnabled()) { - print ''; + if ($module->isEnabled()) { + print ''; - // Show example of numbering model - print ''."\n"; + // Show example of numbering model + print ''."\n"; - print ''; - - $batch = new Productlot($db); - $batch->initAsSpecimen(); - - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $batch); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; + print ''; + + $batch = new Productlot($db); + $batch->initAsSpecimen(); + + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $batch); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; } - - print ''; - - print "\n"; } } + closedir($handle); } - closedir($handle); } } -} -print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->name."\n"; - print $module->info(); - print '
'.$module->name."\n"; + print $module->info(); + print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; - if ($conf->global->PRODUCTBATCH_SN_ADDON == $file) { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; + if ($conf->global->PRODUCTBATCH_SN_ADDON == $file) { + print img_picto($langs->trans("Activated"), 'switch_on'); } else { - $htmltooltip .= $langs->trans($module->error).'
'; + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } + print '
'; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '
'; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print '

\n"; + print "
\n"; +} // End of page llxFooter(); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 2a3b3cf2e20..52322cf4697 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -87,7 +87,7 @@ class Productlot extends CommonObject */ public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>15, 'notnull'=>1, 'index'=>1, 'searchall'=>1), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1, 'searchall'=>1), 'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'sellby' => array('type'=>'date', 'label'=>'SellByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0', 'visible'=>5, 'position'=>60), From 2091120d77232de12b42c2482e9cf56f590b2e47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jul 2021 00:50:57 +0200 Subject: [PATCH 28/47] FIX #18122 --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index b1e892ae2da..9e1cf6af40c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1628,7 +1628,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); print $form->selectarray('status_batch', $statutarray, $object->status_batch); print ''; - if ($object->status_batch !== '0') { + if (!empty($object->status_batch) || !empty($conf->use_javascript_ajax)) { $langs->load("admin"); $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); $tooltip .= '
'.$langs->trans("GenericMaskCodes2"); From e7b3280c172e9c3cb439ae39da27950d1de0b6b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jul 2021 01:12:52 +0200 Subject: [PATCH 29/47] Debug v14 with nojs --- htdocs/admin/accountant.php | 8 +- htdocs/admin/company.php | 8 +- htdocs/core/class/extrafields.class.php | 48 ++--- htdocs/core/class/html.form.class.php | 248 ++++++++++++----------- htdocs/core/tpl/extrafields_view.tpl.php | 1 - htdocs/product/card.php | 88 ++++---- htdocs/societe/card.php | 2 +- 7 files changed, 210 insertions(+), 193 deletions(-) diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index 7c82775abad..24df7e0cb68 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -99,14 +99,16 @@ print "
\n"; /** * Edit parameters */ -print "\n".''."\n"; + print ''."\n"; +} print '
'; print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index d2dac38b500..b33c0adde29 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -384,14 +384,16 @@ print "
\n"; /** * Edit parameters */ -print "\n".''."\n"; + print ''."\n"; +} print ''; print ''; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 54d812aeafb..f6a5ba93d61 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2006,30 +2006,32 @@ class ExtraFields $collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true)); $extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key].(!empty($object->id)?'_'.$object->id:''); - $out .= ''."\n"; - $out .= ''."\n"; } - $out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'").click(function(){'."\n"; - $out .= ' console.log("We click on collapse/uncollapse .trextrafields_collapse'.$extrafields_collapse_num.'");'."\n"; - $out .= ' jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").toggle(300, function(){'."\n"; - $out .= ' if (jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").is(":hidden")) {'."\n"; - $out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.' span").addClass("fa-plus-square").removeClass("fa-minus-square");'."\n"; - $out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=0; path='.$_SERVER["PHP_SELF"].'"'."\n"; - $out .= ' } else {'."\n"; - $out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.' span").addClass("fa-minus-square").removeClass("fa-plus-square");'."\n"; - $out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=1; path='.$_SERVER["PHP_SELF"].'"'."\n"; - $out .= ' }'."\n"; - $out .= ' });'."\n"; - $out .= ' });'."\n"; - $out .= '});'."\n"; - $out .= ''."\n"; } } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 048fbb0cad3..816e0a79225 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7067,7 +7067,7 @@ class Form public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) { global $conf, $langs; - global $delayedhtmlcontent; + global $delayedhtmlcontent; // Will be used later outside of this function // TODO Use an internal dolibarr component instead of select2 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { @@ -7076,68 +7076,71 @@ class Form $out = ''; - $tmpplugin = 'select2'; - $outdelayed = "\n".' - '; + }); + '; + } if ($acceptdelayedhtml) { $delayedhtmlcontent .= $outdelayed; @@ -7168,7 +7171,7 @@ class Form public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) { global $conf, $langs; - global $delayedhtmlcontent; + global $delayedhtmlcontent; // Will be used later outside of this function // TODO Use an internal dolibarr component instead of select2 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { @@ -7187,74 +7190,77 @@ class Form $formattedarrayresult[] = $o; } - $tmpplugin = 'select2'; - $outdelayed = "\n".' - '; + '.($callurlonselect ? ' + /* Code to execute a GET when we select a value */ + $(".'.$htmlname.'").change(function() { + var selected = $(".'.$htmlname.'").val(); + console.log("We select "+selected) + + $(".'.$htmlname.'").val(""); /* reset visible combo value */ + $.each( saveRemoteData, function( key, value ) { + if (key == selected) + { + console.log("selectArrayFilter - Do a redirect to "+value.url) + location.assign(value.url); + } + }); + });' : '').' + + }); + '; + } if ($acceptdelayedhtml) { $delayedhtmlcontent .= $outdelayed; @@ -7297,7 +7303,7 @@ class Form } // Add code for jquery to use multiselect - if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { $out .= "\n".''; $out .= "\n".''."\n"; + print ''."\n"; + } // Load object modCodeProduct $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); @@ -1551,14 +1553,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - print ''."\n"; + } // We set country_id, country_code and country for the selected country $object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $object->country_id; @@ -1646,46 +1650,48 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $inherited_mask_sn = getDolGlobalString('SN_ADVANCED_MASK'); print ''; print $form->textwithpicto('', $tooltip, 1, 1); - - print ''; + '; + } print ''; } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 76ae78fdb51..b62c277cdf2 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1859,7 +1859,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $sub2 = 1; } - if ($conf->use_javascript_ajax) { + if (!empty($conf->use_javascript_ajax)) { print "\n".'