diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 476e4f3c0a3..5133061a811 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -52,6 +52,7 @@ class Fichinter extends CommonObject var $note_private; var $note_public; var $fk_project; + var $fk_contrat; var $modelpdf; var $extraparams=array(); @@ -67,6 +68,7 @@ class Fichinter extends CommonObject $this->db = $db; $this->products = array(); $this->fk_project = 0; + $this->fk_contrat = 0; $this->statut = 0; // List of language codes for status @@ -137,6 +139,7 @@ class Fichinter extends CommonObject $sql.= ", description"; $sql.= ", model_pdf"; $sql.= ", fk_projet"; + $sql.= ", fk_contrat"; $sql.= ", fk_statut"; $sql.= ", note_private"; $sql.= ", note_public"; @@ -150,6 +153,7 @@ class Fichinter extends CommonObject $sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null"); $sql.= ", '".$this->modelpdf."'"; $sql.= ", ".($this->fk_project ? $this->fk_project : 0); + $sql.= ", ".($this->fk_contrat ? $this->fk_contrat : 0); $sql.= ", ".$this->statut; $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); @@ -823,6 +827,40 @@ class Fichinter extends CommonObject } } + + /** + * Define the label of the contract + * + * @param User $user Object user who modify + * @param string $description description + * @return int <0 if ko, >0 if ok + */ + function set_contrat($user, $contratid) + { + global $conf; + + if ($user->rights->ficheinter->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; + $sql.= " SET fk_contrat = '".$contratid."'"; + $sql.= " WHERE rowid = ".$this->id; + $sql.= " AND entity = ".$conf->entity; + //$sql.= " AND fk_statut = 0"; + + if ($this->db->query($sql)) + { + $this->fk_contrat = $contratid; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Fichinter::set_contrat Erreur SQL"); + return -1; + } + } + } + /** * Adding a line of intervention into data base *