From 6cf15c70ac908f8a5e25430b8951c2da75008458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 19 Feb 2025 14:15:05 +0100 Subject: [PATCH 1/4] fix CI --- htdocs/accountancy/bookkeeping/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 7dff65c8697..7ccdfc2354d 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -4,7 +4,7 @@ * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2022 Progiseize * Copyright (C) 2024 MDW * @@ -81,7 +81,7 @@ $search_date_export_start = GETPOSTDATE('search_date_export_start', 'getpost'); $search_date_export_end = GETPOSTDATE('search_date_export_end', 'getpostend'); $search_date_validation_start = GETPOSTDATE('search_date_validation_start', 'getpost'); -$search_date_validation_start = GETPOSTDATE('search_date_validation_end', 'getpostend'); +$search_date_validation_end = GETPOSTDATE('search_date_validation_end', 'getpostend'); // Due date start $search_date_due_start_day = GETPOSTINT('search_date_due_start_day'); From 2049d56cdd9b0f5bb0e81fd79d1219b97304ee45 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Wed, 19 Feb 2025 14:32:17 +0100 Subject: [PATCH 2/4] Clean code --- htdocs/accountancy/bookkeeping/balance.php | 14 ++++---- htdocs/accountancy/bookkeeping/list.php | 36 ++++--------------- .../accountancy/bookkeeping/listbyaccount.php | 6 ++++ 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 3d8d469b63f..600aa59d927 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -100,7 +100,7 @@ $hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules $formaccounting = new FormAccounting($db); $form = new Form($db); -if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { +if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('formfilteraction')) { $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); @@ -157,17 +157,17 @@ if (empty($reshook)) { $show_subgroup = ''; $search_date_start = ''; $search_date_end = ''; - $search_date_startyear = ''; - $search_date_startmonth = ''; - $search_date_startday = ''; - $search_date_endyear = ''; - $search_date_endmonth = ''; - $search_date_endday = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; $search_not_reconciled = ''; $search_ledger_code = array(); $filter = array(); + unset($_SESSION['DOLDATE_search_date_start_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_year']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_year']); } // Must be after the remove filter action, before the export. diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 7dff65c8697..adf581599aa 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -257,44 +257,14 @@ if (empty($reshook)) { $search_mvt_label = ''; $search_direction = ''; $search_ledger_code = array(); - $search_date_startyear = ''; - $search_date_startmonth = ''; - $search_date_startday = ''; - $search_date_endyear = ''; - $search_date_endmonth = ''; - $search_date_endday = ''; $search_date_start = ''; $search_date_end = ''; - $search_date_creation_startyear = ''; - $search_date_creation_startmonth = ''; - $search_date_creation_startday = ''; - $search_date_creation_endyear = ''; - $search_date_creation_endmonth = ''; - $search_date_creation_endday = ''; $search_date_creation_start = ''; $search_date_creation_end = ''; - $search_date_modification_startyear = ''; - $search_date_modification_startmonth = ''; - $search_date_modification_startday = ''; - $search_date_modification_endyear = ''; - $search_date_modification_endmonth = ''; - $search_date_modification_endday = ''; $search_date_modification_start = ''; $search_date_modification_end = ''; - $search_date_export_startyear = ''; - $search_date_export_startmonth = ''; - $search_date_export_startday = ''; - $search_date_export_endyear = ''; - $search_date_export_endmonth = ''; - $search_date_export_endday = ''; $search_date_export_start = ''; $search_date_export_end = ''; - $search_date_validation_startyear = ''; - $search_date_validation_startmonth = ''; - $search_date_validation_startday = ''; - $search_date_validation_endyear = ''; - $search_date_validation_endmonth = ''; - $search_date_validation_endday = ''; $search_date_validation_start = ''; $search_date_validation_end = ''; // Due date start @@ -313,6 +283,12 @@ if (empty($reshook)) { $search_not_reconciled = ''; $search_import_key = ''; $toselect = array(); + unset($_SESSION['DOLDATE_search_date_start_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_year']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_year']); } // Must be after the remove filter action, before the export. diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 5abd6f84719..43c5ebfbab0 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -315,6 +315,12 @@ if (empty($reshook)) { $search_not_reconciled = ''; $search_import_key = ''; $toselect = array(); + unset($_SESSION['DOLDATE_search_date_start_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_start_accountancy_year']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_day']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_month']); + unset($_SESSION['DOLDATE_search_date_end_accountancy_year']); } if (!empty($socid)) { From 7956d3099d44363358a8bb32c6c5aba8e9ff40dd Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Wed, 19 Feb 2025 14:36:06 +0100 Subject: [PATCH 3/4] Fix fatal error --- htdocs/accountancy/bookkeeping/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 979b875fe4d..59217213de3 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -31,6 +31,7 @@ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfiscalyear.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; From e0d459a1b2bcb0e74b7e9bd32d5acd6f734264cd Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 19 Feb 2025 14:41:37 +0100 Subject: [PATCH 4/4] QUAL use one var to determine if sell-by or eat-by date is enabled --- htdocs/expedition/dispatch.php | 47 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 0df964b4214..4dd2665a0a0 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -56,7 +56,10 @@ if (isModEnabled('project')) { // Load translation files required by the page $langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'receptions')); -if (isModEnabled('productbatch')) { +$is_mod_batch_enabled = isModEnabled('productbatch'); +$is_eat_by_enabled = !getDolGlobalInt('PRODUCT_DISABLE_EATBY'); +$is_sell_by_enabled = !getDolGlobalInt('PRODUCT_DISABLE_SELLBY'); +if ($is_mod_batch_enabled) { $langs->load('productbatch'); } @@ -531,7 +534,7 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print '
'; - if (isModEnabled('barcode') || isModEnabled('productbatch')) { + if (isModEnabled('barcode') || $is_mod_batch_enabled) { print ''.img_picto('', 'barcode', 'class="paddingrightonly"').$langs->trans("UpdateByScaning").''; } print ''.img_picto("", 'autofill', 'class="pictofixedwidth"').$langs->trans("RestoreWithCurrentQtySaved").''; @@ -634,12 +637,12 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print ''.$langs->trans("Description").''; - if (isModEnabled('productbatch')) { + if ($is_mod_batch_enabled) { print ''.$langs->trans("batch_number").''; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { + if ($is_sell_by_enabled) { print ''.$langs->trans("SellByDate").''; } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { + if ($is_eat_by_enabled) { print ''.$langs->trans("EatByDate").''; } } else { @@ -733,17 +736,17 @@ if ($object->id > 0 || !empty($object->ref)) { $linktoprod = $tmpproduct->getNomUrl(1); $linktoprod .= ' - '.$objp->label."\n"; - if (isModEnabled('productbatch')) { + if ($is_mod_batch_enabled) { if ($objp->tobatch) { // Product print ''; print $linktoprod; print ""; print ''; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { + if ($is_sell_by_enabled) { print ''; } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { + if ($is_eat_by_enabled) { print ''; } } else { @@ -754,10 +757,10 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print ''.$langs->trans("ProductDoesNotUseBatchSerial").''; print ''; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { + if ($is_sell_by_enabled) { print ''; } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { + if ($is_eat_by_enabled) { print ''; } } @@ -806,7 +809,7 @@ if ($object->id > 0 || !empty($object->ref)) { $suffix = "_".$j."_".$i; $objd = $db->fetch_object($resultsql); - if (isModEnabled('productbatch') && (!empty($objd->batch) || (is_null($objd->batch) && $tmpproduct->status_batch > 0))) { + if ($is_mod_batch_enabled && (!empty($objd->batch) || (is_null($objd->batch) && $tmpproduct->status_batch > 0))) { $type = 'batch'; // Enable hooks to append additional columns @@ -846,13 +849,13 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; //print ''; print ''; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { + if ($is_sell_by_enabled) { print ''; $dlcdatesuffix = !empty($objd->sellby) ? dol_stringtotime($objd->sellby) : dol_mktime(0, 0, 0, GETPOSTINT('dlc'.$suffix.'month'), GETPOSTINT('dlc'.$suffix.'day'), GETPOSTINT('dlc'.$suffix.'year')); print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, 0, 0, 1, ''); print ''; } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { + if ($is_eat_by_enabled) { print ''; $dluodatesuffix = !empty($objd->eatby) ? dol_stringtotime($objd->eatby) : dol_mktime(0, 0, 0, GETPOSTINT('dluo'.$suffix.'month'), GETPOSTINT('dluo'.$suffix.'day'), GETPOSTINT('dluo'.$suffix.'year')); print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, 0, 0, 1, ''); @@ -862,8 +865,8 @@ if ($object->id > 0 || !empty($object->ref)) { } else { $type = 'dispatch'; $colspan = 6; - $colspan = (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) ? --$colspan : $colspan; - $colspan = (getDolGlobalString('PRODUCT_DISABLE_EATBY')) ? --$colspan : $colspan; + $colspan = $is_sell_by_enabled ? $colspan : --$colspan; + $colspan = $is_eat_by_enabled ? $colspan : --$colspan; // Enable hooks to append additional columns $parameters = array( @@ -904,7 +907,7 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print ''; print ''; - if (isModEnabled('productbatch') && $objp->tobatch > 0) { + if ($is_mod_batch_enabled && $objp->tobatch > 0) { $type = 'batch'; print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" '.($numd != $j + 1 ? 'style="display:none"' : '').' onClick="addDispatchLine('.$i.', \''.$type.'\')"'); } else { @@ -953,7 +956,7 @@ if ($object->id > 0 || !empty($object->ref)) { } if ($j == 0) { - if (isModEnabled('productbatch') && !empty($objp->tobatch)) { + if ($is_mod_batch_enabled && !empty($objp->tobatch)) { $type = 'batch'; // Enable hooks to append additional columns @@ -991,13 +994,13 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print ''; print ''; - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { + if ($is_sell_by_enabled) { print ''; $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOSTINT('dlc'.$suffix.'month'), GETPOSTINT('dlc'.$suffix.'day'), GETPOSTINT('dlc'.$suffix.'year')); print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, 0, 0, 1, ''); print ''; } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { + if ($is_eat_by_enabled) { print ''; $dluodatesuffix = dol_mktime(0, 0, 0, GETPOSTINT('dluo'.$suffix.'month'), GETPOSTINT('dluo'.$suffix.'day'), GETPOSTINT('dluo'.$suffix.'year')); print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, 0, 0, 1, ''); @@ -1007,8 +1010,8 @@ if ($object->id > 0 || !empty($object->ref)) { } else { $type = 'dispatch'; $colspan = 6; - $colspan = (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) ? --$colspan : $colspan; - $colspan = (getDolGlobalString('PRODUCT_DISABLE_EATBY')) ? --$colspan : $colspan; + $colspan = $is_sell_by_enabled ? $colspan : --$colspan; + $colspan = $is_eat_by_enabled ? $colspan : --$colspan; // Enable hooks to append additional columns $parameters = array( @@ -1054,7 +1057,7 @@ if ($object->id > 0 || !empty($object->ref)) { print ''; print ''; print ''; - if (isModEnabled('productbatch') && $objp->tobatch > 0) { + if ($is_mod_batch_enabled && $objp->tobatch > 0) { $type = 'batch'; print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"'); } else {