diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 7c8ce40e3e9..f3de1a7cbe1 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -559,9 +559,9 @@ class FactureFournisseur extends Facture } /** - * \brief Set invoice status as validated - * \param user Object user - * \return int <0 if KO, =0 if nothing to do, >0 if OK + * Set invoice status as validated + * @param user Object user + * @return int <0 if KO, =0 if nothing to do, >0 if OK */ function validate($user) { @@ -576,6 +576,13 @@ class FactureFournisseur extends Facture return 0; } + // Check parameters + if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->ref_supplier)) + { + $this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("RefSupplier")); + return -1; + } + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 294d1fdc632..c7b049134da 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -89,6 +89,10 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $ $facturefourn=new FactureFournisseur($db); $facturefourn->fetch($_GET['facid']); $result = $facturefourn->validate($user); + if ($result < 0) + { + $mesg='
'.$facturefourn->error.'
'; + } } if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') @@ -468,7 +472,7 @@ if ($_GET['action'] == 'reopen' && $user->rights->fournisseur->facture->creer) * Build document */ -if ($_REQUEST['action'] == 'builddoc') +if ($_REQUEST['action'] == 'builddoc') { /* * Generation de la facture @@ -626,7 +630,7 @@ else /* */ /* *************************************************************************** */ - $now=gmmktime(); + $now=dol_now(); $productstatic = new Product($db); @@ -1291,7 +1295,7 @@ else /* * Documents generes */ - + $facfournref=dol_sanitizeFileName($fac->ref); $file=$conf->fournisseur->dir_output.'/facture/'. $facfournref . '/' . $facfournref . '.pdf'; $relativepath = $facfournref.'/'.$facfournref.'.pdf'; @@ -1301,7 +1305,7 @@ else $delallowed=$user->rights->fournisseur->facture->supprimer; $somethingshown=$formfile->show_documents('facture_fournisseur',$facfournref,$filedir,$urlsource,$genallowed,$delallowed,$facture->modelpdf); - + print ''; print '
';