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