dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
3  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2013-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array("admin","cron","bills","members"));
34 
35 if (!$user->rights->cron->read) accessforbidden();
36 
37 $action=GETPOST('action','alpha');
38 $massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
39 $confirm=GETPOST('confirm','alpha');
40 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
41 $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'cronjoblist'; // To manage different context of search
42 
43 $id=GETPOST('id','int');
44 
45 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
46 $sortfield = GETPOST("sortfield",'alpha');
47 $sortorder = GETPOST("sortorder",'alpha');
48 $page = GETPOST("page",'int');
49 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 if (! $sortfield) $sortfield='t.status,t.priority';
54 if (! $sortorder) $sortorder='DESC,ASC';
55 
56 $search_status=GETPOST('search_status','int')?GETPOST('search_status','int'):GETPOST('status','int');
57 if ($search_status == '') $search_status=-2;
58 
59 //Search criteria
60 $search_label=GETPOST("search_label",'alpha');
61 $securitykey = GETPOST('securitykey','alpha');
62 
63 $diroutputmassaction=$conf->cronjob->dir_output . '/temp/massgeneration/'.$user->id;
64 
65 $object = new Cronjob($db);
66 
67 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
68 $hookmanager->initHooks(array('cronjoblist'));
69 $extrafields = new ExtraFields($db);
70 
71 // fetch optionals attributes and labels
72 $extralabels = $extrafields->fetch_name_optionals_label('cronjob');
73 $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
74 
75 
76 
77 /*
78  * Actions
79  */
80 
81 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
82 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
83 
84 $parameters=array();
85 $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
86 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
87 
88 if (empty($reshook))
89 {
90  // Selection of new fields
91  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
92 
93  // Purge search criteria
94  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
95  {
96  $search_label='';
97  $search_status=-1;
98  $toselect='';
99  $search_array_options=array();
100  }
101  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
102  || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
103  {
104  $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
105  }
106 
107  $filter=array();
108  if (!empty($search_label))
109  {
110  $filter['t.label']=$search_label;
111  }
112 
113  // Delete jobs
114  if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete)
115  {
116  //Delete cron task
117  $object = new Cronjob($db);
118  $object->id=$id;
119  $result = $object->delete($user);
120 
121  if ($result < 0) {
122  setEventMessages($object->error, $object->errors, 'errors');
123  }
124  }
125 
126  // Execute jobs
127  if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute)
128  {
129  if (! empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey)
130  {
131  setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors');
132  $action='';
133  }
134  else
135  {
136  $object = new Cronjob($db);
137  $job = $object->fetch($id);
138 
139  $now = dol_now(); // Date we start
140 
141  $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK
142  if ($resrunjob < 0) {
143  setEventMessages($object->error, $object->errors, 'errors');
144  }
145 
146  // Programm next run
147  $res = $object->reprogram_jobs($user->login, $now);
148  if ($res > 0)
149  {
150  if ($resrunjob >= 0) // We show the result of reprogram only if no error message already reported
151  {
152  if ($object->lastresult >= 0) setEventMessages($langs->trans("JobFinished"), null, 'mesgs');
153  else setEventMessages($langs->trans("JobFinished"), null, 'errors');
154  }
155  $action='';
156  }
157  else
158  {
159  setEventMessages($object->error, $object->errors, 'errors');
160  $action='';
161  }
162 
163  $param='&search_status='.urlencode($search_status);
164  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
165  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
166  if ($search_label) $param.='&search_label='.urlencode($search_label);
167  if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
168  // Add $param from extra fields
169  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
170 
171  header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); // Make a redirect to avoid to run twice the job when using back
172  exit;
173  }
174  }
175 
176  // Mass actions
177  $objectclass='CronJob';
178  $objectlabel='CronJob';
179  $permtoread = $user->rights->cron->read;
180  $permtocreate = $user->rights->cron->create?$user->rights->cron->create:$user->rights->cron->write;
181  $permtodelete = $user->rights->cron->delete;
182  $uploaddir = $conf->cron->dir_output;
183  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
184  if ($permtocreate)
185  {
186  $tmpcron = new Cronjob($db);
187  foreach($toselect as $id)
188  {
189  $result = $tmpcron->fetch($id);
190  if ($result)
191  {
192  $result = 0;
193  if ($massaction == 'disable') $result = $tmpcron->setStatut(Cronjob::STATUS_DISABLED);
194  elseif ($massaction == 'enable') $result = $tmpcron->setStatut(Cronjob::STATUS_ENABLED);
195  //else dol_print_error($db, 'Bad value for massaction');
196  if ($result < 0) setEventMessages($tmpcron->error, $tmpcron->errors, 'errors');
197  }
198  else
199  {
200  $error++;
201  }
202  }
203  }
204 }
205 
206 
207 /*
208  * View
209  */
210 
211 $form = new Form($db);
212 $cronjob = new Cronjob($db);
213 
214 $pagetitle=$langs->trans("CronList");
215 
216 llxHeader('',$pagetitle);
217 
218 
219 $sql = "SELECT";
220 $sql.= " t.rowid,";
221 $sql.= " t.tms,";
222 $sql.= " t.datec,";
223 $sql.= " t.jobtype,";
224 $sql.= " t.label,";
225 $sql.= " t.command,";
226 $sql.= " t.classesname,";
227 $sql.= " t.objectname,";
228 $sql.= " t.methodename,";
229 $sql.= " t.params,";
230 $sql.= " t.md5params,";
231 $sql.= " t.module_name,";
232 $sql.= " t.priority,";
233 $sql.= " t.processing,";
234 $sql.= " t.datelastrun,";
235 $sql.= " t.datenextrun,";
236 $sql.= " t.dateend,";
237 $sql.= " t.datestart,";
238 $sql.= " t.lastresult,";
239 $sql.= " t.datelastresult,";
240 $sql.= " t.lastoutput,";
241 $sql.= " t.unitfrequency,";
242 $sql.= " t.frequency,";
243 $sql.= " t.status,";
244 $sql.= " t.fk_user_author,";
245 $sql.= " t.fk_user_mod,";
246 $sql.= " t.note,";
247 $sql.= " t.maxrun,";
248 $sql.= " t.nbrun,";
249 $sql.= " t.libname,";
250 $sql.= " t.test";
251 $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
252 $sql.= " WHERE entity IN (0,".$conf->entity.")";
253 if ($search_status >= 0 && $search_status < 2) $sql.= " AND t.status = ".(empty($search_status)?'0':'1');
254 if ($search_status == 2) $sql.= " AND t.status = 2";
255 //Manage filter
256 if (is_array($filter) && count($filter)>0) {
257  foreach($filter as $key => $value) {
258  $sql.= ' AND '.$key.' LIKE \'%'.$db->escape($value).'%\'';
259  }
260 }
261 $sqlwhere = array();
262 if (!empty($module_name)) {
263  $sqlwhere[]='(t.module_name='.$db->escape($module_name).')';
264 }
265 if (count($sqlwhere)>0) {
266  $sql.= " WHERE ".implode(' AND ',$sqlwhere);
267 }
268 // Add where from extra fields
269 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
270 // Add where from hooks
271 $parameters=array();
272 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
273 $sql.=$hookmanager->resPrint;
274 
275 $sql.= $db->order($sortfield,$sortorder);
276 
277 // Count total nb of records
278 $nbtotalofrecords = '';
279 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
280 {
281  $result = $db->query($sql);
282  $nbtotalofrecords = $db->num_rows($result);
283  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
284  {
285  $page = 0;
286  $offset = 0;
287  }
288 }
289 
290 $sql.= $db->plimit($limit+1, $offset);
291 
292 $result=$db->query($sql);
293 if (! $result) dol_print_error($db);
294 
295 $num = $db->num_rows($result);
296 
297 $arrayofselected=is_array($toselect)?$toselect:array();
298 
299 $param = '';
300 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
301 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
302 if ($search_status) $param.='&search_status='.$search_status;
303 if ($search_label) $param.='&search_label='.$search_label;
304 if ($optioncss != '') $param.='&optioncss='.$optioncss;
305 // Add $param from extra fields
306 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
307 
308 $stringcurrentdate = $langs->trans("CurrentHour").': '.dol_print_date(dol_now(), 'dayhour');
309 
310 if ($action == 'delete')
311 {
312  print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.$param,$langs->trans("CronDelete"), $langs->trans("CronConfirmDelete"),"confirm_delete",'','',1);
313 }
314 if ($action == 'execute')
315 {
316  print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&securitykey='.$securitykey.$param, $langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1);
317 }
318 
319 // List of mass actions available
320 $arrayofmassactions = array(
321 //'presend'=>$langs->trans("SendByMail"),
322 //'builddoc'=>$langs->trans("PDFMerge"),
323  'enable'=>$langs->trans("CronStatusActiveBtn"),
324  'disable'=>$langs->trans("CronStatusInactiveBtn"),
325 );
326 if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
327 if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
328 $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
329 
330 
331 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="search_form">'."\n";
332 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
333 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
334 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
335 print '<input type="hidden" name="action" value="list">';
336 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
337 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
338 print '<input type="hidden" name="page" value="'.$page.'">';
339 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
340 print '<input type="hidden" name="search_status" value="'.$search_status.'" >';
341 print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
342 
343 // Line with explanation and button new job
344 $newcardbutton='';
345 if ($user->rights->cron->create)
346 {
347  $newcardbutton.='<a class="butActionNew" style="margin-right: 0px;margin-left: 0px;" href="'.DOL_URL_ROOT.'/cron/card.php?action=create"><span class="valignmiddle">'.$langs->trans("CronCreateJob").'</span>';
348  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
349  $newcardbutton.= '</a>';
350 }
351 else
352 {
353  $newcardbutton.='<a class="butActionNewRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'"><span class="valignmiddle">'.$langs->trans("CronCreateJob").'</span>';
354  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
355  $newcardbutton.= '</a>';
356 }
357 
358 print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_setup', 0, $newcardbutton, '', $limit);
359 
360 
361 print '<span class="opacitymedium">'.$langs->trans('CronInfo').'</span><br>';
362 
363 $text =$langs->trans("HoursOnThisPageAreOnServerTZ").' '.$stringcurrentdate.'<br>';
364 if (! empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text.=$langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS);
365 print info_admin($text);
366 print '<br>';
367 
368 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
369 $selectedfields='';
370 //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
371 $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
372 
373 print '<div class="div-table-responsive">';
374 print '<table class="noborder">';
375 
376 print '<tr class="liste_titre_filter">';
377 print '<td class="liste_titre">&nbsp;</td>';
378 print '<td class="liste_titre">';
379 print '<input type="text" class="flat" name="search_label" value="'.$search_label.'" size="10">';
380 print '</td>';
381 print '<td class="liste_titre">&nbsp;</td>';
382 print '<td class="liste_titre">&nbsp;</td>';
383 print '<td class="liste_titre">&nbsp;</td>';
384 print '<td class="liste_titre">&nbsp;</td>';
385 print '<td class="liste_titre">&nbsp;</td>';
386 print '<td class="liste_titre">&nbsp;</td>';
387 print '<td class="liste_titre">&nbsp;</td>';
388 print '<td class="liste_titre">&nbsp;</td>';
389 print '<td class="liste_titre">&nbsp;</td>';
390 print '<td class="liste_titre">&nbsp;</td>';
391 print '<td class="liste_titre">&nbsp;</td>';
392 print '<td class="liste_titre" align="center">';
393 print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled"), '-2'=>$langs->trans("EnabledAndDisabled"), '2'=>$langs->trans("Archived")), $search_status, 1);
394 print '</td><td class="liste_titre" align="right">';
395 $searchpicto=$form->showFilterButtons();
396 print $searchpicto;
397 print '</td>';
398 print '</tr>';
399 
400 print '<tr class="liste_titre">';
401 print_liste_field_titre("ID",$_SERVER["PHP_SELF"],"t.rowid","",$param,'',$sortfield,$sortorder);
402 print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"t.label","",$param,'',$sortfield,$sortorder);
403 print_liste_field_titre("Prority",$_SERVER["PHP_SELF"],"t.priority","",$param,'',$sortfield,$sortorder);
404 print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder);
405 print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder);
406 print_liste_field_titre("CronDtStart",$_SERVER["PHP_SELF"],"t.datestart","",$param,'align="center"',$sortfield,$sortorder);
407 print_liste_field_titre("CronDtEnd",$_SERVER["PHP_SELF"],"t.dateend","",$param,'align="center"',$sortfield,$sortorder);
408 print_liste_field_titre("CronMaxRun",$_SERVER["PHP_SELF"],"t.maxrun","",$param,'align="right"',$sortfield,$sortorder);
409 print_liste_field_titre("CronNbRun",$_SERVER["PHP_SELF"],"t.nbrun","",$param,'align="right"',$sortfield,$sortorder);
410 print_liste_field_titre("CronDtLastLaunch",$_SERVER["PHP_SELF"],"t.datelastrun","",$param,'align="center"',$sortfield,$sortorder);
411 print_liste_field_titre("CronLastResult",$_SERVER["PHP_SELF"],"t.lastresult","",$param,'align="center"',$sortfield,$sortorder);
412 print_liste_field_titre("CronLastOutput",$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder);
413 print_liste_field_titre("CronDtNextLaunch",$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder);
414 print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"t.status,t.priority","",$param,'align="center"',$sortfield,$sortorder);
415 print_liste_field_titre($selectedfields,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch ');
416 print "</tr>\n";
417 
418 
419 if ($num > 0)
420 {
421  // Loop on each job
422  $now = dol_now();
423  $i=0;
424 
425  while ($i < min($num,$limit))
426  {
427  $obj = $db->fetch_object($result);
428 
429  if (empty($obj)) break;
430  if (! verifCond($obj->test)) continue; // Discard line with test = false
431 
432  $object->id = $obj->rowid;
433  $object->ref = $obj->rowid;
434  $object->label = $obj->label;
435  $object->status = $obj->status;
436  $object->priority = $obj->priority;
437  $object->processing = $obj->processing;
438 
439  print '<tr class="oddeven">';
440 
441  // Ref
442  print '<td class="nowrap">';
443  print $object->getNomUrl(1);
444  print '</td>';
445 
446  // Label
447  print '<td>';
448  if (! empty($obj->label))
449  {
450  $object->ref = $langs->trans($obj->label);
451  print $object->getNomUrl(0, '', 1);
452  $object->ref = $obj->rowid;
453  }
454  else
455  {
456  //print $langs->trans('CronNone');
457  }
458  print '</td>';
459 
460  // Priority
461  print '<td class="right">';
462  print $object->priority;
463  print '</td>';
464 
465  print '<td>';
466  if ($obj->jobtype=='method')
467  {
468  $text=$langs->trans("CronClass");
469  $texttoshow=$langs->trans('CronModule').': '.$obj->module_name.'<br>';
470  $texttoshow.=$langs->trans('CronClass').': '. $obj->classesname.'<br>';
471  $texttoshow.=$langs->trans('CronObject').': '. $obj->objectname.'<br>';
472  $texttoshow.=$langs->trans('CronMethod').': '. $obj->methodename;
473  $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $obj->params;
474  $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($obj->note);
475  }
476  elseif ($obj->jobtype=='command')
477  {
478  $text=$langs->trans('CronCommand');
479  $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($obj->command);
480  $texttoshow.='<br>'.$langs->trans('CronArgs').': '. $obj->params;
481  $texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($obj->note);
482  }
483  print $form->textwithpicto($text, $texttoshow, 1);
484  print '</td>';
485 
486  print '<td>';
487  if($obj->unitfrequency == "60") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Minutes');
488  if($obj->unitfrequency == "3600") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Hours');
489  if($obj->unitfrequency == "86400") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Days');
490  if($obj->unitfrequency == "604800") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Weeks');
491  print '</td>';
492 
493  print '<td class="center">';
494  if(!empty($obj->datestart)) {print dol_print_date($db->jdate($obj->datestart),'dayhour');}
495  print '</td>';
496 
497  print '<td class="center">';
498  if(!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend),'dayhour');}
499  print '</td>';
500 
501  print '<td align="right">';
502  if (!empty($obj->maxrun)) {print $obj->maxrun;}
503  print '</td>';
504 
505  print '<td align="right">';
506  if (!empty($obj->nbrun)) {print $obj->nbrun;} else {print '0';}
507  print '</td>';
508 
509  print '<td class="center">';
510  if(!empty($obj->datelastrun)) {print dol_print_date($db->jdate($obj->datelastrun),'dayhour');}
511  print '</td>';
512 
513  print '<td class="center">';
514  if ($obj->lastresult != '') {
515  if (empty($obj->lastresult)) print $obj->lastresult;
516  else print '<span class="error">'.dol_trunc($obj->lastresult).'</div>';
517  }
518  print '</td>';
519 
520  print '<td>';
521  if(!empty($obj->lastoutput)) {print dol_trunc(nl2br($obj->lastoutput),50);}
522  print '</td>';
523 
524  print '<td class="center">';
525  if (!empty($obj->datenextrun)) {
526  $datenextrun = $db->jdate($obj->datenextrun);
527  if (empty($obj->status)) print '<span class="opacitymedium">';
528  print dol_print_date($datenextrun,'dayhoursec');
529  if ($obj->status == Cronjob::STATUS_ENABLED)
530  {
531  if ($obj->maxrun && $obj->nbrun >= $obj->maxrun) print img_warning($langs->trans("MaxRunReached"));
532  elseif ($datenextrun && $datenextrun < $now) print img_warning($langs->trans("Late"));
533  }
534  if (empty($obj->status)) print '</span>';
535  }
536  print '</td>';
537 
538  // Status
539  print '<td align="center">';
540  print $object->getLibStatut(3);
541  print '</td>';
542 
543  print '<td align="right" class="nowraponall">';
544 
545  $backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''));
546  if ($user->rights->cron->create)
547  {
548  print "<a href=\"".DOL_URL_ROOT."/cron/card.php?id=".$obj->rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param;
549  print "&backtourl=".$backtourl."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."</a> &nbsp;";
550  }
551  if ($user->rights->cron->delete)
552  {
553  print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$obj->rowid."&action=delete".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param;
554  print "\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'),'delete')."</a> &nbsp;";
555  } else {
556  print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'), 'delete')."</a> &nbsp; ";
557  }
558  if ($user->rights->cron->execute)
559  {
560  if (!empty($obj->status)) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute'.(empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY).($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'),"play").'</a>';
561  else print '<a href="#" class="cursordefault" title="'.dol_escape_htmltag($langs->trans('JobDisabled')).'">'.img_picto($langs->trans('JobDisabled'),"playdisabled").'</a>';
562  } else {
563  print '<a href="#" class="cursornotallowed" title="'.dol_escape_htmltag($langs->trans('NotEnoughPermissions')).'">'.img_picto($langs->trans('NotEnoughPermissions'),"playdisabled").'</a>';
564  }
565  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
566  {
567  $selected=0;
568  if (in_array($obj->rowid, $arrayofselected)) $selected=1;
569  print ' &nbsp; <input id="cb'.$obj->rowid.'" class="flat checkforselect valignmiddle" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
570  }
571  print '</td>';
572 
573  print '</tr>';
574 
575  $i++;
576  }
577 }
578 else
579 {
580  print '<tr><td colspan="9" class="opacitymedium">'.$langs->trans('CronNoJobs').'</td></tr>';
581 }
582 
583 print '</table>';
584 print '</div>';
585 
586 print '</from>';
587 
588 
589 print '<br><br>';
590 
591 
593 
594 llxFooter();
595 
596 $db->close();
verifCond($strRights)
Verify if condition in string is ok or not.
img_warning($titlealt='default', $moreatt='')
Show warning logo.
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
dol_print_cron_urls()
Show information with URLs to launch jobs.
Definition: cron.lib.php:84
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
if(! GETPOST('transkey', 'alphanohtml') &&! GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:43
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='')
Show information for admin users or standard users.
llxHeader()
Empty header.
Definition: wrapper.php:44
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Cron Job class.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)