77 global $user, $langs, $conf, $form;
80 $this->info_box_head = array(
'text' => $langs->trans(
"BoxScheduledJobs", $max));
82 if ($user->hasRight(
'cron',
'read')) {
83 include_once DOL_DOCUMENT_ROOT .
'/cron/class/cronjob.class.php';
84 $cronstatic =
new Cronjob($this->db);
85 $resultarray = array();
88 $sql =
"SELECT t.rowid, t.datelastrun, t.datenextrun, t.datestart,";
89 $sql .=
" t.label, t.status, t.test, t.lastresult, t.processing";
90 $sql .=
" FROM " . MAIN_DB_PREFIX .
"cronjob as t";
91 $sql .=
" WHERE status <> ".$cronstatic::STATUS_DISABLED;
92 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
93 $sql .= $this->db->order(
"t.datelastrun",
"DESC");
95 $result = $this->db->query($sql);
98 $nbjobsnotfinished = 0;
100 $num = $this->db->num_rows($result);
104 $objp = $this->db->fetch_object($result);
106 if (
dol_eval($objp->test, 1, 1,
'')) {
107 $nextrun = $this->db->jdate($objp->datenextrun);
108 if (empty($nextrun)) {
109 $nextrun = $this->db->jdate($objp->datestart);
112 if ($line == 0 || ($nextrun < $cronstatic->datenextrun && (empty($objp->nbrun) || empty($objp->maxrun) || $objp->nbrun < $objp->maxrun))) {
114 $cronstatic->id = $objp->rowid;
115 $cronstatic->ref = $objp->rowid;
116 $cronstatic->label = $langs->trans($objp->label);
117 $cronstatic->status = $objp->status;
118 $cronstatic->datenextrun = $this->db->jdate($objp->datenextrun);
119 $cronstatic->datelastrun = $this->db->jdate($objp->datelastrun);
123 $resultarray[$line] = array(
124 $langs->trans(
"LastExecutedScheduledJob"),
125 $cronstatic->getNomUrl(1),
126 $cronstatic->datelastrun,
128 $cronstatic->getLibStatut(3)
133 if ($objp->processing && $this->db->jdate($objp->datelastrun) < (
dol_now() - 3600 * 24)) {
134 $nbjobsnotfinished++;
136 if (!empty($objp->lastresult)) {
144 $resultarray[$line] = array(
145 $langs->trans(
"NextScheduledJobExecute"),
146 $cronstatic->getNomUrl(1),
147 $cronstatic->datenextrun,
149 $cronstatic->getLibStatut(3)
153 foreach ($resultarray as $line => $value) {
154 $this->info_box_contents[$line][] = array(
155 'td' =>
'class="tdoverflowmax200"',
156 'text' => $resultarray[$line][0]
159 $this->info_box_contents[$line][] = array(
160 'td' =>
'class="nowraponall"',
161 'textnoformat' => $resultarray[$line][1]
163 $this->info_box_contents[$line][] = array(
164 'td' =>
'class="right"',
165 'textnoformat' => (empty($resultarray[$line][2]) ?
'' : $form->textwithpicto(
dol_print_date($resultarray[$line][2],
"dayhoursec",
'tzserver'), $langs->trans(
"CurrentTimeZone")))
167 $this->info_box_contents[$line][] = array(
168 'td' =>
'class="center" ',
169 'textnoformat' => $resultarray[$line][4]
173 $this->info_box_contents[$line][] = array(
174 'td' =>
'class="tdoverflowmax300" colspan="3"',
175 'text' => $langs->trans(
"NumberScheduledJobError")
178 if ($nbjobsnotfinished) {
179 $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>';
181 if ($nbjobsinerror) {
182 $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>';
184 if (empty($nbjobsnotfinished) && empty($nbjobsinerror)) {
185 $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>';
187 $this->info_box_contents[$line][] = array(
188 'td' =>
'class="center"',
189 'textnoformat' => $textnoformat
192 $this->info_box_contents[0][0] = array(
195 'text' => ($this->db->lasterror() .
' sql=' . $sql)
199 $this->info_box_contents[0][0] = array(
200 'td' =>
'class="nohover opacitymedium left"',
201 'text' => $langs->trans(
"ReadPermissionNotAllowed")