diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f07e9be9bba..3c8e77051b1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1641,6 +1641,40 @@ class CommandeFournisseur extends CommonOrder return -2; } } + + /** + * Set the id projet + * + * @param User $user Objet utilisateur qui modifie + * @param int $id_projet Date de livraison + * @return int <0 si ko, >0 si ok + */ + function set_id_projet($user, $id_projet) + { + if ($user->rights->fournisseur->commande->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; + $sql.= " SET fk_projet = ".($id_projet > 0 ? (int)$id_projet : 'null'); + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::set_id_projet", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->fk_projet = $id_projet; + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + else + { + return -2; + } + } /** * Update a supplier order from a customer order