Fix do not use CURDATE()

This commit is contained in:
Laurent Destailleur
2021-02-03 23:18:44 +01:00
parent e89cc08ffa
commit c3b409df31
2 changed files with 14 additions and 2 deletions

View File

@@ -779,7 +779,7 @@ $( document ).ready(function() {
if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) {
$sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
$sql .= " entity = ".$conf->entity." AND "; $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); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$obj = $db->fetch_object($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 = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE";
$sql .= " entity = ".$conf->entity." AND "; $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); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {

View File

@@ -364,6 +364,18 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
break; break;
} }
$this->assertTrue($ok, 'Found a declaration @var array() instead of @var array in file '.$file['relativename'].'.'); $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; return;