';
-
+
print '| ';
print $langs->trans('CronId')." | ";
print "".$form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'id');
@@ -466,7 +480,7 @@ if (($action=="create") || ($action=="edit")) {
print $langs->trans('CronLabel')." | ";
print "".$object->label;
print " |
";
-
+
print "| ";
print $langs->trans('CronType')." | ";
print $formCron->select_typejob('jobtype',$object->jobtype,1);
@@ -476,32 +490,32 @@ if (($action=="create") || ($action=="edit")) {
print $langs->trans('CronHourStart')." | ";
if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhourtext');} else {print $langs->trans('CronNone');}
print " |
";
-
+
print "| ";
print $langs->trans('CronDtEnd')." | ";
if(!empty($object->dateend)) {print dol_print_date($object->dateend,'dayhourtext');} else {print $langs->trans('CronNone');}
print " |
";
-
+
print "| ";
print $langs->trans('CronPriority')." | ";
print "".$object->priority;
print " |
";
-
+
print "| ";
print $langs->trans('CronNbRun')." | ";
print "".$object->nbrun;
print " |
";
-
+
print "| ";
print $langs->trans('CronEvery')." | ";
print "";
if($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Minutes');
if($object->unitfrequency == "3600") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Hours');
if($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Days');
- if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Weeks');
+ if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Weeks');
print " |
";
-
-
+
+
print '| ';
print $langs->trans('CronModule')." | ";
print $object->module_name;
@@ -526,44 +540,48 @@ if (($action=="create") || ($action=="edit")) {
print $langs->trans('CronArgs')." | ";
print $object->params;
print " |
";
-
+
print '| ';
print $langs->trans('CronCommand')." | ";
print $object->command;
print " |
";
-
+
print '| ';
print $langs->trans('CronNote')." | ";
print $object->note;
print " |
";
-
+
print '| ';
print $langs->trans('CronDtLastLaunch')." | ";
if(!empty($object->datelastrun)) {print dol_print_date($object->datelastrun,'dayhourtext');} else {print $langs->trans('CronNone');}
print " |
";
-
+
print '| ';
print $langs->trans('CronDtNextLaunch')." | ";
if(!empty($object->datenextrun)) {print dol_print_date($object->datenextrun,'dayhourtext');} else {print $langs->trans('CronNone');}
print " |
";
-
+
print '| ';
print $langs->trans('CronDtLastResult')." | ";
if(!empty($object->datelastresult)) {print dol_print_date($object->datelastresult,'dayhourtext');} else {print $langs->trans('CronNone');}
print " |
";
-
+
print '| ';
print $langs->trans('CronLastResult')." | ";
print $object->lastresult;
print " |
";
-
+
print '| ';
print $langs->trans('CronLastOutput')." | ";
print nl2br($object->lastoutput);
print " |
";
print '
';
-
+
+
+ print dol_fiche_end();
+
+
print "\n\n\n";
if (! $user->rights->cron->create) {
print '
'.$langs->trans("Edit").'';
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index b24055c6f3d..ebc6c4952e3 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -37,7 +37,7 @@ class Cronjob extends CommonObject
var $table_element='cronjob'; //!< Name of table without prefix where object is stored
var $id;
-
+
var $ref; //Use for prevnext_ref
var $jobtype;
var $tms='';
@@ -65,10 +65,10 @@ class Cronjob extends CommonObject
var $fk_user_mod;
var $note;
var $nbrun;
-
+
var $lines;
-
+
/**
@@ -96,7 +96,7 @@ class Cronjob extends CommonObject
$error=0;
// Clean parameters
-
+
if (isset($this->label)) $this->label=trim($this->label);
if (isset($this->jobtype)) $this->jobtype=trim($this->jobtype);
if (isset($this->command)) $this->command=trim($this->command);
@@ -152,7 +152,7 @@ class Cronjob extends CommonObject
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob(";
-
+
$sql.= "datec,";
$sql.= "jobtype,";
$sql.= "label,";
@@ -179,9 +179,9 @@ class Cronjob extends CommonObject
$sql.= "note,";
$sql.= "nbrun";
-
+
$sql.= ") VALUES (";
-
+
$sql.= " ".$this->db->idate(dol_now()).",";
$sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
@@ -208,16 +208,16 @@ class Cronjob extends CommonObject
$sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").",";
$sql.= " ".(! isset($this->nbrun)?'0':"'".$this->db->escape($this->nbrun)."'")."";
-
+
$sql.= ")";
-
+
$this->db->begin();
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
-
+
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."cronjob");
@@ -266,7 +266,7 @@ class Cronjob extends CommonObject
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
-
+
$sql.= " t.tms,";
$sql.= " t.datec,";
$sql.= " t.jobtype,";
@@ -294,7 +294,7 @@ class Cronjob extends CommonObject
$sql.= " t.note,";
$sql.= " t.nbrun";
-
+
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
$sql.= " WHERE t.rowid = ".$id;
@@ -308,7 +308,7 @@ class Cronjob extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
-
+
$this->tms = $this->db->jdate($obj->tms);
$this->datec = $this->db->jdate($obj->datec);
$this->label = $obj->label;
@@ -336,7 +336,7 @@ class Cronjob extends CommonObject
$this->note = $obj->note;
$this->nbrun = $obj->nbrun;
-
+
}
$this->db->free($resql);
@@ -349,7 +349,7 @@ class Cronjob extends CommonObject
return -1;
}
}
-
+
/**
* Load object in memory from the database
*
@@ -392,8 +392,8 @@ class Cronjob extends CommonObject
$sql.= " t.fk_user_mod,";
$sql.= " t.note,";
$sql.= " t.nbrun";
-
-
+
+
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
$status = (empty($status))?'0':'1';
$sql.= " WHERE t.status=".$status;
@@ -403,43 +403,43 @@ class Cronjob extends CommonObject
$sql.= ' AND '.$key.' LIKE \'%'.$value.'%\'';
}
}
-
-
- $sql.= " ORDER BY $sortfield $sortorder ";
+
+
+ $sql.= " ORDER BY $sortfield $sortorder ";
if (!empty($limit) && !empty($offset)) {
$sql.= $this->db->plimit( $limit + 1 ,$offset);
}
-
+
$sqlwhere = array();
-
+
if (!empty($module_name)) {
$sqlwhere[]='(t.module_name='.$module_name.')';
}
if (count($sqlwhere)>0) {
$sql.= " WHERE ".implode(' AND ',$sqlwhere);
}
-
+
dol_syslog(get_class($this)."::fetch_all sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
-
+
if ($num)
{
$this->lines=array();
-
+
while ($i < $num)
{
-
+
$line = new Cronjobline();
-
+
$obj = $this->db->fetch_object($resql);
-
+
$line->id = $obj->rowid;
$line->ref = $obj->rowid;
-
+
$line->tms = $this->db->jdate($obj->tms);
$line->datec = $this->db->jdate($obj->datec);
$line->label = $obj->label;
@@ -466,15 +466,15 @@ class Cronjob extends CommonObject
$line->fk_user_mod = $obj->fk_user_mod;
$line->note = $obj->note;
$line->nbrun = $obj->nbrun;
-
+
$this->lines[]=$line;
-
+
$i++;
-
+
}
}
$this->db->free($resql);
-
+
return 1;
}
else
@@ -496,13 +496,13 @@ class Cronjob extends CommonObject
function update($user=0, $notrigger=0)
{
global $conf, $langs;
-
+
$langs->load('cron');
-
+
$error=0;
// Clean parameters
-
+
if (isset($this->label)) $this->label=trim($this->label);
if (isset($this->jobtype)) $this->jobtype=trim($this->jobtype);
if (isset($this->command)) $this->command=trim($this->command);
@@ -558,11 +558,11 @@ class Cronjob extends CommonObject
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject'));
$error++;
}
-
+
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."cronjob SET";
-
+
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " jobtype=".(isset($this->jobtype)?"'".$this->db->escape($this->jobtype)."'":"null").",";
$sql.= " command=".(isset($this->command)?"'".$this->db->escape($this->command)."'":"null").",";
@@ -587,7 +587,7 @@ class Cronjob extends CommonObject
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
$sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null");
-
+
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
@@ -595,7 +595,7 @@ class Cronjob extends CommonObject
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
-
+
if (! $error)
{
if (! $notrigger)
@@ -755,7 +755,7 @@ class Cronjob extends CommonObject
{
$this->id=0;
$this->ref=0;
-
+
$this->tms='';
$this->datec='';
$this->label='';
@@ -780,24 +780,24 @@ class Cronjob extends CommonObject
$this->status='';
$this->fk_user_author='';
$this->fk_user_mod='';
- $this->note='';
+ $this->note='';
$this->nbrun='';
}
-
+
/**
- * Load object information
+ * Load object information
*
* @return void
*/
function info()
{
global $langs;
-
+
$sql = "SELECT";
$sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author";
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as f";
$sql.= " WHERE f.rowid = ".$this->id;
-
+
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
@@ -812,7 +812,7 @@ class Cronjob extends CommonObject
$this->user_creation = $obj->fk_user_author;
}
$this->db->free($resql);
-
+
return 1;
}
else
@@ -822,26 +822,26 @@ class Cronjob extends CommonObject
return -1;
}
}
-
+
/**
* Run a job
- *
+ *
* @param string $userlogin User login
* @return int <0 if KO, >0 if OK
*/
function run_jobs($userlogin)
{
global $langs, $conf;
-
+
$langs->load('cron');
-
+
if (empty($userlogin)) {
$this->error="User login is mandatory";
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
return -1;
}
-
+
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$user=new User($this->db);
$result=$user->fetch('',$userlogin);
@@ -856,14 +856,14 @@ class Cronjob extends CommonObject
return -1;
}
}
-
+
dol_syslog(get_class($this)."::run_jobs userlogin:$userlogin", LOG_DEBUG);
-
+
$error=0;
$now=dol_now();
-
+
$this->db->begin();
-
+
if ($this->jobtype=='method') {
// load classes
$ret=dol_include_once("/".$this->module_name."/class/".$this->classesname,$this->objectname);
@@ -872,19 +872,19 @@ class Cronjob extends CommonObject
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
return -1;
}
-
+
// Load langs
$result=$langs->load($this->module_name.'@'.$this->module_name);
if ($result<0) {
dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR);
return -1;
}
-
+
dol_syslog(get_class($this)."::run_jobs ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG);
-
+
// Create Object for the call module
$object = new $this->objectname($this->db);
-
+
$params_arr = array();
$params_arr=explode(", ",$this->params);
if (!is_array($params_arr)) {
@@ -892,7 +892,7 @@ class Cronjob extends CommonObject
}else {
$result = call_user_func_array(array($object, $this->methodename), $params_arr);
}
-
+
if ($result===false) {
dol_syslog(get_class($this)."::run_jobs ".$object->error, LOG_ERR);
return -1;
@@ -900,15 +900,15 @@ class Cronjob extends CommonObject
$this->lastoutput=var_export($result,true);
$this->lastresult=var_export($result,true);
}
-
+
} elseif ($this->jobtype=='command') {
dol_syslog(get_class($this)."::run_jobs system:".$this->command, LOG_DEBUG);
$output_arr=array();
-
+
exec($this->command, $output_arr,$retval);
-
+
dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG);
-
+
$this->lastoutput='';
if (is_array($output_arr) && count($output_arr)>0) {
foreach($output_arr as $val) {
@@ -917,7 +917,7 @@ class Cronjob extends CommonObject
}
$this->lastresult=$retval;
}
-
+
$this->datelastresult=$now;
$this->datelastrun=$now;
$this->nbrun=$this->nbrun+1;
@@ -930,23 +930,23 @@ class Cronjob extends CommonObject
$this->db->commit();
return 1;
}
-
-
+
+
}
-
+
/**
* Reprogram a job
*
* @param string $userlogin User login
- * @return int <0 if KO, >0 if OK
- *
+ * @return int <0 if KO, >0 if OK
+ *
*/
function reprogram_jobs($userlogin)
{
global $langs, $conf;
-
+
dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG);
-
+
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$user=new User($this->db);
$result=$user->fetch('',$userlogin);
@@ -961,9 +961,9 @@ class Cronjob extends CommonObject
return -1;
}
}
-
+
dol_syslog(get_class($this)."::reprogram_jobs ", LOG_DEBUG);
-
+
if (empty($this->datenextrun)) {
$this->datenextrun=dol_now()+$this->frequency;
} else {
@@ -972,15 +972,15 @@ class Cronjob extends CommonObject
} else {
$this->datenextrun=$this->datenextrun+$this->frequency;
}
- }
+ }
$result = $this->update($user);
if ($result<0) {
dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR);
return -1;
}
-
+
return 1;
-
+
}
}
@@ -989,10 +989,10 @@ class Cronjob extends CommonObject
* Crob Job line class
*/
class Cronjobline{
-
+
var $id;
var $ref;
-
+
var $tms='';
var $datec='';
var $label;
@@ -1018,7 +1018,7 @@ class Cronjobline{
var $fk_user_mod;
var $note;
var $nbrun;
-
+
/**
* Constructor
*
diff --git a/htdocs/langs/fr_FR/cron.lang b/htdocs/langs/fr_FR/cron.lang
index d0aaccfecf7..b5fa47b336a 100644
--- a/htdocs/langs/fr_FR/cron.lang
+++ b/htdocs/langs/fr_FR/cron.lang
@@ -9,8 +9,8 @@ URLToLaunchCronJobs=URL pour lancer les taches automatiques
OrToLaunchASpecificJob=Ou pour lancer une tache spécifique
KeyForCronAccess=Clé de sécurité pour l'URL de lancement des taches automatiques
FileToLaunchCronJobs=Commande pour lancer les taches automatiques
-CronExplainHowToRunUnix=Sur un environement Unix vous pouvez paramétré CronTab pour executer cette commande toute les minutes
-CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utilisr le planificateur de tache pour lancer cette commande toute les minutes
+CronExplainHowToRunUnix=Sur un environement Unix vous pouvez paramétrer CronTab pour executer cette commande toute les minutes.
+CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utiliser le planificateur de tache pour lancer cette commande toute les minutes.
#
# Menu
diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php
index 838c298212f..7f25cfaf63c 100644
--- a/htdocs/public/cron/cron_run_jobs.php
+++ b/htdocs/public/cron/cron_run_jobs.php
@@ -49,7 +49,7 @@ if (empty($key)) {
echo 'securitykey is require';
exit;
}
-if($key != $conf->global->MAIN_CRON_KEY)
+if($key != $conf->global->CRON_KEY)
{
echo 'securitykey is wrong';
exit;
@@ -104,13 +104,13 @@ if(is_array($object->lines) && (count($object->lines)>0)){
foreach($object->lines as $line){
dol_syslog("cron_run_jobs.php:: fetch cronjobid:".$line->id, LOG_ERR);
-
+
//If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database
if ((($line->datenextrun <= $now) && $line->dateend < $now)
|| ((empty($line->datenextrun)) && (empty($line->dateend)))){
-
+
dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourtext')." line->dateend:".dol_print_date($line->dateend,'dayhourtext')." now:".dol_print_date($now,'dayhourtext'), LOG_ERR);
-
+
$cronjob=new Cronjob($db);
$result=$cronjob->fetch($line->id);
if ($result<0) {
@@ -125,7 +125,7 @@ if(is_array($object->lines) && (count($object->lines)>0)){
dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR);
exit;
}
-
+
// we re-program the next execution and stores the last execution time for this job
$result=$cronjob->reprogram_jobs($userlogin);
if ($result<0) {
@@ -133,7 +133,7 @@ if(is_array($object->lines) && (count($object->lines)>0)){
dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR);
exit;
}
-
+
}
}
echo "OK";
diff --git a/htdocs/theme/eldy/img/menus/object_cron.png b/htdocs/theme/eldy/img/object_cron.png
similarity index 100%
rename from htdocs/theme/eldy/img/menus/object_cron.png
rename to htdocs/theme/eldy/img/object_cron.png
diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php
old mode 100644
new mode 100755
index 0c22107bde6..159fadd3a61
--- a/scripts/cron/cron_run_jobs.php
+++ b/scripts/cron/cron_run_jobs.php
@@ -27,72 +27,74 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
-if (! defined('NOLOGIN')) define('NOLOGIN','1');
+if (! defined('NOLOGIN')) define('NOLOGIN','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
-$sapi_type = php_sapi_name();
-$script_file = basename(__FILE__);
-$path=dirname(__FILE__).'/';
-
-// Test if batch mode
-if (substr($sapi_type, 0, 3) == 'cgi') {
- echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
- exit;
-}
+$sapi_type = php_sapi_name();
+$script_file = basename(__FILE__);
+$path=dirname(__FILE__).'/';
+
+// Test if batch mode
+if (substr($sapi_type, 0, 3) == 'cgi') {
+ echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
+ exit;
+}
+
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n";
exit;
}
-$key=$argv[1];
+$key=$argv[1];
-if (! isset($argv[2]) || ! $argv[2]) {
- print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n";
- exit;
-} else {
- $userlogin=$argv[2];
-}
+if (! isset($argv[2]) || ! $argv[2]) {
+ print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n";
+ exit;
+} else {
+ $userlogin=$argv[2];
+}
+
+require_once ($path."../../htdocs/master.inc.php");
+require_once (DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php");
+require_once (DOL_DOCUMENT_ROOT.'/user/class/user.class.php');
+require_once (DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php");
-$res=@include("../../master.inc.php"); // For root directory
-if (! $res) $res=@include("../../../master.inc.php"); // For "custom" directory
-if (! $res) die("Include of master.inc.php fails");
+/*
+ * Main
+ */
-
-// librarie jobs
-require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php");
-
-
-//Check security key
-if($key != $conf->global->MAIN_CRON_KEY)
+// Check security key
+if ($key != $conf->global->CRON_KEY)
{
- echo 'securitykey is wrong';
+ print "Error: securitykey is wrong\n";
exit;
}
-//Check user login
-require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
+// Check user login
$user=new User($db);
$result=$user->fetch('',$userlogin);
-if ($result<0) {
- echo "User Error:".$user->error;
+if ($result < 0)
+{
+ echo "User Error: ".$user->error;
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
exit;
-}else {
- if (empty($user->id)) {
- echo " User user login:".$userlogin." do not exists";
+}
+else
+{
+ if (empty($user->id))
+ {
+ echo " User user login: ".$userlogin." do not exists";
dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR);
exit;
}
}
-if (isset($argv[3]) || $argv[3]) {
+if (isset($argv[3]) || $argv[3])
+{
$id = $argv[3];
}
-// librarie jobs
-require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php");
-
// create a jobs object
$object = new Cronjob($db);
@@ -103,18 +105,21 @@ if (empty($id)) {
}
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter);
-if ($result<0) {
- echo "Error:".$cronjob->error;
- dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR);
+if ($result<0)
+{
+ echo "Error: ".$object->error;
+ dol_syslog("cron_run_jobs.php:: fetch Error ".$object->error, LOG_ERR);
exit;
}
// current date
$now=dol_now();
-if(is_array($object->lines) && (count($object->lines)>0)){
+if(is_array($object->lines) && (count($object->lines)>0))
+{
// Loop over job
- foreach($object->lines as $line){
+ foreach($object->lines as $line)
+ {
//If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database
if (($line->datenextrun < $now) && $line->dateend < $now){
@@ -132,7 +137,7 @@ if(is_array($object->lines) && (count($object->lines)>0)){
dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR);
exit;
}
-
+
// we re-program the next execution and stores the last execution time for this job
$result=$cronjob->reprogram_jobs($userlogin);
if ($result<0) {
@@ -140,7 +145,10 @@ if(is_array($object->lines) && (count($object->lines)>0)){
dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR);
exit;
}
-
+
}
}
-}
\ No newline at end of file
+}
+
+$db->close();
+?>
\ No newline at end of file