*
* 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 .
*/
/**
* \file cron/cron/list.php
* \ingroup cron
* \brief Lists Jobs
*/
require '../main.inc.php';
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
// librairie jobs
require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php";
require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
$langs->load("admin");
$langs->load("cron");
if (!$user->rights->cron->read) accessforbidden();
/*
* Actions
*/
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int');
$sortorder=GETPOST('sortorder','alpha');
$sortfield=GETPOST('sortfield','alpha');
$page=GETPOST('page','int');
$status=GETPOST('status','int');
//Search criteria
$search_label=GETPOST("search_label",'alpha');
if (empty($sortorder)) $sortorder="DESC";
if (empty($sortfield)) $sortfield="t.datenextrun";
if (empty($arch)) $arch = 0;
if ($page == -1) {
$page = 0 ;
}
$limit = $conf->global->MAIN_SIZE_LISTE_LIMIT;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x"))
{
$search_label='';
}
$filter=array();
if (!empty($search_label)) {
$filter['t.label']=$search_label;
}
// Delete jobs
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete){
//Delete de la tache cron
$object = new Cronjob($db);
$object->id=$id;
$result = $object->delete($user);
if ($result < 0) {
setEventMessage($object->error,'errors');
}
}
// Execute jobs
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute){
//Execute jobs
$object = new Cronjob($db);
$job = $object->fetch($id);
$result = $object->run_jobs($user->login);
if ($result < 0) {
setEventMessage($object->error,'errors');
}
}
/*
* View
*/
$form = new Form($db);
if (!empty($status)) $pagetitle=$langs->trans("CronListActive");
else $pagetitle=$langs->trans("CronListInactive");
llxHeader('',$pagetitle);
print_fiche_titre($pagetitle,'','setup');
print $langs->trans('CronInfo');
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1);
if ($ret == 'html') print '
';
}
if ($action == 'execute'){
$ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1);
if ($ret == 'html') print '
';
}
// liste des jobs creer
$object = new Cronjob($db);
$result=$object->fetch_all($sortorder, $sortfield, $limit, $offset, $status, $filter);
if ($result < 0) {
setEventMessage($object->error,'errors');
}
print "
";
if (count($object->lines)>0) {
print '
';
print '';
$arg_url='&page='.$page.'&status='.$status.'&search_label='.$search_label;
print_liste_field_titre($langs->trans("CronLabel"),$_SERVEUR['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"),$_SERVEUR['PHP_SELF'],"t.datestart","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronDtEnd"),$_SERVEUR['PHP_SELF'],"t.dateend","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronDtLastLaunch"),$_SERVEUR['PHP_SELF'],"t.datelastrun","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVEUR['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"),$_SERVEUR['PHP_SELF'],"t.nbrun","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronLastResult"),$_SERVEUR['PHP_SELF'],"t.lastresult","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVEUR['PHP_SELF'],"t.lastoutput","",$arg_url,'',$sortfield,$sortorder);
print ' | ';
print '
';
print '
';
} else {
print $langs->trans('CronNoJobs');
}
print "\n';
print '
';
llxFooter();
$db->close();
?>