FIX #6586 Introduce processing status
This commit is contained in:
parent
41063e7cf2
commit
6bf61c677f
@ -55,6 +55,7 @@ class Cronjob extends CommonObject
|
||||
var $unitfrequency;
|
||||
var $frequency;
|
||||
var $status;
|
||||
var $processing;
|
||||
var $fk_user_author;
|
||||
var $fk_user_mod;
|
||||
var $nbrun;
|
||||
@ -287,6 +288,7 @@ class Cronjob extends CommonObject
|
||||
$sql.= " t.unitfrequency,";
|
||||
$sql.= " t.frequency,";
|
||||
$sql.= " t.status,";
|
||||
$sql.= " t.processing,";
|
||||
$sql.= " t.fk_user_author,";
|
||||
$sql.= " t.fk_user_mod,";
|
||||
$sql.= " t.note,";
|
||||
@ -330,6 +332,7 @@ class Cronjob extends CommonObject
|
||||
$this->unitfrequency = $obj->unitfrequency;
|
||||
$this->frequency = $obj->frequency;
|
||||
$this->status = $obj->status;
|
||||
$this->processing = $obj->processing;
|
||||
$this->fk_user_author = $obj->fk_user_author;
|
||||
$this->fk_user_mod = $obj->fk_user_mod;
|
||||
$this->note = $obj->note;
|
||||
@ -352,15 +355,16 @@ class Cronjob extends CommonObject
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param string $sortorder sort order
|
||||
* @param string $sortfield sort field
|
||||
* @param int $limit limit page
|
||||
* @param int $offset page
|
||||
* @param int $status display active or not
|
||||
* @param array $filter filter output
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param string $sortorder sort order
|
||||
* @param string $sortfield sort field
|
||||
* @param int $limit limit page
|
||||
* @param int $offset page
|
||||
* @param int $status display active or not
|
||||
* @param array $filter filter output
|
||||
* @param int $processing Processing or not
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='')
|
||||
function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='', $processing=-1)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@ -391,6 +395,7 @@ class Cronjob extends CommonObject
|
||||
$sql.= " t.unitfrequency,";
|
||||
$sql.= " t.frequency,";
|
||||
$sql.= " t.status,";
|
||||
$sql.= " t.processing,";
|
||||
$sql.= " t.fk_user_author,";
|
||||
$sql.= " t.fk_user_mod,";
|
||||
$sql.= " t.note,";
|
||||
@ -399,6 +404,7 @@ class Cronjob extends CommonObject
|
||||
$sql.= " t.test";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
|
||||
$sql.= " WHERE 1 = 1";
|
||||
if ($processing >= 0) $sql.= " AND t.processing = ".(empty($processing)?'0':'1');
|
||||
if ($status >= 0 && $status < 2) $sql.= " AND t.status = ".(empty($status)?'0':'1');
|
||||
if ($status == 2) $sql.= " AND t.status = 2";
|
||||
//Manage filter
|
||||
@ -463,6 +469,7 @@ class Cronjob extends CommonObject
|
||||
$line->unitfrequency = $obj->unitfrequency;
|
||||
$line->frequency = $obj->frequency;
|
||||
$line->status = $obj->status;
|
||||
$line->processing = $obj->processing;
|
||||
$line->fk_user_author = $obj->fk_user_author;
|
||||
$line->fk_user_mod = $obj->fk_user_mod;
|
||||
$line->note = $obj->note;
|
||||
@ -520,9 +527,11 @@ class Cronjob extends CommonObject
|
||||
if (isset($this->status)) $this->status=trim($this->status);
|
||||
if (isset($this->note)) $this->note=trim($this->note);
|
||||
if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun);
|
||||
if (empty($this->maxrun)) $this->maxrun=0;
|
||||
if (isset($this->libname)) $this->libname = trim($this->libname);
|
||||
if (isset($this->test)) $this->test = trim($this->test);
|
||||
|
||||
if (empty($this->maxrun)) $this->maxrun=0;
|
||||
if (empty($this->processing)) $this->processing=0;
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add a control on parameters values
|
||||
@ -588,6 +597,7 @@ class Cronjob extends CommonObject
|
||||
$sql.= " unitfrequency=".(isset($this->unitfrequency)?$this->unitfrequency:"null").",";
|
||||
$sql.= " frequency=".(isset($this->frequency)?$this->frequency:"null").",";
|
||||
$sql.= " status=".(isset($this->status)?$this->status:"null").",";
|
||||
$sql.= " processing=".((isset($this->processing) && $this->processing > 0)?$this->processing:"0").",";
|
||||
$sql.= " fk_user_mod=".$user->id.",";
|
||||
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
|
||||
$sql.= " nbrun=".((isset($this->nbrun) && $this->nbrun >0)?$this->nbrun:"null").",";
|
||||
@ -786,7 +796,8 @@ class Cronjob extends CommonObject
|
||||
$this->lastresult='';
|
||||
$this->unitfrequency='';
|
||||
$this->frequency='';
|
||||
$this->status='';
|
||||
$this->status=0;
|
||||
$this->processing=0;
|
||||
$this->fk_user_author='';
|
||||
$this->fk_user_mod='';
|
||||
$this->note='';
|
||||
@ -898,6 +909,7 @@ class Cronjob extends CommonObject
|
||||
$this->datelastresult=null;
|
||||
$this->lastoutput='';
|
||||
$this->lastresult='';
|
||||
$this->processing = 1; // To know job was started
|
||||
$this->nbrun=$this->nbrun + 1;
|
||||
$result = $this->update($user); // This include begin/commit
|
||||
if ($result<0) {
|
||||
@ -1099,6 +1111,7 @@ class Cronjob extends CommonObject
|
||||
dol_syslog(get_class($this)."::run_jobs now we update job to track it is finished (with success or error)");
|
||||
|
||||
$this->datelastresult=dol_now();
|
||||
$this->processing=0;
|
||||
$result = $this->update($user); // This include begin/commit
|
||||
if ($result < 0)
|
||||
{
|
||||
|
||||
@ -125,6 +125,9 @@ INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('USER_A
|
||||
ALTER TABLE llx_chargesociales ADD COLUMN ref varchar(16);
|
||||
ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL;
|
||||
|
||||
ALTER TABLE llx_cronjob ADD COLUMN processing integer NOT NULL DEFAULT 0;
|
||||
|
||||
|
||||
create table llx_payment_various
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
@ -144,3 +147,6 @@ create table llx_payment_various
|
||||
fk_user_author integer,
|
||||
fk_user_modif integer
|
||||
)ENGINE=innodb;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ CREATE TABLE llx_cronjob
|
||||
nbrun integer, -- nb of run complete (failed or not)
|
||||
autodelete integer DEFAULT 0, -- 0=Job is kept unchanged once nbrun > maxrun or date > dateend, 2=Job must be archived (archive = status 2) once nbrun > maxrun or date > dateend
|
||||
status integer NOT NULL DEFAULT 1, -- 0=disabled, 1=enabled, 2=archived
|
||||
processing integer NOT NULL DEFAULT 0, -- 1=process currently running
|
||||
test varchar(255) DEFAULT '1',
|
||||
fk_user_author integer DEFAULT NULL,
|
||||
fk_user_mod integer DEFAULT NULL,
|
||||
|
||||
@ -111,7 +111,7 @@ if (! empty($id))
|
||||
$filter['t.rowid']=$id;
|
||||
}
|
||||
|
||||
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter);
|
||||
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter, 0);
|
||||
if ($result<0)
|
||||
{
|
||||
echo "Error: ".$cronjob->error;
|
||||
|
||||
@ -128,7 +128,7 @@ if (! empty($id)) {
|
||||
$filter['t.rowid']=$id;
|
||||
}
|
||||
|
||||
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter);
|
||||
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter, 0);
|
||||
if ($result<0)
|
||||
{
|
||||
echo "Error: ".$object->error;
|
||||
@ -136,7 +136,7 @@ if ($result<0)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// TODO This sequence of code must be shared with code into cron_run_jobs.php php page.
|
||||
// TODO This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page.
|
||||
|
||||
// current date
|
||||
$now=dol_now();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user