30require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
42require_once DOL_DOCUMENT_ROOT.
"/cron/class/cronjob.class.php";
43require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formcron.class.php";
44require_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');
59$permissiontoadd = $user->hasRight(
'cron',
'write') && $user->admin;
60$permissiontoexecute = $user->hasRight(
'cron',
'write') && $user->admin;
61$permissiontodelete = $user->hasRight(
'cron',
'delete');
63if (!$permissiontoadd) {
79 if ($result > 0 && empty(
$object->id)) {
85 if (!empty($id) && empty($backtopage)) {
89 header(
"Location: ".$backtopage);
91 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
98if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontodelete) {
99 $result =
$object->delete($user);
105 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
111if ($action ==
'confirm_execute' && $confirm ==
"yes" && $permissiontoexecute) {
117 $result =
$object->run_jobs($user->login);
122 $res =
$object->reprogram_jobs($user->login, $now);
138if ($action ==
'add') {
161 $result =
$object->create($user);
174if ($action ==
'update') {
196 $result =
$object->update($user);
208if ($action ==
'activate') {
212 $result =
$object->update($user);
224if ($action ==
'inactive') {
229 $result =
$object->update($user);
242if ($action ==
'confirm_clone' && $confirm ==
'yes') {
244 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
249 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id :
$id));
250 if (is_object($result) || $result > 0) {
252 if (is_object($result)) {
253 $newid = $result->id;
257 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$newid);
278if ($action ==
'create') {
282if (
$conf->use_javascript_ajax) {
283 print
"\n".
'<script type="text/javascript">';
284 print
'jQuery(document).ready(function () {
285 function initfields()
287 if ($("#jobtype option:selected").val()==\'method\') {
288 $(".blockmethod").show();
289 $(".blockcommand").hide();
291 if ($("#jobtype option:selected").val()==\'command\') {
292 $(".blockmethod").hide();
293 $(".blockcommand").show();
297 jQuery("#jobtype").change(function() {
301 print
'</script>'.
"\n";
305if ($action ==
'delete') {
306 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"CronDelete"), $langs->trans(
"CronConfirmDelete"),
"confirm_delete",
'',
'', 1);
311if ($action ==
'execute') {
312 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&securitykey='.$securitykey, $langs->trans(
"CronExecute"), $langs->trans(
"CronConfirmExecute"),
"confirm_execute",
'',
'', 1);
318if ($action ==
'clone') {
320 $formquestion = array();
321 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
332if (empty(
$object->status) && $action !=
'create') {
336if (($action ==
"create") || ($action ==
"edit")) {
337 print
'<form name="cronform" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
338 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
339 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage').
'">'.
"\n";
341 print
'<input type="hidden" name="action" value="update">'.
"\n";
342 print
'<input type="hidden" name="id" value="'.$object->id.
'">'.
"\n";
344 print
'<input type="hidden" name="action" value="add">'.
"\n";
347 if ($action ==
"edit") {
353 print
'<table class="border centpercent">';
355 print
'<tr><td class="fieldrequired titlefieldcreate">';
356 print $langs->trans(
'CronLabel').
"</td>";
357 print
'<td><input type="text" class="width200" name="label" value="'.dol_escape_htmltag(
$object->label).
'" spellcheck="false"> ';
363 print
'<tr><td class="fieldrequired">';
364 print $langs->trans(
'CronType').
"</td><td>";
365 print $formCron->select_typejob(
'jobtype',
$object->jobtype);
371 print
'<tr class="blockmethod"><td>';
372 print $langs->trans(
'CronModule').
"</td><td>";
373 print
'<input type="text" class="width200" name="module_name" value="'.dol_escape_htmltag(
$object->module_name).
'" spellcheck="false"> ';
376 print $form->textwithpicto(
'', $langs->trans(
"CronModuleHelp"), 1,
'help');
380 print
'<tr class="blockmethod"><td>';
381 print $langs->trans(
'CronClassFile').
"</td><td>";
382 print
'<input type="text" class="minwidth300" name="classesname" value="'.dol_escape_htmltag(
$object->classesname).
'" spellcheck="false"> ';
385 print $form->textwithpicto(
'', $langs->trans(
"CronClassFileHelp"), 1,
'help');
389 print
'<tr class="blockmethod"><td>';
390 print $langs->trans(
'CronObject').
"</td><td>";
391 print
'<input type="text" class="width200" name="objectname" value="'.dol_escape_htmltag(
$object->objectname).
'" spellcheck="false"> ';
394 print $form->textwithpicto(
'', $langs->trans(
"CronObjectHelp"), 1,
'help');
398 print
'<tr class="blockmethod"><td>';
399 print $langs->trans(
'CronMethod').
"</td><td>";
400 print
'<input type="text" class="minwidth300" name="methodename" value="'.dol_escape_htmltag(
$object->methodename).
'" spellcheck="false"> ';
403 print $form->textwithpicto(
'', $langs->trans(
"CronMethodHelp"), 1,
'help');
407 print
'<tr class="blockmethod"><td>';
408 print $langs->trans(
'CronArgs').
"</td><td>";
409 print
'<input type="text" class="quatrevingtpercent" name="params" value="'.dol_escape_htmltag(
$object->params).
'" spellcheck="false"> ';
412 print $form->textwithpicto(
'', $langs->trans(
"CronArgsHelp"), 1,
'help');
416 print
'<tr class="blockcommand"><td>';
417 print $langs->trans(
'CronCommand').
"</td><td>";
418 print
'<input type="text" class="minwidth150" name="command" value="'.dol_escape_htmltag(
$object->command).
'" spellcheck="false" /> ';
421 print $form->textwithpicto(
'', $langs->trans(
"CronCommandHelp"), 1,
'help');
426 print $langs->trans(
'CronNote').
"</td><td>";
427 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 160,
'dolibarr_notes',
'In',
true,
false, 0, ROWS_4,
'90%');
428 $doleditor->Create();
434 print
'<tr class="blockemailalert"><td>';
435 print $langs->trans(
'EmailIfError').
"</td><td>";
436 print
'<input type="text" class="minwidth150" name="email_alert" value="'.dol_escape_htmltag(
$object->email_alert).
'" /> ';
443 print
'<tr><td class="fieldrequired">';
444 print $langs->trans(
'CronEvery').
"</td>";
446 print
img_picto(
'',
'recurring',
'class="pictofixedwidth"');
447 print
'<select name="nbfrequency" id="nbfrequency" class="width50 maxwidth50imp">';
448 for ($i = 1; $i <= 60; $i++) {
449 if (
$object->frequency == $i) {
450 print
"<option value='".$i.
"' selected>".$i.
"</option>";
452 print
"<option value='".$i.
"'>".$i.
"</option>";
457 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
458 if (
$object->unitfrequency ==
"60") {
459 $input .=
' checked />';
463 $input .=
"<label for=\"frequency_minute\">".$langs->trans(
'Minutes').
"</label>";
466 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
467 if (
$object->unitfrequency ==
"3600") {
468 $input .=
' checked />';
472 $input .=
"<label for=\"frequency_heures\">".$langs->trans(
'Hours').
"</label>";
475 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
476 if (
$object->unitfrequency ==
"86400") {
477 $input .=
' checked />';
481 $input .=
"<label for=\"frequency_jours\">".$langs->trans(
'Days').
"</label>";
484 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
485 if (
$object->unitfrequency ==
"604800") {
486 $input .=
' checked />';
490 $input .=
"<label for=\"frequency_semaine\">".$langs->trans(
'Weeks').
"</label>";
493 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
494 if (
$object->unitfrequency ==
"2678400") {
495 $input .=
' checked />';
499 $input .=
'<label for="frequency_month">'.$langs->trans(
'Months').
"</label>";
509 print $langs->trans(
'CronPriority').
"</td>";
511 if (!empty(
$object->priority)) {
514 print
'<td><input type="text" class="width50" name="priority" value="'.$priority.
'" /> ';
521 print $langs->trans(
'CronDtStart').
"</td><td>";
522 if (!empty(
$object->datestart)) {
523 print $form->selectDate(
$object->datestart,
'datestart', 1, 1, 0,
"cronform");
525 print $form->selectDate(-1,
'datestart', 1, 1, 1,
"cronform");
533 print $langs->trans(
'CronDtEnd').
"</td><td>";
534 if (!empty(
$object->dateend)) {
535 print $form->selectDate(
$object->dateend,
'dateend', 1, 1, 0,
"cronform");
537 print $form->selectDate(-1,
'dateend', 1, 1, 1,
"cronform");
549 print $langs->trans(
'CronMaxRun').
"</td>";
550 print
'<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.
'" /> ';
556 print
'<tr><td class="fieldrequired">';
557 print $langs->trans(
'CronDtNextLaunch');
560 if (!empty(
$object->datenextrun)) {
561 print $form->selectDate(
$object->datenextrun,
'datenextrun', 1, 1, 0,
"cronform");
563 print $form->selectDate(-1,
'datenextrun', 1, 1, 0,
"cronform", 1, 1);
574 print $form->buttonsSaveCancel();
583 $linkback =
'<a href="'.DOL_URL_ROOT.
'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
586 if (preg_match(
'/:(.*)$/',
$object->label, $reg)) {
587 $langs->load($reg[1]);
590 $labeltoshow = preg_replace(
'/:.*$/',
'',
$object->label);
592 $morehtmlref =
'<div class="refidno">';
593 $morehtmlref .= $langs->trans($labeltoshow);
594 $morehtmlref .=
'</div>';
596 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
599 print
'<div class="fichecenter">';
600 print
'<div class="fichehalfleft">';
602 print
'<div class="underbanner clearboth"></div>';
603 print
'<table class="border centpercent tableforfield">';
610 print
'<tr><td class="titlefieldmiddle">';
611 print $langs->trans(
'CronType').
"</td><td>";
612 print $formCron->select_typejob(
'jobtype',
$object->jobtype, 1);
615 print
'<tr class="blockmethod"><td>';
616 print $langs->trans(
'CronModule').
"</td><td>";
620 print
'<tr class="blockmethod"><td>';
621 print $langs->trans(
'CronClassFile').
"</td><td>";
625 print
'<tr class="blockmethod"><td>';
626 print $langs->trans(
'CronObject').
"</td><td>";
630 print
'<tr class="blockmethod"><td>';
631 print $langs->trans(
'CronMethod').
"</td><td>";
635 print
'<tr class="blockmethod"><td>';
636 print $langs->trans(
'CronArgs').
"</td><td>";
640 print
'<tr class="blockcommand"><td>';
641 print $langs->trans(
'CronCommand').
"</td><td>";
646 print $langs->trans(
'CronNote').
"</td><td>";
647 if (!is_null(
$object->note_private) &&
$object->note_private !=
'') {
648 print
'<div class="small lineheightsmall">'.$langs->trans(
$object->note_private).
'</div>';
652 print
'<tr class="blockemailalert"><td>';
653 print $langs->trans(
'EmailIfError').
"</td><td>";
659 print $langs->trans(
'Entity').
"</td><td>";
661 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$langs->trans(
"AllEntities");
664 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$mc->label;
672 print
'<div class="fichehalfright">';
674 print
'<div class="underbanner clearboth"></div>';
675 print
'<table class="border centpercent tableforfield">';
677 print
'<tr><td class="titlefieldmiddle">';
678 print $langs->trans(
'CronEvery').
"</td>";
680 print
img_picto(
'',
'recurring',
'class="pictofixedwidth"');
681 if (
$object->unitfrequency ==
"60") {
682 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Minutes');
684 if (
$object->unitfrequency ==
"3600") {
685 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Hours');
687 if (
$object->unitfrequency ==
"86400") {
688 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Days');
690 if (
$object->unitfrequency ==
"604800") {
691 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Weeks');
693 if (
$object->unitfrequency ==
"2678400") {
694 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Months');
700 print $langs->trans(
'CronPriority').
"</td>";
701 print
"<td>".$object->priority;
705 print $langs->trans(
'CronDtStart').
"</td><td>";
706 if (!empty(
$object->datestart)) {
707 print $form->textwithpicto(
dol_print_date(
$object->datestart,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
712 print $langs->trans(
'CronDtEnd').
"</td><td>";
713 if (!empty(
$object->dateend)) {
714 print $form->textwithpicto(
dol_print_date(
$object->dateend,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
719 print $langs->trans(
'CronMaxRun').
"</td>";
725 print $langs->trans(
'CronNbRun').
"</td>";
726 print
"<td>".$object->nbrun;
731 print $langs->trans(
'CronDtNextLaunch');
732 print
' ('.$langs->trans(
'CronFrom').
')';
735 print
img_picto(
'',
'object_calendarday').
' <span class="opacitymedium strikefordisabled">'.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone")).
'</span> ';
736 print $langs->trans(
"Disabled");
737 } elseif (!empty(
$object->datenextrun)) {
738 print
img_picto(
'',
'object_calendarday').
' '.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
740 print
'<span class="opacitymedium">'.$langs->trans(
'CronNone').
'</span>';
742 if (
$object->status == Cronjob::STATUS_ENABLED) {
757 print
'<div class="underbanner clearboth"></div>';
758 print
'<table class="border centpercent tableforfield">';
760 print
'<tr><td class="titlefieldmiddle">';
761 print $langs->trans(
'CronDtLastLaunch').
"</td><td>";
762 if (!empty(
$object->datelastrun)) {
763 print $form->textwithpicto(
dol_print_date(
$object->datelastrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
765 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
770 print $langs->trans(
'CronDtLastResult').
"</td><td>";
771 if (!empty(
$object->datelastresult)) {
772 print $form->textwithpicto(
dol_print_date(
$object->datelastresult,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
774 if (empty(
$object->datelastrun)) {
775 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
783 print $langs->trans(
'CronLastResult').
"</td><td>";
785 print
'<span class="error">';
794 print $langs->trans(
'CronLastOutput').
"</td><td>";
795 print
'<span class="small">'.(!empty(
$object->lastoutput) ? nl2br(
$object->lastoutput) :
'').
'</span>';
802 print
'<div class="clearboth"></div>';
808 print
"\n\n".
'<div class="tabsAction">'.
"\n";
809 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Edit").
'</a>';
811 if (!$permissiontoexecute) {
812 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"CronExecute").
'</a>';
813 } elseif (empty(
$object->status)) {
814 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"JobDisabled")).
'">'.$langs->trans(
"CronExecute").
'</a>';
816 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>';
820 print
'<a class="butAction butActionClone" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
823 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=activate&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusActiveBtn").
'</a>';
825 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=inactive&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
829 if (!$permissiontodelete) {
830 print
'<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Delete").
'</a>';
832 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.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
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.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.