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