diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 62b251ac01d..a5c4d4980e8 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -146,7 +146,7 @@ if (empty($reshook)) { $object->fetch($id); $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); - $result=$object->set_prospect_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -155,7 +155,7 @@ if (empty($reshook)) { $object->fetch($id); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); - $result=$object->set_commnucation_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -164,7 +164,7 @@ if (empty($reshook)) { $object->fetch($id); $object->outstanding_limit=GETPOST('outstanding_limit'); - $result=$object->set_OutstandingBill($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6bb8dfa0fc5..17f96a93c3c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -678,6 +678,7 @@ class Societe extends CommonObject $this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):''); $this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):''); $this->prefix_comm = trim($this->prefix_comm); + $this->outstanding_limit = price2num($this->outstanding_limit); $this->tva_assuj = trim($this->tva_assuj); $this->tva_intra = dol_sanitizeFileName($this->tva_intra,''); @@ -831,7 +832,7 @@ class Societe extends CommonObject $sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null"); $sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null"); - + $sql .= ",fk_stcomm='".$this->stcomm_id."'"; $sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0"); $sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null"); @@ -847,6 +848,8 @@ class Societe extends CommonObject $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null"); $sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null"); + $sql .= ",outstanding_limit= '".($this->outstanding_limit!=''?$this->outstanding_limit:'null')."'"; + $sql .= ",fk_prospectlevel='".$this->fk_prospectlevel."'"; $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); @@ -3178,30 +3181,11 @@ class Societe extends CommonObject * * @param User $user Utilisateur qui definie la remise * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_prospect_level(User $user) { - if ($this->id) - { - $this->db->begin(); - - // Positionne remise courante - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " fk_prospectlevel='".$this->fk_prospectlevel."'"; - $sql.= ",fk_user_modif='".$user->id."'"; - $sql.= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_prospect_level", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->error(); - return -1; - } - - $this->db->commit(); - return 1; - } + return $this->update($this->id, $user); } /** @@ -3274,31 +3258,11 @@ class Societe extends CommonObject * * @param User $user User making change * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_commnucation_level($user) { - if ($this->id) - { - $this->db->begin(); - - // Positionne remise courante - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " fk_stcomm='".$this->stcomm_id."'"; - $sql.= ",fk_user_modif='".$user->id."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::set_commnucation_level", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } - - $this->db->commit(); - return 1; - } + return $this->update($this->id, $user); } /** @@ -3306,35 +3270,11 @@ class Societe extends CommonObject * * @param User $user User making change * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_OutstandingBill(User $user) { - if ($this->id) - { - $this->db->begin(); - - // Clean parameters - $outstanding = price2num($this->outstanding_limit); - - // Set outstanding amount - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " outstanding_limit= '".($outstanding!=''?$outstanding:'null')."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::set_outstanding", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } - } + return $this->update($this->id, $user); } /** diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e01331617ea..4e9d0b1ed18 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -191,7 +191,7 @@ if (empty($reshook)) $object = new Client($db); $result=$object->fetch(GETPOST('stcommsocid')); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); - $result=$object->set_commnucation_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); $action='';