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