From 21ba24a0cdfd3452f21dac5026e0f6e8585e5d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 22:13:28 +0200 Subject: [PATCH] NEW Deprecated Societe::set_prospect_level, Societe::set_commnucation_level, Societe::set_OutstandingBill functions --- htdocs/comm/card.php | 6 +- htdocs/societe/class/societe.class.php | 80 ++++---------------------- htdocs/societe/list.php | 2 +- 3 files changed, 14 insertions(+), 74 deletions(-) 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 1005b8c3c8d..60e954c9f6e 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='';