diff --git a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php index 088247a7af0..969287835d0 100644 --- a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -234,10 +234,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures /** * Function to build a document on disk using the generic odt module. - * @param object Object source to build document - * @param outputlangs Lang output object - * @param srctemplatepath Full path of source filename for generator using a template file - * @return int 1 if OK, <=0 if KO + * + * @param Facture $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @return int 1 if OK, <=0 if KO */ function write_file($object,$outputlangs,$srctemplatepath) { @@ -274,8 +275,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures } } - $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->facture->dir_output; + $objectref = dol_sanitizeFileName($object->ref); if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; $file = $dir . "/" . $objectref . ".odt"; @@ -293,6 +294,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile=basename($srctemplatepath); $newfiletmp=preg_replace('/\.odt/i','',$newfile); + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); + $newfiletmp=$objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; $file=$dir.'/'.$newfiletmp.'.odt'; //print "newdir=".$dir; diff --git a/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php index db81b13b1f8..d5445f970c9 100644 --- a/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php @@ -75,8 +75,11 @@ class doc_generic_odt extends ModeleThirdPartyDoc } - /** \brief Return description of a module - * \return string Description + /** + * Return description of a module + * + * @param Translate $langs Object language + * @return string Description */ function info($langs) { @@ -152,10 +155,11 @@ class doc_generic_odt extends ModeleThirdPartyDoc /** * Function to build a document on disk using the generic odt module. - * @param object Object source to build document - * @param outputlangs Lang output object - * @param srctemplatepath Full path of source filename for generator using a template file - * @return int 1 if OK, <=0 if KO + * + * @param Societe $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @return int 1 if OK, <=0 if KO */ function write_file($object,$outputlangs,$srctemplatepath) { @@ -192,10 +196,9 @@ class doc_generic_odt extends ModeleThirdPartyDoc } } - $objectref = dol_sanitizeFileName($object->id); $dir = $conf->societe->dir_output; + $objectref = dol_sanitizeFileName($object->id); if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; if (! file_exists($dir)) { @@ -211,6 +214,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile=basename($srctemplatepath); $newfiletmp=preg_replace('/\.odt/i','',$newfile); + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); $file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; //print "newdir=".$dir; //print "newfile=".$newfile;