27 include_once DOL_DOCUMENT_ROOT .
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"scheduledjobs";
36 public $boximg =
"object_cron";
37 public $boxlabel =
"BoxScheduledJobs";
38 public $depends = array(
"cron");
47 public $info_box_head = array();
48 public $info_box_contents = array();
63 $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire);
74 global $user, $langs, $conf, $form;
77 $this->info_box_head = array(
'text' => $langs->trans(
"BoxScheduledJobs", $max));
79 if ($user->rights->cron->read) {
80 include_once DOL_DOCUMENT_ROOT .
'/cron/class/cronjob.class.php';
82 $resultarray = array();
85 $sql =
"SELECT t.rowid, t.datelastrun, t.datenextrun,";
86 $sql .=
" t.label, t.status, t.test, t.lastresult";
87 $sql .=
" FROM " . MAIN_DB_PREFIX .
"cronjob as t";
88 $sql .=
" WHERE status <> ".$cronstatic::STATUS_DISABLED;
89 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
90 $sql .= $this->
db->order(
"t.datelastrun",
"DESC");
92 $result = $this->
db->query($sql);
96 $num = $this->
db->num_rows($result);
100 $objp = $this->
db->fetch_object($result);
103 $nextrun = $this->
db->jdate($objp->datenextrun);
104 if (empty($nextrun)) $nextrun = $this->
db->jdate($objp->datestart);
106 if ($line == 0 || ($nextrun < $cronstatic->datenextrun && (empty($objp->nbrun) || empty($objp->maxrun) || $objp->nbrun < $objp->maxrun))) {
107 $cronstatic->id = $objp->rowid;
108 $cronstatic->ref = $objp->rowid;
109 $cronstatic->label = $langs->trans($objp->label);
110 $cronstatic->status = $objp->status;
111 $cronstatic->datenextrun = $this->
db->jdate($objp->datenextrun);
112 $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 (!empty($objp->lastresult)) {
133 $resultarray[$line] = array(
134 $langs->trans(
"NextScheduledJobExecute"),
135 $cronstatic->getNomUrl(1),
136 $cronstatic->datenextrun,
138 $cronstatic->getLibStatut(3)
142 foreach ($resultarray as $line => $value) {
143 $this->info_box_contents[$line][] = array(
144 'td' =>
'class="tdoverflowmax200"',
145 'text' => $resultarray[$line][0]
148 $this->info_box_contents[$line][] = array(
149 'td' =>
'class="nowraponall"',
150 'textnoformat' => $resultarray[$line][1]
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="right"',
154 'textnoformat' => (empty($resultarray[$line][2]) ?
'' : $form->textwithpicto(
dol_print_date($resultarray[$line][2],
"dayhoursec"), $langs->trans(
"CurrentTimeZone")))
156 $this->info_box_contents[$line][] = array(
157 'td' =>
'class="center" ',
158 'textnoformat' => $resultarray[$line][4]
162 $this->info_box_contents[$line][] = array(
163 'td' =>
'class="tdoverflowmax300" colspan="3"',
164 'text' => $langs->trans(
"NumberScheduledJobError")
166 $this->info_box_contents[$line][] = array(
167 'td' =>
'class="center"',
168 'textnoformat' => ($nbjobsinerror ?
'<a href="'.DOL_URL_ROOT.
'/cron/list.php?search_lastresult='.urlencode(
'<>0').
'"><div class="badge badge-danger"><i class="fa fa-exclamation-triangle"></i> '.$nbjobsinerror.
'</div></a>' :
'<div class="center badge-status4">0</div>')
171 $this->info_box_contents[0][0] = array(
174 'text' => ($this->
db->lasterror() .
' sql=' . $sql)
178 $this->info_box_contents[0][0] = array(
179 'td' =>
'class="nohover opacitymedium left"',
180 'text' => $langs->trans(
"ReadPermissionNotAllowed")
193 public function showBox($head = null, $contents = null, $nooutput = 0)
195 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
__construct($db, $param)
Constructor.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
$conf db
API class for accounts.
Class to manage the box to show last contracted products/services lines.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
loadBox($max=5)
Load data into info_box_contents array to show array later.