dolibarr 22.0.5
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
3 * Copyright (C) 2013 Florian Henry <florian.henry@open-concpt.pro>
4 * Copyright (C) 2013-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
7 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31
32require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
33
34// Cron job libraries
35require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php";
36require_once DOL_DOCUMENT_ROOT."/core/class/html.formcron.class.php";
37require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
38
47// Load translation files required by the page
48$langs->loadLangs(array('admin', 'cron', 'members', 'bills'));
49
50$id = GETPOSTINT('id');
51$action = GETPOST('action', 'aZ09');
52$confirm = GETPOST('confirm', 'alpha');
53$cancel = GETPOST('cancel', 'alpha');
54$backtopage = GETPOST('backtopage', 'alpha');
55$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
56
57$securitykey = GETPOST('securitykey', 'alpha');
58
59if (!$user->hasRight('cron', 'create')) {
61}
62
63$permissiontoadd = $user->hasRight('cron', 'create');
64$permissiontoexecute = $user->hasRight('cron', 'execute');
65$permissiontodelete = $user->hasRight('cron', 'delete');
66
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') && $conf->global->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 if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { // @phan-suppress-current-line PhanPluginBothLiteralsBinaryOp
240 setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
241 } else {
242 $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.
243
244 $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
245 if (is_object($result) || $result > 0) {
246 $newid = 0;
247 if (is_object($result)) {
248 $newid = $result->id;
249 } else {
250 $newid = $result;
251 }
252 header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
253 exit;
254 } else {
255 setEventMessages($objectutil->error, $objectutil->errors, 'errors');
256 $action = '';
257 }
258 }
259}
260
261
262/*
263 * View
264 */
265
266$form = new Form($db);
267$formCron = new FormCron($db);
268
269llxHeader('', $langs->trans("CronTask"));
270
272
273if ($action == 'create') {
274 print load_fiche_titre($langs->trans("CronTask"), '', 'title_setup');
275}
276
277if ($conf->use_javascript_ajax) {
278 print "\n".'<script type="text/javascript">';
279 print 'jQuery(document).ready(function () {
280 function initfields()
281 {
282 if ($("#jobtype option:selected").val()==\'method\') {
283 $(".blockmethod").show();
284 $(".blockcommand").hide();
285 }
286 if ($("#jobtype option:selected").val()==\'command\') {
287 $(".blockmethod").hide();
288 $(".blockcommand").show();
289 }
290 }
291 initfields();
292 jQuery("#jobtype").change(function() {
293 initfields();
294 });
295 })';
296 print '</script>'."\n";
297}
298
299$formconfirm = '';
300if ($action == 'delete') {
301 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CronDelete"), $langs->trans("CronConfirmDelete"), "confirm_delete", '', '', 1);
302
303 $action = '';
304}
305
306if ($action == 'execute') {
307 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id.'&securitykey='.$securitykey, $langs->trans("CronExecute"), $langs->trans("CronConfirmExecute"), "confirm_execute", '', '', 1);
308
309 $action = '';
310}
311
312// Clone confirmation
313if ($action == 'clone') {
314 // Create an array for form
315 $formquestion = array();
316 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
317}
318
319// Print form confirm
320print $formconfirm;
321
322
323/*
324 * Create Template
325 */
326
327if (empty($object->status) && $action != 'create') {
328 setEventMessages($langs->trans("CronTaskInactive"), null, 'warnings');
329}
330
331if (($action == "create") || ($action == "edit")) {
332 print '<form name="cronform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
333 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
334 print '<input type="hidden" name="backtopage" value="'.GETPOST('backtopage').'">'."\n";
335 if (!empty($object->id)) {
336 print '<input type="hidden" name="action" value="update">'."\n";
337 print '<input type="hidden" name="id" value="'.$object->id.'">'."\n";
338 } else {
339 print '<input type="hidden" name="action" value="add">'."\n";
340 }
341
342 if ($action == "edit") {
343 print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'cron');
344 } else {
345 print dol_get_fiche_head([]);
346 }
347
348 print '<table class="border centpercent">';
349
350 print '<tr><td class="fieldrequired titlefieldcreate">';
351 print $langs->trans('CronLabel')."</td>";
352 print '<td><input type="text" class="width200" name="label" value="'.dol_escape_htmltag($object->label).'"> ';
353 print "</td>";
354 print "<td>";
355 print "</td>";
356 print "</tr>\n";
357
358 print '<tr><td class="fieldrequired">';
359 print $langs->trans('CronType')."</td><td>";
360 print $formCron->select_typejob('jobtype', $object->jobtype);
361 print "</td>";
362 print "<td>";
363 print "</td>";
364 print "</tr>\n";
365
366 print '<tr class="blockmethod"><td>';
367 print $langs->trans('CronModule')."</td><td>";
368 print '<input type="text" class="width200" name="module_name" value="'.dol_escape_htmltag($object->module_name).'"> ';
369 print "</td>";
370 print "<td>";
371 print $form->textwithpicto('', $langs->trans("CronModuleHelp"), 1, 'help');
372 print "</td>";
373 print "</tr>\n";
374
375 print '<tr class="blockmethod"><td>';
376 print $langs->trans('CronClassFile')."</td><td>";
377 print '<input type="text" class="minwidth300" name="classesname" value="'.dol_escape_htmltag($object->classesname).'"> ';
378 print "</td>";
379 print "<td>";
380 print $form->textwithpicto('', $langs->trans("CronClassFileHelp"), 1, 'help');
381 print "</td>";
382 print "</tr>\n";
383
384 print '<tr class="blockmethod"><td>';
385 print $langs->trans('CronObject')."</td><td>";
386 print '<input type="text" class="width200" name="objectname" value="'.dol_escape_htmltag($object->objectname).'"> ';
387 print "</td>";
388 print "<td>";
389 print $form->textwithpicto('', $langs->trans("CronObjectHelp"), 1, 'help');
390 print "</td>";
391 print "</tr>\n";
392
393 print '<tr class="blockmethod"><td>';
394 print $langs->trans('CronMethod')."</td><td>";
395 print '<input type="text" class="minwidth300" name="methodename" value="'.dol_escape_htmltag($object->methodename).'" /> ';
396 print "</td>";
397 print "<td>";
398 print $form->textwithpicto('', $langs->trans("CronMethodHelp"), 1, 'help');
399 print "</td>";
400 print "</tr>\n";
401
402 print '<tr class="blockmethod"><td>';
403 print $langs->trans('CronArgs')."</td><td>";
404 print '<input type="text" class="quatrevingtpercent" name="params" value="'.$object->params.'" /> ';
405 print "</td>";
406 print "<td>";
407 print $form->textwithpicto('', $langs->trans("CronArgsHelp"), 1, 'help');
408 print "</td>";
409 print "</tr>\n";
410
411 print '<tr class="blockcommand"><td>';
412 print $langs->trans('CronCommand')."</td><td>";
413 print '<input type="text" class="minwidth150" name="command" value="'.$object->command.'" /> ';
414 print "</td>";
415 print "<td>";
416 print $form->textwithpicto('', $langs->trans("CronCommandHelp"), 1, 'help');
417 print "</td>";
418 print "</tr>\n";
419
420 print '<tr><td>';
421 print $langs->trans('CronNote')."</td><td>";
422 $doleditor = new DolEditor('note', $object->note_private, '', 160, 'dolibarr_notes', 'In', true, false, 0, ROWS_4, '90%');
423 $doleditor->Create();
424 print "</td>";
425 print "<td>";
426 print "</td>";
427 print "</tr>\n";
428
429 print '<tr class="blockemailalert"><td>';
430 print $langs->trans('EmailIfError')."</td><td>";
431 print '<input type="text" class="minwidth150" name="email_alert" value="'.dol_escape_htmltag($object->email_alert).'" /> ';
432 print "</td>";
433 print "<td>";
434 //print $form->textwithpicto('', $langs->trans("CronCommandHelp"), 1, 'help');
435 print "</td>";
436 print "</tr>\n";
437
438 print '<tr><td class="fieldrequired">';
439 print $langs->trans('CronEvery')."</td>";
440 print "<td>";
441 print '<select name="nbfrequency" id="nbfrequency" class="width50 maxwidth50imp">';
442 for ($i = 1; $i <= 60; $i++) {
443 if ($object->frequency == $i) {
444 print "<option value='".$i."' selected>".$i."</option>";
445 } else {
446 print "<option value='".$i."'>".$i."</option>";
447 }
448 }
449 print "</select>";
450 print ajax_combobox('nbfrequency');
451 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
452 if ($object->unitfrequency == "60") {
453 $input .= ' checked />';
454 } else {
455 $input .= ' />';
456 }
457 $input .= "<label for=\"frequency_minute\">".$langs->trans('Minutes')."</label>";
458 print $input;
459
460 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
461 if ($object->unitfrequency == "3600") {
462 $input .= ' checked />';
463 } else {
464 $input .= ' />';
465 }
466 $input .= "<label for=\"frequency_heures\">".$langs->trans('Hours')."</label>";
467 print $input;
468
469 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
470 if ($object->unitfrequency == "86400") {
471 $input .= ' checked />';
472 } else {
473 $input .= ' />';
474 }
475 $input .= "<label for=\"frequency_jours\">".$langs->trans('Days')."</label>";
476 print $input;
477
478 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
479 if ($object->unitfrequency == "604800") {
480 $input .= ' checked />';
481 } else {
482 $input .= ' />';
483 }
484 $input .= "<label for=\"frequency_semaine\">".$langs->trans('Weeks')."</label>";
485 print $input;
486
487 $input = " &nbsp;<input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
488 if ($object->unitfrequency == "2678400") {
489 $input .= ' checked />';
490 } else {
491 $input .= ' />';
492 }
493 $input .= '<label for="frequency_month">'.$langs->trans('Months')."</label>";
494 print $input;
495
496 print "</td>";
497 print "<td>";
498 print "</td>";
499 print "</tr>\n";
500
501 // Priority
502 print "<tr><td>";
503 print $langs->trans('CronPriority')."</td>";
504 $priority = 0;
505 if (!empty($object->priority)) {
506 $priority = $object->priority;
507 }
508 print '<td><input type="text" class="width50" name="priority" value="'.$priority.'" /> ';
509 print "</td>";
510 print "<td>";
511 print "</td>";
512 print "</tr>\n";
513
514 print "<tr><td>";
515 print $langs->trans('CronDtStart')."</td><td>";
516 if (!empty($object->datestart)) {
517 print $form->selectDate($object->datestart, 'datestart', 1, 1, 0, "cronform");
518 } else {
519 print $form->selectDate(-1, 'datestart', 1, 1, 1, "cronform");
520 }
521 print "</td>";
522 print "<td>";
523 print "</td>";
524 print "</tr>\n";
525
526 print "<tr><td>";
527 print $langs->trans('CronDtEnd')."</td><td>";
528 if (!empty($object->dateend)) {
529 print $form->selectDate($object->dateend, 'dateend', 1, 1, 0, "cronform");
530 } else {
531 print $form->selectDate(-1, 'dateend', 1, 1, 1, "cronform");
532 }
533 print "</td>";
534 print "<td>";
535 print "</td>";
536 print "</tr>\n";
537
538 print '<tr><td>';
539 $maxrun = '';
540 if (!empty($object->maxrun)) {
541 $maxrun = $object->maxrun;
542 }
543 print $langs->trans('CronMaxRun')."</td>";
544 print '<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.'" /> ';
545 print "</td>";
546 print "<td>";
547 print "</td>";
548 print "</tr>\n";
549
550 print '<tr><td class="fieldrequired">';
551 print $langs->trans('CronDtNextLaunch');
552 //print ' ('.$langs->trans('CronFrom').')';
553 print "</td><td>";
554 if (!empty($object->datenextrun)) {
555 print $form->selectDate($object->datenextrun, 'datenextrun', 1, 1, 0, "cronform");
556 } else {
557 print $form->selectDate(-1, 'datenextrun', 1, 1, 0, "cronform", 1, 1);
558 }
559 print "</td>";
560 print "<td>";
561 print "</td>";
562 print "</tr>";
563
564 print '</table>';
565
566 print dol_get_fiche_end();
567
568 print $form->buttonsSaveCancel();
569
570 print "</form>\n";
571} else {
572 // view card
573 $now = dol_now();
574
575 print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron');
576
577 $linkback = '<a href="'.DOL_URL_ROOT.'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
578
579 $reg = array();
580 if (preg_match('/:(.*)$/', $object->label, $reg)) {
581 $langs->load($reg[1]);
582 }
583
584 $labeltoshow = preg_replace('/:.*$/', '', $object->label);
585
586 $morehtmlref = '<div class="refidno">';
587 $morehtmlref .= $langs->trans($labeltoshow);
588 $morehtmlref .= '</div>';
589
590 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
591
592 // box add_jobs_box
593 print '<div class="fichecenter">';
594 print '<div class="fichehalfleft">';
595
596 print '<div class="underbanner clearboth"></div>';
597 print '<table class="border centpercent tableforfield">';
598
599 /*print '<tr><td class="titlefield">';
600 print $langs->trans('CronLabel')."</td>";
601 print "<td>".$langs->trans($object->label);
602 print "</td></tr>";*/
603
604 print '<tr><td class="titlefieldmiddle">';
605 print $langs->trans('CronType')."</td><td>";
606 print $formCron->select_typejob('jobtype', $object->jobtype, 1);
607 print "</td></tr>";
608
609 print '<tr class="blockmethod"><td>';
610 print $langs->trans('CronModule')."</td><td>";
611 print dol_escape_htmltag($object->module_name);
612 print "</td></tr>";
613
614 print '<tr class="blockmethod"><td>';
615 print $langs->trans('CronClassFile')."</td><td>";
616 print dol_escape_htmltag($object->classesname);
617 print "</td></tr>";
618
619 print '<tr class="blockmethod"><td>';
620 print $langs->trans('CronObject')."</td><td>";
621 print dol_escape_htmltag($object->objectname);
622 print "</td></tr>";
623
624 print '<tr class="blockmethod"><td>';
625 print $langs->trans('CronMethod')."</td><td>";
626 print dol_escape_htmltag($object->methodename);
627 print "</td></tr>";
628
629 print '<tr class="blockmethod"><td>';
630 print $langs->trans('CronArgs')."</td><td>";
631 print dol_escape_htmltag($object->params);
632 print "</td></tr>";
633
634 print '<tr class="blockcommand"><td>';
635 print $langs->trans('CronCommand')."</td><td>";
636 print dol_escape_htmltag($object->command);
637 print "</td></tr>";
638
639 print '<tr><td>';
640 print $langs->trans('CronNote')."</td><td>";
641 if (!is_null($object->note_private) && $object->note_private != '') {
642 print '<div class="small lineheightsmall">'.$langs->trans($object->note_private).'</div>';
643 }
644 print "</td></tr>";
645
646 print '<tr class="blockemailalert"><td>';
647 print $langs->trans('EmailIfError')."</td><td>";
648 print dol_escape_htmltag($object->email_alert);
649 print "</td></tr>";
650
651 if (isModEnabled('multicompany')) {
652 print '<tr><td>';
653 print $langs->trans('Entity')."</td><td>";
654 if (empty($object->entity)) {
655 print img_picto($langs->trans("AllEntities"), 'entity', 'class="pictofixedwidth"').$langs->trans("AllEntities");
656 } else {
657 $mc->getInfo($object->entity);
658 print img_picto($langs->trans("AllEntities"), 'entity', 'class="pictofixedwidth"').$mc->label;
659 }
660 print "</td></tr>";
661 }
662
663 print '</table>';
664 print '</div>';
665
666 print '<div class="fichehalfright">';
667
668 print '<div class="underbanner clearboth"></div>';
669 print '<table class="border centpercent tableforfield">';
670
671 print '<tr><td class="titlefieldmiddle">';
672 print $langs->trans('CronEvery')."</td>";
673 print "<td>";
674 if ($object->unitfrequency == "60") {
675 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Minutes');
676 }
677 if ($object->unitfrequency == "3600") {
678 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Hours');
679 }
680 if ($object->unitfrequency == "86400") {
681 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Days');
682 }
683 if ($object->unitfrequency == "604800") {
684 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks');
685 }
686 if ($object->unitfrequency == "2678400") {
687 print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Months');
688 }
689 print "</td></tr>";
690
691 // Priority
692 print "<tr><td>";
693 print $langs->trans('CronPriority')."</td>";
694 print "<td>".$object->priority;
695 print "</td></tr>";
696
697 print '<tr><td>';
698 print $langs->trans('CronDtStart')."</td><td>";
699 if (!empty($object->datestart)) {
700 print $form->textwithpicto(dol_print_date($object->datestart, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
701 }
702 print "</td></tr>";
703
704 print "<tr><td>";
705 print $langs->trans('CronDtEnd')."</td><td>";
706 if (!empty($object->dateend)) {
707 print $form->textwithpicto(dol_print_date($object->dateend, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
708 }
709 print "</td></tr>";
710
711 print "<tr><td>";
712 print $langs->trans('CronMaxRun')."</td>";
713 print "<td>";
714 print $object->maxrun > 0 ? $object->maxrun : '';
715 print "</td></tr>";
716
717 print "<tr><td>";
718 print $langs->trans('CronNbRun')."</td>";
719 print "<td>".$object->nbrun;
720 print "</td></tr>";
721
722 // Date next run (from)
723 print '<tr><td>';
724 print $langs->trans('CronDtNextLaunch');
725 print ' ('.$langs->trans('CronFrom').')';
726 print "</td><td>";
727 if (!$object->status) {
728 print img_picto('', 'object_calendarday').' <span class="opacitymedium strikefordisabled">'.$form->textwithpicto(dol_print_date($object->datenextrun, 'dayhoursec'), $langs->trans("CurrentTimeZone")).'</span> ';
729 print $langs->trans("Disabled");
730 } elseif (!empty($object->datenextrun)) {
731 print img_picto('', 'object_calendarday').' '.$form->textwithpicto(dol_print_date($object->datenextrun, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
732 } else {
733 print '<span class="opacitymedium">'.$langs->trans('CronNone').'</span>';
734 }
735 if ($object->status == Cronjob::STATUS_ENABLED) {
736 if ($object->maxrun && $object->nbrun >= $object->maxrun) {
737 print img_warning($langs->trans("MaxRunReached"));
738 } elseif ($object->datenextrun && $object->datenextrun < $now) {
739 print img_warning($langs->trans("Late"));
740 }
741 }
742 print "</td></tr>";
743
744 print '</table>';
745
746
747 print '<br>';
748
749
750 print '<div class="underbanner clearboth"></div>';
751 print '<table class="border centpercent tableforfield">';
752
753 print '<tr><td class="titlefieldmiddle">';
754 print $langs->trans('CronDtLastLaunch')."</td><td>";
755 if (!empty($object->datelastrun)) {
756 print $form->textwithpicto(dol_print_date($object->datelastrun, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
757 } else {
758 print '<span class="opacitymedium">'.$langs->trans('CronNotYetRan').'</span>';
759 }
760 print "</td></tr>";
761
762 print '<tr><td>';
763 print $langs->trans('CronDtLastResult')."</td><td>";
764 if (!empty($object->datelastresult)) {
765 print $form->textwithpicto(dol_print_date($object->datelastresult, 'dayhoursec'), $langs->trans("CurrentTimeZone"));
766 } else {
767 if (empty($object->datelastrun)) {
768 print '<span class="opacitymedium">'.$langs->trans('CronNotYetRan').'</span>';
769 } else {
770 // In progress
771 }
772 }
773 print "</td></tr>";
774
775 print '<tr><td>';
776 print $langs->trans('CronLastResult')."</td><td>";
777 if ($object->lastresult) {
778 print '<span class="error">';
779 }
780 print $object->lastresult;
781 if ($object->lastresult) {
782 print '</span>';
783 }
784 print "</td></tr>";
785
786 print '<tr><td>';
787 print $langs->trans('CronLastOutput')."</td><td>";
788 print '<span class="small">'.(!empty($object->lastoutput) ? nl2br($object->lastoutput) : '').'</span>';
789 print "</td></tr>";
790
791 print '</table>';
792
793 print '</div>';
794
795 print '<div class="clearboth"></div>';
796
797
798 print dol_get_fiche_end();
799
800
801 print "\n\n".'<div class="tabsAction">'."\n";
802 if (!$user->hasRight('cron', 'create')) {
803 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Edit").'</a>';
804 } else {
805 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Edit").'</a>';
806 }
807
808 if ((!$user->hasRight('cron', 'execute'))) {
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 if (!$user->hasRight('cron', 'create')) {
817 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("CronStatusActiveBtn").'/'.$langs->trans("CronStatusInactiveBtn").'</a>';
818 } else {
819 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=clone&token='.newToken().'&id='.$object->id.'">'.$langs->trans("ToClone").'</a>';
820
821 if (empty($object->status)) {
822 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=activate&token='.newToken().'&id='.$object->id.'">'.$langs->trans("CronStatusActiveBtn").'</a>';
823 } else {
824 print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=inactive&id='.$object->id.'">'.$langs->trans("CronStatusInactiveBtn").'</a>';
825 }
826 }
827
828 if (!$user->hasRight('cron', 'delete')) {
829 print '<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Delete").'</a>';
830 } else {
831 print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>';
832 }
833 print '</div>';
834
835 print '<br>';
836}
837
838
839llxFooter();
840
841$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:475
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Cron Job class.
Class to manage a WYSIWYG editor.
Class to manage building of HTML components.
Class to manage generation of HTML components Only common components must be here.
cron_prepare_head(Cronjob $object)
Return array of tabs to used on a cron job.
Definition cron.lib.php:62
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.