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