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