Merge pull request #864 from jfefe/doc_ods

Task [#838] : Can generate ods document on thirdparty
This commit is contained in:
Laurent Destailleur 2013-04-21 16:32:07 -07:00
commit 9b07271460
3 changed files with 15 additions and 4 deletions

View File

@ -1283,7 +1283,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
if (! $tmpdir) { unset($listofdir[$key]); continue; } if (! $tmpdir) { unset($listofdir[$key]); continue; }
if (is_dir($tmpdir)) if (is_dir($tmpdir))
{ {
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt','','name',SORT_ASC,0,true); // Disable hook for the moment $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
} }
} }

View File

@ -109,7 +109,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
else else
{ {
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt','','name',SORT_ASC,0,true); // Disable hook for the moment $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0,true); // Disable hook for the moment
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
} }
} }
@ -210,16 +210,27 @@ 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('/\.od(s|t)/i','',$newfile);
$newfiletmp=preg_replace('/template_/i','',$newfiletmp); $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
$newfiletmp=preg_replace('/modele_/i','',$newfiletmp); $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
$filename=$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_ODT_USE_TIMING))
{
$filename=$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename; $file=$dir.'/'.$filename;
$object->builddoc_filename=$filename; // For triggers $object->builddoc_filename=$filename; // For triggers
//print "newfileformat=".$newfileformat;
//print "newdir=".$dir; //print "newdir=".$dir;
//print "newfile=".$newfile; //print "newfile=".$newfile;
//print "file=".$file; //print "file=".$file;
//print "conf->societe->dir_temp=".$conf->societe->dir_temp; //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
//exit;
dol_mkdir($conf->societe->multidir_temp[$object->entity]); dol_mkdir($conf->societe->multidir_temp[$object->entity]);