diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 2230aebdbb5..c6d32ac2ea3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -4134,7 +4134,7 @@ class Form
* - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location)
* - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1)
*
- * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date.
+ * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date (emptydate must be 0).
* @param string $prefix Prefix for fields name
* @param int $h 1=Show also hours
* @param int $m 1=Show also minutes
diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php
index 76781d6645e..79b1cfa996c 100644
--- a/htdocs/cron/card.php
+++ b/htdocs/cron/card.php
@@ -142,6 +142,7 @@ if ($action=='add')
$object->note=GETPOST('note');
$object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int'));
$object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int'));
+ $object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int'));
$object->unitfrequency=GETPOST('unitfrequency','int');
$object->frequency=GETPOST('nbfrequency','int');
$object->maxrun=GETPOST('maxrun','int');
@@ -177,6 +178,7 @@ if ($action=='update')
$object->note=GETPOST('note');
$object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int'));
$object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int'));
+ $object->datenextrun=dol_mktime(GETPOST('datenextrunhour','int'), GETPOST('datenextrunmin','int'), 0, GETPOST('datenextrunmonth','int'), GETPOST('datenextrunday','int'), GETPOST('datenextrunyear','int'));
$object->unitfrequency=GETPOST('unitfrequency','int');
$object->frequency=GETPOST('nbfrequency','int');
$object->maxrun=GETPOST('maxrun','int');
@@ -475,7 +477,7 @@ if (($action=="create") || ($action=="edit"))
$form->select_date($object->dateend,'dateend',1,1,'',"cronform");
}
else{
- $form->select_date('','dateend',1,1,1,"cronform");
+ $form->select_date(-1,'dateend',1,1,1,"cronform");
}
print "";
print "
";
@@ -506,6 +508,23 @@ if (($action=="create") || ($action=="edit"))
print " | ";
print "\n";
+ print '| ';
+ print $langs->trans('CronDtNextLaunch');
+ print ' ('.$langs->trans('CronFrom').')';
+ print " | ";
+ if(!empty($object->datenextrun))
+ {
+ $form->select_date($object->datenextrun,'datenextrun',1,1,'',"cronform");
+ }
+ else
+ {
+ $form->select_date(-1,'datenextrun',1,1,'',"cronform");
+ }
+ print " | ";
+ print "";
+ print " | ";
+ print "
";
+
print '';
dol_fiche_end();
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 31b4fc39c7c..9ef47c30ea7 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -107,7 +107,8 @@ class Cronjob extends CommonObject
if (isset($this->note)) $this->note=trim($this->note);
if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun);
if (isset($this->libname)) $this->libname = trim($this->libname);
-
+ if (isset($this->test)) $this->test = trim($this->test);
+
// Check parameters
// Put here code to add a control on parameters values
if (dol_strlen($this->datestart)==0) {
@@ -177,11 +178,9 @@ class Cronjob extends CommonObject
$sql.= "note,";
$sql.= "nbrun,";
$sql.= "maxrun,";
- $sql.= "libname";
-
-
+ $sql.= "libname,";
+ $sql.= "test";
$sql.= ") VALUES (";
-
$sql.= " '".$this->db->idate($now)."',";
$sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
@@ -208,7 +207,8 @@ 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.= " ".(empty($this->maxrun)?'null':"'".$this->db->escape($this->maxrun)."'").",";
- $sql.= " ".(! isset($this->libname)?'NULL':"'".$this->db->escape($this->libname)."'")."";
+ $sql.= " ".(! isset($this->libname)?'NULL':"'".$this->db->escape($this->libname)."'").",";
+ $sql.= " ".(! isset($this->test)?'NULL':"'".$this->db->escape($this->test)."'")."";
$sql.= ")";
$this->db->begin();
@@ -292,9 +292,8 @@ class Cronjob extends CommonObject
$sql.= " t.note,";
$sql.= " t.nbrun,";
$sql.= " t.maxrun,";
- $sql.= " t.libname";
-
-
+ $sql.= " t.libname,";
+ $sql.= " t.test";
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
$sql.= " WHERE t.rowid = ".$id;
@@ -337,7 +336,7 @@ class Cronjob extends CommonObject
$this->nbrun = $obj->nbrun;
$this->maxrun = $obj->maxrun;
$this->libname = $obj->libname;
-
+ $this->test = $obj->test;
}
$this->db->free($resql);
@@ -394,7 +393,6 @@ class Cronjob extends CommonObject
$sql.= " t.nbrun,";
$sql.= " t.libname,";
$sql.= " t.test";
-
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
$sql.= " WHERE 1 = 1";
if ($status >= 0) $sql.= " AND t.status = ".(empty($status)?'0':'1');
@@ -521,7 +519,8 @@ class Cronjob extends CommonObject
if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun);
if (isset($this->maxrun)) $this->maxrun=trim($this->maxrun);
if (isset($this->libname)) $this->libname = trim($this->libname);
-
+ if (isset($this->test)) $this->test = trim($this->test);
+
// Check parameters
// Put here code to add a control on parameters values
if (dol_strlen($this->datestart)==0) {
@@ -588,10 +587,11 @@ class Cronjob extends CommonObject
$sql.= " status=".(isset($this->status)?$this->status:"null").",";
$sql.= " fk_user_mod=".$user->id.",";
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
- $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null").",";
- $sql.= " maxrun=".(isset($this->maxrun)?$this->maxrun:"null").",";
- $sql.= " libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null");
- $sql.= " WHERE rowid=".$this->id;
+ $sql.= " nbrun=".((isset($this->nbrun) && $this->nbrun >0)?$this->nbrun:"null").",";
+ $sql.= " maxrun=".((isset($this->maxrun) && $this->maxrun > 0)?$this->maxrun:"null").",";
+ $sql.= " libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null").",";
+ $sql.= " test=".(isset($this->test)?"'".$this->db->escape($this->test)."'":"null");
+ $sql.= " WHERE rowid=".$this->id;
$this->db->begin();
diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php
index b6d830dd201..49f5878d436 100644
--- a/htdocs/cron/list.php
+++ b/htdocs/cron/list.php
@@ -228,7 +228,7 @@ if ($num > 0)
print '';
- print '| ';
+ print ' | ';
print '';
print img_picto('', 'object_cron').' ';
print $line->id;
diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php
index cfd4b28711d..fc8e15aeed6 100644
--- a/htdocs/public/cron/cron_run_jobs.php
+++ b/htdocs/public/cron/cron_run_jobs.php
@@ -144,7 +144,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
$result=$cronjob->fetch($line->id);
if ($result<0)
{
- echo "Error:".$cronjob->error;
+ echo "Error:".$cronjob->error." \n";
dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR);
exit;
}
@@ -152,7 +152,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
$result=$cronjob->run_jobs($userlogin);
if ($result < 0)
{
- echo "Error:".$cronjob->error;
+ echo "Error:".$cronjob->error." \n";
dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR);
$nbofjobslaunchedko++;
}
@@ -165,7 +165,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
$result=$cronjob->reprogram_jobs($userlogin, $now);
if ($result<0)
{
- echo "Error:".$cronjob->error;
+ echo "Error:".$cronjob->error." \n";
dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR);
exit;
}
|