dolibarr  13.0.2
card.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-concpt.pro>
4  * Copyright (C) 2013-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2018 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 
27 require '../main.inc.php';
28 
29 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
30 
31 // librairie jobs
32 require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php";
33 require_once DOL_DOCUMENT_ROOT."/core/class/html.formcron.class.php";
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('admin', 'cron', 'members'));
38 
39 if (!$user->rights->cron->create) accessforbidden();
40 
41 $id = GETPOST('id', 'int');
42 $action = GETPOST('action', 'aZ09');
43 $confirm = GETPOST('confirm', 'alpha');
44 $cancel = GETPOST('cancel', 'alpha');
45 $backtopage = GETPOST('backtopage', 'alpha');
46 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
47 
48 $securitykey = GETPOST('securitykey', 'alpha');
49 
50 
51 /*
52  * Actions
53  */
54 
55 $object = new Cronjob($db);
56 if (!empty($id))
57 {
58  $result = $object->fetch($id);
59  if ($result < 0)
60  {
61  setEventMessages($object->error, $object->errors, 'errors');
62  }
63 }
64 
65 if (!empty($cancel))
66 {
67  if (!empty($id) && empty($backtopage))
68  {
69  $action = '';
70  } else {
71  if ($backtopage)
72  {
73  header("Location: ".$backtopage);
74  exit;
75  } else {
76  header("Location: ".DOL_URL_ROOT.'/cron/list.php');
77  exit;
78  }
79  }
80 }
81 
82 // Delete jobs
83 if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete)
84 {
85  $result = $object->delete($user);
86 
87  if ($result < 0)
88  {
89  setEventMessages($object->error, $object->errors, 'errors');
90  $action = 'edit';
91  } else {
92  Header("Location: ".DOL_URL_ROOT.'/cron/list.php');
93  exit;
94  }
95 }
96 
97 // Execute jobs
98 if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute)
99 {
100  if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey)
101  {
102  setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors');
103  $action = '';
104  } else {
105  $now = dol_now(); // Date we start
106 
107  $result = $object->run_jobs($user->login);
108 
109  if ($result < 0)
110  {
111  setEventMessages($object->error, $object->errors, 'errors');
112  $action = '';
113  } else {
114  $res = $object->reprogram_jobs($user->login, $now);
115  if ($res > 0)
116  {
117  if ($object->lastresult > 0) setEventMessages($langs->trans("JobFinished"), null, 'warnings');
118  else setEventMessages($langs->trans("JobFinished"), null, 'mesgs');
119  $action = '';
120  } else {
121  setEventMessages($object->error, $object->errors, 'errors');
122  $action = '';
123  }
124  }
125  }
126 }
127 
128 
129 if ($action == 'add')
130 {
131  $object->jobtype = GETPOST('jobtype');
132  $object->label = GETPOST('label');
133  $object->command = GETPOST('command');
134  $object->classesname = GETPOST('classesname', 'alphanohtml');
135  $object->objectname = GETPOST('objectname', 'aZ09');
136  $object->methodename = GETPOST('methodename', 'aZ09');
137  $object->params = GETPOST('params');
138  $object->md5params = GETPOST('md5params');
139  $object->module_name = GETPOST('module_name');
140  $object->note_private = GETPOST('note', 'restricthtml');
141  $object->datestart = dol_mktime(GETPOST('datestarthour', 'int'), GETPOST('datestartmin', 'int'), 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'));
142  $object->dateend = dol_mktime(GETPOST('dateendhour', 'int'), GETPOST('dateendmin', 'int'), 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'));
143  $object->priority = GETPOST('priority', 'int');
144  $object->datenextrun = dol_mktime(GETPOST('datenextrunhour', 'int'), GETPOST('datenextrunmin', 'int'), 0, GETPOST('datenextrunmonth', 'int'), GETPOST('datenextrunday', 'int'), GETPOST('datenextrunyear', 'int'));
145  $object->unitfrequency = GETPOST('unitfrequency', 'int');
146  $object->frequency = GETPOST('nbfrequency', 'int');
147  $object->maxrun = GETPOST('maxrun', 'int');
148 
149  // Add cron task
150  $result = $object->create($user);
151 
152  // test du Resultat de la requete
153  if ($result < 0) {
154  setEventMessages($object->error, $object->errors, 'errors');
155  $action = 'create';
156  } else {
157  setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs');
158  $action = '';
159  }
160 }
161 
162 // Save parameters
163 if ($action == 'update')
164 {
165  $object->id = $id;
166  $object->jobtype = GETPOST('jobtype');
167  $object->label = GETPOST('label');
168  $object->command = GETPOST('command');
169  $object->classesname = GETPOST('classesname', 'alphanohtml');
170  $object->objectname = GETPOST('objectname', 'aZ09');
171  $object->methodename = GETPOST('methodename', 'aZ09');
172  $object->params = GETPOST('params');
173  $object->md5params = GETPOST('md5params');
174  $object->module_name = GETPOST('module_name');
175  $object->note_private = GETPOST('note', 'restricthtml');
176  $object->datestart = dol_mktime(GETPOST('datestarthour', 'int'), GETPOST('datestartmin', 'int'), 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'));
177  $object->dateend = dol_mktime(GETPOST('dateendhour', 'int'), GETPOST('dateendmin', 'int'), 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'));
178  $object->priority = GETPOST('priority', 'int');
179  $object->datenextrun = dol_mktime(GETPOST('datenextrunhour', 'int'), GETPOST('datenextrunmin', 'int'), 0, GETPOST('datenextrunmonth', 'int'), GETPOST('datenextrunday', 'int'), GETPOST('datenextrunyear', 'int'));
180  $object->unitfrequency = GETPOST('unitfrequency', 'int');
181  $object->frequency = GETPOST('nbfrequency', 'int');
182  $object->maxrun = GETPOST('maxrun', 'int');
183 
184  // Add cron task
185  $result = $object->update($user);
186 
187  // test du Resultat de la requete
188  if ($result < 0) {
189  setEventMessages($object->error, $object->errors, 'errors');
190  $action = 'edit';
191  } else {
192  setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs');
193  $action = '';
194  }
195 }
196 
197 if ($action == 'activate')
198 {
199  $object->status = 1;
200 
201  // Add cron task
202  $result = $object->update($user);
203 
204  // test du Resultat de la requete
205  if ($result < 0) {
206  setEventMessages($object->error, $object->errors, 'errors');
207  $action = 'edit';
208  } else {
209  setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs');
210  $action = '';
211  }
212 }
213 
214 if ($action == 'inactive')
215 {
216  $object->status = 0;
217  $object->processing = 0;
218 
219  // Add cron task
220  $result = $object->update($user);
221 
222  // test du Resultat de la requete
223  if ($result < 0) {
224  setEventMessages($object->error, $object->errors, 'errors');
225  $action = 'edit';
226  } else {
227  setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs');
228  $action = '';
229  }
230 }
231 
232 
233 
234 /*
235  * View
236  */
237 
238 $form = new Form($db);
239 $formCron = new FormCron($db);
240 
241 llxHeader('', $langs->trans("CronTask"));
242 
243 if ($action == 'edit' || empty($action) || $action == 'delete' || $action == 'execute')
244 {
245  $head = cron_prepare_head($object);
246 } elseif ($action == 'create')
247 {
248  print load_fiche_titre($langs->trans("CronTask"), '', 'title_setup');
249 }
250 
251 if ($conf->use_javascript_ajax)
252 {
253  print "\n".'<script type="text/javascript" language="javascript">';
254  print 'jQuery(document).ready(function () {
255  function initfields()
256  {
257  if ($("#jobtype option:selected").val()==\'method\') {
258  $(".blockmethod").show();
259  $(".blockcommand").hide();
260  }
261  if ($("#jobtype option:selected").val()==\'command\') {
262  $(".blockmethod").hide();
263  $(".blockcommand").show();
264  }
265  }
266  initfields();
267  jQuery("#jobtype").change(function() {
268  initfields();
269  });
270  })';
271  print '</script>'."\n";
272 }
273 
274 if ($action == 'delete')
275 {
276  print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CronDelete"), $langs->trans("CronConfirmDelete"), "confirm_delete", '', '', 1);
277 
278  $action = '';
279 }
280 
281 if ($action == 'execute') {
282  print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id.'&securitykey='.$securitykey, $langs->trans("CronExecute"), $langs->trans("CronConfirmExecute"), "confirm_execute", '', '', 1);
283 
284  $action = '';
285 }
286 
287 
288 
289 /*
290  * Create Template
291  */
292 
293 if (empty($object->status) && $action != 'create')
294 {
295  setEventMessages($langs->trans("CronTaskInactive"), null, 'warnings');
296 }
297 
298 if (($action == "create") || ($action == "edit"))
299 {
300  print '<form name="cronform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
301  print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
302  print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage').'">'."\n";
303  if (!empty($object->id)) {
304  print '<input type="hidden" name="action" value="update">'."\n";
305  print '<input type="hidden" name="id" value="'.$object->id.'">'."\n";
306  } else {
307  print '<input type="hidden" name="action" value="add">'."\n";
308  }
309 
310  if ($action == "edit") print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'cron');
311  else print dol_get_fiche_head('');
312 
313  print '<table class="border centpercent">';
314 
315  print '<tr><td class="fieldrequired titlefieldcreate">';
316  print $langs->trans('CronLabel')."</td>";
317  print "<td><input type=\"text\" size=\"30\" name=\"label\" value=\"".$object->label."\" /> ";
318  print "</td>";
319  print "<td>";
320  print "</td>";
321  print "</tr>\n";
322 
323  print '<tr><td class="fieldrequired">';
324  print $langs->trans('CronType')."</td><td>";
325  print $formCron->select_typejob('jobtype', $object->jobtype);
326  print "</td>";
327  print "<td>";
328  print "</td>";
329  print "</tr>\n";
330 
331  print '<tr class="blockmethod"><td>';
332  print $langs->trans('CronModule')."</td><td>";
333  print "<input type=\"text\" size=\"20\" name=\"module_name\" value=\"".$object->module_name."\" /> ";
334  print "</td>";
335  print "<td>";
336  print $form->textwithpicto('', $langs->trans("CronModuleHelp"), 1, 'help');
337  print "</td>";
338  print "</tr>\n";
339 
340  print '<tr class="blockmethod"><td>';
341  print $langs->trans('CronClassFile')."</td><td>";
342  print '<input type="text" class="minwidth300" name="classesname" value="'.$object->classesname.'" /> ';
343  print "</td>";
344  print "<td>";
345  print $form->textwithpicto('', $langs->trans("CronClassFileHelp"), 1, 'help');
346  print "</td>";
347  print "</tr>\n";
348 
349  print '<tr class="blockmethod"><td>';
350  print $langs->trans('CronObject')."</td><td>";
351  print "<input type=\"text\" size=\"20\" name=\"objectname\" value=\"".$object->objectname."\" /> ";
352  print "</td>";
353  print "<td>";
354  print $form->textwithpicto('', $langs->trans("CronObjectHelp"), 1, 'help');
355  print "</td>";
356  print "</tr>\n";
357 
358  print '<tr class="blockmethod"><td>';
359  print $langs->trans('CronMethod')."</td><td>";
360  print '<input type="text" class="minwidth300" name="methodename" value="'.$object->methodename.'" /> ';
361  print "</td>";
362  print "<td>";
363  print $form->textwithpicto('', $langs->trans("CronMethodHelp"), 1, 'help');
364  print "</td>";
365  print "</tr>\n";
366 
367  print '<tr class="blockmethod"><td>';
368  print $langs->trans('CronArgs')."</td><td>";
369  print "<input type=\"text\" class=\"quatrevingtpercent\" name=\"params\" value=\"".$object->params."\" /> ";
370  print "</td>";
371  print "<td>";
372  print $form->textwithpicto('', $langs->trans("CronArgsHelp"), 1, 'help');
373  print "</td>";
374  print "</tr>\n";
375 
376  print '<tr class="blockcommand"><td>';
377  print $langs->trans('CronCommand')."</td><td>";
378  print "<input type=\"text\" size=\"50\" name=\"command\" value=\"".$object->command."\" /> ";
379  print "</td>";
380  print "<td>";
381  print $form->textwithpicto('', $langs->trans("CronCommandHelp"), 1, 'help');
382  print "</td>";
383  print "</tr>\n";
384 
385  print '<tr><td>';
386  print $langs->trans('CronNote')."</td><td>";
387  $doleditor = new DolEditor('note', $object->note_private, '', 160, 'dolibarr_notes', 'In', true, false, 0, ROWS_4, '90%');
388  $doleditor->Create();
389  print "</td>";
390  print "<td>";
391  print "</td>";
392  print "</tr>\n";
393 
394  print '<tr><td class="fieldrequired">';
395  print $langs->trans('CronEvery')."</td>";
396  print "<td>";
397  print '<select name="nbfrequency">';
398  for ($i = 1; $i <= 60; $i++)
399  {
400  if ($object->frequency == $i)
401  {
402  print "<option value='".$i."' selected>".$i."</option>";
403  } else {
404  print "<option value='".$i."'>".$i."</option>";
405  }
406  }
407  print "</select>";
408  $input = " <input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
409  if ($object->unitfrequency == "60")
410  {
411  $input .= ' checked />';
412  } else {
413  $input .= ' />';
414  }
415  $input .= "<label for=\"frequency_minute\">".$langs->trans('Minutes')."</label>";
416  print $input;
417 
418  $input = " <input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
419  if ($object->unitfrequency == "3600") {
420  $input .= ' checked />';
421  } else {
422  $input .= ' />';
423  }
424  $input .= "<label for=\"frequency_heures\">".$langs->trans('Hours')."</label>";
425  print $input;
426 
427  $input = " <input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
428  if ($object->unitfrequency == "86400") {
429  $input .= ' checked />';
430  } else {
431  $input .= ' />';
432  }
433  $input .= "<label for=\"frequency_jours\">".$langs->trans('Days')."</label>";
434  print $input;
435 
436  $input = " <input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
437  if ($object->unitfrequency == "604800") {
438  $input .= ' checked />';
439  } else {
440  $input .= ' />';
441  }
442  $input .= "<label for=\"frequency_semaine\">".$langs->trans('Weeks')."</label>";
443  print $input;
444  print "</td>";
445  print "<td>";
446  print "</td>";
447  print "</tr>\n";
448 
449  print "<tr><td>";
450  print $langs->trans('CronDtStart')."</td><td>";
451  if (!empty($object->datestart))
452  {
453  print $form->selectDate($object->datestart, 'datestart', 1, 1, '', "cronform");
454  } else {
455  print $form->selectDate('', 'datestart', 1, 1, '', "cronform");
456  }
457  print "</td>";
458  print "<td>";
459  print "</td>";
460  print "</tr>\n";
461 
462  print "<tr><td>";
463  print $langs->trans('CronDtEnd')."</td><td>";
464  if (!empty($object->dateend)) {
465  print $form->selectDate($object->dateend, 'dateend', 1, 1, '', "cronform");
466  } else {
467  print $form->selectDate(-1, 'dateend', 1, 1, 1, "cronform");
468  }
469  print "</td>";
470  print "<td>";
471  print "</td>";
472  print "</tr>\n";
473 
474  print "<tr><td>";
475  print $langs->trans('CronPriority')."</td>";
476  $priority = 0;
477  if (!empty($object->priority)) {
478  $priority = $object->priority;
479  }
480  print "<td><input type=\"text\" size=\"2\" name=\"priority\" value=\"".$priority."\" /> ";
481  print "</td>";
482  print "<td>";
483  print "</td>";
484  print "</tr>\n";
485 
486  print '<tr><td>';
487  $maxrun = '';
488  if (!empty($object->maxrun)) {
489  $maxrun = $object->maxrun;
490  }
491  print $langs->trans('CronMaxRun')."</td>";
492  print "<td><input type=\"text\" size=\"2\" name=\"maxrun\" value=\"".$maxrun."\" /> ";
493  print "</td>";
494  print "<td>";
495  print "</td>";
496  print "</tr>\n";
497 
498  print '<tr><td>';
499  print $langs->trans('CronDtNextLaunch');
500  print ' ('.$langs->trans('CronFrom').')';
501  print "</td><td>";
502  if (!empty($object->datenextrun))
503  {
504  print $form->selectDate($object->datenextrun, 'datenextrun', 1, 1, '', "cronform");
505  } else {
506  print $form->selectDate(-1, 'datenextrun', 1, 1, '', "cronform");
507  }
508  print "</td>";
509  print "<td>";
510  print "</td>";
511  print "</tr>";
512 
513  print '</table>';
514 
516 
517  print '<div align="center">';
518  print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
519  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
520  print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">';
521  print "</div>";
522 
523  print "</form>\n";
524 } else {
525  /*
526  * view card
527  */
528  $now = dol_now();
529 
530  print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron');
531 
532  $linkback = '<a href="'.DOL_URL_ROOT.'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
533 
534  $morehtmlref = '<div class="refidno">';
535  $morehtmlref .= '</div>';
536 
537  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
538 
539  // box add_jobs_box
540  print '<div class="fichecenter">';
541  print '<div class="underbanner clearboth"></div>';
542  print '<table class="border centpercent tableforfield">';
543 
544  print '<tr><td class="titlefield">';
545  print $langs->trans('CronLabel')."</td>";
546  print "<td>".$langs->trans($object->label);
547  print "</td></tr>";
548 
549  print "<tr><td>";
550  print $langs->trans('CronType')."</td><td>";
551  print $formCron->select_typejob('jobtype', $object->jobtype, 1);
552  print "</td></tr>";
553 
554  print '<tr class="blockmethod"><td>';
555  print $langs->trans('CronModule')."</td><td>";
556  print $object->module_name;
557  print "</td></tr>";
558 
559  print '<tr class="blockmethod"><td>';
560  print $langs->trans('CronClassFile')."</td><td>";
561  print $object->classesname;
562  print "</td></tr>";
563 
564  print '<tr class="blockmethod"><td>';
565  print $langs->trans('CronObject')."</td><td>";
566  print $object->objectname;
567  print "</td></tr>";
568 
569  print '<tr class="blockmethod"><td>';
570  print $langs->trans('CronMethod')."</td><td>";
571  print $object->methodename;
572  print "</td></tr>";
573 
574  print '<tr class="blockmethod"><td>';
575  print $langs->trans('CronArgs')."</td><td>";
576  print $object->params;
577  print "</td></tr>";
578 
579  print '<tr class="blockcommand"><td>';
580  print $langs->trans('CronCommand')."</td><td>";
581  print $object->command;
582  print "</td></tr>";
583 
584  print '<tr><td>';
585  print $langs->trans('CronNote')."</td><td>";
586  if (!is_null($object->note_private) && $object->note_private != '') {
587  print $langs->trans($object->note_private);
588  }
589  print "</td></tr>";
590 
591  if (!empty($conf->multicompany->enabled))
592  {
593  print '<tr><td>';
594  print $langs->trans('Entity')."</td><td>";
595  if (!$object->entity)
596  {
597  print $langs->trans("AllEntities");
598  } else {
599  $mc->getInfo($object->entity);
600  print $mc->label;
601  }
602  print "</td></tr>";
603  }
604 
605  print '</table>';
606  print '</div>';
607 
608  print '<br>';
609 
610 
611  print '<div class="fichecenter">';
612  print '<div class="underbanner clearboth"></div>';
613  print '<table class="border centpercent tableforfield">';
614 
615  print '<tr><td class="titlefield">';
616  print $langs->trans('CronEvery')."</td>";
617  print "<td>";
618  if ($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Minutes');
619  if ($object->unitfrequency == "3600") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Hours');
620  if ($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Days');
621  if ($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks');
622  print "</td></tr>";
623 
624  print '<tr><td>';
625  print $langs->trans('CronDtStart')."</td><td>";
626  if (!empty($object->datestart)) {print $form->textwithpicto(dol_print_date($object->datestart, 'dayhoursec'), $langs->trans("CurrentTimeZone")); }
627  print "</td></tr>";
628 
629  print "<tr><td>";
630  print $langs->trans('CronDtEnd')."</td><td>";
631  if (!empty($object->dateend)) {print $form->textwithpicto(dol_print_date($object->dateend, 'dayhoursec'), $langs->trans("CurrentTimeZone")); }
632  print "</td></tr>";
633 
634  print "<tr><td>";
635  print $langs->trans('CronPriority')."</td>";
636  print "<td>".$object->priority;
637  print "</td></tr>";
638 
639  print "<tr><td>";
640  print $langs->trans('CronMaxRun')."</td>";
641  print "<td>";
642  print $object->maxrun > 0 ? $object->maxrun : '';
643  print "</td></tr>";
644 
645  print "<tr><td>";
646  print $langs->trans('CronNbRun')."</td>";
647  print "<td>".$object->nbrun;
648  print "</td></tr>";
649 
650  // Date next run (from)
651  print '<tr><td>';
652  print $langs->trans('CronDtNextLaunch');
653  print ' ('.$langs->trans('CronFrom').')';
654  print "</td><td>";
655  if (!$object->status) print $langs->trans("Disabled");
656  elseif (!empty($object->datenextrun)) { print img_picto('', 'object_calendarday').' '.$form->textwithpicto(dol_print_date($object->datenextrun, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } else { print $langs->trans('CronNone'); }
657  if ($object->status == Cronjob::STATUS_ENABLED)
658  {
659  if ($object->maxrun && $object->nbrun >= $object->maxrun) print img_warning($langs->trans("MaxRunReached"));
660  elseif ($object->datenextrun && $object->datenextrun < $now) print img_warning($langs->trans("Late"));
661  }
662  print "</td></tr>";
663 
664  print '</table>';
665  print '</div>';
666 
667  print '<br>';
668 
669  print '<div class="fichecenter">';
670  print '<div class="underbanner clearboth"></div>';
671  print '<table class="border centpercent tableforfield">';
672 
673  print '<tr><td class="titlefield">';
674  print $langs->trans('CronDtLastLaunch')."</td><td>";
675  if (!empty($object->datelastrun)) {print $form->textwithpicto(dol_print_date($object->datelastrun, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } else {print $langs->trans('CronNone'); }
676  print "</td></tr>";
677 
678  print '<tr><td>';
679  print $langs->trans('CronDtLastResult')."</td><td>";
680  if (!empty($object->datelastresult)) {print $form->textwithpicto(dol_print_date($object->datelastresult, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } else {print $langs->trans('CronNone'); }
681  print "</td></tr>";
682 
683  print '<tr><td>';
684  print $langs->trans('CronLastResult')."</td><td>";
685  if ($object->lastresult) print '<span class="error">';
686  print $object->lastresult;
687  if ($object->lastresult) print '</span>';
688  print "</td></tr>";
689 
690  print '<tr><td>';
691  print $langs->trans('CronLastOutput')."</td><td>";
692  print nl2br($object->lastoutput);
693  print "</td></tr>";
694 
695  print '</table>';
696  print '</div>';
697 
699 
700 
701  print "\n\n<div class=\"tabsAction\">\n";
702  if (!$user->rights->cron->create) {
703  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Edit").'</a>';
704  } else {
705  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'">'.$langs->trans("Edit").'</a>';
706  }
707 
708  if ((empty($user->rights->cron->execute)))
709  {
710  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("CronExecute").'</a>';
711  } elseif (empty($object->status))
712  {
713  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("JobDisabled")).'">'.$langs->trans("CronExecute").'</a>';
714  } else {
715  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=execute&id='.$object->id.(empty($conf->global->CRON_KEY) ? '' : '&securitykey='.$conf->global->CRON_KEY).'">'.$langs->trans("CronExecute").'</a>';
716  }
717 
718  if (!$user->rights->cron->create) {
719  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("CronStatusActiveBtn").'/'.$langs->trans("CronStatusInactiveBtn").'</a>';
720  } else {
721  if (empty($object->status)) {
722  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=activate&id='.$object->id.'">'.$langs->trans("CronStatusActiveBtn").'</a>';
723  } else {
724  print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=inactive&id='.$object->id.'">'.$langs->trans("CronStatusInactiveBtn").'</a>';
725  }
726  }
727 
728  if (!$user->rights->cron->delete) {
729  print '<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Delete").'</a>';
730  } else {
731  print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
732  }
733  print '</div>';
734 
735  print '<br>';
736 }
737 
738 
739 llxFooter();
740 
741 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
cron_prepare_head(Cronjob $object)
Return array of tabs to used on a cron job.
Definition: cron.lib.php:61
dol_now($mode= 'auto')
Return date for now.
Class to manage building of HTML components.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
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)
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 ...
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).
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.
Class to manage a WYSIWYG editor.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.