diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bd1fae497f2..811c2c55e4d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -126,6 +126,7 @@ class Societe extends CommonObject var $statut_commercial; var $price_level; + var $outstanding; var $datec; var $date_update; @@ -710,7 +711,7 @@ class Societe extends CommonObject $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang, s.logo'; - $sql .= ', s.import_key, s.canvas'; + $sql .= ', s.outstanding, s.import_key, s.canvas'; $sql .= ', fj.libelle as forme_juridique'; $sql .= ', e.libelle as effectif'; $sql .= ', p.code as country_code, p.libelle as country'; @@ -840,6 +841,8 @@ class Societe extends CommonObject $this->default_lang = $obj->default_lang; $this->logo = $obj->logo; + $this->outstanding = $obj->outstanding; + // multiprix $this->price_level = $obj->price_level; @@ -2740,6 +2743,42 @@ class Societe extends CommonObject } } + /** + * Set outstanding value + * + * @param User $user User making change + * @return int <0 if KO, >0 if OK + */ + function set_outstanding($user) + { + if ($this->id) + { + $this->db->begin(); + + $now=dol_now(); + + $outstanding = price2num($this->outstanding); + + // Positionne l'encours de facturaiton + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; + $sql.= " outstanding=".$outstanding; + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::set_outstanding sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) + { + $this->db->rollback(); + $this->error=$this->db->error(); + return -1; + } + + $this->db->commit(); + return 1; + } + } + + /** * Return label of status customer is prospect/customer *