Fix pagination on cron jobs
Fix perf when too much lines
This commit is contained in:
parent
bd91f327b8
commit
a973c91c24
@ -128,7 +128,7 @@ class modCron extends DolibarrModules
|
||||
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'CronList',
|
||||
'url'=>'/cron/list.php?status=-1',
|
||||
'url'=>'/cron/list.php?status=-2',
|
||||
'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>200,
|
||||
'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||
|
||||
@ -43,6 +43,11 @@ $action=GETPOST('action','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$cancel=GETPOST('cancel');
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$object = new Cronjob($db);
|
||||
if (!empty($id))
|
||||
{
|
||||
@ -53,7 +58,7 @@ if (!empty($id))
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($cancel))
|
||||
if (!empty($cancel))
|
||||
{
|
||||
if (!empty($id))
|
||||
{
|
||||
@ -61,7 +66,7 @@ if(!empty($cancel))
|
||||
}
|
||||
else
|
||||
{
|
||||
Header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=1');
|
||||
Header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -78,7 +83,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->del
|
||||
}
|
||||
else
|
||||
{
|
||||
Header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=1');
|
||||
Header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@ $sortorder=GETPOST('sortorder','alpha');
|
||||
$sortfield=GETPOST('sortfield','alpha');
|
||||
$page=GETPOST('page','int');
|
||||
$status=GETPOST('status','int');
|
||||
if ($status == '') $status=-2;
|
||||
|
||||
//Search criteria
|
||||
$search_label=GETPOST("search_label",'alpha');
|
||||
@ -116,7 +117,7 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-1'); // Make a call to avoid to run twice job when using back
|
||||
header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2'); // Make a call to avoid to run twice job when using back
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -131,22 +132,6 @@ $pagetitle=$langs->trans("CronList");
|
||||
|
||||
llxHeader('',$pagetitle);
|
||||
|
||||
print load_fiche_titre($pagetitle,'','title_setup');
|
||||
|
||||
print $langs->trans('CronInfo');
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1);
|
||||
|
||||
}
|
||||
|
||||
if ($action == 'execute')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1);
|
||||
|
||||
}
|
||||
|
||||
// list of jobs created
|
||||
$object = new Cronjob($db);
|
||||
$result=$object->fetch_all($sortorder, $sortfield, $limit, $offset, $status, $filter);
|
||||
@ -154,29 +139,50 @@ if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
$nbtotalofrecord=0;
|
||||
$num=count($object->lines);
|
||||
|
||||
$param='&page='.$page.'&status='.$status.'&search_label='.$search_label;
|
||||
|
||||
|
||||
print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_setup');
|
||||
|
||||
|
||||
print $langs->trans('CronInfo');
|
||||
print "<br><br>";
|
||||
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1);
|
||||
|
||||
}
|
||||
|
||||
if ($action == 'execute')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
print '<form method="GET" action="'.$url_form.'" name="search_form">'."\n";
|
||||
print '<input type="hidden" name="status" value="'.$status.'" >';
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
$arg_url='&page='.$page.'&status='.$status.'&search_label='.$search_label;
|
||||
print_liste_field_titre($langs->trans("ID"),$_SERVER["PHP_SELF"],"t.rowid","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronLabel"),$_SERVER["PHP_SELF"],"t.label","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronTask"),'','',"",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtStart"),$_SERVER["PHP_SELF"],"t.datestart","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtEnd"),$_SERVER["PHP_SELF"],"t.dateend","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtLastLaunch"),$_SERVER["PHP_SELF"],"t.datelastrun","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVER["PHP_SELF"],"t.datenextrun","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronNbRun"),$_SERVER["PHP_SELF"],"t.nbrun","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronLastResult"),$_SERVER["PHP_SELF"],"t.lastresult","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVER["PHP_SELF"],"t.lastoutput","",$arg_url,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Enabled"),$_SERVER["PHP_SELF"],"t.status","",$arg_url,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ID"),$_SERVER["PHP_SELF"],"t.rowid","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronLabel"),$_SERVER["PHP_SELF"],"t.label","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronTask"),'','',"",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtStart"),$_SERVER["PHP_SELF"],"t.datestart","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtEnd"),$_SERVER["PHP_SELF"],"t.dateend","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtLastLaunch"),$_SERVER["PHP_SELF"],"t.datelastrun","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronNbRun"),$_SERVER["PHP_SELF"],"t.nbrun","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronMaxRun"),$_SERVER["PHP_SELF"],"t.maxrun","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronLastResult"),$_SERVER["PHP_SELF"],"t.lastresult","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('');
|
||||
print "</tr>\n";
|
||||
|
||||
@ -194,8 +200,9 @@ print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $form->selectarray('status', array('0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")), $status, 1);
|
||||
print $form->selectarray('status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled"), '-2'=>$langs->trans("EnabledAndDisabled"), '2'=>$langs->trans("Archived")), $status, 1);
|
||||
print '</td><td class="liste_titre" align="right">';
|
||||
print '<input class="liste_titre" type="image" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
@ -203,9 +210,9 @@ print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
if (count($object->lines) > 0)
|
||||
if ($num > 0)
|
||||
{
|
||||
// Loop on each active job
|
||||
// Loop on each job
|
||||
$style='pair';
|
||||
foreach($object->lines as $line)
|
||||
{
|
||||
@ -229,7 +236,7 @@ if (count($object->lines) > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('CronNone');
|
||||
//print $langs->trans('CronNone');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -253,19 +260,19 @@ if (count($object->lines) > 0)
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->datestart)) {print dol_print_date($line->datestart,'dayhour');} else {print $langs->trans('CronNone');}
|
||||
if(!empty($line->datestart)) {print dol_print_date($line->datestart,'dayhour');}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->dateend)) {print dol_print_date($line->dateend,'dayhour');} else {print $langs->trans('CronNone');}
|
||||
if(!empty($line->dateend)) {print dol_print_date($line->dateend,'dayhour');}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->datelastrun)) {print dol_print_date($line->datelastrun,'dayhour');} else {print $langs->trans('CronNone');}
|
||||
if(!empty($line->datelastrun)) {print dol_print_date($line->datelastrun,'dayhour');}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhour');} else {print $langs->trans('CronNone');}
|
||||
if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhour');}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
@ -276,20 +283,26 @@ if (count($object->lines) > 0)
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->nbrun)) {print $line->nbrun;} else {print '0';}
|
||||
if (!empty($line->nbrun)) {print $line->nbrun;} else {print '0';}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->lastresult)) {print dol_trunc($line->lastresult);} else {print $langs->trans('CronNone');}
|
||||
if (!empty($line->maxrun)) {print $line->maxrun;}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->lastresult)) {print dol_trunc($line->lastresult);}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if(!empty($line->lastoutput)) {print dol_trunc(nl2br($line->lastoutput),100);} else {print $langs->trans('CronNone');}
|
||||
if(!empty($line->lastoutput)) {print dol_trunc(nl2br($line->lastoutput),100);}
|
||||
print '</td>';
|
||||
|
||||
// Status
|
||||
print '<td align="center">';
|
||||
print yn($line->status);
|
||||
if ($line->status == 1) print $langs->trans("Enabled");
|
||||
elseif ($line->status == 2) print $langs->trans("Archived");
|
||||
else print $langs->trans("Disabled");
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right" class="nowrap">';
|
||||
|
||||
23
htdocs/install/mysql/tables/llx_cronjob.key.sql
Normal file
23
htdocs/install/mysql/tables/llx_cronjob.key.sql
Normal file
@ -0,0 +1,23 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_cronjob ADD INDEX idx_cronjob_status (status);
|
||||
ALTER TABLE llx_cronjob ADD INDEX idx_cronjob_datelastrun (datelastrun);
|
||||
ALTER TABLE llx_cronjob ADD INDEX idx_cronjob_datenextrun (datenextrun);
|
||||
ALTER TABLE llx_cronjob ADD INDEX idx_cronjob_datestart (datestart);
|
||||
ALTER TABLE llx_cronjob ADD INDEX idx_cronjob_dateend (dateend);
|
||||
@ -44,8 +44,8 @@ CREATE TABLE llx_cronjob
|
||||
frequency integer NOT NULL DEFAULT 0,
|
||||
maxrun integer NOT NULL DEFAULT 0, -- set this to 1 for a job queued for on run only
|
||||
nbrun integer, -- nb of run complete (failed or not)
|
||||
autodelete integer DEFAULT 0, -- Job can be delete once finished
|
||||
status integer NOT NULL DEFAULT 1,
|
||||
autodelete integer DEFAULT 0, -- 1=Job must be deleted once finished, 2=Job must be archived once finished (archive = status 2)
|
||||
status integer NOT NULL DEFAULT 1, -- 0=disabled, 1=enabled, 2=archived
|
||||
fk_user_author integer DEFAULT NULL,
|
||||
fk_user_mod integer DEFAULT NULL,
|
||||
fk_mailing integer DEFAULT NULL, -- id of emailing if job was queued to send mass emailing
|
||||
|
||||
@ -18,8 +18,9 @@ CronExplainHowToRunUnix=On Unix environment you should use the following crontab
|
||||
CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run the command line each 5 minutes
|
||||
# Menu
|
||||
CronJobs=Scheduled jobs
|
||||
CronListActive=List of active/scheduled jobs
|
||||
CronListActive=List of enabled/scheduled jobs
|
||||
CronListInactive=List of disabled jobs
|
||||
EnabledAndDisabled=Enabled and disabled
|
||||
# Page list
|
||||
CronDateLastRun=Last run
|
||||
CronLastOutput=Last run output
|
||||
@ -51,6 +52,7 @@ CronNoJobs=No jobs registered
|
||||
CronPriority=Priority
|
||||
CronLabel=Description
|
||||
CronNbRun=Nb. launch
|
||||
CronMaxRun=Max nb. launch
|
||||
CronEach=Every
|
||||
JobFinished=Job launched and finished
|
||||
#Page card
|
||||
|
||||
Loading…
Reference in New Issue
Block a user