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';
39$langs->loadLangs(array(
'admin',
'cron',
'members',
'bills'));
42$action =
GETPOST(
'action',
'aZ09');
43$confirm =
GETPOST(
'confirm',
'alpha');
44$cancel =
GETPOST(
'cancel',
'alpha');
45$backtopage =
GETPOST(
'backtopage',
'alpha');
46$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
48$securitykey =
GETPOST(
'securitykey',
'alpha');
50if (!$user->hasRight(
'cron',
'create')) {
54$permissiontoadd = $user->hasRight(
'cron',
'create');
55$permissiontoexecute = $user->hasRight(
'cron',
'execute');
56$permissiontodelete = $user->hasRight(
'cron',
'delete');
72 if (!empty($id) && empty($backtopage)) {
76 header(
"Location: ".$backtopage);
78 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
85if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontodelete) {
86 $result =
$object->delete($user);
92 header(
"Location: ".DOL_URL_ROOT.
'/cron/list.php');
98if ($action ==
'confirm_execute' && $confirm ==
"yes" && $permissiontoexecute) {
104 $result =
$object->run_jobs($user->login);
109 $res =
$object->reprogram_jobs($user->login, $now);
125if ($action ==
'add' && $permissiontoadd) {
148 $result =
$object->create($user);
161if ($action ==
'update' && $permissiontoadd) {
183 $result =
$object->update($user);
195if ($action ==
'activate' && $permissiontoadd) {
199 $result =
$object->update($user);
211if ($action ==
'inactive' && $permissiontoadd) {
216 $result =
$object->update($user);
229if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
230 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
235 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id : $id));
236 if (is_object($result) || $result > 0) {
238 if (is_object($result)) {
239 $newid = $result->id;
243 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$newid);
258$form =
new Form($db);
265if ($action ==
'create') {
269if ($conf->use_javascript_ajax) {
270 print
"\n".
'<script type="text/javascript">';
271 print
'jQuery(document).ready(function () {
272 function initfields()
274 if ($("#jobtype option:selected").val()==\'method\') {
275 $(".blockmethod").show();
276 $(".blockcommand").hide();
278 if ($("#jobtype option:selected").val()==\'command\') {
279 $(".blockmethod").hide();
280 $(".blockcommand").show();
284 jQuery("#jobtype").change(function() {
288 print
'</script>'.
"\n";
292if ($action ==
'delete') {
293 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"CronDelete"), $langs->trans(
"CronConfirmDelete"),
"confirm_delete",
'',
'', 1);
298if ($action ==
'execute') {
299 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&securitykey='.$securitykey, $langs->trans(
"CronExecute"), $langs->trans(
"CronConfirmExecute"),
"confirm_execute",
'',
'', 1);
305if ($action ==
'clone') {
307 $formquestion = array();
308 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
319if (empty(
$object->status) && $action !=
'create') {
323if (($action ==
"create") || ($action ==
"edit")) {
324 print
'<form name="cronform" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
325 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
326 print
'<input type="hidden" name="backtopage" value="'.GETPOST(
'backtopage').
'">'.
"\n";
328 print
'<input type="hidden" name="action" value="update">'.
"\n";
329 print
'<input type="hidden" name="id" value="'.$object->id.
'">'.
"\n";
331 print
'<input type="hidden" name="action" value="add">'.
"\n";
334 if ($action ==
"edit") {
340 print
'<table class="border centpercent">';
342 print
'<tr><td class="fieldrequired titlefieldcreate">';
343 print $langs->trans(
'CronLabel').
"</td>";
344 print
'<td><input type="text" class="width200" name="label" value="'.dol_escape_htmltag(
$object->label).
'"> ';
350 print
'<tr><td class="fieldrequired">';
351 print $langs->trans(
'CronType').
"</td><td>";
352 print $formCron->select_typejob(
'jobtype',
$object->jobtype);
358 print
'<tr class="blockmethod"><td>';
359 print $langs->trans(
'CronModule').
"</td><td>";
360 print
'<input type="text" class="width200" name="module_name" value="'.dol_escape_htmltag(
$object->module_name).
'"> ';
363 print $form->textwithpicto(
'', $langs->trans(
"CronModuleHelp"), 1,
'help');
367 print
'<tr class="blockmethod"><td>';
368 print $langs->trans(
'CronClassFile').
"</td><td>";
369 print
'<input type="text" class="minwidth300" name="classesname" value="'.dol_escape_htmltag(
$object->classesname).
'"> ';
372 print $form->textwithpicto(
'', $langs->trans(
"CronClassFileHelp"), 1,
'help');
376 print
'<tr class="blockmethod"><td>';
377 print $langs->trans(
'CronObject').
"</td><td>";
378 print
'<input type="text" class="width200" name="objectname" value="'.dol_escape_htmltag(
$object->objectname).
'"> ';
381 print $form->textwithpicto(
'', $langs->trans(
"CronObjectHelp"), 1,
'help');
385 print
'<tr class="blockmethod"><td>';
386 print $langs->trans(
'CronMethod').
"</td><td>";
387 print
'<input type="text" class="minwidth300" name="methodename" value="'.dol_escape_htmltag(
$object->methodename).
'" /> ';
390 print $form->textwithpicto(
'', $langs->trans(
"CronMethodHelp"), 1,
'help');
394 print
'<tr class="blockmethod"><td>';
395 print $langs->trans(
'CronArgs').
"</td><td>";
396 print
'<input type="text" class="quatrevingtpercent" name="params" value="'.$object->params.
'" /> ';
399 print $form->textwithpicto(
'', $langs->trans(
"CronArgsHelp"), 1,
'help');
403 print
'<tr class="blockcommand"><td>';
404 print $langs->trans(
'CronCommand').
"</td><td>";
405 print
'<input type="text" class="minwidth150" name="command" value="'.$object->command.
'" /> ';
408 print $form->textwithpicto(
'', $langs->trans(
"CronCommandHelp"), 1,
'help');
413 print $langs->trans(
'CronNote').
"</td><td>";
414 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 160,
'dolibarr_notes',
'In',
true,
false, 0, ROWS_4,
'90%');
415 $doleditor->Create();
421 print
'<tr class="blockemailalert"><td>';
422 print $langs->trans(
'EmailIfError').
"</td><td>";
423 print
'<input type="text" class="minwidth150" name="email_alert" value="'.dol_escape_htmltag(
$object->email_alert).
'" /> ';
430 print
'<tr><td class="fieldrequired">';
431 print $langs->trans(
'CronEvery').
"</td>";
433 print
'<select name="nbfrequency">';
434 for ($i = 1; $i <= 60; $i++) {
435 if (
$object->frequency == $i) {
436 print
"<option value='".$i.
"' selected>".$i.
"</option>";
438 print
"<option value='".$i.
"'>".$i.
"</option>";
442 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
443 if (
$object->unitfrequency ==
"60") {
444 $input .=
' checked />';
448 $input .=
"<label for=\"frequency_minute\">".$langs->trans(
'Minutes').
"</label>";
451 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
452 if (
$object->unitfrequency ==
"3600") {
453 $input .=
' checked />';
457 $input .=
"<label for=\"frequency_heures\">".$langs->trans(
'Hours').
"</label>";
460 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
461 if (
$object->unitfrequency ==
"86400") {
462 $input .=
' checked />';
466 $input .=
"<label for=\"frequency_jours\">".$langs->trans(
'Days').
"</label>";
469 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"604800\" id=\"frequency_semaine\" ";
470 if (
$object->unitfrequency ==
"604800") {
471 $input .=
' checked />';
475 $input .=
"<label for=\"frequency_semaine\">".$langs->trans(
'Weeks').
"</label>";
478 $input =
" <input type=\"radio\" name=\"unitfrequency\" value=\"2678400\" id=\"frequency_month\" ";
479 if (
$object->unitfrequency ==
"2678400") {
480 $input .=
' checked />';
484 $input .=
'<label for="frequency_month">'.$langs->trans(
'Months').
"</label>";
494 print $langs->trans(
'CronPriority').
"</td>";
496 if (!empty(
$object->priority)) {
499 print
'<td><input type="text" class="width50" name="priority" value="'.$priority.
'" /> ';
506 print $langs->trans(
'CronDtStart').
"</td><td>";
507 if (!empty(
$object->datestart)) {
508 print $form->selectDate(
$object->datestart,
'datestart', 1, 1, 0,
"cronform");
510 print $form->selectDate(-1,
'datestart', 1, 1, 1,
"cronform");
518 print $langs->trans(
'CronDtEnd').
"</td><td>";
519 if (!empty(
$object->dateend)) {
520 print $form->selectDate(
$object->dateend,
'dateend', 1, 1, 0,
"cronform");
522 print $form->selectDate(-1,
'dateend', 1, 1, 1,
"cronform");
534 print $langs->trans(
'CronMaxRun').
"</td>";
535 print
'<td><input type="text" class="width50" name="maxrun" value="'.$maxrun.
'" /> ';
541 print
'<tr><td class="fieldrequired">';
542 print $langs->trans(
'CronDtNextLaunch');
545 if (!empty(
$object->datenextrun)) {
546 print $form->selectDate(
$object->datenextrun,
'datenextrun', 1, 1, 0,
"cronform");
548 print $form->selectDate(-1,
'datenextrun', 1, 1, 0,
"cronform", 1, 1);
559 print $form->buttonsSaveCancel();
570 $linkback =
'<a href="'.DOL_URL_ROOT.
'/cron/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
573 if (preg_match(
'/:(.*)$/',
$object->label, $reg)) {
574 $langs->load($reg[1]);
577 $labeltoshow = preg_replace(
'/:.*$/',
'',
$object->label);
579 $morehtmlref =
'<div class="refidno">';
580 $morehtmlref .= $langs->trans($labeltoshow);
581 $morehtmlref .=
'</div>';
583 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
586 print
'<div class="fichecenter">';
587 print
'<div class="fichehalfleft">';
589 print
'<div class="underbanner clearboth"></div>';
590 print
'<table class="border centpercent tableforfield">';
597 print
'<tr><td class="titlefieldmiddle">';
598 print $langs->trans(
'CronType').
"</td><td>";
599 print $formCron->select_typejob(
'jobtype',
$object->jobtype, 1);
602 print
'<tr class="blockmethod"><td>';
603 print $langs->trans(
'CronModule').
"</td><td>";
607 print
'<tr class="blockmethod"><td>';
608 print $langs->trans(
'CronClassFile').
"</td><td>";
612 print
'<tr class="blockmethod"><td>';
613 print $langs->trans(
'CronObject').
"</td><td>";
617 print
'<tr class="blockmethod"><td>';
618 print $langs->trans(
'CronMethod').
"</td><td>";
622 print
'<tr class="blockmethod"><td>';
623 print $langs->trans(
'CronArgs').
"</td><td>";
627 print
'<tr class="blockcommand"><td>';
628 print $langs->trans(
'CronCommand').
"</td><td>";
633 print $langs->trans(
'CronNote').
"</td><td>";
634 if (!is_null(
$object->note_private) &&
$object->note_private !=
'') {
635 print
'<span class="small">'.$langs->trans(
$object->note_private).
'</small>';
639 print
'<tr class="blockemailalert"><td>';
640 print $langs->trans(
'EmailIfError').
"</td><td>";
644 if (isModEnabled(
'multicompany')) {
646 print $langs->trans(
'Entity').
"</td><td>";
648 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$langs->trans(
"AllEntities");
651 print
img_picto($langs->trans(
"AllEntities"),
'entity',
'class="pictofixedwidth"').$mc->label;
659 print
'<div class="fichehalfright">';
661 print
'<div class="underbanner clearboth"></div>';
662 print
'<table class="border centpercent tableforfield">';
664 print
'<tr><td class="titlefieldmiddle">';
665 print $langs->trans(
'CronEvery').
"</td>";
667 if (
$object->unitfrequency ==
"60") {
668 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Minutes');
670 if (
$object->unitfrequency ==
"3600") {
671 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Hours');
673 if (
$object->unitfrequency ==
"86400") {
674 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Days');
676 if (
$object->unitfrequency ==
"604800") {
677 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Weeks');
679 if (
$object->unitfrequency ==
"2678400") {
680 print $langs->trans(
'CronEach').
" ".(
$object->frequency).
" ".$langs->trans(
'Months');
686 print $langs->trans(
'CronPriority').
"</td>";
687 print
"<td>".$object->priority;
691 print $langs->trans(
'CronDtStart').
"</td><td>";
692 if (!empty(
$object->datestart)) {
693 print $form->textwithpicto(
dol_print_date(
$object->datestart,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
698 print $langs->trans(
'CronDtEnd').
"</td><td>";
699 if (!empty(
$object->dateend)) {
700 print $form->textwithpicto(
dol_print_date(
$object->dateend,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
705 print $langs->trans(
'CronMaxRun').
"</td>";
711 print $langs->trans(
'CronNbRun').
"</td>";
712 print
"<td>".$object->nbrun;
717 print $langs->trans(
'CronDtNextLaunch');
718 print
' ('.$langs->trans(
'CronFrom').
')';
721 print
img_picto(
'',
'object_calendarday').
' <span class="opacitymedium strikefordisabled">'.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone")).
'</span> ';
722 print $langs->trans(
"Disabled");
723 } elseif (!empty(
$object->datenextrun)) {
724 print
img_picto(
'',
'object_calendarday').
' '.$form->textwithpicto(
dol_print_date(
$object->datenextrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
726 print
'<span class="opacitymedium">'.$langs->trans(
'CronNone').
'</span>';
728 if (
$object->status == Cronjob::STATUS_ENABLED) {
743 print
'<div class="underbanner clearboth"></div>';
744 print
'<table class="border centpercent tableforfield">';
746 print
'<tr><td class="titlefieldmiddle">';
747 print $langs->trans(
'CronDtLastLaunch').
"</td><td>";
748 if (!empty(
$object->datelastrun)) {
749 print $form->textwithpicto(
dol_print_date(
$object->datelastrun,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
751 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
756 print $langs->trans(
'CronDtLastResult').
"</td><td>";
757 if (!empty(
$object->datelastresult)) {
758 print $form->textwithpicto(
dol_print_date(
$object->datelastresult,
'dayhoursec'), $langs->trans(
"CurrentTimeZone"));
760 if (empty(
$object->datelastrun)) {
761 print
'<span class="opacitymedium">'.$langs->trans(
'CronNotYetRan').
'</span>';
769 print $langs->trans(
'CronLastResult').
"</td><td>";
771 print
'<span class="error">';
780 print $langs->trans(
'CronLastOutput').
"</td><td>";
781 print
'<span class="small">'.(!empty(
$object->lastoutput) ? nl2br(
$object->lastoutput) :
'').
'</span>';
788 print
'<div class="clearboth"></div>';
794 print
"\n\n".
'<div class="tabsAction">'.
"\n";
795 if (!$user->hasRight(
'cron',
'create')) {
796 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Edit").
'</a>';
798 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Edit").
'</a>';
801 if ((!$user->hasRight(
'cron',
'execute'))) {
802 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"CronExecute").
'</a>';
803 } elseif (empty(
$object->status)) {
804 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"JobDisabled")).
'">'.$langs->trans(
"CronExecute").
'</a>';
806 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>';
809 if (!$user->hasRight(
'cron',
'create')) {
810 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"CronStatusActiveBtn").
'/'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
812 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=clone&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
815 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=activate&token='.
newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"CronStatusActiveBtn").
'</a>';
817 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=inactive&id='.
$object->id.
'">'.$langs->trans(
"CronStatusInactiveBtn").
'</a>';
821 if (!$user->hasRight(
'cron',
'delete')) {
822 print
'<a class="butActionDeleteRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions")).
'">'.$langs->trans(
"Delete").
'</a>';
824 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()
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.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return 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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.