From f1ea19e09b9e2dc9540ac2407ec1371efb485b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 6 Sep 2015 18:26:48 +0200 Subject: [PATCH] Created ActionComm:hasDelay function --- htdocs/comm/action/class/actioncomm.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index bc5bf9da9e3..44ac0425de7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -883,6 +883,7 @@ class ActionComm extends CommonObject if ($resql) { $now = dol_now(); + $agenda_static = new ActionComm($this->db); $response = new WorkboardResponse(); $response->warning_delay = $conf->actions->warning_delay/60/60/24; @@ -895,7 +896,9 @@ class ActionComm extends CommonObject { $response->nbtodo++; - if (isset($obj->dp) && $this->db->jdate($obj->dp) < ($now - $conf->actions->warning_delay)) { + $agenda_static->datep = $this->db->jdate($obj->dp); + + if ($agenda_static->hasDelay()) { $response->nbtodolate++; } } @@ -1360,5 +1363,19 @@ class ActionComm extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + /** + * Is the action delayed? + * + * @return bool + */ + public function hasDelay() + { + global $conf; + + $now = dol_now(); + + return $this->datep && ($this->datep < ($now - $conf->actions->warning_delay)); + } + }