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');
59if (!$user->hasRight(
'cron',
'create')) {
63$permissiontoadd = $user->hasRight(
'cron',
'create');
64$permissiontoexecute = $user->hasRight(
'cron',
'execute');
65$permissiontodelete = $user->hasRight(
'cron',
'delete');
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' && $permissiontoadd) {
157 $result =
$object->create($user);
170if ($action ==
'update' && $permissiontoadd) {
192 $result =
$object->update($user);
204if ($action ==
'activate' && $permissiontoadd) {
208 $result =
$object->update($user);
220if ($action ==
'inactive' && $permissiontoadd) {
225 $result =
$object->update($user);
238if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
239 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
244 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id :
$id));
245 if (is_object($result) || $result > 0) {
247 if (is_object($result)) {
248 $newid = $result->id;
252 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$newid);
266$form =
new Form($db);
273if ($action ==
'create') {
277if (
$conf->use_javascript_ajax) {
278 print
"\n".
'<script type="text/javascript">';
279 print
'jQuery(document).ready(function () {
280 function initfields()
282 if ($("#jobtype option:selected").val()==\'method\') {
283 $(".blockmethod").show();
284 $(".blockcommand").hide();
286 if ($("#jobtype option:selected").val()==\'command\') {
287 $(".blockmethod").hide();
288 $(".blockcommand").show();
292 jQuery("#jobtype").change(function() {
296 print
'</script>'.
"\n";
300if ($action ==
'delete') {
301 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"CronDelete"), $langs->trans(
"CronConfirmDelete"),
"confirm_delete",
'',
'', 1);
306if ($action ==
'execute') {
307 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&securitykey='.$securitykey, $langs->trans(
"CronExecute"), $langs->trans(
"CronConfirmExecute"),
"confirm_execute",
'',
'', 1);
313if ($action ==
'clone') {
315 $formquestion = array();
316 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
327if (empty(
$object->status) && $action !=
'create') {
331if (($action ==
"create") || ($action ==
"edit")) {
332 print
'<form name="cronform" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
333 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
334 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage').
'">'.
"\n";
336 print
'<input type="hidden" name="action" value="update">'.
"\n";
337 print
'<input type="hidden" name="id" value="'.$object->id.
'">'.
"\n";
339 print
'<input type="hidden" name="action" value="add">'.
"\n";
342 if ($action ==
"edit") {
348 print
'<table class="border centpercent">';
350 print
'<tr><td class="fieldrequired titlefieldcreate">';
351 print $langs->trans(
'CronLabel').
"</td>";
352 print
'<td><input type="text" class="width200" name="label" value="'.dol_escape_htmltag(
$object->label).
'"> ';
358 print
'<tr><td class="fieldrequired">';
359 print $langs->trans(
'CronType').
"</td><td>";
360 print $formCron->select_typejob(
'jobtype',
$object->jobtype);
366 print
'<tr class="blockmethod"><td>';
367 print $langs->trans(
'CronModule').
"</td><td>";
368 print
'<input type="text" class="width200" name="module_name" value="'.dol_escape_htmltag(
$object->module_name).
'"> ';
371 print $form->textwithpicto(
'', $langs->trans(
"CronModuleHelp"), 1,
'help');
375 print
'<tr class="blockmethod"><td>';
376 print $langs->trans(
'CronClassFile').
"</td><td>";
377 print
'<input type="text" class="minwidth300" name="classesname" value="'.dol_escape_htmltag(
$object->classesname).
'"> ';
380 print $form->textwithpicto(
'', $langs->trans(
"CronClassFileHelp"), 1,
'help');
384 print
'<tr class="blockmethod"><td>';
385 print $langs->trans(
'CronObject').
"</td><td>";
386 print
'<input type="text" class="width200" name="objectname" value="'.dol_escape_htmltag(
$object->objectname).
'"> ';
389 print $form->textwithpicto(
'', $langs->trans(
"CronObjectHelp"), 1,
'help');
393 print
'<tr class="blockmethod"><td>';
394 print $langs->trans(
'CronMethod').
"</td><td>";
395 print
'<input type="text" class="minwidth300" name="methodename" value="'.dol_escape_htmltag(
$object->methodename).
'" /> ';
398 print $form->textwithpicto(
'', $langs->trans(
"CronMethodHelp"), 1,
'help');
402 print
'<tr class="blockmethod"><td>';
403 print $langs->trans(
'CronArgs').
"</td><td>";
404 print
'<input type="text" class="quatrevingtpercent" name="params" value="'.$object->params.
'" /> ';
407 print $form->textwithpicto(
'', $langs->trans(
"CronArgsHelp"), 1,
'help');
411 print
'<tr class="blockcommand"><td>';
412 print $langs->trans(
'CronCommand').
"</td><td>";
413 print
'<input type="text" class="minwidth150" name="command" value="'.$object->command.
'" /> ';
416 print $form->textwithpicto(
'', $langs->trans(
"CronCommandHelp"), 1,
'help');
421 print $langs->trans(
'CronNote').
"</td><td>";
422 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 160,
'dolibarr_notes',
'In',
true,
false, 0, ROWS_4,
'90%');
423 $doleditor->Create();
429 print
'<tr class="blockemailalert"><td>';
430 print $langs->trans(
'EmailIfError').
"</td><td>";
431 print
'<input type="text" class="minwidth150" name="email_alert" value="'.dol_escape_htmltag(
$object->email_alert).
'" /> ';
438 print
'<tr><td class="fieldrequired">';
439 print $langs->trans(
'CronEvery').
"</td>";
441 print
'<select name="nbfrequency" id="nbfrequency" class="width50 maxwidth50imp">';
442 for ($i = 1; $i <= 60; $i++) {
443 if (
$object->frequency == $i) {
444 print
"<option value='".$i.
"' selected>".$i.
"</option>";
446 print
"<option value='".$i.
"'>".$i.
"</option>";
451 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
452 if (
$object->unitfrequency ==
"60") {
453 $input .=
' checked />';
457 $input .=
"<label for=\"frequency_minute\">".$langs->trans(
'Minutes').
"</label>";
460 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
461 if (
$object->unitfrequency ==
"3600") {
462 $input .=
' checked />';
466 $input .=
"<label for=\"frequency_heures\">".$langs->trans(
'Hours').
"</label>";
469 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
470 if (
$object->unitfrequency ==
"86400") {
471 $input .=
' checked />';
475 $input .=
"<label for=\"frequency_jours\">".$langs->trans(
'Days').
"</label>";
478 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
479 if (
$object->unitfrequency ==
"604800") {
480 $input .=
' checked />';
484 $input .=
"<label for=\"frequency_semaine\">".$langs->trans(
'Weeks').
"</label>";
487 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
488 if (
$object->unitfrequency ==
"2678400") {
489 $input .=
' checked />';
493 $input .=
'<label for="frequency_month">'.$langs->trans(
'Months').
"</label>";
503 print $langs->trans(
'CronPriority').
"</td>";
505 if (!empty(
$object->priority)) {
508 print
'<td><input type="text" class="width50" name="priority" value="'.$priority.
'" /> ';
515 print $langs->trans(
'CronDtStart').
"</td><td>";
516 if (!empty(
$object->datestart)) {
517 print $form->selectDate(
$object->datestart,
'datestart', 1, 1, 0,
"cronform");
519 print $form->selectDate(-1,
'datestart', 1, 1, 1,
"cronform");
527 print $langs->trans(
'CronDtEnd').
"</td><td>";
528 if (!empty(
$object->dateend)) {
529 print $form->selectDate(
$object->dateend,
'dateend', 1, 1, 0,
"cronform");
531 print $form->selectDate(-1,
'dateend', 1, 1, 1,
"cronform");
543 print $langs->trans(
'CronMaxRun').
"</td>";
544 print
'<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.
'" /> ';
550 print
'<tr><td class="fieldrequired">';
551 print $langs->trans(
'CronDtNextLaunch');
554 if (!empty(
$object->datenextrun)) {
555 print $form->selectDate(
$object->datenextrun,
'datenextrun', 1, 1, 0,
"cronform");
557 print $form->selectDate(-1,
'datenextrun', 1, 1, 0,
"cronform", 1, 1);
568 print $form->buttonsSaveCancel();
577 $linkback =
'<a href="'.DOL_URL_ROOT.
'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
580 if (preg_match(
'/:(.*)$/',
$object->label, $reg)) {
581 $langs->load($reg[1]);
584 $labeltoshow = preg_replace(
'/:.*$/',
'',
$object->label);
586 $morehtmlref =
'<div class="refidno">';
587 $morehtmlref .= $langs->trans($labeltoshow);
588 $morehtmlref .=
'</div>';
590 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
593 print
'<div class="fichecenter">';
594 print
'<div class="fichehalfleft">';
596 print
'<div class="underbanner clearboth"></div>';
597 print
'<table class="border centpercent tableforfield">';
604 print
'<tr><td class="titlefieldmiddle">';
605 print $langs->trans(
'CronType').
"</td><td>";
606 print $formCron->select_typejob(
'jobtype',
$object->jobtype, 1);
609 print
'<tr class="blockmethod"><td>';
610 print $langs->trans(
'CronModule').
"</td><td>";
614 print
'<tr class="blockmethod"><td>';
615 print $langs->trans(
'CronClassFile').
"</td><td>";
619 print
'<tr class="blockmethod"><td>';
620 print $langs->trans(
'CronObject').
"</td><td>";
624 print
'<tr class="blockmethod"><td>';
625 print $langs->trans(
'CronMethod').
"</td><td>";
629 print
'<tr class="blockmethod"><td>';
630 print $langs->trans(
'CronArgs').
"</td><td>";
634 print
'<tr class="blockcommand"><td>';
635 print $langs->trans(
'CronCommand').
"</td><td>";
640 print $langs->trans(
'CronNote').
"</td><td>";
641 if (!is_null(
$object->note_private) &&
$object->note_private !=
'') {
642 print
'<div class="small lineheightsmall">'.$langs->trans(
$object->note_private).
'</div>';
646 print
'<tr class="blockemailalert"><td>';
647 print $langs->trans(
'EmailIfError').
"</td><td>";
651 if (isModEnabled(
'multicompany')) {
653 print $langs->trans(
'Entity').
"</td><td>";
655 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$langs->trans(
"AllEntities");
658 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$mc->label;
666 print
'<div class="fichehalfright">';
668 print
'<div class="underbanner clearboth"></div>';
669 print
'<table class="border centpercent tableforfield">';
671 print
'<tr><td class="titlefieldmiddle">';
672 print $langs->trans(
'CronEvery').
"</td>";
674 if (
$object->unitfrequency ==
"60") {
675 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Minutes');
677 if (
$object->unitfrequency ==
"3600") {
678 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Hours');
680 if (
$object->unitfrequency ==
"86400") {
681 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Days');
683 if (
$object->unitfrequency ==
"604800") {
684 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Weeks');
686 if (
$object->unitfrequency ==
"2678400") {
687 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Months');
693 print $langs->trans(
'CronPriority').
"</td>";
694 print
"<td>".$object->priority;
698 print $langs->trans(
'CronDtStart').
"</td><td>";
699 if (!empty(
$object->datestart)) {
700 print $form->textwithpicto(
dol_print_date(
$object->datestart,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
705 print $langs->trans(
'CronDtEnd').
"</td><td>";
706 if (!empty(
$object->dateend)) {
707 print $form->textwithpicto(
dol_print_date(
$object->dateend,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
712 print $langs->trans(
'CronMaxRun').
"</td>";
718 print $langs->trans(
'CronNbRun').
"</td>";
719 print
"<td>".$object->nbrun;
724 print $langs->trans(
'CronDtNextLaunch');
725 print
' ('.$langs->trans(
'CronFrom').
')';
728 print
img_picto(
'',
'object_calendarday').
' <span class="opacitymedium strikefordisabled">'.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone")).
'</span> ';
729 print $langs->trans(
"Disabled");
730 } elseif (!empty(
$object->datenextrun)) {
731 print
img_picto(
'',
'object_calendarday').
' '.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
733 print
'<span class="opacitymedium">'.$langs->trans(
'CronNone').
'</span>';
735 if (
$object->status == Cronjob::STATUS_ENABLED) {
750 print
'<div class="underbanner clearboth"></div>';
751 print
'<table class="border centpercent tableforfield">';
753 print
'<tr><td class="titlefieldmiddle">';
754 print $langs->trans(
'CronDtLastLaunch').
"</td><td>";
755 if (!empty(
$object->datelastrun)) {
756 print $form->textwithpicto(
dol_print_date(
$object->datelastrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
758 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
763 print $langs->trans(
'CronDtLastResult').
"</td><td>";
764 if (!empty(
$object->datelastresult)) {
765 print $form->textwithpicto(
dol_print_date(
$object->datelastresult,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
767 if (empty(
$object->datelastrun)) {
768 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
776 print $langs->trans(
'CronLastResult').
"</td><td>";
778 print
'<span class="error">';
787 print $langs->trans(
'CronLastOutput').
"</td><td>";
788 print
'<span class="small">'.(!empty(
$object->lastoutput) ? nl2br(
$object->lastoutput) :
'').
'</span>';
795 print
'<div class="clearboth"></div>';
801 print
"\n\n".
'<div class="tabsAction">'.
"\n";
802 if (!$user->hasRight(
'cron',
'create')) {
803 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Edit").
'</a>';
805 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Edit").
'</a>';
808 if ((!$user->hasRight(
'cron',
'execute'))) {
809 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"CronExecute").
'</a>';
810 } elseif (empty(
$object->status)) {
811 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"JobDisabled")).
'">'.$langs->trans(
"CronExecute").
'</a>';
813 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 if (!$user->hasRight(
'cron',
'create')) {
817 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"CronStatusActiveBtn").
'/'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
819 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
822 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=activate&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusActiveBtn").
'</a>';
824 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=inactive&id='.
$object->id.
'">'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
828 if (!$user->hasRight(
'cron',
'delete')) {
829 print
'<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Delete").
'</a>';
831 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( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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_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_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.
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.