--- /tmp/dsg/dolibarr/htdocs/cron/github_card.php +++ /tmp/dsg/dolibarr/htdocs/cron/client_card.php @@ -39,12 +39,10 @@ if (!$user->rights->cron->create) accessforbidden(); $id = GETPOST('id', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); - +$backtourl = GETPOST('backtourl', 'alpha'); $securitykey = GETPOST('securitykey', 'alpha'); @@ -64,18 +62,22 @@ if (!empty($cancel)) { - if (!empty($id) && empty($backtopage)) + if (!empty($id) && empty($backtourl)) { $action = ''; - } else { - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: ".DOL_URL_ROOT.'/cron/list.php'); - exit; - } + } + else + { + if ($backtourl) + { + header("Location: ".$backtourl); + exit; + } + else + { + header("Location: ".DOL_URL_ROOT.'/cron/list.php'); + exit; + } } } @@ -88,7 +90,9 @@ { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; - } else { + } + else + { Header("Location: ".DOL_URL_ROOT.'/cron/list.php'); exit; } @@ -97,50 +101,56 @@ // Execute jobs if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) { - if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) - { - setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); - $action = ''; - } else { - $now = dol_now(); // Date we start - - $result = $object->run_jobs($user->login); - - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - $res = $object->reprogram_jobs($user->login, $now); - if ($res > 0) - { - if ($object->lastresult > 0) setEventMessages($langs->trans("JobFinished"), null, 'warnings'); - else setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); - $action = ''; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } - } - } + if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) + { + setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); + $action = ''; + } + else + { + $now = dol_now(); // Date we start + + $result = $object->run_jobs($user->login); + + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + else + { + $res = $object->reprogram_jobs($user->login, $now); + if ($res > 0) + { + if ($object->lastresult > 0) setEventMessages($langs->trans("JobFinished"), null, 'warnings'); + else setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); + $action = ''; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + } + } } if ($action == 'add') { - $object->jobtype = GETPOST('jobtype'); - $object->label = GETPOST('label'); - $object->command = GETPOST('command'); - $object->classesname = GETPOST('classesname', 'alphanohtml'); - $object->objectname = GETPOST('objectname', 'aZ09'); - $object->methodename = GETPOST('methodename', 'aZ09'); + $object->jobtype = GETPOST('jobtype', 'alpha'); + $object->label = GETPOST('label', 'alpha'); + $object->command = GETPOST('command', 'alpha'); + $object->priority = GETPOST('priority', 'int'); + $object->classesname = GETPOST('classesname', 'alpha'); + $object->objectname = GETPOST('objectname', 'alpha'); + $object->methodename = GETPOST('methodename', 'alpha'); $object->params = GETPOST('params'); $object->md5params = GETPOST('md5params'); - $object->module_name = GETPOST('module_name'); - $object->note_private = GETPOST('note', 'restricthtml'); + $object->module_name = GETPOST('module_name', 'alpha'); + $object->note = GETPOST('note', 'none'); $object->datestart = dol_mktime(GETPOST('datestarthour', 'int'), GETPOST('datestartmin', 'int'), 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); $object->dateend = dol_mktime(GETPOST('dateendhour', 'int'), GETPOST('dateendmin', 'int'), 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); - $object->priority = GETPOST('priority', 'int'); $object->datenextrun = dol_mktime(GETPOST('datenextrunhour', 'int'), GETPOST('datenextrunmin', 'int'), 0, GETPOST('datenextrunmonth', 'int'), GETPOST('datenextrunday', 'int'), GETPOST('datenextrunyear', 'int')); $object->unitfrequency = GETPOST('unitfrequency', 'int'); $object->frequency = GETPOST('nbfrequency', 'int'); @@ -153,7 +163,8 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; - } else { + } + else { setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs'); $action = ''; } @@ -166,16 +177,16 @@ $object->jobtype = GETPOST('jobtype'); $object->label = GETPOST('label'); $object->command = GETPOST('command'); - $object->classesname = GETPOST('classesname', 'alphanohtml'); - $object->objectname = GETPOST('objectname', 'aZ09'); - $object->methodename = GETPOST('methodename', 'aZ09'); + $object->classesname = GETPOST('classesname', 'alpha'); + $object->priority = GETPOST('priority', 'int'); + $object->objectname = GETPOST('objectname', 'alpha'); + $object->methodename = GETPOST('methodename', 'alpha'); $object->params = GETPOST('params'); $object->md5params = GETPOST('md5params'); - $object->module_name = GETPOST('module_name'); - $object->note_private = GETPOST('note', 'restricthtml'); + $object->module_name = GETPOST('module_name', 'alpha'); + $object->note = GETPOST('note', 'none'); $object->datestart = dol_mktime(GETPOST('datestarthour', 'int'), GETPOST('datestartmin', 'int'), 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); $object->dateend = dol_mktime(GETPOST('dateendhour', 'int'), GETPOST('dateendmin', 'int'), 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); - $object->priority = GETPOST('priority', 'int'); $object->datenextrun = dol_mktime(GETPOST('datenextrunhour', 'int'), GETPOST('datenextrunmin', 'int'), 0, GETPOST('datenextrunmonth', 'int'), GETPOST('datenextrunday', 'int'), GETPOST('datenextrunyear', 'int')); $object->unitfrequency = GETPOST('unitfrequency', 'int'); $object->frequency = GETPOST('nbfrequency', 'int'); @@ -188,7 +199,8 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; - } else { + } + else { setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs'); $action = ''; } @@ -205,7 +217,8 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; - } else { + } + else { setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs'); $action = ''; } @@ -223,7 +236,8 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; - } else { + } + else { setEventMessages($langs->trans('CronSaveSucess'), null, 'mesgs'); $action = ''; } @@ -243,7 +257,8 @@ if ($action == 'edit' || empty($action) || $action == 'delete' || $action == 'execute') { $head = cron_prepare_head($object); -} elseif ($action == 'create') +} +elseif ($action == 'create') { print load_fiche_titre($langs->trans("CronTask"), '', 'title_setup'); } @@ -299,7 +314,7 @@ { print '
'; print ''."\n"; - print ''."\n"; + print ''."\n"; if (!empty($object->id)) { print ''."\n"; print ''."\n"; @@ -307,8 +322,8 @@ print ''."\n"; } - if ($action == "edit") print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'cron'); - else print dol_get_fiche_head(''); + if ($action == "edit") dol_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'cron'); + else dol_fiche_head(''); print ''; @@ -384,7 +399,7 @@ print '"; print ""; print ""; print ""; $priority = 0; if (!empty($object->priority)) { - $priority = $object->priority; + $priority = $object->priority; } print ""; @@ -486,7 +510,7 @@ print '"; print ""; - print ""; + print ""; print ""; print '
'; print $langs->trans('CronNote').""; - $doleditor = new DolEditor('note', $object->note_private, '', 160, 'dolibarr_notes', 'In', true, false, 0, ROWS_4, '90%'); + $doleditor = new DolEditor('note', $object->note, '', 160, 'dolibarr_notes', 'In', true, false, 0, ROWS_4, '90%'); $doleditor->Create(); print ""; @@ -397,47 +412,53 @@ print '"; $input = " unitfrequency == "60") { - $input .= ' checked />'; - } else { - $input .= ' />'; + $input .= ' checked />'; + } + else { + $input .= ' />'; } $input .= ""; print $input; $input = " unitfrequency == "3600") { - $input .= ' checked />'; - } else { - $input .= ' />'; + $input .= ' checked />'; + } + else { + $input .= ' />'; } $input .= ""; print $input; $input = " unitfrequency == "86400") { - $input .= ' checked />'; - } else { - $input .= ' />'; + $input .= ' checked />'; + } + else { + $input .= ' />'; } $input .= ""; print $input; $input = " unitfrequency == "604800") { - $input .= ' checked />'; - } else { - $input .= ' />'; + $input .= ' checked />'; + } + else { + $input .= ' />'; } $input .= ""; print $input; @@ -450,9 +471,11 @@ print $langs->trans('CronDtStart').""; if (!empty($object->datestart)) { - print $form->selectDate($object->datestart, 'datestart', 1, 1, '', "cronform"); - } else { - print $form->selectDate('', 'datestart', 1, 1, '', "cronform"); + print $form->selectDate($object->datestart, 'datestart', 1, 1, '', "cronform"); + } + else + { + print $form->selectDate('', 'datestart', 1, 1, '', "cronform"); } print ""; @@ -462,9 +485,10 @@ print "
"; print $langs->trans('CronDtEnd').""; if (!empty($object->dateend)) { - print $form->selectDate($object->dateend, 'dateend', 1, 1, '', "cronform"); - } else { - print $form->selectDate(-1, 'dateend', 1, 1, 1, "cronform"); + print $form->selectDate($object->dateend, 'dateend', 1, 1, '', "cronform"); + } + else { + print $form->selectDate(-1, 'dateend', 1, 1, 1, "cronform"); } print ""; @@ -475,7 +499,7 @@ print $langs->trans('CronPriority')." "; print "
'; $maxrun = ''; if (!empty($object->maxrun)) { - $maxrun = $object->maxrun; + $maxrun = $object->maxrun; } print $langs->trans('CronMaxRun')." "; @@ -501,33 +525,37 @@ print ""; if (!empty($object->datenextrun)) { - print $form->selectDate($object->datenextrun, 'datenextrun', 1, 1, '', "cronform"); - } else { - print $form->selectDate(-1, 'datenextrun', 1, 1, '', "cronform"); - } - print ""; + print $form->selectDate($object->datenextrun, 'datenextrun', 1, 1, '', "cronform"); + } + else + { + print $form->selectDate(-1, 'datenextrun', 1, 1, '', "cronform"); + } + print ""; print "
'; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print "
"; print "
\n"; -} else { +} +else +{ /* * view card */ - $now = dol_now(); - - print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron'); + $now = dol_now(); + + dol_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron'); $linkback = ''.$langs->trans("BackToList").''; @@ -583,9 +611,7 @@ print ''; print $langs->trans('CronNote').""; - if (!is_null($object->note_private) && $object->note_private != '') { - print $langs->trans($object->note_private); - } + print $langs->trans($object->note); print ""; if (!empty($conf->multicompany->enabled)) @@ -595,7 +621,9 @@ if (!$object->entity) { print $langs->trans("AllEntities"); - } else { + } + else + { $mc->getInfo($object->entity); print $mc->label; } @@ -603,7 +631,7 @@ } print ''; - print ''; + print ''; print '
'; @@ -623,12 +651,12 @@ print ''; print $langs->trans('CronDtStart').""; - if (!empty($object->datestart)) {print $form->textwithpicto(dol_print_date($object->datestart, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } + if (!empty($object->datestart)) {print dol_print_date($object->datestart, 'dayhoursec'); } print ""; print ""; print $langs->trans('CronDtEnd').""; - if (!empty($object->dateend)) {print $form->textwithpicto(dol_print_date($object->dateend, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } + if (!empty($object->dateend)) {print dol_print_date($object->dateend, 'dayhoursec'); } print ""; print ""; @@ -653,7 +681,8 @@ print ' ('.$langs->trans('CronFrom').')'; print ""; if (!$object->status) print $langs->trans("Disabled"); - elseif (!empty($object->datenextrun)) { print img_picto('', 'object_calendarday').' '.$form->textwithpicto(dol_print_date($object->datenextrun, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } else { print $langs->trans('CronNone'); } + elseif (!empty($object->datenextrun)) { print img_picto('', 'object_calendarday').' '.dol_print_date($object->datenextrun, 'dayhoursec'); } + else { print $langs->trans('CronNone'); } if ($object->status == Cronjob::STATUS_ENABLED) { if ($object->maxrun && $object->nbrun >= $object->maxrun) print img_warning($langs->trans("MaxRunReached")); @@ -672,12 +701,12 @@ print ''; print $langs->trans('CronDtLastLaunch').""; - if (!empty($object->datelastrun)) {print $form->textwithpicto(dol_print_date($object->datelastrun, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } else {print $langs->trans('CronNone'); } + if (!empty($object->datelastrun)) {print dol_print_date($object->datelastrun, 'dayhoursec'); } else {print $langs->trans('CronNone'); } print ""; print ''; print $langs->trans('CronDtLastResult').""; - if (!empty($object->datelastresult)) {print $form->textwithpicto(dol_print_date($object->datelastresult, 'dayhoursec'), $langs->trans("CurrentTimeZone")); } else {print $langs->trans('CronNone'); } + if (!empty($object->datelastresult)) {print dol_print_date($object->datelastresult, 'dayhoursec'); } else {print $langs->trans('CronNone'); } print ""; print ''; @@ -693,9 +722,9 @@ print ""; print ''; - print ''; - - print dol_get_fiche_end(); + print ''; + + dol_fiche_end(); print "\n\n
\n"; @@ -708,27 +737,29 @@ if ((empty($user->rights->cron->execute))) { print ''.$langs->trans("CronExecute").''; - } elseif (empty($object->status)) + } + elseif (empty($object->status)) { print ''.$langs->trans("CronExecute").''; + } + else { + print ''.$langs->trans("CronExecute").''; + } + + if (!$user->rights->cron->create) { + print ''.$langs->trans("CronStatusActiveBtn").'/'.$langs->trans("CronStatusInactiveBtn").''; } else { - print ''.$langs->trans("CronExecute").''; - } - - if (!$user->rights->cron->create) { - print ''.$langs->trans("CronStatusActiveBtn").'/'.$langs->trans("CronStatusInactiveBtn").''; - } else { - if (empty($object->status)) { - print ''.$langs->trans("CronStatusActiveBtn").''; - } else { - print ''.$langs->trans("CronStatusInactiveBtn").''; - } + if (empty($object->status)) { + print ''.$langs->trans("CronStatusActiveBtn").''; + } else { + print ''.$langs->trans("CronStatusInactiveBtn").''; + } } if (!$user->rights->cron->delete) { print ''.$langs->trans("Delete").''; } else { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } print '
'; --- /tmp/dsg/dolibarr/htdocs/cron/github_info.php +++ /tmp/dsg/dolibarr/htdocs/cron/client_info.php @@ -48,7 +48,7 @@ $head = cron_prepare_head($object); -print dol_get_fiche_head($head, 'info', $langs->trans("CronTask"), -1, 'cron'); +dol_fiche_head($head, 'info', $langs->trans("CronTask"), -1, 'cron'); $linkback = ''.$langs->trans("BackToList").''; --- /tmp/dsg/dolibarr/htdocs/cron/github_list.php +++ /tmp/dsg/dolibarr/htdocs/cron/client_list.php @@ -36,7 +36,7 @@ if (!$user->rights->cron->read) accessforbidden(); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list @@ -55,12 +55,10 @@ if (!$sortfield) $sortfield = 't.status,t.priority'; if (!$sortorder) $sortorder = 'DESC,ASC'; -$mode = GETPOST('mode', 'aZ09'); +$search_status = (GETPOSTISSET('search_status') ?GETPOST('search_status', 'int') : GETPOST('status', 'int')); + //Search criteria -$search_status = (GETPOSTISSET('search_status') ?GETPOST('search_status', 'int') : GETPOST('status', 'int')); $search_label = GETPOST("search_label", 'alpha'); -$search_module_name = GETPOST("search_module_name", 'alpha'); -$search_lastresult = GETPOST("search_lastresult", "alpha"); $securitykey = GETPOST('securitykey', 'alpha'); $diroutputmassaction = $conf->cronjob->dir_output.'/temp/massgeneration/'.$user->id; @@ -99,7 +97,6 @@ { $search_label = ''; $search_status = -1; - $search_lastresult = ''; $toselect = ''; $search_array_options = array(); } @@ -131,47 +128,51 @@ // Execute jobs if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) { - if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) - { - setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); - $action = ''; - } else { - $object = new Cronjob($db); - $job = $object->fetch($id); - - $now = dol_now(); // Date we start - - $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK - if ($resrunjob < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - - // Programm next run - $res = $object->reprogram_jobs($user->login, $now); - if ($res > 0) - { - if ($resrunjob >= 0) // We show the result of reprogram only if no error message already reported - { - if ($object->lastresult >= 0) setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); - else setEventMessages($langs->trans("JobFinished"), null, 'errors'); - } - $action = ''; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } - - $param = '&search_status='.urlencode($search_status); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_label) $param .= '&search_label='.urlencode($search_label); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - - header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); // Make a redirect to avoid to run twice the job when using back - exit; - } + if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) + { + setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); + $action = ''; + } + else + { + $object = new Cronjob($db); + $job = $object->fetch($id); + + $now = dol_now(); // Date we start + + $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK + if ($resrunjob < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + // Programm next run + $res = $object->reprogram_jobs($user->login, $now); + if ($res > 0) + { + if ($resrunjob >= 0) // We show the result of reprogram only if no error message already reported + { + if ($object->lastresult >= 0) setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); + else setEventMessages($langs->trans("JobFinished"), null, 'errors'); + } + $action = ''; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + + $param = '&search_status='.urlencode($search_status); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); // Make a redirect to avoid to run twice the job when using back + exit; + } } // Mass actions @@ -195,7 +196,9 @@ elseif ($massaction == 'enable') $result = $tmpcron->setStatut(Cronjob::STATUS_ENABLED); //else dol_print_error($db, 'Bad value for massaction'); if ($result < 0) setEventMessages($tmpcron->error, $tmpcron->errors, 'errors'); - } else { + } + else + { $error++; } } @@ -213,6 +216,7 @@ $pagetitle = $langs->trans("CronList"); llxHeader('', $pagetitle); + $sql = "SELECT"; $sql .= " t.rowid,"; @@ -249,7 +253,6 @@ $sql .= " FROM ".MAIN_DB_PREFIX."cronjob as t"; $sql .= " WHERE entity IN (0,".$conf->entity.")"; if ($search_status >= 0 && $search_status < 2 && $search_status != '') $sql .= " AND t.status = ".(empty($search_status) ? '0' : '1'); -if ($search_lastresult != '') $sql .= natural_search("t.lastresult", $search_lastresult, 1); //Manage filter if (is_array($filter) && count($filter) > 0) { foreach ($filter as $key => $value) { @@ -257,8 +260,8 @@ } } $sqlwhere = array(); -if (!empty($search_module_name)) { - $sqlwhere[] = '(t.module_name='.$db->escape($search_module_name).')'; +if (!empty($module_name)) { + $sqlwhere[] = '(t.module_name='.$db->escape($module_name).')'; } if (count($sqlwhere) > 0) { $sql .= " WHERE ".implode(' AND ', $sqlwhere); @@ -276,13 +279,13 @@ $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -299,9 +302,6 @@ if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($search_status) $param .= '&search_status='.urlencode($search_status); if ($search_label) $param .= '&search_label='.urlencode($search_label); -if ($search_module_name) $param .= '&search_module_name='.urlencode($search_module_name); -if ($search_lastresult) $param .= '&search_lastresult='.urlencode($search_lastresult); -if ($mode) $param .= '&mode='.urlencode($mode); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -328,13 +328,6 @@ if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -if ($mode == 'modulesetup') { - $linkback = ''.$langs->trans("BackToModuleList").''; - print load_fiche_titre($langs->trans("CronSetup"), $linkback, 'title_setup'); - - // Configuration header - $head = cronadmin_prepare_head(); -} print '
'."\n"; if ($optioncss != '') print ''; @@ -345,28 +338,22 @@ print ''; print ''; print ''; -print ''; // Line with explanation and button new -$newcardbutton = dolGetButtonTitle($langs->trans('New'), $langs->trans('CronCreateJob'), 'fa fa-plus-circle', DOL_URL_ROOT.'/cron/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?mode=modulesetup'), '', $user->rights->cron->create); - - -if ($mode == 'modulesetup') { - print dol_get_fiche_head($head, 'jobs', $langs->trans("Module2300Name"), -1, 'cron'); - - //print ''.$langs->trans('CronInfo').'
'; -} - - -print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, ($mode == 'modulesetup' ? '' : 'title_setup'), 0, $newcardbutton, '', $limit); - +$newcardbutton = dolGetButtonTitle($langs->trans('New'), $langs->trans('CronCreateJob'), 'fa fa-plus-circle', DOL_URL_ROOT.'/cron/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->cron->create); + + +print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_setup', 0, $newcardbutton, '', $limit); + + +print ''.$langs->trans('CronInfo').'
'; $text = $langs->trans("HoursOnThisPageAreOnServerTZ").' '.$stringcurrentdate.'
'; if (!empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text .= $langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS); print info_admin($text); print '
'; -//$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = ''; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); @@ -377,7 +364,7 @@ print ''; print ' '; print ''; -print ''; +print ''; print ''; print ' '; print ' '; @@ -387,11 +374,12 @@ print ' '; print ' '; print ' '; -print ''; +print ' '; +print ' '; print ' '; print ' '; print ''; -print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1); +print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled")), $search_status, 1); print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; @@ -406,6 +394,7 @@ print_liste_field_titre("CronFrequency", '', "", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("CronDtStart", $_SERVER["PHP_SELF"], "t.datestart", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("CronDtEnd", $_SERVER["PHP_SELF"], "t.dateend", "", $param, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre("CronMaxRun", $_SERVER["PHP_SELF"], "t.maxrun", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("CronNbRun", $_SERVER["PHP_SELF"], "t.nbrun", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("CronDtLastLaunch", $_SERVER["PHP_SELF"], "t.datelastrun", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder); @@ -449,13 +438,15 @@ print ''; // Label - print ''; + print ''; if (!empty($obj->label)) { $object->ref = $langs->trans($obj->label); - print ''.$object->getNomUrl(0, '', 1).''; + print $object->getNomUrl(0, '', 1); $object->ref = $obj->rowid; - } else { + } + else + { //print $langs->trans('CronNone'); } print ''; @@ -468,14 +459,15 @@ print ''; if ($obj->jobtype == 'method') { - $text = $langs->trans("CronClass"); + $text = $langs->trans("CronClass"); $texttoshow = $langs->trans('CronModule').': '.$obj->module_name.'
'; $texttoshow .= $langs->trans('CronClass').': '.$obj->classesname.'
'; $texttoshow .= $langs->trans('CronObject').': '.$obj->objectname.'
'; $texttoshow .= $langs->trans('CronMethod').': '.$obj->methodename; $texttoshow .= '
'.$langs->trans('CronArgs').': '.$obj->params; $texttoshow .= '
'.$langs->trans('Comment').': '.$langs->trans($obj->note); - } elseif ($obj->jobtype == 'command') + } + elseif ($obj->jobtype == 'command') { $text = $langs->trans('CronCommand'); $texttoshow = $langs->trans('CronCommand').': '.dol_trunc($obj->command); @@ -493,28 +485,31 @@ print ''; print ''; - if (!empty($obj->datestart)) { print dol_print_date($db->jdate($obj->datestart), 'dayhour', 'tzserver'); } + if (!empty($obj->datestart)) {print dol_print_date($db->jdate($obj->datestart), 'dayhour'); } print ''; print ''; - if (!empty($obj->dateend)) { print dol_print_date($db->jdate($obj->dateend), 'dayhour', 'tzserver'); } + if (!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend), 'dayhour'); } print ''; print ''; - if (!empty($obj->nbrun)) { print $obj->nbrun; } else {print '0'; } - if (!empty($obj->maxrun)) { print ' / '.$obj->maxrun.''; } + if (!empty($obj->maxrun)) {print $obj->maxrun; } + print ''; + + print ''; + if (!empty($obj->nbrun)) {print $obj->nbrun; } else {print '0'; } print ''; // Date start last run print ''; - if (!empty($datelastrun)) { print dol_print_date($datelastrun, 'dayhoursec', 'tzserver'); } + if (!empty($datelastrun)) {print dol_print_date($datelastrun, 'dayhoursec'); } print ''; // Duration print ''; if (!empty($datelastresult) && ($datelastresult >= $datelastrun)) { - print convertSecondToTime(max($datelastresult - $datelastrun, 1), 'allhourminsec'); - //print '
'.($datelastresult - $datelastrun).' '.$langs->trans("seconds"); + print convertSecondToTime(max($datelastresult - $datelastrun, 1), 'allhourminsec'); + //print '
'.($datelastresult - $datelastrun).' '.$langs->trans("seconds"); } print ''; @@ -552,15 +547,15 @@ print ''; - $backtopage = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); + $backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); if ($user->rights->cron->create) { - print 'trans('Edit'))."\">".img_picto($langs->trans('Edit'), 'edit')."  "; + print 'trans('Edit'))."\">".img_picto($langs->trans('Edit'), 'edit')."  "; } if ($user->rights->cron->delete) { - print 'trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'), 'delete', '', false, 0, 0, '', 'marginleftonly')."   "; } else { print "trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'), 'delete', '', false, 0, 0, '', 'marginleftonly')."   "; @@ -591,8 +586,10 @@ $i++; } -} else { - print ''.$langs->trans('CronNoJobs').''; +} +else +{ + print ''.$langs->trans('CronNoJobs').''; } print ''; @@ -600,10 +597,11 @@ print ''; -if ($mode == 'modulesetup') { - print dol_get_fiche_end(); -} - + +print '

'; + + +dol_print_cron_urls(); llxFooter();