dolibarr/htdocs/cron/list.php

609 lines
24 KiB
PHP
Raw Normal View History

2013-03-22 17:10:17 +01:00
<?php
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
2016-02-07 16:02:30 +01:00
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
2019-08-17 15:22:26 +02:00
* Copyright (C) 2013-2019 Laurent Destailleur <eldy@users.sourceforge.net>
2019-05-13 10:22:26 +02:00
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
2013-03-22 17:10:17 +01:00
*
* 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
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2013-03-22 17:10:17 +01:00
*/
/**
2017-07-26 10:11:39 +02:00
* \file htdocs/cron/list.php
2013-03-22 17:10:17 +01:00
* \ingroup cron
* \brief Lists Jobs
*/
require '../main.inc.php';
2018-05-26 20:51:17 +02:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
2013-03-22 17:10:17 +01:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
2019-02-02 18:33:48 +01:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
2013-03-22 17:10:17 +01:00
2018-05-26 20:51:17 +02:00
// Load translation files required by the page
$langs->loadLangs(array("admin", "cron", "bills", "members"));
2013-03-22 17:10:17 +01:00
if (!$user->rights->cron->read) accessforbidden();
$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
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cronjoblist'; // To manage different context of search
2013-03-22 17:10:17 +01:00
$id = GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
2017-06-06 10:53:53 +02:00
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = 't.status,t.priority';
if (!$sortorder) $sortorder = 'DESC,ASC';
2016-08-17 15:40:17 +02:00
$search_status = (GETPOSTISSET('search_status') ?GETPOST('search_status', 'int') : GETPOST('status', 'int'));
2013-03-22 17:10:17 +01:00
//Search criteria
$search_label = GETPOST("search_label", 'alpha');
$securitykey = GETPOST('securitykey', 'alpha');
2016-08-17 15:40:17 +02:00
$diroutputmassaction = $conf->cronjob->dir_output.'/temp/massgeneration/'.$user->id;
2016-08-17 15:40:17 +02:00
2018-11-07 12:49:17 +01:00
$object = new Cronjob($db);
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2016-08-17 15:40:17 +02:00
$hookmanager->initHooks(array('cronjoblist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
2019-09-28 10:55:09 +02:00
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
2016-08-17 15:40:17 +02:00
2013-03-22 17:10:17 +01:00
2016-02-07 16:02:30 +01:00
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
2013-03-22 17:10:17 +01:00
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2018-03-01 12:53:40 +01:00
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2013-03-22 17:10:17 +01:00
2018-03-01 12:53:40 +01:00
if (empty($reshook))
2016-02-07 16:02:30 +01:00
{
2018-03-01 12:53:40 +01:00
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
2018-03-01 12:53:40 +01:00
{
$search_label = '';
$search_status = -1;
$toselect = '';
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
2018-03-01 12:53:40 +01:00
}
2013-03-22 17:10:17 +01:00
$filter = array();
2018-03-01 12:53:40 +01:00
if (!empty($search_label))
{
$filter['t.label'] = $search_label;
2013-03-22 17:10:17 +01:00
}
2018-03-01 12:53:40 +01:00
// Delete jobs
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete)
{
//Delete cron task
$object = new Cronjob($db);
$object->id = $id;
2018-03-01 12:53:40 +01:00
$result = $object->delete($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Execute jobs
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute)
{
if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey)
2018-03-01 12:53:40 +01:00
{
setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors');
$action = '';
2018-03-01 12:53:40 +01:00
}
else
{
$object = new Cronjob($db);
$job = $object->fetch($id);
$now = dol_now(); // Date we start
2018-03-01 12:53:40 +01:00
$resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK
2018-03-01 12:53:40 +01:00
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 = '';
2018-03-01 12:53:40 +01:00
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
2018-03-01 12:53:40 +01:00
}
$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);
2018-03-01 12:53:40 +01:00
// 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
2018-03-01 12:53:40 +01:00
exit;
}
}
// Mass actions
$objectclass = 'CronJob';
$objectlabel = 'CronJob';
$permissiontoread = $user->rights->cron->read;
$permissiontoadd = $user->rights->cron->create ? $user->rights->cron->create : $user->rights->cron->write;
$permissiontodelete = $user->rights->cron->delete;
$uploaddir = $conf->cron->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($permissiontoadd)
{
$tmpcron = new Cronjob($db);
foreach ($toselect as $id)
{
$result = $tmpcron->fetch($id);
if ($result)
{
$result = 0;
if ($massaction == 'disable') $result = $tmpcron->setStatut(Cronjob::STATUS_DISABLED);
elseif ($massaction == 'enable') $result = $tmpcron->setStatut(Cronjob::STATUS_ENABLED);
2018-11-09 19:30:44 +01:00
//else dol_print_error($db, 'Bad value for massaction');
if ($result < 0) setEventMessages($tmpcron->error, $tmpcron->errors, 'errors');
}
else
{
$error++;
}
}
}
2013-03-22 17:10:17 +01:00
}
/*
* View
*/
$form = new Form($db);
2018-02-22 12:15:11 +01:00
$cronjob = new Cronjob($db);
2013-03-22 17:10:17 +01:00
$pagetitle = $langs->trans("CronList");
2013-03-22 17:10:17 +01:00
llxHeader('', $pagetitle);
2013-03-22 17:10:17 +01:00
2016-08-17 15:40:17 +02:00
$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.processing,";
$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.maxrun,";
$sql .= " t.nbrun,";
$sql .= " t.libname,";
$sql .= " t.test";
$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');
2016-08-17 15:40:17 +02:00
//Manage filter
if (is_array($filter) && count($filter) > 0) {
foreach ($filter as $key => $value) {
$sql .= ' AND '.$key.' LIKE \'%'.$db->escape($value).'%\'';
2016-08-17 15:40:17 +02:00
}
2013-06-05 16:24:32 +02:00
}
2016-08-17 15:40:17 +02:00
$sqlwhere = array();
if (!empty($module_name)) {
$sqlwhere[] = '(t.module_name='.$db->escape($module_name).')';
2016-08-17 15:40:17 +02:00
}
if (count($sqlwhere) > 0) {
$sql .= " WHERE ".implode(' AND ', $sqlwhere);
2016-08-17 15:40:17 +02:00
}
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
2016-08-17 15:40:17 +02:00
// 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);
2013-06-23 22:30:33 +02:00
2016-08-17 15:40:17 +02:00
// Count total nb of records
$nbtotalofrecords = '';
2016-08-17 15:40:17 +02:00
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
2016-03-03 10:05:40 +01:00
{
2016-08-17 15:40:17 +02:00
$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;
}
2016-03-03 10:05:40 +01:00
}
2013-06-23 22:30:33 +02:00
$sql .= $db->plimit($limit + 1, $offset);
2016-08-17 15:40:17 +02:00
$result = $db->query($sql);
if (!$result) dol_print_error($db);
2013-06-23 22:30:33 +02:00
2016-08-17 15:40:17 +02:00
$num = $db->num_rows($result);
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
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 ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
2016-08-17 15:40:17 +02:00
$stringcurrentdate = $langs->trans("CurrentHour").': '.dol_print_date(dol_now(), 'dayhour');
if ($action == 'delete')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.$param, $langs->trans("CronDelete"), $langs->trans("CronConfirmDelete"), "confirm_delete", '', '', 1);
}
if ($action == 'execute')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&securitykey='.$securitykey.$param, $langs->trans("CronExecute"), $langs->trans("CronConfirmExecute"), "confirm_execute", '', '', 1);
}
2018-03-01 12:53:40 +01:00
// List of mass actions available
$arrayofmassactions = array(
2018-03-01 12:53:40 +01:00
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
2018-03-21 20:15:21 +01:00
'enable'=>$langs->trans("CronStatusActiveBtn"),
'disable'=>$langs->trans("CronStatusInactiveBtn"),
2018-03-01 12:53:40 +01:00
);
if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
2018-03-01 12:53:40 +01:00
2018-03-01 12:53:40 +01:00
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" name="search_form">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
2018-03-01 12:53:40 +01:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
2017-05-21 02:43:51 +02:00
print '<input type="hidden" name="page" value="'.$page.'">';
2018-03-01 12:53:40 +01:00
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
2019-05-29 09:38:19 +02:00
// 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']), '', $user->rights->cron->create);
2019-04-15 00:21:58 +02:00
2018-04-15 16:35:18 +02:00
print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_setup', 0, $newcardbutton, '', $limit);
2018-09-04 00:29:31 +02:00
print '<span class="opacitymedium">'.$langs->trans('CronInfo').'</span><br>';
2017-05-12 19:14:54 +02:00
$text = $langs->trans("HoursOnThisPageAreOnServerTZ").' '.$stringcurrentdate.'<br>';
if (!empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text .= $langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS);
2017-05-12 19:14:54 +02:00
print info_admin($text);
print '<br>';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = '';
2018-02-22 12:15:11 +01:00
//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
2017-01-17 20:04:41 +01:00
print '<div class="div-table-responsive">';
2017-03-28 13:22:11 +02:00
print '<table class="noborder">';
2017-03-28 13:22:11 +02:00
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_label" value="'.$search_label.'" size="10">';
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
2019-01-16 22:59:42 +01:00
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="center">';
2019-05-13 10:23:09 +02:00
print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled")), $search_status, 1);
2019-03-14 19:00:12 +01:00
print '</td><td class="liste_titre right">';
$searchpicto = $form->showFilterButtons();
2018-02-28 19:36:04 +01:00
print $searchpicto;
print '</td>';
print '</tr>';
2017-03-28 13:22:11 +02:00
print '<tr class="liste_titre">';
print_liste_field_titre("ID", $_SERVER["PHP_SELF"], "t.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("CronLabel", $_SERVER["PHP_SELF"], "t.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Prority", $_SERVER["PHP_SELF"], "t.priority", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("CronTask", '', '', "", $param, '', $sortfield, $sortorder);
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);
print_liste_field_titre("CronLastResult", $_SERVER["PHP_SELF"], "t.lastresult", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("CronLastOutput", $_SERVER["PHP_SELF"], "t.lastoutput", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("CronDtNextLaunch", $_SERVER["PHP_SELF"], "t.datenextrun", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "t.status,t.priority", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
2017-03-28 13:22:11 +02:00
print "</tr>\n";
if ($num > 0)
{
// Loop on each job
2016-08-17 15:40:17 +02:00
$now = dol_now();
$i = 0;
2018-12-12 12:16:57 +01:00
while ($i < min($num, $limit))
{
2016-08-17 15:40:17 +02:00
$obj = $db->fetch_object($result);
2017-07-13 00:35:10 +02:00
2017-08-03 11:01:43 +02:00
if (empty($obj)) break;
if (!verifCond($obj->test)) continue; // Discard line with test = false
2017-07-13 00:35:10 +02:00
2018-02-22 12:15:11 +01:00
$object->id = $obj->rowid;
$object->ref = $obj->rowid;
$object->label = $obj->label;
2018-02-27 20:04:29 +01:00
$object->status = $obj->status;
$object->priority = $obj->priority;
2018-12-12 12:16:57 +01:00
$object->processing = $obj->processing;
2020-01-25 11:50:16 +01:00
$object->lastresult = $obj->lastresult;
2018-02-22 12:15:11 +01:00
2019-01-17 17:50:21 +01:00
$datelastrun = $db->jdate($obj->datelastrun);
$datelastresult = $db->jdate($obj->datelastresult);
2017-07-26 10:11:39 +02:00
print '<tr class="oddeven">';
2013-03-26 21:18:01 +01:00
// Ref
2019-02-06 00:56:28 +01:00
print '<td class="nowraponall">';
2018-02-22 12:15:11 +01:00
print $object->getNomUrl(1);
print '</td>';
// Label
print '<td>';
if (!empty($obj->label))
{
2018-02-27 19:37:29 +01:00
$object->ref = $langs->trans($obj->label);
2018-02-22 12:15:11 +01:00
print $object->getNomUrl(0, '', 1);
$object->ref = $obj->rowid;
2013-03-26 21:18:01 +01:00
}
else
{
//print $langs->trans('CronNone');
2013-03-22 17:10:17 +01:00
}
print '</td>';
2013-03-26 21:18:01 +01:00
// Priority
print '<td class="right">';
print $object->priority;
print '</td>';
2013-03-22 17:10:17 +01:00
print '<td>';
if ($obj->jobtype == 'method')
{
$text = $langs->trans("CronClass");
$texttoshow = $langs->trans('CronModule').': '.$obj->module_name.'<br>';
$texttoshow .= $langs->trans('CronClass').': '.$obj->classesname.'<br>';
$texttoshow .= $langs->trans('CronObject').': '.$obj->objectname.'<br>';
$texttoshow .= $langs->trans('CronMethod').': '.$obj->methodename;
$texttoshow .= '<br>'.$langs->trans('CronArgs').': '.$obj->params;
$texttoshow .= '<br>'.$langs->trans('Comment').': '.$langs->trans($obj->note);
}
elseif ($obj->jobtype == 'command')
{
$text = $langs->trans('CronCommand');
$texttoshow = $langs->trans('CronCommand').': '.dol_trunc($obj->command);
$texttoshow .= '<br>'.$langs->trans('CronArgs').': '.$obj->params;
$texttoshow .= '<br>'.$langs->trans('Comment').': '.$langs->trans($obj->note);
2013-03-22 17:10:17 +01:00
}
print $form->textwithpicto($text, $texttoshow, 1);
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
print '<td>';
if ($obj->unitfrequency == "60") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Minutes');
if ($obj->unitfrequency == "3600") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Hours');
if ($obj->unitfrequency == "86400") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Days');
if ($obj->unitfrequency == "604800") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Weeks');
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
2015-12-19 03:27:55 +01:00
print '<td class="center">';
if (!empty($obj->datestart)) {print dol_print_date($db->jdate($obj->datestart), 'dayhour'); }
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
2015-12-19 03:27:55 +01:00
print '<td class="center">';
if (!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend), 'dayhour'); }
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
2019-03-14 19:00:12 +01:00
print '<td class="right">';
if (!empty($obj->maxrun)) {print $obj->maxrun; }
2015-12-19 03:27:55 +01:00
print '</td>';
2017-07-13 00:35:10 +02:00
2019-03-14 19:00:12 +01:00
print '<td class="right">';
if (!empty($obj->nbrun)) {print $obj->nbrun; } else {print '0'; }
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
2019-01-16 22:59:42 +01:00
// Date start last run
print '<td class="center">';
if (!empty($datelastrun)) {print dol_print_date($datelastrun, 'dayhoursec'); }
2019-01-16 22:59:42 +01:00
print '</td>';
2019-01-17 17:50:21 +01:00
// Duration
2015-12-19 03:27:55 +01:00
print '<td class="center">';
2019-01-17 17:50:21 +01:00
if (!empty($datelastresult) && ($datelastresult >= $datelastrun)) {
print convertSecondToTime(max($datelastresult - $datelastrun, 1), 'allhourminsec');
//print '<br>'.($datelastresult - $datelastrun).' '.$langs->trans("seconds");
}
print '</td>';
2015-12-19 03:27:55 +01:00
2019-01-16 22:59:42 +01:00
// Return code of last run
2015-12-19 03:27:55 +01:00
print '<td class="center">';
if ($obj->lastresult != '') {
if (empty($obj->lastresult)) print $obj->lastresult;
else print '<span class="error">'.dol_trunc($obj->lastresult).'</div>';
}
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
2019-01-16 22:59:42 +01:00
// Output of last run
2013-03-22 17:10:17 +01:00
print '<td>';
if (!empty($obj->lastoutput)) {print dol_trunc(nl2br($obj->lastoutput), 50); }
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
2017-08-21 12:24:58 +02:00
print '<td class="center">';
2018-09-18 23:39:49 +02:00
if (!empty($obj->datenextrun)) {
$datenextrun = $db->jdate($obj->datenextrun);
2018-06-16 23:51:30 +02:00
if (empty($obj->status)) print '<span class="opacitymedium">';
print dol_print_date($datenextrun, 'dayhoursec');
2018-09-18 23:45:22 +02:00
if ($obj->status == Cronjob::STATUS_ENABLED)
{
if ($obj->maxrun && $obj->nbrun >= $obj->maxrun) print img_warning($langs->trans("MaxRunReached"));
elseif ($datenextrun && $datenextrun < $now) print img_warning($langs->trans("Late"));
}
2018-09-18 23:39:49 +02:00
if (empty($obj->status)) print '</span>';
2018-06-16 23:51:30 +02:00
}
2017-08-21 12:24:58 +02:00
print '</td>';
// Status
2019-03-14 19:00:12 +01:00
print '<td class="center">';
2020-01-25 11:50:16 +01:00
print $object->getLibStatut(5);
print '</td>';
2019-03-14 19:00:12 +01:00
print '<td class="nowraponall right">';
2018-05-27 15:53:18 +02:00
$backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : ''));
if ($user->rights->cron->create)
{
print "<a href=\"".DOL_URL_ROOT."/cron/card.php?id=".$obj->rowid."&action=edit".($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').$param;
print "&backtourl=".$backtourl."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'), 'edit')."</a> &nbsp;";
}
if ($user->rights->cron->delete)
{
2019-12-15 21:09:00 +01:00
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"]."?id=".$obj->rowid."&action=delete".($page ? '&page='.$page : '').($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').$param;
print "\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'), 'delete')."</a> &nbsp;";
2013-03-22 17:10:17 +01:00
} else {
print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'), 'delete')."</a> &nbsp; ";
2013-03-22 17:10:17 +01:00
}
if ($user->rights->cron->execute)
{
2019-10-19 19:34:28 +02:00
if (!empty($obj->status)) {
2019-12-15 21:09:00 +01:00
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute';
print (empty($conf->global->CRON_KEY) ? '' : '&securitykey='.$conf->global->CRON_KEY);
print ($sortfield ? '&sortfield='.$sortfield : '');
print ($sortorder ? '&sortorder='.$sortorder : '');
2019-10-19 19:34:28 +02:00
print $param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play").'</a>';
} else {
print '<a href="#" class="cursordefault" title="'.dol_escape_htmltag($langs->trans('JobDisabled')).'">'.img_picto($langs->trans('JobDisabled'), "playdisabled").'</a>';
}
2013-03-22 17:10:17 +01:00
} else {
print '<a href="#" class="cursornotallowed" title="'.dol_escape_htmltag($langs->trans('NotEnoughPermissions')).'">'.img_picto($langs->trans('NotEnoughPermissions'), "playdisabled").'</a>';
2013-03-22 17:10:17 +01:00
}
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print ' &nbsp; <input id="cb'.$obj->rowid.'" class="flat checkforselect valignmiddle" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
2013-03-22 17:10:17 +01:00
print '</td>';
2013-03-26 21:18:01 +01:00
2013-03-22 17:10:17 +01:00
print '</tr>';
2017-07-13 00:35:10 +02:00
2016-08-17 15:40:17 +02:00
$i++;
2013-03-22 17:10:17 +01:00
}
}
2013-06-23 22:30:33 +02:00
else
{
print '<tr><td colspan="9" class="opacitymedium">'.$langs->trans('CronNoJobs').'</td></tr>';
2013-06-23 22:30:33 +02:00
}
print '</table>';
2017-01-17 20:04:41 +01:00
print '</div>';
2013-06-23 22:30:33 +02:00
2013-06-24 17:36:33 +02:00
print '</from>';
2013-06-23 22:30:33 +02:00
2016-03-03 10:05:40 +01:00
print '<br><br>';
2013-03-22 17:10:17 +01:00
dol_print_cron_urls();
2013-03-22 17:10:17 +01:00
llxFooter();
2013-03-27 13:24:26 +01:00
$db->close();