New: Add ref_ext on actions
This commit is contained in:
parent
ecb6c1e67d
commit
28d6fc03f9
@ -34,6 +34,7 @@ class ActionComm extends CommonObject
|
|||||||
{
|
{
|
||||||
public $element='action';
|
public $element='action';
|
||||||
public $table_element = 'actioncomm';
|
public $table_element = 'actioncomm';
|
||||||
|
public $table_rowid = 'id';
|
||||||
protected $ismultientitymanaged = 2; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
protected $ismultientitymanaged = 2; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||||
|
|
||||||
var $type_id;
|
var $type_id;
|
||||||
@ -82,7 +83,8 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param db Database handler
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
function ActionComm($db)
|
function ActionComm($db)
|
||||||
{
|
{
|
||||||
@ -123,12 +125,13 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
if (! $this->type_id && $this->type_code)
|
if (! $this->type_id && $this->type_code)
|
||||||
{
|
{
|
||||||
// Get id from code
|
// Get id from code
|
||||||
$cactioncomm=new CActionComm($this->db);
|
$cactioncomm=new CActionComm($this->db);
|
||||||
$result=$cactioncomm->fetch($this->type_code);
|
$result=$cactioncomm->fetch($this->type_code);
|
||||||
if ($result > 0)
|
|
||||||
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$this->type_id=$cactioncomm->id;
|
$this->type_id=$cactioncomm->id;
|
||||||
}
|
}
|
||||||
else if ($result == 0)
|
else if ($result == 0)
|
||||||
{
|
{
|
||||||
@ -149,7 +152,6 @@ class ActionComm extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm";
|
||||||
@ -879,6 +881,31 @@ class ActionComm extends CommonObject
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise an instance with random values.
|
||||||
|
* Used to build previews or test instances.
|
||||||
|
* id must be 0 if object instance is a specimen.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function initAsSpecimen()
|
||||||
|
{
|
||||||
|
global $user,$langs,$conf;
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
|
// Initialise parametres
|
||||||
|
$this->id=0;
|
||||||
|
$this->specimen=1;
|
||||||
|
|
||||||
|
$this->type_code='AC_OTH';
|
||||||
|
$this->label='Event Specimen';
|
||||||
|
$this->note = 'Note';
|
||||||
|
$this->location='Location';
|
||||||
|
$this->datep=$now;
|
||||||
|
$this->datef=$now;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -45,11 +45,11 @@ class CActionComm
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $DB Database handler
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
function CActionComm($DB)
|
function CActionComm($db)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1073,6 +1073,38 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update private note of element
|
||||||
|
*
|
||||||
|
* @param string $ref_ext Update field ref_ext
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function update_ref_ext($ref_ext)
|
||||||
|
{
|
||||||
|
if (! $this->table_element)
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::update_ref_ext was called on objet with property table_element not defined", LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||||
|
$sql.= " SET ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||||
|
$sql.= " WHERE ".(isset($this->table_rowid)?$this->table_rowid:'rowid')." = ". $this->id;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::update_ref_ext sql=".$sql, LOG_DEBUG);
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
$this->ref_ext = $ref_ext;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dol_syslog(get_class($this)."::update_ref_ext error=".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update private note of element
|
* Update private note of element
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user