67 global $user, $langs, $conf, $form;
70 $this->info_box_head = array(
'text' => $langs->trans(
"BoxScheduledJobs", $max),
'nbcol' => 4);
72 if ($user->hasRight(
'cron',
'read')) {
73 include_once DOL_DOCUMENT_ROOT .
'/cron/class/cronjob.class.php';
74 $cronstatic =
new Cronjob($this->db);
75 $resultarray = array();
78 $sql =
"SELECT t.rowid, t.datelastrun, t.datenextrun, t.datestart,";
79 $sql .=
" t.label, t.status, t.test, t.lastresult, t.processing";
80 $sql .=
" FROM " . MAIN_DB_PREFIX .
"cronjob as t";
81 $sql .=
" WHERE status <> ".$cronstatic::STATUS_DISABLED;
82 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
83 $sql .= $this->db->order(
"t.datelastrun",
"DESC");
85 $result = $this->db->query($sql);
88 $nbjobsnotfinished = 0;
90 $num = $this->db->num_rows($result);
94 $objp = $this->db->fetch_object($result);
96 if ((
int)
dol_eval($objp->test, 1, 1,
'2')) {
97 $nextrun = $this->db->jdate($objp->datenextrun);
98 if (empty($nextrun)) {
99 $nextrun = $this->db->jdate($objp->datestart);
102 if ($line == 0 || ($nextrun < $cronstatic->datenextrun && (empty($objp->nbrun) || empty($objp->maxrun) || $objp->nbrun < $objp->maxrun))) {
104 $cronstatic->id = $objp->rowid;
105 $cronstatic->ref = $objp->rowid;
106 $cronstatic->label = $langs->trans($objp->label);
107 $cronstatic->status = $objp->status;
108 $cronstatic->processing = $objp->processing;
109 $cronstatic->lastresult = $objp->lastresult ??
'';
110 $cronstatic->datenextrun = $this->db->jdate($objp->datenextrun);
111 $cronstatic->datelastrun = $this->db->jdate($objp->datelastrun);
115 $resultarray[$line] = array(
116 $langs->trans(
"LastExecutedScheduledJob"),
117 $cronstatic->getNomUrl(1),
118 $cronstatic->datelastrun,
120 $cronstatic->getLibStatut(3)
125 if ($objp->processing && $this->db->jdate($objp->datelastrun) < (
dol_now() - 3600 * 24)) {
126 $nbjobsnotfinished++;
128 if (!empty($objp->lastresult)) {
136 $resultarray[$line] = array(
137 $langs->trans(
"NextScheduledJobExecute"),
138 $cronstatic->getNomUrl(1),
139 $cronstatic->datenextrun,
141 $cronstatic->getLibStatut(3)
145 foreach ($resultarray as $line => $value) {
146 $this->info_box_contents[$line][] = array(
147 'td' =>
'class="tdoverflowmax200"',
148 'text' => $resultarray[$line][0]
151 $this->info_box_contents[$line][] = array(
152 'td' =>
'class="nowraponall"',
153 'textnoformat' => $resultarray[$line][1]
155 $this->info_box_contents[$line][] = array(
156 'td' =>
'class="right"',
157 'textnoformat' => (empty($resultarray[$line][2]) ?
'' : $form->textwithpicto(
dol_print_date($resultarray[$line][2],
"dayhoursec",
'tzserver'), $langs->trans(
"CurrentTimeZone")))
159 $this->info_box_contents[$line][] = array(
160 'td' =>
'class="right" ',
161 'textnoformat' => $resultarray[$line][4]
167 $this->info_box_contents[$line][] = array(
168 'td' =>
'class="tdoverflowmax300" colspan="3"',
169 'text' => $langs->trans(
"NumberScheduledJobError")
172 if ($nbjobsnotfinished) {
173 $textnoformat .=
'<a class="inline-block paddingleft paddingright marginleftonly'.($nbjobsinerror ?
' marginrightonly' :
'').
' minwidth25 nounderlineimp" href="'.DOL_URL_ROOT.
'/cron/list.php" title="'.$langs->trans(
"NumberScheduledJobNeverFinished").
'"><div class="center badge badge-warning nounderlineimp"><i class="fa fa-exclamation-triangle"></i> '.$nbjobsnotfinished.
'</div></a>';
175 if ($nbjobsinerror) {
176 $textnoformat .=
'<a class="inline-block paddingleft paddingright marginleftonly minwidth25 nounderlineimp" href="'.DOL_URL_ROOT.
'/cron/list.php?search_lastresult='.urlencode(
'<>0').
'" title="'.$langs->trans(
"NumberScheduledJobError").
'"><div class="badge badge-danger nounderlineimp"><i class="fa fa-exclamation-triangle"></i> '.$nbjobsinerror.
'</div></a>';
178 if (empty($nbjobsnotfinished) && empty($nbjobsinerror)) {
179 $textnoformat .=
'<a class="inline-block paddingleft marginleftonly minwidth25 nounderlineimp" href="'.DOL_URL_ROOT.
'/cron/list.php"><div class="center badge badge-status4 nounderline">0</div></a>';
181 $this->info_box_contents[$line][] = array(
182 'td' =>
'class="right"',
183 'textnoformat' => $textnoformat
187 $this->info_box_contents[0][0] = array(
190 'text' => ($this->db->lasterror() .
' sql=' . $sql)
194 $this->info_box_contents[0][0] = array(
195 'td' =>
'class="nohover left"',
196 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'