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