30require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
35require_once DOL_DOCUMENT_ROOT.
"/cron/class/cronjob.class.php";
36require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formcron.class.php";
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/cron.lib.php';
48$langs->loadLangs(array(
'admin',
'cron',
'members',
'bills'));
51$action =
GETPOST(
'action',
'aZ09');
52$confirm =
GETPOST(
'confirm',
'alpha');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
57$securitykey =
GETPOST(
'securitykey',
'alpha');
59$permissiontoadd = $user->hasRight(
'cron',
'create');
60$permissiontoexecute = $user->hasRight(
'cron',
'execute');
61$permissiontodelete = $user->hasRight(
'cron',
'delete');
63if (!$permissiontoadd) {
81 if (!empty($id) && empty($backtopage)) {
85 header(
"Location: ".$backtopage);
87 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
94if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontodelete) {
95 $result =
$object->delete($user);
101 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
107if ($action ==
'confirm_execute' && $confirm ==
"yes" && $permissiontoexecute) {
113 $result =
$object->run_jobs($user->login);
118 $res =
$object->reprogram_jobs($user->login, $now);
134if ($action ==
'add') {
157 $result =
$object->create($user);
170if ($action ==
'update') {
192 $result =
$object->update($user);
204if ($action ==
'activate') {
208 $result =
$object->update($user);
220if ($action ==
'inactive') {
225 $result =
$object->update($user);
238if ($action ==
'confirm_clone' && $confirm ==
'yes') {
240 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
245 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id :
$id));
246 if (is_object($result) || $result > 0) {
248 if (is_object($result)) {
249 $newid = $result->id;
253 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$newid);
267$form =
new Form($db);
274if ($action ==
'create') {
278if ($conf->use_javascript_ajax) {
279 print
"\n".
'<script type="text/javascript">';
280 print
'jQuery(document).ready(function () {
281 function initfields()
283 if ($("#jobtype option:selected").val()==\'method\') {
284 $(".blockmethod").show();
285 $(".blockcommand").hide();
287 if ($("#jobtype option:selected").val()==\'command\') {
288 $(".blockmethod").hide();
289 $(".blockcommand").show();
293 jQuery("#jobtype").change(function() {
297 print
'</script>'.
"\n";
301if ($action ==
'delete') {
302 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"CronDelete"), $langs->trans(
"CronConfirmDelete"),
"confirm_delete",
'',
'', 1);
307if ($action ==
'execute') {
308 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&securitykey='.$securitykey, $langs->trans(
"CronExecute"), $langs->trans(
"CronConfirmExecute"),
"confirm_execute",
'',
'', 1);
314if ($action ==
'clone') {
316 $formquestion = array();
317 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
328if (empty(
$object->status) && $action !=
'create') {
332if (($action ==
"create") || ($action ==
"edit")) {
333 print
'<form name="cronform" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
334 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
335 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage').
'">'.
"\n";
337 print
'<input type="hidden" name="action" value="update">'.
"\n";
338 print
'<input type="hidden" name="id" value="'.$object->id.
'">'.
"\n";
340 print
'<input type="hidden" name="action" value="add">'.
"\n";
343 if ($action ==
"edit") {
349 print
'<table class="border centpercent">';
351 print
'<tr><td class="fieldrequired titlefieldcreate">';
352 print $langs->trans(
'CronLabel').
"</td>";
353 print
'<td><input type="text" class="width200" name="label" value="'.dol_escape_htmltag(
$object->label).
'"> ';
359 print
'<tr><td class="fieldrequired">';
360 print $langs->trans(
'CronType').
"</td><td>";
361 print $formCron->select_typejob(
'jobtype',
$object->jobtype);
367 print
'<tr class="blockmethod"><td>';
368 print $langs->trans(
'CronModule').
"</td><td>";
369 print
'<input type="text" class="width200" name="module_name" value="'.dol_escape_htmltag(
$object->module_name).
'"> ';
372 print $form->textwithpicto(
'', $langs->trans(
"CronModuleHelp"), 1,
'help');
376 print
'<tr class="blockmethod"><td>';
377 print $langs->trans(
'CronClassFile').
"</td><td>";
378 print
'<input type="text" class="minwidth300" name="classesname" value="'.dol_escape_htmltag(
$object->classesname).
'"> ';
381 print $form->textwithpicto(
'', $langs->trans(
"CronClassFileHelp"), 1,
'help');
385 print
'<tr class="blockmethod"><td>';
386 print $langs->trans(
'CronObject').
"</td><td>";
387 print
'<input type="text" class="width200" name="objectname" value="'.dol_escape_htmltag(
$object->objectname).
'"> ';
390 print $form->textwithpicto(
'', $langs->trans(
"CronObjectHelp"), 1,
'help');
394 print
'<tr class="blockmethod"><td>';
395 print $langs->trans(
'CronMethod').
"</td><td>";
396 print
'<input type="text" class="minwidth300" name="methodename" value="'.dol_escape_htmltag(
$object->methodename).
'" /> ';
399 print $form->textwithpicto(
'', $langs->trans(
"CronMethodHelp"), 1,
'help');
403 print
'<tr class="blockmethod"><td>';
404 print $langs->trans(
'CronArgs').
"</td><td>";
405 print
'<input type="text" class="quatrevingtpercent" name="params" value="'.$object->params.
'" /> ';
408 print $form->textwithpicto(
'', $langs->trans(
"CronArgsHelp"), 1,
'help');
412 print
'<tr class="blockcommand"><td>';
413 print $langs->trans(
'CronCommand').
"</td><td>";
414 print
'<input type="text" class="minwidth150" name="command" value="'.$object->command.
'" /> ';
417 print $form->textwithpicto(
'', $langs->trans(
"CronCommandHelp"), 1,
'help');
422 print $langs->trans(
'CronNote').
"</td><td>";
423 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 160,
'dolibarr_notes',
'In',
true,
false, 0, ROWS_4,
'90%');
424 $doleditor->Create();
430 print
'<tr class="blockemailalert"><td>';
431 print $langs->trans(
'EmailIfError').
"</td><td>";
432 print
'<input type="text" class="minwidth150" name="email_alert" value="'.dol_escape_htmltag(
$object->email_alert).
'" /> ';
439 print
'<tr><td class="fieldrequired">';
440 print $langs->trans(
'CronEvery').
"</td>";
442 print
'<select name="nbfrequency" id="nbfrequency" class="width50 maxwidth50imp">';
443 for ($i = 1; $i <= 60; $i++) {
444 if (
$object->frequency == $i) {
445 print
"<option value='".$i.
"' selected>".$i.
"</option>";
447 print
"<option value='".$i.
"'>".$i.
"</option>";
452 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
453 if (
$object->unitfrequency ==
"60") {
454 $input .=
' checked />';
458 $input .=
"<label for=\"frequency_minute\">".$langs->trans(
'Minutes').
"</label>";
461 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
462 if (
$object->unitfrequency ==
"3600") {
463 $input .=
' checked />';
467 $input .=
"<label for=\"frequency_heures\">".$langs->trans(
'Hours').
"</label>";
470 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
471 if (
$object->unitfrequency ==
"86400") {
472 $input .=
' checked />';
476 $input .=
"<label for=\"frequency_jours\">".$langs->trans(
'Days').
"</label>";
479 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
480 if (
$object->unitfrequency ==
"604800") {
481 $input .=
' checked />';
485 $input .=
"<label for=\"frequency_semaine\">".$langs->trans(
'Weeks').
"</label>";
488 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
489 if (
$object->unitfrequency ==
"2678400") {
490 $input .=
' checked />';
494 $input .=
'<label for="frequency_month">'.$langs->trans(
'Months').
"</label>";
504 print $langs->trans(
'CronPriority').
"</td>";
506 if (!empty(
$object->priority)) {
509 print
'<td><input type="text" class="width50" name="priority" value="'.$priority.
'" /> ';
516 print $langs->trans(
'CronDtStart').
"</td><td>";
517 if (!empty(
$object->datestart)) {
518 print $form->selectDate(
$object->datestart,
'datestart', 1, 1, 0,
"cronform");
520 print $form->selectDate(-1,
'datestart', 1, 1, 1,
"cronform");
528 print $langs->trans(
'CronDtEnd').
"</td><td>";
529 if (!empty(
$object->dateend)) {
530 print $form->selectDate(
$object->dateend,
'dateend', 1, 1, 0,
"cronform");
532 print $form->selectDate(-1,
'dateend', 1, 1, 1,
"cronform");
544 print $langs->trans(
'CronMaxRun').
"</td>";
545 print
'<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.
'" /> ';
551 print
'<tr><td class="fieldrequired">';
552 print $langs->trans(
'CronDtNextLaunch');
555 if (!empty(
$object->datenextrun)) {
556 print $form->selectDate(
$object->datenextrun,
'datenextrun', 1, 1, 0,
"cronform");
558 print $form->selectDate(-1,
'datenextrun', 1, 1, 0,
"cronform", 1, 1);
569 print $form->buttonsSaveCancel();
578 $linkback =
'<a href="'.DOL_URL_ROOT.
'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
581 if (preg_match(
'/:(.*)$/',
$object->label, $reg)) {
582 $langs->load($reg[1]);
585 $labeltoshow = preg_replace(
'/:.*$/',
'',
$object->label);
587 $morehtmlref =
'<div class="refidno">';
588 $morehtmlref .= $langs->trans($labeltoshow);
589 $morehtmlref .=
'</div>';
591 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
594 print
'<div class="fichecenter">';
595 print
'<div class="fichehalfleft">';
597 print
'<div class="underbanner clearboth"></div>';
598 print
'<table class="border centpercent tableforfield">';
605 print
'<tr><td class="titlefieldmiddle">';
606 print $langs->trans(
'CronType').
"</td><td>";
607 print $formCron->select_typejob(
'jobtype',
$object->jobtype, 1);
610 print
'<tr class="blockmethod"><td>';
611 print $langs->trans(
'CronModule').
"</td><td>";
615 print
'<tr class="blockmethod"><td>';
616 print $langs->trans(
'CronClassFile').
"</td><td>";
620 print
'<tr class="blockmethod"><td>';
621 print $langs->trans(
'CronObject').
"</td><td>";
625 print
'<tr class="blockmethod"><td>';
626 print $langs->trans(
'CronMethod').
"</td><td>";
630 print
'<tr class="blockmethod"><td>';
631 print $langs->trans(
'CronArgs').
"</td><td>";
635 print
'<tr class="blockcommand"><td>';
636 print $langs->trans(
'CronCommand').
"</td><td>";
641 print $langs->trans(
'CronNote').
"</td><td>";
642 if (!is_null(
$object->note_private) &&
$object->note_private !=
'') {
643 print
'<div class="small lineheightsmall">'.$langs->trans(
$object->note_private).
'</div>';
647 print
'<tr class="blockemailalert"><td>';
648 print $langs->trans(
'EmailIfError').
"</td><td>";
654 print $langs->trans(
'Entity').
"</td><td>";
656 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$langs->trans(
"AllEntities");
659 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$mc->label;
667 print
'<div class="fichehalfright">';
669 print
'<div class="underbanner clearboth"></div>';
670 print
'<table class="border centpercent tableforfield">';
672 print
'<tr><td class="titlefieldmiddle">';
673 print $langs->trans(
'CronEvery').
"</td>";
675 if (
$object->unitfrequency ==
"60") {
676 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Minutes');
678 if (
$object->unitfrequency ==
"3600") {
679 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Hours');
681 if (
$object->unitfrequency ==
"86400") {
682 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Days');
684 if (
$object->unitfrequency ==
"604800") {
685 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Weeks');
687 if (
$object->unitfrequency ==
"2678400") {
688 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Months');
694 print $langs->trans(
'CronPriority').
"</td>";
695 print
"<td>".$object->priority;
699 print $langs->trans(
'CronDtStart').
"</td><td>";
700 if (!empty(
$object->datestart)) {
701 print $form->textwithpicto(
dol_print_date(
$object->datestart,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
706 print $langs->trans(
'CronDtEnd').
"</td><td>";
707 if (!empty(
$object->dateend)) {
708 print $form->textwithpicto(
dol_print_date(
$object->dateend,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
713 print $langs->trans(
'CronMaxRun').
"</td>";
719 print $langs->trans(
'CronNbRun').
"</td>";
720 print
"<td>".$object->nbrun;
725 print $langs->trans(
'CronDtNextLaunch');
726 print
' ('.$langs->trans(
'CronFrom').
')';
729 print
img_picto(
'',
'object_calendarday').
' <span class="opacitymedium strikefordisabled">'.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone")).
'</span> ';
730 print $langs->trans(
"Disabled");
731 } elseif (!empty(
$object->datenextrun)) {
732 print
img_picto(
'',
'object_calendarday').
' '.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
734 print
'<span class="opacitymedium">'.$langs->trans(
'CronNone').
'</span>';
736 if (
$object->status == Cronjob::STATUS_ENABLED) {
751 print
'<div class="underbanner clearboth"></div>';
752 print
'<table class="border centpercent tableforfield">';
754 print
'<tr><td class="titlefieldmiddle">';
755 print $langs->trans(
'CronDtLastLaunch').
"</td><td>";
756 if (!empty(
$object->datelastrun)) {
757 print $form->textwithpicto(
dol_print_date(
$object->datelastrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
759 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
764 print $langs->trans(
'CronDtLastResult').
"</td><td>";
765 if (!empty(
$object->datelastresult)) {
766 print $form->textwithpicto(
dol_print_date(
$object->datelastresult,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
768 if (empty(
$object->datelastrun)) {
769 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
777 print $langs->trans(
'CronLastResult').
"</td><td>";
779 print
'<span class="error">';
788 print $langs->trans(
'CronLastOutput').
"</td><td>";
789 print
'<span class="small">'.(!empty(
$object->lastoutput) ? nl2br(
$object->lastoutput) :
'').
'</span>';
796 print
'<div class="clearboth"></div>';
802 print
"\n\n".
'<div class="tabsAction">'.
"\n";
803 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Edit").
'</a>';
805 if ((!$user->hasRight(
'cron',
'execute'))) {
806 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"CronExecute").
'</a>';
807 } elseif (empty(
$object->status)) {
808 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"JobDisabled")).
'">'.$langs->trans(
"CronExecute").
'</a>';
810 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 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
817 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=activate&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusActiveBtn").
'</a>';
819 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=inactive&id='.
$object->id.
'">'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
823 if (!$user->hasRight(
'cron',
'delete')) {
824 print
'<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Delete").
'</a>';
826 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.