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 >
* Copyright ( C ) 2013 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
2013-08-22 16:49:23 +02:00
* \file htdocs / cron / cron / list . php
2013-03-22 17:10:17 +01:00
* \ingroup cron
* \brief Lists Jobs
*/
require '../main.inc.php' ;
require_once ( DOL_DOCUMENT_ROOT . " /core/lib/admin.lib.php " );
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 " );
2016-01-19 23:45:03 +01:00
$langs -> load ( " bills " );
2013-03-22 17:10:17 +01:00
if ( ! $user -> rights -> cron -> read ) accessforbidden ();
$action = GETPOST ( 'action' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$id = GETPOST ( 'id' , 'int' );
2016-08-17 15:40:17 +02:00
$limit = GETPOST ( " limit " ) ? GETPOST ( " limit " , " int " ) : $conf -> liste_limit ;
2016-02-16 00:31:05 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
2016-08-17 15:40:17 +02:00
if ( $page == - 1 ) { $page = 0 ; }
2016-02-16 00:31:05 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2016-08-17 15:40:17 +02:00
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' ;
2016-02-16 00:31:05 +01:00
2013-03-22 17:10:17 +01:00
$status = GETPOST ( 'status' , 'int' );
2015-12-19 02:38:11 +01:00
if ( $status == '' ) $status =- 2 ;
2013-03-22 17:10:17 +01:00
//Search criteria
$search_label = GETPOST ( " search_label " , 'alpha' );
2016-09-08 13:01:50 +02:00
$securitykey = GETPOST ( 'securitykey' , 'alpha' );
2016-08-17 15:40:17 +02:00
$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 );
2013-03-22 17:10:17 +01:00
2016-02-07 16:02:30 +01:00
/*
* Actions
*/
2013-03-22 17:10:17 +01:00
// Do we click on purge search criteria ?
2016-08-17 15:40:17 +02:00
if ( GETPOST ( " button_removefilter_x " ) || GETPOST ( " button_removefilter.x " ) || GETPOST ( " button_removefilter " )) // All test are required to be compatible with all browsers
2013-03-22 17:10:17 +01:00
{
$search_label = '' ;
2013-06-23 22:30:33 +02:00
$status =- 1 ;
2013-03-22 17:10:17 +01:00
}
$filter = array ();
2013-06-23 22:30:33 +02:00
if ( ! empty ( $search_label ))
{
2013-03-22 17:10:17 +01:00
$filter [ 't.label' ] = $search_label ;
}
// Delete jobs
2016-02-07 16:02:30 +01:00
if ( $action == 'confirm_delete' && $confirm == " yes " && $user -> rights -> cron -> delete )
{
2013-11-05 15:29:33 +01:00
//Delete cron task
2013-03-22 17:10:17 +01:00
$object = new Cronjob ( $db );
$object -> id = $id ;
$result = $object -> delete ( $user );
if ( $result < 0 ) {
2015-11-21 05:20:08 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2013-03-22 17:10:17 +01:00
}
}
// Execute jobs
2016-02-07 16:02:30 +01:00
if ( $action == 'confirm_execute' && $confirm == " yes " && $user -> rights -> cron -> execute )
{
2016-09-08 13:01:50 +02:00
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 add result of reprogram ony 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 = '' ;
}
header ( " Location: " . DOL_URL_ROOT . '/cron/list.php?status=-2' ); // Make a call to avoid to run twice job when using back
exit ;
}
2013-03-22 17:10:17 +01:00
}
/*
* View
*/
$form = new Form ( $db );
2013-04-17 16:26:14 +02:00
$pagetitle = $langs -> trans ( " CronList " );
2013-03-22 17:10:17 +01:00
2013-04-01 20:15:52 +02:00
llxHeader ( '' , $pagetitle );
2013-03-22 17:10:17 +01:00
2014-07-28 20:30:31 +02: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.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 . '%\'' ;
}
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=' . $module_name . ')' ;
}
if ( count ( $sqlwhere ) > 0 ) {
$sql .= " WHERE " . implode ( ' AND ' , $sqlwhere );
}
// Add where from extra fields
foreach ( $search_array_options as $key => $val )
2013-06-23 22:30:33 +02:00
{
2016-08-17 15:40:17 +02:00
$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 );
}
2013-06-05 16:24:32 +02:00
}
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 ;
2013-04-01 20:15:52 +02:00
2016-08-17 15:40:17 +02:00
$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 = 0 ;
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 );
2016-03-03 10:05:40 +01:00
}
2013-06-23 22:30:33 +02:00
2016-08-17 15:40:17 +02:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
$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 );
2016-09-10 19:53:32 +02:00
$param = '&status=' . $status ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
if ( $search_label ) $param .= '&search_label=' . $search_label ;
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
// Add $param from extra fields
foreach ( $search_array_options as $key => $val )
2013-06-24 17:36:33 +02:00
{
2016-09-10 19:53:32 +02:00
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
if ( $val != '' ) $param .= '&search_options_' . $tmpkey . '=' . urlencode ( $val );
}
2016-08-17 15:40:17 +02:00
2016-09-10 19:53:32 +02:00
//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
$stringcurrentdate = $langs -> trans ( " CurrentHour " ) . ': ' . dol_print_date ( dol_now (), 'dayhour' );
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 . '&securitykey=' . $securitykey , $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 . '" >' ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="viewstatut" value="' . $viewstatut . '">' ;
// Line with explanation and button new job
if ( ! $user -> rights -> cron -> create )
{
$buttontoshow .= '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " CronCreateJob " ) . '</a>' ;
}
else
{
$buttontoshow .= '<a class="butAction" style="margin-right: 0px;margin-left: 0px;" href="' . DOL_URL_ROOT . '/cron/card.php?action=create">' . $langs -> trans ( " CronCreateJob " ) . '</a>' ;
}
2016-09-20 12:51:09 +02:00
print_barre_liste ( $pagetitle , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $buttontoshow , $num , $nbtotalofrecords , 'title_setup' , 0 , '' , '' , $limit );
print $langs -> trans ( 'CronInfo' ) . '<br>' ;
print $stringcurrentdate . '<br>' ;
if ( ! empty ( $conf -> global -> CRON_WARNING_DELAY_HOURS )) print info_admin ( $langs -> trans ( " WarningCronDelayed " , $conf -> global -> CRON_WARNING_DELAY_HOURS ));
2016-09-10 19:53:32 +02:00
print '<br>' ;
print '<table width="100%" class="noborder">' ;
print '<tr class="liste_titre">' ;
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 ( " CronFrequency " ), '' , " " , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " CronDtStart " ), $_SERVER [ " PHP_SELF " ], " t.datestart " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " CronDtEnd " ), $_SERVER [ " PHP_SELF " ], " t.dateend " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " CronMaxRun " ), $_SERVER [ " PHP_SELF " ], " t.maxrun " , " " , $param , 'align="right"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " CronNbRun " ), $_SERVER [ " PHP_SELF " ], " t.nbrun " , " " , $param , 'align="right"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " CronDtNextLaunch " ), $_SERVER [ " PHP_SELF " ], " t.datenextrun " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " CronDtLastLaunch " ), $_SERVER [ " PHP_SELF " ], " t.datelastrun " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " CronLastResult " ), $_SERVER [ " PHP_SELF " ], " t.lastresult " , " " , $param , 'align="center"' , $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 " ;
print '<tr class="liste_titre">' ;
print '<td> </td>' ;
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_label" value="' . $search_label . '" size="10">' ;
print '</td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
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 ( " 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 " )) . '">' ;
print '</td>' ;
print '</tr>' ;
if ( $num > 0 )
{
2015-12-19 02:38:11 +01:00
// Loop on each job
2015-08-31 12:13:23 +02:00
$style = 'pair' ;
2016-08-17 15:40:17 +02:00
$now = dol_now ();
$i = 0 ;
$var = true ;
$totalarray = array ();
while ( $i < min ( $num , $limit ))
2013-04-17 16:26:14 +02:00
{
2016-08-17 15:40:17 +02:00
$obj = $db -> fetch_object ( $result );
$var =! $var ;
if ( ! verifCond ( $obj -> test )) continue ; // Discard line with test = false
2016-01-31 14:58:04 +01:00
2013-03-22 17:10:17 +01:00
// title profil
if ( $style == 'pair' ) { $style = 'impair' ;}
else { $style = 'pair' ;}
2013-03-26 21:18:01 +01:00
2013-03-22 17:10:17 +01:00
print '<tr class="' . $style . '">' ;
2013-03-26 21:18:01 +01:00
2016-01-31 15:37:23 +01:00
print '<td class="nowrap">' ;
2016-08-17 15:40:17 +02:00
print '<a href="' . DOL_URL_ROOT . '/cron/card.php?id=' . $obj -> rowid . '">' ;
2015-06-04 12:57:49 +02:00
print img_picto ( '' , 'object_cron' ) . ' ' ;
2016-08-17 15:40:17 +02:00
print $obj -> rowid ;
2015-06-04 12:57:49 +02:00
print '</a>' ;
print '</td>' ;
print '<td>' ;
2016-08-17 15:40:17 +02:00
if ( ! empty ( $obj -> label ))
2015-06-04 12:57:49 +02:00
{
2016-08-17 15:40:17 +02:00
print '<a href="' . DOL_URL_ROOT . '/cron/card.php?id=' . $obj -> rowid . '">' . $langs -> trans ( $obj -> label ) . '</a>' ;
2013-03-26 21:18:01 +01:00
}
2015-06-04 12:57:49 +02:00
else
{
2015-12-19 02:38:11 +01:00
//print $langs->trans('CronNone');
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 '<td>' ;
2016-08-17 15:40:17 +02:00
if ( $obj -> jobtype == 'method' )
2015-06-04 12:57:49 +02:00
{
2016-01-19 23:45:03 +01:00
$text = $langs -> trans ( " CronClass " );
2016-08-17 15:40:17 +02:00
$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 );
2016-01-19 23:45:03 +01:00
}
2016-08-17 15:40:17 +02:00
elseif ( $obj -> jobtype == 'command' )
2016-01-19 23:45:03 +01:00
{
$text = $langs -> trans ( 'CronCommand' );
2016-08-17 15:40:17 +02:00
$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
}
2016-03-25 15:24:57 +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
2016-01-19 23:45:03 +01:00
print '<td>' ;
2016-08-17 15:40:17 +02:00
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">' ;
2016-08-17 15:40:17 +02:00
if ( ! empty ( $obj -> datestart )) { print dol_print_date ( $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">' ;
2016-08-17 15:40:17 +02:00
if ( ! empty ( $obj -> dateend )) { print dol_print_date ( $obj -> dateend , '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 align="right">' ;
2016-08-17 15:40:17 +02:00
if ( ! empty ( $obj -> maxrun )) { print $obj -> maxrun ;}
2015-12-19 03:27:55 +01:00
print '</td>' ;
print '<td align="right">' ;
2016-08-17 15:40:17 +02:00
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
2016-01-19 23:45:03 +01:00
print '<td class="center">' ;
2016-08-17 15:40:17 +02:00
if ( ! empty ( $obj -> datenextrun )) { print dol_print_date ( $obj -> datenextrun , 'dayhour' );}
2016-01-19 23:45:03 +01:00
print '</td>' ;
2015-12-19 03:27:55 +01:00
print '<td class="center">' ;
2016-08-17 15:40:17 +02:00
if ( ! empty ( $obj -> datelastrun )) { print dol_print_date ( $obj -> datelastrun , 'dayhour' );}
2015-12-19 02:38:11 +01:00
print '</td>' ;
2015-12-19 03:27:55 +01:00
print '<td class="center">' ;
2016-08-17 15:40:17 +02:00
if ( $obj -> lastresult != '' ) { print dol_trunc ( $obj -> lastresult );}
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 '<td>' ;
2016-08-17 15:40:17 +02:00
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
2015-06-04 12:57:49 +02:00
// Status
2013-03-26 21:18:01 +01:00
print '<td align="center">' ;
2016-08-17 15:40:17 +02:00
if ( $obj -> status == 1 ) print $langs -> trans ( " Enabled " );
elseif ( $obj -> status == 2 ) print $langs -> trans ( " Archived " );
2015-12-19 02:38:11 +01:00
else print $langs -> trans ( " Disabled " );
2013-04-17 16:26:14 +02:00
print '</td>' ;
2015-10-07 07:57:09 +02:00
print '<td align="right" class="nowrap">' ;
2016-01-19 23:45:03 +01:00
if ( $user -> rights -> cron -> create )
{
2016-08-17 15:40:17 +02:00
print " <a href= \" " . DOL_URL_ROOT . " /cron/card.php?id= " . $obj -> rowid . " &action=edit " . ( $sortfield ? '&sortfield=' . $sortfield : '' ) . ( $sortorder ? '&sortorder=' . $sortorder : '' ) . $param . " &backtourl= " . urlencode ( $_SERVER [ " PHP_SELF " ]) . " \" title= \" " . dol_escape_htmltag ( $langs -> trans ( 'Edit' )) . " \" > " . img_picto ( $langs -> trans ( 'Edit' ), 'edit' ) . " </a> " ;
2016-01-19 23:45:03 +01:00
}
2015-06-04 12:57:49 +02:00
if ( $user -> rights -> cron -> delete )
{
2016-08-17 15:40:17 +02:00
print " <a href= \" " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $obj -> rowid . " &action=delete " . ( $sortfield ? '&sortfield=' . $sortfield : '' ) . ( $sortorder ? '&sortorder=' . $sortorder : '' ) . $param . " \" title= \" " . dol_escape_htmltag ( $langs -> trans ( 'CronDelete' )) . " \" > " . img_picto ( $langs -> trans ( 'CronDelete' ), 'delete' ) . " </a> " ;
2013-03-22 17:10:17 +01:00
} else {
2015-06-04 12:57:49 +02:00
print " <a href= \" # \" title= \" " . dol_escape_htmltag ( $langs -> trans ( 'NotEnoughPermissions' )) . " \" > " . img_picto ( $langs -> trans ( 'NotEnoughPermissions' ), 'delete' ) . " </a> " ;
2013-03-22 17:10:17 +01:00
}
2015-06-04 12:57:49 +02:00
if ( $user -> rights -> cron -> execute )
{
2016-09-09 18:24:51 +02:00
if ( ! empty ( $obj -> status )) print " <a href= \" " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $obj -> rowid . " &action=execute " . ( empty ( $conf -> global -> CRON_KEY ) ? '' : '&securitykey=' . $conf -> global -> CRON_KEY ) . ( $sortfield ? '&sortfield=' . $sortfield : '' ) . ( $sortorder ? '&sortorder=' . $sortorder : '' ) . $param . " \" title= \" " . dol_escape_htmltag ( $langs -> trans ( 'CronExecute' )) . " \" > " . img_picto ( $langs -> trans ( 'CronExecute' ), " play " ) . " </a> " ;
2016-09-10 19:48:50 +02:00
else print " <a href= \" # \" title= \" " . dol_escape_htmltag ( $langs -> trans ( 'JobDisabled' )) . " \" > " . img_picto ( $langs -> trans ( 'JobDisabled' ), " playdisabled " ) . " </a> " ;
2013-03-22 17:10:17 +01:00
} else {
2016-09-10 19:48:50 +02:00
print " <a href= \" # \" title= \" " . dol_escape_htmltag ( $langs -> trans ( 'NotEnoughPermissions' )) . " \" > " . img_picto ( $langs -> trans ( 'NotEnoughPermissions' ), " playdisabled " ) . " </a> " ;
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>' ;
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
{
2016-09-10 19:53:32 +02:00
print '<tr><td colspan="9" class="opacitymedium">' . $langs -> trans ( 'CronNoJobs' ) . '</td></tr>' ;
2013-06-23 22:30:33 +02:00
}
print '</table>' ;
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
2013-06-23 22:21:21 +02:00
dol_print_cron_urls ();
2013-03-22 17:10:17 +01:00
llxFooter ();
2013-03-27 13:24:26 +01:00
$db -> close ();