diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5b68773428d..9ecf815ffa1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -658,6 +658,7 @@ class CommandeFournisseur extends Commande function approve($user, $idwarehouse=0) { global $langs,$conf; + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); $error=0; @@ -667,6 +668,20 @@ class CommandeFournisseur extends Commande { $this->db->begin(); + // Definition du nom de modele de numerotation de commande + $soc = new Societe($this->db); + $soc->fetch($this->fourn_id); + + // Check if object has a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + $num = $this->getNextNumRef($soc); + } + else + { + $num = $this->ref; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " SET ref='".$this->db->escape($num)."',"; $sql.= " fk_statut = 2,"; @@ -1885,4 +1900,4 @@ class CommandeFournisseurLigne extends OrderLine } } -?> +?> \ No newline at end of file