From d25c16bf7732714b11e4f14fb6591032fc96c77a Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Wed, 26 Oct 2022 12:14:53 +0200 Subject: [PATCH 01/12] FIX: Fix the position of the verification condition of the test field in case of multi entities --- scripts/cron/cron_run_jobs.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 8aa996f9c17..ec8abcdea80 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -173,25 +173,17 @@ if ($result < 0) { exit(-1); } -$qualifiedjobs = array(); -foreach ($object->lines as $val) { - if (!verifCond($val->test)) { - continue; - } - $qualifiedjobs[] = $val; -} - // TODO Duplicate code. This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page. -$nbofjobs = count($qualifiedjobs); +$nbofjobs = count($object->lines); $nbofjobslaunchedok = 0; $nbofjobslaunchedko = 0; -if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { +if (is_array($object->lines) && (count($object->lines) > 0)) { $savconf = dol_clone($conf); // Loop over job - foreach ($qualifiedjobs as $line) { + foreach ($object->lines as $line) { dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG); echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label; @@ -233,6 +225,10 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { } } + if (!verifCond($line->test)) { + continue; + } + //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { echo " - qualified"; From dff5f46749ea012777909dcc2c39d00155aaac06 Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Fri, 18 Nov 2022 10:37:35 +0100 Subject: [PATCH 02/12] Add for htdocs/public/cron/cron_run_jobs_by_url.php --- htdocs/public/cron/cron_run_jobs_by_url.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/htdocs/public/cron/cron_run_jobs_by_url.php b/htdocs/public/cron/cron_run_jobs_by_url.php index 133c5d1b18a..3d6b9c74d7a 100644 --- a/htdocs/public/cron/cron_run_jobs_by_url.php +++ b/htdocs/public/cron/cron_run_jobs_by_url.php @@ -132,26 +132,18 @@ if ($result < 0) { exit; } -$qualifiedjobs = array(); -foreach ($object->lines as $val) { - if (!verifCond($val->test)) { - continue; - } - $qualifiedjobs[] = $val; -} - // TODO Duplicate code. This sequence of code must be shared with code into cron_run_jobs.php script. // current date -$nbofjobs = count($qualifiedjobs); +$nbofjobs = count($object->lines); $nbofjobslaunchedok = 0; $nbofjobslaunchedko = 0; -if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { +if (is_array($object->lines) && (count($object->lines) > 0)) { $savconf = dol_clone($conf); // Loop over job - foreach ($qualifiedjobs as $line) { + foreach ($object->lines as $line) { dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG); echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label; @@ -181,6 +173,10 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) { } } + if (!verifCond($line->test)) { + continue; + } + //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { echo " - qualified"; From ed2a9a22e8c7958093a85333b9232dbbba58751d Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 23 Nov 2022 08:36:20 +0100 Subject: [PATCH 03/12] FIX compute next value when year is on one digit for reset counter --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 0035688c66f..066027aa24a 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1215,7 +1215,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } elseif ($yearlen == 2) { $yearcomp = sprintf("%02d", date("y", $date) + $yearoffset); } elseif ($yearlen == 1) { - $yearcomp = substr(date("y", $date), 2, 1) + $yearoffset; + $yearcomp = substr(date('y', $date), 1, 1) + $yearoffset; } if ($monthcomp > 1 && empty($resetEveryMonth)) { // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) if ($yearlen == 4) { From 05e850dbfc25eb930012ab06dccc6d8916272889 Mon Sep 17 00:00:00 2001 From: David Pareja Rodriguez Date: Wed, 23 Nov 2022 11:58:21 +0100 Subject: [PATCH 04/12] FIX Broken Permissions check, $object is null. This code was probably copy&paste'd from `htdocs/compta/prelevement/card.php` where the `$object` variable exists. On `htdocs/compta/prelevement/line.php` `$object` is not defined, and `$type` come from the `$type = GETPOST('type', 'aZ09');` which ends up being overwritten with null. --- htdocs/compta/prelevement/line.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 65ba71a0d2f..f706e94a656 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -61,7 +61,7 @@ if ($sortfield == "") { $sortfield = "pl.fk_soc"; } -$type = $object->type; + if ($type == 'bank-transfer') { $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); } else { From 2ada053855bb3d93ca4b6e009cb7e56401b1cc8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Fri, 25 Nov 2022 11:44:34 +0100 Subject: [PATCH 05/12] FIX: Use the Hook addMoreActionsButtons resPrint --- htdocs/accountancy/bookkeeping/balance.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 1d210e74d8a..15b435d45c8 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -235,10 +235,18 @@ if ($action != 'export_csv') { print ''; print ''; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $button = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $button = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; + + if (empty($reshook)) { + $button .= 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; print '