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