';
$maxrun='';
if (!empty($object->maxrun)) {
$maxrun=$object->maxrun;
@@ -552,7 +552,7 @@ else
// box add_jobs_box
print '';
- print '| ';
+ print ' | | ';
print $langs->trans('CronId')." | ";
print "".$form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'id', '', '', 0);
print " | \n";
@@ -614,7 +614,7 @@ else
print '';
- print "| ";
+ print ' | | ';
print $langs->trans('CronEvery')." | ";
print "";
if($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Minutes');
@@ -623,7 +623,7 @@ else
if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks');
print " | ";
- print '| ';
+ print ' | | ';
print $langs->trans('CronDtStart')." | ";
if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhoursec');}
print " | ";
@@ -653,11 +653,13 @@ else
print $langs->trans('CronDtNextLaunch');
print ' ('.$langs->trans('CronFrom').')';
print "";
- print '';
- if (!empty($object->datenextrun)) {print dol_print_date($object->datenextrun,'dayhoursec');} else {print $langs->trans('CronNone');}
+ //print '';
+ if (! $object->status) print $langs->trans("Disabled");
+ elseif (!empty($object->datenextrun)) { print img_picto('','object_calendarday').' '.dol_print_date($object->datenextrun,'dayhoursec');}
+ else {print $langs->trans('CronNone');}
+ //print '';
if ($object->maxnbrun && $object->nbrun >= $object->maxrun) print img_warning($langs->trans("Finished"));
if ($object->datenextrun && $object->datenextrun < $now) print img_warning($langs->trans("Late"));
- print '';
print " | ";
print ' ';
@@ -666,7 +668,7 @@ else
print '';
- print '| ';
+ print ' | | ';
print $langs->trans('CronDtLastLaunch')." | ";
if(!empty($object->datelastrun)) {print dol_print_date($object->datelastrun,'dayhoursec');} else {print $langs->trans('CronNone');}
print " | ";
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 99b17da3899..b60ad5c963a 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -411,9 +411,6 @@ class Cronjob extends CommonObject
$sqlwhere = array();
- if (!empty($module_name)) {
- $sqlwhere[]='(t.module_name='.$module_name.')';
- }
if (count($sqlwhere)>0) {
$sql.= " WHERE ".implode(' AND ',$sqlwhere);
}
diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php
index b6ad4a8d2aa..10f9b954cb1 100644
--- a/htdocs/cron/list.php
+++ b/htdocs/cron/list.php
@@ -39,31 +39,38 @@ $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int');
-$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
+$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if ($page == -1) {
- $page = 0;
-}
+if ($page == -1) { $page = 0; }
$offset = $limit * $page;
-if (! $sortorder) $sortorder='ASC';
-if (! $sortfield) $sortfield='t.label';
$pageprev = $page - 1;
$pagenext = $page + 1;
+if (! $sortfield) $sortfield='t.status';
+if (! $sortorder) $sortorder='ASC';
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$contextpage='cronjoblist';
$status=GETPOST('status','int');
if ($status == '') $status=-2;
//Search criteria
$search_label=GETPOST("search_label",'alpha');
-
-if (empty($sortorder)) $sortorder="DESC";
-if (empty($sortfield)) $sortfield="t.status";
if (empty($arch)) $arch = 0;
-if ($page == -1) {
- $page = 0 ;
-}
+
+$diroutputmassaction=$conf->cronjob->dir_output . '/temp/massgeneration/'.$user->id;
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('cronjoblist'));
+$extrafields = new ExtraFields($db);
+
+// fetch optionals attributes and labels
+$extralabels = $extrafields->fetch_name_optionals_label('cronjob');
+$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
+
+$object = new Cronjob($db);
/*
@@ -71,7 +78,7 @@ if ($page == -1) {
*/
// Do we click on purge search criteria ?
-if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
+if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_label='';
$status=-1;
@@ -141,110 +148,195 @@ $pagetitle=$langs->trans("CronList");
llxHeader('',$pagetitle);
-// list of jobs created
-// TODO Replace this with an embedded select.
-$object = new Cronjob($db);
-$result=$object->fetch_all($sortorder, $sortfield, $limit, $offset, $status, $filter);
-if ($result < 0)
-{
- setEventMessages($object->error, $object->errors, 'errors');
+
+$sql = "SELECT";
+$sql.= " t.rowid,";
+$sql.= " t.tms,";
+$sql.= " t.datec,";
+$sql.= " t.jobtype,";
+$sql.= " t.label,";
+$sql.= " t.command,";
+$sql.= " t.classesname,";
+$sql.= " t.objectname,";
+$sql.= " t.methodename,";
+$sql.= " t.params,";
+$sql.= " t.md5params,";
+$sql.= " t.module_name,";
+$sql.= " t.priority,";
+$sql.= " t.datelastrun,";
+$sql.= " t.datenextrun,";
+$sql.= " t.dateend,";
+$sql.= " t.datestart,";
+$sql.= " t.lastresult,";
+$sql.= " t.datelastresult,";
+$sql.= " t.lastoutput,";
+$sql.= " t.unitfrequency,";
+$sql.= " t.frequency,";
+$sql.= " t.status,";
+$sql.= " t.fk_user_author,";
+$sql.= " t.fk_user_mod,";
+$sql.= " t.note,";
+$sql.= " t.nbrun,";
+$sql.= " t.libname,";
+$sql.= " t.test";
+$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
+$sql.= " WHERE 1 = 1";
+if ($status >= 0 && $status < 2) $sql.= " AND t.status = ".(empty($status)?'0':'1');
+if ($status == 2) $sql.= " AND t.status = 2";
+//Manage filter
+if (is_array($filter) && count($filter)>0) {
+ foreach($filter as $key => $value) {
+ $sql.= ' AND '.$key.' LIKE \'%'.$value.'%\'';
+ }
}
-$nbtotalofrecord=0;
-$num=count($object->lines);
-
-$param='&page='.$page.'&status='.$status.'&search_label='.$search_label;
-
-$stringcurrentdate = $langs->trans("CurrentHour").': '.dol_print_date(dol_now(), 'dayhour');
-
-
-
-if ($action == 'delete')
+$sqlwhere = array();
+if (!empty($module_name)) {
+ $sqlwhere[]='(t.module_name='.$module_name.')';
+}
+if (count($sqlwhere)>0) {
+ $sql.= " WHERE ".implode(' AND ',$sqlwhere);
+}
+// Add where from extra fields
+foreach ($search_array_options as $key => $val)
{
- print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1);
+ $crit=$val;
+ $tmpkey=preg_replace('/search_options_/','',$key);
+ $typ=$extrafields->attribute_type[$tmpkey];
+ $mode=0;
+ if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
+ if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
+ {
+ $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
+ }
+}
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+$sql.= $db->order($sortfield,$sortorder);
+
+// Count total nb of records
+$nbtotalofrecords = 0;
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
}
-if ($action == 'execute')
-{
- print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1);
-
-}
-
-
-print ' |