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);
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).
'" spellcheck="false"> ';
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).
'" spellcheck="false"> ';
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).
'" spellcheck="false"> ';
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).
'" spellcheck="false"> ';
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).
'" spellcheck="false"> ';
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.
'" spellcheck="false"> ';
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.
'" spellcheck="false" /> ';
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
img_picto(
'',
'recurring',
'class="pictofixedwidth"');
443 print
'<select name="nbfrequency" id="nbfrequency" class="width50 maxwidth50imp">';
444 for ($i = 1; $i <= 60; $i++) {
445 if (
$object->frequency == $i) {
446 print
"<option value='".$i.
"' selected>".$i.
"</option>";
448 print
"<option value='".$i.
"'>".$i.
"</option>";
453 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
454 if (
$object->unitfrequency ==
"60") {
455 $input .=
' checked />';
459 $input .=
"<label for=\"frequency_minute\">".$langs->trans(
'Minutes').
"</label>";
462 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
463 if (
$object->unitfrequency ==
"3600") {
464 $input .=
' checked />';
468 $input .=
"<label for=\"frequency_heures\">".$langs->trans(
'Hours').
"</label>";
471 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
472 if (
$object->unitfrequency ==
"86400") {
473 $input .=
' checked />';
477 $input .=
"<label for=\"frequency_jours\">".$langs->trans(
'Days').
"</label>";
480 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
481 if (
$object->unitfrequency ==
"604800") {
482 $input .=
' checked />';
486 $input .=
"<label for=\"frequency_semaine\">".$langs->trans(
'Weeks').
"</label>";
489 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
490 if (
$object->unitfrequency ==
"2678400") {
491 $input .=
' checked />';
495 $input .=
'<label for="frequency_month">'.$langs->trans(
'Months').
"</label>";
505 print $langs->trans(
'CronPriority').
"</td>";
507 if (!empty(
$object->priority)) {
510 print
'<td><input type="text" class="width50" name="priority" value="'.$priority.
'" /> ';
517 print $langs->trans(
'CronDtStart').
"</td><td>";
518 if (!empty(
$object->datestart)) {
519 print $form->selectDate(
$object->datestart,
'datestart', 1, 1, 0,
"cronform");
521 print $form->selectDate(-1,
'datestart', 1, 1, 1,
"cronform");
529 print $langs->trans(
'CronDtEnd').
"</td><td>";
530 if (!empty(
$object->dateend)) {
531 print $form->selectDate(
$object->dateend,
'dateend', 1, 1, 0,
"cronform");
533 print $form->selectDate(-1,
'dateend', 1, 1, 1,
"cronform");
545 print $langs->trans(
'CronMaxRun').
"</td>";
546 print
'<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.
'" /> ';
552 print
'<tr><td class="fieldrequired">';
553 print $langs->trans(
'CronDtNextLaunch');
556 if (!empty(
$object->datenextrun)) {
557 print $form->selectDate(
$object->datenextrun,
'datenextrun', 1, 1, 0,
"cronform");
559 print $form->selectDate(-1,
'datenextrun', 1, 1, 0,
"cronform", 1, 1);
570 print $form->buttonsSaveCancel();
579 $linkback =
'<a href="'.DOL_URL_ROOT.
'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
582 if (preg_match(
'/:(.*)$/',
$object->label, $reg)) {
583 $langs->load($reg[1]);
586 $labeltoshow = preg_replace(
'/:.*$/',
'',
$object->label);
588 $morehtmlref =
'<div class="refidno">';
589 $morehtmlref .= $langs->trans($labeltoshow);
590 $morehtmlref .=
'</div>';
592 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
595 print
'<div class="fichecenter">';
596 print
'<div class="fichehalfleft">';
598 print
'<div class="underbanner clearboth"></div>';
599 print
'<table class="border centpercent tableforfield">';
606 print
'<tr><td class="titlefieldmiddle">';
607 print $langs->trans(
'CronType').
"</td><td>";
608 print $formCron->select_typejob(
'jobtype',
$object->jobtype, 1);
611 print
'<tr class="blockmethod"><td>';
612 print $langs->trans(
'CronModule').
"</td><td>";
616 print
'<tr class="blockmethod"><td>';
617 print $langs->trans(
'CronClassFile').
"</td><td>";
621 print
'<tr class="blockmethod"><td>';
622 print $langs->trans(
'CronObject').
"</td><td>";
626 print
'<tr class="blockmethod"><td>';
627 print $langs->trans(
'CronMethod').
"</td><td>";
631 print
'<tr class="blockmethod"><td>';
632 print $langs->trans(
'CronArgs').
"</td><td>";
636 print
'<tr class="blockcommand"><td>';
637 print $langs->trans(
'CronCommand').
"</td><td>";
642 print $langs->trans(
'CronNote').
"</td><td>";
643 if (!is_null(
$object->note_private) &&
$object->note_private !=
'') {
644 print
'<div class="small lineheightsmall">'.$langs->trans(
$object->note_private).
'</div>';
648 print
'<tr class="blockemailalert"><td>';
649 print $langs->trans(
'EmailIfError').
"</td><td>";
655 print $langs->trans(
'Entity').
"</td><td>";
657 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$langs->trans(
"AllEntities");
660 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$mc->label;
668 print
'<div class="fichehalfright">';
670 print
'<div class="underbanner clearboth"></div>';
671 print
'<table class="border centpercent tableforfield">';
673 print
'<tr><td class="titlefieldmiddle">';
674 print $langs->trans(
'CronEvery').
"</td>";
676 print
img_picto(
'',
'recurring',
'class="pictofixedwidth"');
677 if (
$object->unitfrequency ==
"60") {
678 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Minutes');
680 if (
$object->unitfrequency ==
"3600") {
681 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Hours');
683 if (
$object->unitfrequency ==
"86400") {
684 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Days');
686 if (
$object->unitfrequency ==
"604800") {
687 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Weeks');
689 if (
$object->unitfrequency ==
"2678400") {
690 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Months');
696 print $langs->trans(
'CronPriority').
"</td>";
697 print
"<td>".$object->priority;
701 print $langs->trans(
'CronDtStart').
"</td><td>";
702 if (!empty(
$object->datestart)) {
703 print $form->textwithpicto(
dol_print_date(
$object->datestart,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
708 print $langs->trans(
'CronDtEnd').
"</td><td>";
709 if (!empty(
$object->dateend)) {
710 print $form->textwithpicto(
dol_print_date(
$object->dateend,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
715 print $langs->trans(
'CronMaxRun').
"</td>";
721 print $langs->trans(
'CronNbRun').
"</td>";
722 print
"<td>".$object->nbrun;
727 print $langs->trans(
'CronDtNextLaunch');
728 print
' ('.$langs->trans(
'CronFrom').
')';
731 print
img_picto(
'',
'object_calendarday').
' <span class="opacitymedium strikefordisabled">'.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone")).
'</span> ';
732 print $langs->trans(
"Disabled");
733 } elseif (!empty(
$object->datenextrun)) {
734 print
img_picto(
'',
'object_calendarday').
' '.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
736 print
'<span class="opacitymedium">'.$langs->trans(
'CronNone').
'</span>';
738 if (
$object->status == Cronjob::STATUS_ENABLED) {
753 print
'<div class="underbanner clearboth"></div>';
754 print
'<table class="border centpercent tableforfield">';
756 print
'<tr><td class="titlefieldmiddle">';
757 print $langs->trans(
'CronDtLastLaunch').
"</td><td>";
758 if (!empty(
$object->datelastrun)) {
759 print $form->textwithpicto(
dol_print_date(
$object->datelastrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
761 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
766 print $langs->trans(
'CronDtLastResult').
"</td><td>";
767 if (!empty(
$object->datelastresult)) {
768 print $form->textwithpicto(
dol_print_date(
$object->datelastresult,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
770 if (empty(
$object->datelastrun)) {
771 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
779 print $langs->trans(
'CronLastResult').
"</td><td>";
781 print
'<span class="error">';
790 print $langs->trans(
'CronLastOutput').
"</td><td>";
791 print
'<span class="small">'.(!empty(
$object->lastoutput) ? nl2br(
$object->lastoutput) :
'').
'</span>';
798 print
'<div class="clearboth"></div>';
804 print
"\n\n".
'<div class="tabsAction">'.
"\n";
805 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Edit").
'</a>';
807 if ((!$user->hasRight(
'cron',
'execute'))) {
808 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"CronExecute").
'</a>';
809 } elseif (empty(
$object->status)) {
810 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"JobDisabled")).
'">'.$langs->trans(
"CronExecute").
'</a>';
812 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>';
816 print
'<a class="butAction butActionClone" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
819 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=activate&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusActiveBtn").
'</a>';
821 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=inactive&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
825 if (!$user->hasRight(
'cron',
'delete')) {
826 print
'<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Delete").
'</a>';
828 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.
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.