From e8163945fe88a6ee987accd572b144c0a7118671 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Mar 2010 19:33:45 +0000 Subject: [PATCH] Work on odt module --- htdocs/admin/societe.php | 29 ++--- .../societe/doc/doc_generic_odt.modules.php | 116 +++++++++++++++--- htdocs/langs/fr_FR/admin.lang | 3 +- htdocs/societe.class.php | 9 +- 4 files changed, 116 insertions(+), 41 deletions(-) diff --git a/htdocs/admin/societe.php b/htdocs/admin/societe.php index da27b2e40df..794ff74d1eb 100644 --- a/htdocs/admin/societe.php +++ b/htdocs/admin/societe.php @@ -141,7 +141,7 @@ if ($_GET["action"] == 'setdoc') $form=new Form($db); -llxHeader(); +llxHeader('',$langs->trans("CompanySetup"),'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("CompanySetup"),$linkback,'setup'); @@ -159,7 +159,7 @@ print ' '.$langs->trans("Name").''; print ' '.$langs->trans("Description").''; print ' '.$langs->trans("Example").''; print ' '.$langs->trans("Status").''; -print ' '.$langs->trans("Infos").''; +print ' '.$langs->trans("Infos").''; print "\n"; clearstatcache(); @@ -226,11 +226,11 @@ print_titre($langs->trans("AccountCodeManager")); print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print "\n"; clearstatcache(); @@ -252,7 +252,7 @@ if ($handle) $var = !$var; print ''; - print ''; print '\n"; @@ -310,11 +310,10 @@ else print '
'.$langs->trans("Name").''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").'  
'.$modCodeCompta->nom."\n"; + print ''.$modCodeCompta->nom."\n"; print $modCodeCompta->info($langs); print ''.$modCodeCompta->getExample($langs)."
'; print ''; -print ''; +print ''; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; print "\n"; clearstatcache(); @@ -371,18 +370,6 @@ foreach ($conf->file->dol_document_root as $dirroot) print ""; } - // Defaut - print "'; - // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); 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 b98f4cabd97..7b2148c09f7 100644 --- a/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php @@ -19,7 +19,7 @@ /** * \file htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php - * \ingroup project + * \ingroup societe * \brief File of class to build ODT documents for third parties * \author Laurent Destailleur * \version $Id$ @@ -32,8 +32,8 @@ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); /** - * \class doc_genericodt - * \brief Classe permettant de generer les projets au modele Baleine + * \class doc_generic_odt + * \brief Class to build documents using ODF templates generator */ class doc_generic_odt extends ModeleThirdPartyDoc { @@ -70,6 +70,66 @@ class doc_generic_odt extends ModeleThirdPartyDoc if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'�tait pas d�fini } + + /** + * Define array with couple subtitution key => subtitution value + * + * @param unknown_type $mysoc + */ + function get_substitutionarray_mysoc($mysoc) + { + return array( + 'mycompany_name'=>$mysoc->name, + 'mycompany_email'=>$mysoc->email, + 'mycompany_phone'=>$mysoc->phone, + 'mycompany_fax'=>$mysoc->fax, + 'mycompany_address'=>$mysoc->address, + 'mycompany_zip'=>$mysoc->zip, + 'mycompany_town'=>$mysoc->town, + 'mycompany_country'=>$mysoc->country, + 'mycompany_url'=>$mysoc->url, + 'mycompany_barcode'=>$mysoc->gencode, + 'mycompany_vat'=>$mysoc->tva_intra, + 'mycompany_idprof1'=>$mysoc->idprof1, + 'mycompany_idprof2'=>$mysoc->idprof2, + 'mycompany_idprof3'=>$mysoc->idprof3, + 'mycompany_idprof4'=>$mysoc->idprof4, + 'mycompany_note'=>$mysoc->note, + ); + } + + + /** + * Define array with couple subtitution key => subtitution value + * + * @param unknown_type $object + */ + function get_substitutionarray_object($object) + { + return array( + 'company_name'=>$object->name, + 'company_email'=>$object->email, + 'company_phone'=>$object->phone, + 'company_fax'=>$object->fax, + 'company_address'=>$object->address, + 'company_zip'=>$object->zip, + 'company_town'=>$object->town, + 'company_country'=>$object->country, + 'company_url'=>$object->url, + 'company_barcode'=>$object->gencode, + 'company_vat'=>$object->tva_intra, + 'company_customercode'=>$object->code_client, + 'company_suppliercode'=>$object->code_fournisseur, + 'company_customeraccountancycode'=>$object->code_compta, + 'company_supplieraccountancycode'=>$object->code_compta_fournisseur, + 'company_idprof1'=>$object->idprof1, + 'company_idprof2'=>$object->idprof2, + 'company_idprof3'=>$object->idprof3, + 'company_idprof4'=>$object->idprof4, + 'company_note'=>$object->note, + ); + } + /** \brief Return description of a module * \return string Description */ @@ -91,7 +151,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc // List of directories area $texte.= '
'.$langs->trans("Name").''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Activated").''.$langs->trans("Default").''.$langs->trans("Infos").''.$langs->trans("Status").''.$langs->trans("Infos").'
"; - if ($conf->global->COMPANY_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print '
'; - $textbis=$langs->trans("ListOfDirectories"); + $texttitle=$langs->trans("ListOfDirectories"); $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); $listoffiles=array(); foreach($listofdir as $key=>$tmpdir) @@ -99,14 +159,36 @@ class doc_generic_odt extends ModeleThirdPartyDoc $tmpdir=trim($tmpdir); $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); if (! $tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $textbis.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); else { $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt'); if (sizeof($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); } } - $texte.= $form->textwithpicto($textbis,$langs->trans("ListOfDirectoriesForModelGenODT"),1,'help'); + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $dummy=new Societe($db); + $tmparray=$this->get_substitutionarray_mysoc($dummy); + $nb=0; + foreach($tmparray as $key => $val) + { + $texthelp.='{'.$key.'}
'; + $nb++; + if ($nb >= 5) { $texthelp.='...
'; break; } + } + $tmparray=$this->get_substitutionarray_object($dummy); + $nb=0; + foreach($tmparray as $key => $val) + { + $texthelp.='{'.$key.'}
'; + $nb++; + if ($nb >= 5) { $texthelp.='...
'; break; } + } + $texthelp.=$langs->trans("FullListOnOnlineDocumentation"); + + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help'); //var_dump($listofdir); $texte.= '