From 1701ecfd89b4ea207d639ebb7b65d9afd181aa51 Mon Sep 17 00:00:00 2001 From: phf Date: Tue, 10 Feb 2015 10:23:38 +0100 Subject: [PATCH] =?UTF-8?q?[CORE]=20fonction=20setIncoterms=20g=C3=A9n?= =?UTF-8?q?=C3=A9rique=20pour=20mettre=20=C3=A0=20jour=20les=20valeurs=20d?= =?UTF-8?q?e=20incotermsdes=20diff=C3=A9rentes=20tables=20(#incoterm).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/class/commonobject.class.php | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 79f509225f6..ad87502fe1b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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; + } /**