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)); + } + }