63 global $user, $langs, $conf, $form;
66 $this->info_box_head = array(
'text' => $langs->trans(
"BoxScheduledJobs", $max),
'nbcol' => 4);
68 if ($user->hasRight(
'cron',
'read')) {
69 include_once DOL_DOCUMENT_ROOT .
'/cron/class/cronjob.class.php';
70 $cronstatic =
new Cronjob($this->db);
71 $resultarray = array();
74 $sql =
"SELECT t.rowid, t.datelastrun, t.datenextrun, t.datestart,";
75 $sql .=
" t.label, t.status, t.test, t.lastresult, t.processing";
76 $sql .=
" FROM " . MAIN_DB_PREFIX .
"cronjob as t";
77 $sql .=
" WHERE status <> ".$cronstatic::STATUS_DISABLED;
78 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
79 $sql .= $this->db->order(
"t.datelastrun",
"DESC");
81 $result = $this->db->query($sql);
84 $nbjobsnotfinished = 0;
86 $num = $this->db->num_rows($result);
90 $objp = $this->db->fetch_object($result);
92 if ((
int)
dol_eval($objp->test, 1, 1,
'2')) {
93 $nextrun = $this->db->jdate($objp->datenextrun);
94 if (empty($nextrun)) {
95 $nextrun = $this->db->jdate($objp->datestart);
98 if ($line == 0 || ($nextrun < $cronstatic->datenextrun && (empty($objp->nbrun) || empty($objp->maxrun) || $objp->nbrun < $objp->maxrun))) {
100 $cronstatic->id = $objp->rowid;
101 $cronstatic->ref = $objp->rowid;
102 $cronstatic->label = $langs->trans($objp->label);
103 $cronstatic->status = $objp->status;
104 $cronstatic->processing = $objp->processing;
105 $cronstatic->lastresult = $objp->lastresult ??
'';
106 $cronstatic->datenextrun = $this->db->jdate($objp->datenextrun);
107 $cronstatic->datelastrun = $this->db->jdate($objp->datelastrun);
111 $resultarray[$line] = array(
112 $langs->trans(
"LastExecutedScheduledJob"),
113 $cronstatic->getNomUrl(1),
114 $cronstatic->datelastrun,
116 $cronstatic->getLibStatut(3)
121 if ($objp->processing && $this->db->jdate($objp->datelastrun) < (
dol_now() - 3600 * 24)) {
122 $nbjobsnotfinished++;
124 if (!empty($objp->lastresult)) {
132 $resultarray[$line] = array(
133 $langs->trans(
"NextScheduledJobExecute"),
134 $cronstatic->getNomUrl(1),
135 $cronstatic->datenextrun,
137 $cronstatic->getLibStatut(3)
141 foreach ($resultarray as $line => $value) {
142 $this->info_box_contents[$line][] = array(
143 'td' =>
'class="tdoverflowmax200"',
144 'text' => $resultarray[$line][0]
147 $this->info_box_contents[$line][] = array(
148 'td' =>
'class="nowraponall"',
149 'textnoformat' => $resultarray[$line][1]
151 $this->info_box_contents[$line][] = array(
152 'td' =>
'class="right"',
153 'textnoformat' => (empty($resultarray[$line][2]) ?
'' : $form->textwithpicto(
dol_print_date($resultarray[$line][2],
"dayhoursec",
'tzserver'), $langs->trans(
"CurrentTimeZone")))
155 $this->info_box_contents[$line][] = array(
156 'td' =>
'class="center" ',
157 'textnoformat' => $resultarray[$line][4]
163 $this->info_box_contents[$line][] = array(
164 'td' =>
'class="tdoverflowmax300" colspan="3"',
165 'text' => $langs->trans(
"NumberScheduledJobError")
168 if ($nbjobsnotfinished) {
169 $textnoformat .=
'<a class="inline-block paddingleft paddingright marginleftonly 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>';
171 if ($nbjobsinerror) {
172 $textnoformat .=
'<a class="inline-block paddingleft paddingright marginleftonly marginrightonly 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>';
174 if (empty($nbjobsnotfinished) && empty($nbjobsinerror)) {
175 $textnoformat .=
'<a class="inline-block paddingleft paddingright marginleftonly marginrightonly minwidth25 nounderlineimp" href="'.DOL_URL_ROOT.
'/cron/list.php"><div class="center badge badge-status4 nounderline">0</div></a>';
177 $this->info_box_contents[$line][] = array(
178 'td' =>
'class="center"',
179 'textnoformat' => $textnoformat
182 $this->info_box_contents[0][0] = array(
185 'text' => ($this->db->lasterror() .
' sql=' . $sql)
189 $this->info_box_contents[0][0] = array(
190 'td' =>
'class="nohover left"',
191 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'