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