From d608a46c956f9576ec8e6a09d61099dec0a6acac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 22:47:35 +0100 Subject: [PATCH 1/3] Fix dates --- htdocs/comm/action/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index a603010f46a..5396454667b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1716,7 +1716,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Hour start if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { - $daterange .= dol_print_date($event->date_start_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuser'); if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) @@ -1736,7 +1736,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) - $daterange .= dol_print_date($event->date_end_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuser'); } } else { if ($showinfo) From 91c594a66a3ee53c6c85043b5f2bde7df8cc919b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 23:03:47 +0100 Subject: [PATCH 2/3] Fix syntax error --- htdocs/takepos/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 2182973a219..344955a9167 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -729,10 +729,10 @@ $( document ).ready(function() { if ($conf->global->TAKEPOS_NUM_TERMINALS == "1") $_SESSION["takeposterminal"] = 1; else print "TerminalsDialog();"; } - if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) - $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; - $sql .= " entity = ".$conf->entity." AND "; - $sql .= " date(date_creation) = CURDATE()"; + if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { + $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; + $sql .= " entity = ".$conf->entity." AND "; + $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); From c3b409df312b6efaba42c8b2f784b13bdf0a2a8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 23:18:44 +0100 Subject: [PATCH 3/3] Fix do not use CURDATE() --- htdocs/takepos/index.php | 4 ++-- test/phpunit/CodingPhpTest.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 130e9f16680..b641efd2502 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -779,7 +779,7 @@ $( document ).ready(function() { if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; - $sql .= " date(date_creation) = CURDATE()"; + $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1027,7 +1027,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; -$sql .= " date(date_creation) = CURDATE()"; +$sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; $resql = $db->query($sql); if ($resql) { diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 9acb13432d2..c18987b8931 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -364,6 +364,18 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase break; } $this->assertTrue($ok, 'Found a declaration @var array() instead of @var array in file '.$file['relativename'].'.'); + + + // Test we don't have CURDATE() + $ok=true; + $matches=array(); + preg_match_all('/CURDATE\(\)/', $filecontent, $matches, PREG_SET_ORDER); + foreach ($matches as $key => $val) + { + $ok=false; + break; + } + $this->assertTrue($ok, 'Found a CURDATE\(\) into code. Do not use this SQL method in file '.$file['relativename'].'. You must use the PHP function dol_now() instead.'); } return;