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