[CORE] fonction setIncoterms générique pour mettre à jour les valeurs de incotermsdes différentes tables (#incoterm).

This commit is contained in:
phf 2015-02-10 10:23:38 +01:00
parent 23751c75dc
commit 1701ecfd89

View File

@ -2375,6 +2375,37 @@ abstract class CommonObject
return 1;
}
}
/**
* Define incoterms values of current object
*
* @param int $id_incoterm Id of incoterm to set or '' to remove
* @param string $location location of incoterm
* @return int <0 if KO, >0 if OK
*/
function setIncoterms($id_incoterm, $location)
{
if ($this->id && $this->table_element)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
$sql.= ", location_incoterms = '".($id_incoterm > 0 ? $this->db->escape($location) : "null")."'";
$sql.= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->fk_incoterms = $id_incoterm;
$this->location_incoterms = $location;
return 1;
}
else
{
return -1;
}
}
else return -1;
}
/**