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