dolibarr 24.0.0-beta
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';
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).'" spellcheck="false"> ';
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).'" spellcheck="false"> ';
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).'" spellcheck="false"> ';
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).'" spellcheck="false"> ';
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).'" spellcheck="false"> ';
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.'" spellcheck="false"> ';
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.'" spellcheck="false" /> ';
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 img_picto('', 'recurring', 'class="pictofixedwidth"');
443 print '<select name="nbfrequency" id="nbfrequency" class="width50 maxwidth50imp">';
444 for ($i = 1; $i <= 60; $i++) {
445 if ($object->frequency == $i) {
446 print "<option value='".$i."' selected>".$i."</option>";
447 } else {
448 print "<option value='".$i."'>".$i."</option>";
449 }
450 }
451 print "</select>";
452 print ajax_combobox('nbfrequency');
453 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
454 if ($object->unitfrequency == "60") {
455 $input .= ' checked />';
456 } else {
457 $input .= ' />';
458 }
459 $input .= "<label for=\"frequency_minute\">".$langs->trans('Minutes')."</label>";
460 print $input;
461
462 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
463 if ($object->unitfrequency == "3600") {
464 $input .= ' checked />';
465 } else {
466 $input .= ' />';
467 }
468 $input .= "<label for=\"frequency_heures\">".$langs->trans('Hours')."</label>";
469 print $input;
470
471 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
472 if ($object->unitfrequency == "86400") {
473 $input .= ' checked />';
474 } else {
475 $input .= ' />';
476 }
477 $input .= "<label for=\"frequency_jours\">".$langs->trans('Days')."</label>";
478 print $input;
479
480 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
481 if ($object->unitfrequency == "604800") {
482 $input .= ' checked />';
483 } else {
484 $input .= ' />';
485 }
486 $input .= "<label for=\"frequency_semaine\">".$langs->trans('Weeks')."</label>";
487 print $input;
488
489 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
490 if ($object->unitfrequency == "2678400") {
491 $input .= ' checked />';
492 } else {
493 $input .= ' />';
494 }
495 $input .= '<label for="frequency_month">'.$langs->trans('Months')."</label>";
496 print $input;
497
498 print "</td>";
499 print "<td>";
500 print "</td>";
501 print "</tr>\n";
502
503 // Priority
504 print "<tr><td>";
505 print $langs->trans('CronPriority')."</td>";
506 $priority = 0;
507 if (!empty($object->priority)) {
508 $priority = $object->priority;
509 }
510 print '<td><input type="text" class="width50" name="priority" value="'.$priority.'" /> ';
511 print "</td>";
512 print "<td>";
513 print "</td>";
514 print "</tr>\n";
515
516 print "<tr><td>";
517 print $langs->trans('CronDtStart')."</td><td>";
518 if (!empty($object->datestart)) {
519 print $form->selectDate($object->datestart, 'datestart', 1, 1, 0, "cronform");
520 } else {
521 print $form->selectDate(-1, 'datestart', 1, 1, 1, "cronform");
522 }
523 print "</td>";
524 print "<td>";
525 print "</td>";
526 print "</tr>\n";
527
528 print "<tr><td>";
529 print $langs->trans('CronDtEnd')."</td><td>";
530 if (!empty($object->dateend)) {
531 print $form->selectDate($object->dateend, 'dateend', 1, 1, 0, "cronform");
532 } else {
533 print $form->selectDate(-1, 'dateend', 1, 1, 1, "cronform");
534 }
535 print "</td>";
536 print "<td>";
537 print "</td>";
538 print "</tr>\n";
539
540 print '<tr><td>';
541 $maxrun = '';
542 if (!empty($object->maxrun)) {
543 $maxrun = $object->maxrun;
544 }
545 print $langs->trans('CronMaxRun')."</td>";
546 print '<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.'" /> ';
547 print "</td>";
548 print "<td>";
549 print "</td>";
550 print "</tr>\n";
551
552 print '<tr><td class="fieldrequired">';
553 print $langs->trans('CronDtNextLaunch');
554 //print ' ('.$langs->trans('CronFrom').')';
555 print "</td><td>";
556 if (!empty($object->datenextrun)) {
557 print $form->selectDate($object->datenextrun, 'datenextrun', 1, 1, 0, "cronform");
558 } else {
559 print $form->selectDate(-1, 'datenextrun', 1, 1, 0, "cronform", 1, 1);
560 }
561 print "</td>";
562 print "<td>";
563 print "</td>";
564 print "</tr>";
565
566 print '</table>';
567
568 print dol_get_fiche_end();
569
570 print $form->buttonsSaveCancel();
571
572 print "</form>\n";
573} else {
574 // view card
575 $now = dol_now();
576
577 print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron');
578
579 $linkback = '<a href="'.DOL_URL_ROOT.'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
580
581 $reg = array();
582 if (preg_match('/:(.*)$/', $object->label, $reg)) {
583 $langs->load($reg[1]);
584 }
585
586 $labeltoshow = preg_replace('/:.*$/', '', $object->label);
587
588 $morehtmlref = '<div class="refidno">';
589 $morehtmlref .= $langs->trans($labeltoshow);
590 $morehtmlref .= '</div>';
591
592 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
593
594 // box add_jobs_box
595 print '<div class="fichecenter">';
596 print '<div class="fichehalfleft">';
597
598 print '<div class="underbanner clearboth"></div>';
599 print '<table class="border centpercent tableforfield">';
600
601 /*print '<tr><td class="titlefield">';
602 print $langs->trans('CronLabel')."</td>";
603 print "<td>".$langs->trans($object->label);
604 print "</td></tr>";*/
605
606 print '<tr><td class="titlefieldmiddle">';
607 print $langs->trans('CronType')."</td><td>";
608 print $formCron->select_typejob('jobtype', $object->jobtype, 1);
609 print "</td></tr>";
610
611 print '<tr class="blockmethod"><td>';
612 print $langs->trans('CronModule')."</td><td>";
613 print dol_escape_htmltag($object->module_name);
614 print "</td></tr>";
615
616 print '<tr class="blockmethod"><td>';
617 print $langs->trans('CronClassFile')."</td><td>";
618 print dol_escape_htmltag($object->classesname);
619 print "</td></tr>";
620
621 print '<tr class="blockmethod"><td>';
622 print $langs->trans('CronObject')."</td><td>";
623 print dol_escape_htmltag($object->objectname);
624 print "</td></tr>";
625
626 print '<tr class="blockmethod"><td>';
627 print $langs->trans('CronMethod')."</td><td>";
628 print dol_escape_htmltag($object->methodename);
629 print "</td></tr>";
630
631 print '<tr class="blockmethod"><td>';
632 print $langs->trans('CronArgs')."</td><td>";
633 print dol_escape_htmltag($object->params);
634 print "</td></tr>";
635
636 print '<tr class="blockcommand"><td>';
637 print $langs->trans('CronCommand')."</td><td>";
638 print dol_escape_htmltag($object->command);
639 print "</td></tr>";
640
641 print '<tr><td>';
642 print $langs->trans('CronNote')."</td><td>";
643 if (!is_null($object->note_private) && $object->note_private != '') {
644 print '<div class="small lineheightsmall">'.$langs->trans($object->note_private).'</div>';
645 }
646 print "</td></tr>";
647
648 print '<tr class="blockemailalert"><td>';
649 print $langs->trans('EmailIfError')."</td><td>";
650 print dol_escape_htmltag($object->email_alert);
651 print "</td></tr>";
652
653 if (isModEnabled('multicompany') && isset($mc)) {
654 print '<tr><td>';
655 print $langs->trans('Entity')."</td><td>";
656 if (empty($object->entity)) {
657 print img_picto($langs->trans("AllEntities"), 'entity', 'class="pictofixedwidth"').$langs->trans("AllEntities");
658 } else {
659 $mc->getInfo($object->entity);
660 print img_picto($langs->trans("AllEntities"), 'entity', 'class="pictofixedwidth"').$mc->label;
661 }
662 print "</td></tr>";
663 }
664
665 print '</table>';
666 print '</div>';
667
668 print '<div class="fichehalfright">';
669
670 print '<div class="underbanner clearboth"></div>';
671 print '<table class="border centpercent tableforfield">';
672
673 print '<tr><td class="titlefieldmiddle">';
674 print $langs->trans('CronEvery')."</td>";
675 print "<td>";
676 print img_picto('', 'recurring', 'class="pictofixedwidth"');
677 if ($object->unitfrequency == "60") {
678 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Minutes');
679 }
680 if ($object->unitfrequency == "3600") {
681 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Hours');
682 }
683 if ($object->unitfrequency == "86400") {
684 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Days');
685 }
686 if ($object->unitfrequency == "604800") {
687 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks');
688 }
689 if ($object->unitfrequency == "2678400") {
690 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Months');
691 }
692 print "</td></tr>";
693
694 // Priority
695 print "<tr><td>";
696 print $langs->trans('CronPriority')."</td>";
697 print "<td>".$object->priority;
698 print "</td></tr>";
699
700 print '<tr><td>';
701 print $langs->trans('CronDtStart')."</td><td>";
702 if (!empty($object->datestart)) {
703 print $form->textwithpicto(dol_print_date($object->datestart, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
704 }
705 print "</td></tr>";
706
707 print "<tr><td>";
708 print $langs->trans('CronDtEnd')."</td><td>";
709 if (!empty($object->dateend)) {
710 print $form->textwithpicto(dol_print_date($object->dateend, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
711 }
712 print "</td></tr>";
713
714 print "<tr><td>";
715 print $langs->trans('CronMaxRun')."</td>";
716 print "<td>";
717 print $object->maxrun > 0 ? $object->maxrun : '';
718 print "</td></tr>";
719
720 print "<tr><td>";
721 print $langs->trans('CronNbRun')."</td>";
722 print "<td>".$object->nbrun;
723 print "</td></tr>";
724
725 // Date next run (from)
726 print '<tr><td>';
727 print $langs->trans('CronDtNextLaunch');
728 print ' ('.$langs->trans('CronFrom').')';
729 print "</td><td>";
730 if (!$object->status) {
731 print img_picto('', 'object_calendarday').' <span class="opacitymedium strikefordisabled">'.$form->textwithpicto(dol_print_date($object->datenextrun, 'dayhoursec'), $langs->trans("CurrentTimeZone")).'</span> ';
732 print $langs->trans("Disabled");
733 } elseif (!empty($object->datenextrun)) {
734 print img_picto('', 'object_calendarday').' '.$form->textwithpicto(dol_print_date($object->datenextrun, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
735 } else {
736 print '<span class="opacitymedium">'.$langs->trans('CronNone').'</span>';
737 }
738 if ($object->status == Cronjob::STATUS_ENABLED) {
739 if ($object->maxrun && $object->nbrun >= $object->maxrun) {
740 print img_warning($langs->trans("MaxRunReached"));
741 } elseif ($object->datenextrun && $object->datenextrun < $now) {
742 print img_warning($langs->trans("Late"));
743 }
744 }
745 print "</td></tr>";
746
747 print '</table>';
748
749
750 print '<br>';
751
752
753 print '<div class="underbanner clearboth"></div>';
754 print '<table class="border centpercent tableforfield">';
755
756 print '<tr><td class="titlefieldmiddle">';
757 print $langs->trans('CronDtLastLaunch')."</td><td>";
758 if (!empty($object->datelastrun)) {
759 print $form->textwithpicto(dol_print_date($object->datelastrun, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
760 } else {
761 print '<span class="opacitymedium">'.$langs->trans('CronNotYetRan').'</span>';
762 }
763 print "</td></tr>";
764
765 print '<tr><td>';
766 print $langs->trans('CronDtLastResult')."</td><td>";
767 if (!empty($object->datelastresult)) {
768 print $form->textwithpicto(dol_print_date($object->datelastresult, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
769 } else {
770 if (empty($object->datelastrun)) {
771 print '<span class="opacitymedium">'.$langs->trans('CronNotYetRan').'</span>';
772 } else {
773 // In progress
774 }
775 }
776 print "</td></tr>";
777
778 print '<tr><td>';
779 print $langs->trans('CronLastResult')."</td><td>";
780 if ($object->lastresult) {
781 print '<span class="error">';
782 }
783 print $object->lastresult;
784 if ($object->lastresult) {
785 print '</span>';
786 }
787 print "</td></tr>";
788
789 print '<tr><td>';
790 print $langs->trans('CronLastOutput')."</td><td>";
791 print '<span class="small">'.(!empty($object->lastoutput) ? nl2br($object->lastoutput) : '').'</span>';
792 print "</td></tr>";
793
794 print '</table>';
795
796 print '</div>';
797
798 print '<div class="clearboth"></div>';
799
800
801 print dol_get_fiche_end();
802
803
804 print "\n\n".'<div class="tabsAction">'."\n";
805 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Edit").'</a>';
806
807 if ((!$user->hasRight('cron', 'execute'))) {
808 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("CronExecute").'</a>';
809 } elseif (empty($object->status)) {
810 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("JobDisabled")).'">'.$langs->trans("CronExecute").'</a>';
811 } else {
812 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>';
813 }
814
815
816 print '<a class="butAction butActionClone" href="'.$_SERVER['PHP_SELF'].'?action=clone&token='.newToken().'&id='.$object->id.'">'.$langs->trans("ToClone").'</a>';
817
818 if (empty($object->status)) {
819 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=activate&token='.newToken().'&id='.$object->id.'">'.$langs->trans("CronStatusActiveBtn").'</a>';
820 } else {
821 print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=inactive&token='.newToken().'&id='.$object->id.'">'.$langs->trans("CronStatusInactiveBtn").'</a>';
822 }
823
824
825 if (!$user->hasRight('cron', 'delete')) {
826 print '<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Delete").'</a>';
827 } else {
828 print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
829 }
830 print '</div>';
831
832 print '<br>';
833}
834
835
836llxFooter();
837
838$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.
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.
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.