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