29require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
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';
47$langs->loadLangs(array(
'admin',
'cron',
'members',
'bills'));
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');
56$securitykey =
GETPOST(
'securitykey',
'alpha');
58if (!$user->hasRight(
'cron',
'create')) {
62$permissiontoadd = $user->hasRight(
'cron',
'create');
63$permissiontoexecute = $user->hasRight(
'cron',
'execute');
64$permissiontodelete = $user->hasRight(
'cron',
'delete');
80 if (!empty($id) && empty($backtopage)) {
84 header(
"Location: ".$backtopage);
86 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
93if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontodelete) {
94 $result =
$object->delete($user);
100 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
106if ($action ==
'confirm_execute' && $confirm ==
"yes" && $permissiontoexecute) {
112 $result =
$object->run_jobs($user->login);
117 $res =
$object->reprogram_jobs($user->login, $now);
133if ($action ==
'add' && $permissiontoadd) {
156 $result =
$object->create($user);
169if ($action ==
'update' && $permissiontoadd) {
191 $result =
$object->update($user);
203if ($action ==
'activate' && $permissiontoadd) {
207 $result =
$object->update($user);
219if ($action ==
'inactive' && $permissiontoadd) {
224 $result =
$object->update($user);
237if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
238 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
243 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id :
$id));
244 if (is_object($result) || $result > 0) {
246 if (is_object($result)) {
247 $newid = $result->id;
251 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$newid);
265$form =
new Form($db);
272if ($action ==
'create') {
276if (
$conf->use_javascript_ajax) {
277 print
"\n".
'<script type="text/javascript">';
278 print
'jQuery(document).ready(function () {
279 function initfields()
281 if ($("#jobtype option:selected").val()==\'method\') {
282 $(".blockmethod").show();
283 $(".blockcommand").hide();
285 if ($("#jobtype option:selected").val()==\'command\') {
286 $(".blockmethod").hide();
287 $(".blockcommand").show();
291 jQuery("#jobtype").change(function() {
295 print
'</script>'.
"\n";
299if ($action ==
'delete') {
300 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"CronDelete"), $langs->trans(
"CronConfirmDelete"),
"confirm_delete",
'',
'', 1);
305if ($action ==
'execute') {
306 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&securitykey='.$securitykey, $langs->trans(
"CronExecute"), $langs->trans(
"CronConfirmExecute"),
"confirm_execute",
'',
'', 1);
312if ($action ==
'clone') {
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);
326if (empty(
$object->status) && $action !=
'create') {
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";
335 print
'<input type="hidden" name="action" value="update">'.
"\n";
336 print
'<input type="hidden" name="id" value="'.$object->id.
'">'.
"\n";
338 print
'<input type="hidden" name="action" value="add">'.
"\n";
341 if ($action ==
"edit") {
347 print
'<table class="border centpercent">';
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).
'"> ';
357 print
'<tr><td class="fieldrequired">';
358 print $langs->trans(
'CronType').
"</td><td>";
359 print $formCron->select_typejob(
'jobtype',
$object->jobtype);
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).
'"> ';
370 print $form->textwithpicto(
'', $langs->trans(
"CronModuleHelp"), 1,
'help');
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).
'"> ';
379 print $form->textwithpicto(
'', $langs->trans(
"CronClassFileHelp"), 1,
'help');
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).
'"> ';
388 print $form->textwithpicto(
'', $langs->trans(
"CronObjectHelp"), 1,
'help');
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).
'" /> ';
397 print $form->textwithpicto(
'', $langs->trans(
"CronMethodHelp"), 1,
'help');
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.
'" /> ';
406 print $form->textwithpicto(
'', $langs->trans(
"CronArgsHelp"), 1,
'help');
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.
'" /> ';
415 print $form->textwithpicto(
'', $langs->trans(
"CronCommandHelp"), 1,
'help');
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();
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).
'" /> ';
437 print
'<tr><td class="fieldrequired">';
438 print $langs->trans(
'CronEvery').
"</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>";
445 print
"<option value='".$i.
"'>".$i.
"</option>";
449 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
450 if (
$object->unitfrequency ==
"60") {
451 $input .=
' checked />';
455 $input .=
"<label for=\"frequency_minute\">".$langs->trans(
'Minutes').
"</label>";
458 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
459 if (
$object->unitfrequency ==
"3600") {
460 $input .=
' checked />';
464 $input .=
"<label for=\"frequency_heures\">".$langs->trans(
'Hours').
"</label>";
467 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
468 if (
$object->unitfrequency ==
"86400") {
469 $input .=
' checked />';
473 $input .=
"<label for=\"frequency_jours\">".$langs->trans(
'Days').
"</label>";
476 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
477 if (
$object->unitfrequency ==
"604800") {
478 $input .=
' checked />';
482 $input .=
"<label for=\"frequency_semaine\">".$langs->trans(
'Weeks').
"</label>";
485 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
486 if (
$object->unitfrequency ==
"2678400") {
487 $input .=
' checked />';
491 $input .=
'<label for="frequency_month">'.$langs->trans(
'Months').
"</label>";
501 print $langs->trans(
'CronPriority').
"</td>";
503 if (!empty(
$object->priority)) {
506 print
'<td><input type="text" class="width50" name="priority" value="'.$priority.
'" /> ';
513 print $langs->trans(
'CronDtStart').
"</td><td>";
514 if (!empty(
$object->datestart)) {
515 print $form->selectDate(
$object->datestart,
'datestart', 1, 1, 0,
"cronform");
517 print $form->selectDate(-1,
'datestart', 1, 1, 1,
"cronform");
525 print $langs->trans(
'CronDtEnd').
"</td><td>";
526 if (!empty(
$object->dateend)) {
527 print $form->selectDate(
$object->dateend,
'dateend', 1, 1, 0,
"cronform");
529 print $form->selectDate(-1,
'dateend', 1, 1, 1,
"cronform");
541 print $langs->trans(
'CronMaxRun').
"</td>";
542 print
'<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.
'" /> ';
548 print
'<tr><td class="fieldrequired">';
549 print $langs->trans(
'CronDtNextLaunch');
552 if (!empty(
$object->datenextrun)) {
553 print $form->selectDate(
$object->datenextrun,
'datenextrun', 1, 1, 0,
"cronform");
555 print $form->selectDate(-1,
'datenextrun', 1, 1, 0,
"cronform", 1, 1);
566 print $form->buttonsSaveCancel();
575 $linkback =
'<a href="'.DOL_URL_ROOT.
'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
578 if (preg_match(
'/:(.*)$/',
$object->label, $reg)) {
579 $langs->load($reg[1]);
582 $labeltoshow = preg_replace(
'/:.*$/',
'',
$object->label);
584 $morehtmlref =
'<div class="refidno">';
585 $morehtmlref .= $langs->trans($labeltoshow);
586 $morehtmlref .=
'</div>';
588 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
591 print
'<div class="fichecenter">';
592 print
'<div class="fichehalfleft">';
594 print
'<div class="underbanner clearboth"></div>';
595 print
'<table class="border centpercent tableforfield">';
602 print
'<tr><td class="titlefieldmiddle">';
603 print $langs->trans(
'CronType').
"</td><td>";
604 print $formCron->select_typejob(
'jobtype',
$object->jobtype, 1);
607 print
'<tr class="blockmethod"><td>';
608 print $langs->trans(
'CronModule').
"</td><td>";
612 print
'<tr class="blockmethod"><td>';
613 print $langs->trans(
'CronClassFile').
"</td><td>";
617 print
'<tr class="blockmethod"><td>';
618 print $langs->trans(
'CronObject').
"</td><td>";
622 print
'<tr class="blockmethod"><td>';
623 print $langs->trans(
'CronMethod').
"</td><td>";
627 print
'<tr class="blockmethod"><td>';
628 print $langs->trans(
'CronArgs').
"</td><td>";
632 print
'<tr class="blockcommand"><td>';
633 print $langs->trans(
'CronCommand').
"</td><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>';
644 print
'<tr class="blockemailalert"><td>';
645 print $langs->trans(
'EmailIfError').
"</td><td>";
649 if (isModEnabled(
'multicompany')) {
651 print $langs->trans(
'Entity').
"</td><td>";
653 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$langs->trans(
"AllEntities");
656 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$mc->label;
664 print
'<div class="fichehalfright">';
666 print
'<div class="underbanner clearboth"></div>';
667 print
'<table class="border centpercent tableforfield">';
669 print
'<tr><td class="titlefieldmiddle">';
670 print $langs->trans(
'CronEvery').
"</td>";
672 if (
$object->unitfrequency ==
"60") {
673 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Minutes');
675 if (
$object->unitfrequency ==
"3600") {
676 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Hours');
678 if (
$object->unitfrequency ==
"86400") {
679 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Days');
681 if (
$object->unitfrequency ==
"604800") {
682 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Weeks');
684 if (
$object->unitfrequency ==
"2678400") {
685 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Months');
691 print $langs->trans(
'CronPriority').
"</td>";
692 print
"<td>".$object->priority;
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"));
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"));
710 print $langs->trans(
'CronMaxRun').
"</td>";
716 print $langs->trans(
'CronNbRun').
"</td>";
717 print
"<td>".$object->nbrun;
722 print $langs->trans(
'CronDtNextLaunch');
723 print
' ('.$langs->trans(
'CronFrom').
')';
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"));
731 print
'<span class="opacitymedium">'.$langs->trans(
'CronNone').
'</span>';
733 if (
$object->status == Cronjob::STATUS_ENABLED) {
748 print
'<div class="underbanner clearboth"></div>';
749 print
'<table class="border centpercent tableforfield">';
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"));
756 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
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"));
765 if (empty(
$object->datelastrun)) {
766 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
774 print $langs->trans(
'CronLastResult').
"</td><td>";
776 print
'<span class="error">';
785 print $langs->trans(
'CronLastOutput').
"</td><td>";
786 print
'<span class="small">'.(!empty(
$object->lastoutput) ? nl2br(
$object->lastoutput) :
'').
'</span>';
793 print
'<div class="clearboth"></div>';
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>';
803 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Edit").
'</a>';
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>';
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>';
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>';
817 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
820 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=activate&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusActiveBtn").
'</a>';
822 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=inactive&id='.
$object->id.
'">'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
826 if (!$user->hasRight(
'cron',
'delete')) {
827 print
'<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Delete").
'</a>';
829 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
Class to manage a WYSIWYG editor.
cron_prepare_head(Cronjob $object)
Return array of tabs to used on a cron job.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.