Work on odt module

This commit is contained in:
Laurent Destailleur 2010-03-06 19:33:45 +00:00
parent b8c3177eb8
commit e8163945fe
4 changed files with 116 additions and 41 deletions

View File

@ -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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("CompanySetup"),$linkback,'setup');
@ -159,7 +159,7 @@ print ' <td>'.$langs->trans("Name").'</td>';
print ' <td>'.$langs->trans("Description").'</td>';
print ' <td>'.$langs->trans("Example").'</td>';
print ' <td align="center">'.$langs->trans("Status").'</td>';
print ' <td align="center" width="30">'.$langs->trans("Infos").'</td>';
print ' <td align="center" width="60">'.$langs->trans("Infos").'</td>';
print "</tr>\n";
clearstatcache();
@ -226,11 +226,11 @@ print_titre($langs->trans("AccountCodeManager"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td width="140">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td align="center" width="30">&nbsp;</td>';
print '<td align="center" width="60">&nbsp;</td>';
print "</tr>\n";
clearstatcache();
@ -252,7 +252,7 @@ if ($handle)
$var = !$var;
print '<tr '.$bc[$var].'>';
print '<td width="140">'.$modCodeCompta->nom."</td><td>\n";
print '<td>'.$modCodeCompta->nom."</td><td>\n";
print $modCodeCompta->info($langs);
print '</td>';
print '<td nowrap="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
@ -310,11 +310,10 @@ else
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td width="140">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
print '<td align="center" width="32" colspan="2">'.$langs->trans("Infos").'</td>';
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td align="center" width="60" colspan="2">'.$langs->trans("Infos").'</td>';
print "</tr>\n";
clearstatcache();
@ -371,18 +370,6 @@ foreach ($conf->file->dol_document_root as $dirroot)
print "</td>";
}
// Defaut
print "<td align=\"center\">";
if ($conf->global->COMPANY_ADDON_PDF == "$name")
{
print img_picto($langs->trans("Default"),'on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));

View File

@ -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'<27>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.= '<tr><td>';
$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.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$dummy=new Societe($db);
$tmparray=$this->get_substitutionarray_mysoc($dummy);
$nb=0;
foreach($tmparray as $key => $val)
{
$texthelp.='{'.$key.'}<br>';
$nb++;
if ($nb >= 5) { $texthelp.='...<br>'; break; }
}
$tmparray=$this->get_substitutionarray_object($dummy);
$nb=0;
foreach($tmparray as $key => $val)
{
$texthelp.='{'.$key.'}<br>';
$nb++;
if ($nb >= 5) { $texthelp.='...<br>'; break; }
}
$texthelp.=$langs->trans("FullListOnOnlineDocumentation");
$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help');
//var_dump($listofdir);
$texte.= '<textarea class="flat" cols="80" name="value1">';
@ -145,7 +227,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
*/
function write_file($object,$outputlangs,$srctemplatepath)
{
global $user,$langs,$conf;
global $user,$langs,$conf,$mysoc;
if (! is_object($outputlangs)) $outputlangs=$langs;
// Force output charset to ISO, because, FPDF expect text encoded in ISO
@ -197,20 +279,22 @@ class doc_generic_odt extends ModeleThirdPartyDoc
create_exdir($conf->societe->dir_temp);
// Define substitution array
$soc=array('societe'=>'bb','nom'=>'ee','name'=>'tt');
// Read template
// Open and load template
require_once(DOL_DOCUMENT_ROOT.'/includes/odtphp/odf.php');
$odfHandler = new odf($srctemplatepath, array(
'PATH_TO_TMP' => $conf->societe->dir_temp.'/',
'ZIP_PROXY' => 'PhpZipProxy'));
// Make substitution
foreach($soc as $socProperty=>$socPropertyValue){
try {
$odfHandler->setVars($socProperty, $socPropertyValue, true, 'UTF-8');
} catch(OdfException $e) {}
// Make substitutions
$tmparray=$this->get_substitutionarray_mysoc($mysoc);
foreach($tmparray as $key=>$value)
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
$tmparray=$this->get_substitutionarray_object($object);
foreach($tmparray as $key=>$value)
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
// Write new file

View File

@ -270,7 +270,8 @@ ListOfDirectories=Liste des répertoires de modèles OpenDocument
ListOfDirectoriesForModelGenODT=Liste des répertoires contenant des documents modèles OpenDocument.<br><br>Indiquer les chemins complets de répertoire.<br>Ajouter un retour à la ligne entre chaque répertoire.<br>Pour indiquer un répertoire du module GED, indiquer<br><b>DOL_DATA_ROOT/ecm/nomdurepertoireged</b><br><br>Les fichiers modèles dans ces répertoires doivent se terminer par <b>.odt</b>.
NumberOfModelFilesFound=Nombre de fichiers modèles ODT trouvés dans ce(s) répertoire(s)
ExampleOfDirectoriesForModelGen=Exemples de syntaxe:<br>c:\mydir<br>/home/mydir<br>DOL_DATA_ROOT/ecm/ecmdir
FollowingSubstitutionKeysCanBeUsed=En plaçant les tags suivant dans le modèle, vous obtiendrez une subsitution avec la valeur personnalisée lors de la génération du document:
FullListOnOnlineDocumentation=Liste complète des tags disponibles sur la documentation utilisateur du module Tiers sur le wiki http://wiki.dolibarr.org
# Modules = undefined
Module0Name = Utilisateurs & groupes
Module0Desc = Gestion des utilisateurs et groupes

View File

@ -64,9 +64,12 @@ class Societe extends CommonObject
var $gencod;
// 4 identifiants professionnels (leur utilisation depend du pays)
var $siren; // IdProf1
var $siret; // IdProf2
var $ape; // IdProf3
var $siren; // IdProf1 - Deprecated
var $siret; // IdProf2 - Deprecated
var $ape; // IdProf3 - Deprecated
var $idprof1; // IdProf1
var $idprof2; // IdProf2
var $idprof3; // IdProf3
var $idprof4; // IdProf4
var $prefix_comm;