[ bug #85 ] Facture sur modèle ODT

This commit is contained in:
Laurent Destailleur 2011-10-18 03:47:20 +02:00
parent 81d93563af
commit 20d5927922
2 changed files with 22 additions and 13 deletions

View File

@ -234,9 +234,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures
/** /**
* Function to build a document on disk using the generic odt module. * 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 Facture $object Object source to build document
* @param srctemplatepath Full path of source filename for generator using a template file * @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 * @return int 1 if OK, <=0 if KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath) 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; $dir = $conf->facture->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt"; $file = $dir . "/" . $objectref . ".odt";
@ -293,6 +294,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures
//print "srctemplatepath=".$srctemplatepath; // Src filename //print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath); $newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.odt/i','',$newfile); $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.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
$file=$dir.'/'.$newfiletmp.'.odt'; $file=$dir.'/'.$newfiletmp.'.odt';
//print "newdir=".$dir; //print "newdir=".$dir;

View File

@ -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) function info($langs)
{ {
@ -152,9 +155,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc
/** /**
* Function to build a document on disk using the generic odt module. * 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 Societe $object Object source to build document
* @param srctemplatepath Full path of source filename for generator using a template file * @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 * @return int 1 if OK, <=0 if KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath) 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; $dir = $conf->societe->dir_output;
$objectref = dol_sanitizeFileName($object->id);
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (! file_exists($dir)) if (! file_exists($dir))
{ {
@ -211,6 +214,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc
//print "srctemplatepath=".$srctemplatepath; // Src filename //print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath); $newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.odt/i','',$newfile); $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'; $file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
//print "newdir=".$dir; //print "newdir=".$dir;
//print "newfile=".$newfile; //print "newfile=".$newfile;