From 946c79ced021fc7937551e4caec0d99f96a3be37 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 4 Oct 2022 17:43:24 +0200 Subject: [PATCH] NEW set thirdparty type with company modify trigger --- htdocs/societe/class/societe.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 586f955c1e0..c01f83401cf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4932,15 +4932,16 @@ class Societe extends CommonObject */ public function setThirdpartyType($typent_id) { + global $user; + + dol_syslog(__METHOD__, LOG_DEBUG); + if ($this->id) { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " SET fk_typent = ".($typent_id > 0 ? $typent_id : "null"); - $sql .= " WHERE rowid = ".((int) $this->id); - dol_syslog(get_class($this).'::setThirdpartyType', LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { + $result = $this->setValueFrom('fk_typent', $typent_id, '', null, '', '', $user, 'COMPANY_MODIFY'); + + if ($result > 0) { $this->typent_id = $typent_id; - $this->typent_code = dol_getIdFromCode($this->db, $this->$typent_id, 'c_typent', 'id', 'code'); + $this->typent_code = dol_getIdFromCode($this->db, $this->typent_id, 'c_typent', 'id', 'code'); return 1; } else { return -1;