Fix: [ bug #524 ] Donation receipt html_cerfafr is not localized

This commit is contained in:
Laurent Destailleur 2012-08-26 18:01:29 +02:00
parent a5a3121771
commit 56d19437f4
5 changed files with 98 additions and 32 deletions

View File

@ -14,13 +14,12 @@
<td width="15%" nowrap="nowrap" valign="middle">Cerfa No 11580 01</td>
<td nowrap="nowrap" align="center" valign="middle">
<font size="+2">Reçu de dons</font><br>
<font size="+1"><b>(Article 200-5 du Code Général des Impôts)</b></font><br>
+ article 238 bis
<font size="+2">__DonationReceipt__</font><br>
__FrenchArticle__
</td>
<td width="15%" nowrap="nowrap" align="center" valign="middle">
Numéro de référence du reçu
__DonationRef__
<table width="100%" border="0" bgcolor="#000000" cellspacing="0" cellpadding="3">
<tr bgcolor="#ffffff" align="center">
<td nowrap>
@ -48,7 +47,7 @@
<tr bgcolor="#e0e0e0" align="center">
<td nowrap>
<font size="+2">
<b>Bénéficiaire des versements</b>
<b>__DonationRecipient__</b>
</font>
</td>
</tr>
@ -63,12 +62,12 @@
<table width="100%" border="0" bgcolor="#ffffff" cellspacing="0" cellpadding="3">
<tr>
<td>
<b>Nom ou dénomination :</b><br>
<b>__Name__ :</b><br>
__MAIN_INFO_SOCIETE_NOM__<br>
<b>Adresse :</b><br>
<b>__Address__ :</b><br>
__MAIN_INFO_SOCIETE_ADRESSE__<br>
<b>Code postal :</b> __MAIN_INFO_SOCIETE_CP__<br>
<b>Commune :</b> __MAIN_INFO_SOCIETE_VILLE__<br>
<b>__Zip__ :</b> __MAIN_INFO_SOCIETE_CP__<br>
<b>__Town__ :</b> __MAIN_INFO_SOCIETE_VILLE__<br>
</td>
</tr>
</table>
@ -82,7 +81,7 @@
<tr bgcolor="#e0e0e0" align="center">
<td nowrap>
<font size="+2">
<b>Donateur</b>
<b>__Donor__</b>
</font>
</td>
</tr>
@ -98,12 +97,12 @@
<table width="100%" border="0" bgcolor="#ffffff" cellspacing="0" cellpadding="3">
<tr>
<td>
<b>Nom :</b><br>
<b>__Name__ :</b><br>
__DONATOR_NAME__<br>
<b>Adresse :</b><br>
<b>__Address__ :</b><br>
__DONATOR_ADDRESS__<br>
<b>Code postal :</b> __DONATOR_ZIP__<br>
<b>Commune :</b> __DONATOR_TOWN__<br>
<b>__Zip__ :</b> __DONATOR_ZIP__<br>
<b>__Town__ :</b> __DONATOR_TOWN__<br>
</td>
</tr>
</table>
@ -116,9 +115,7 @@
<table width="100%" border="0" bgcolor="#ffffff" cellspacing="0" cellpadding="3">
<tr>
<td>
Le bénéficiaire reconnait avoir reçu au titre des
versements ouvrant droit à réduction d'impôt, la
somme de : <br>
__IConfirmDonationReception__ : <br>
<table width="100%">
<tr align="center">
<td>
@ -126,15 +123,15 @@
</td>
</tr>
</table>
<b>Date du versement</b> : __DATE__ <br>
<b>Mode de versement</b> : __PAYMENTMODE_LIB__ <br>
<b>__DonationPaymentDate__</b> : __DATE__ <br>
<b>__DonationPaymentMode__</b> : __PAYMENTMODE_LIB__ <br>
<table width="100%">
<tr align="center">
<td valign="top">
<br><br>
Merci pour votre don.
__ThankYou__
</td>
@ -145,7 +142,7 @@
<table border="0" bgcolor="#ffffff" cellspacing="0" cellpadding="3">
<tr>
<td width="160" height="100" valign="top">
<center>Date et signature</center>
<center>__Date__ __Signature__</center>
__NOW__
</td>
</tr>

View File

@ -82,6 +82,7 @@ class html_cerfafr extends ModeleDon
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("products");
$outputlangs->load("donations");
if (! empty($conf->don->dir_output))
{
@ -136,6 +137,23 @@ class html_cerfafr extends ModeleDon
$form = str_replace('__DONATOR_TOWN__',$don->ville,$form);
$form = str_replace('__PAYMENTMODE_LIB__ ',$don->modepaiement,$form);
$form = str_replace('__NOW__',dol_print_date($now,'',false,$outputlangs),$form);
$form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
$form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form);
$form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form);
$form = str_replace('__DonationPaymentDate__',$outputlangs->trans("DonationPaymentDate"),$form);
$form = str_replace('__DonationPaymentMode__',$outputlangs->trans("DonationPaymentMode"),$form);
$form = str_replace('__Name__',$outputlangs->trans("Name"),$form);
$form = str_replace('__Address__',$outputlangs->trans("Address"),$form);
$form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form);
$form = str_replace('__Town__',$outputlangs->trans("Town"),$form);
$form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form);
$form = str_replace('__Date__',$outputlangs->trans("Date"),$form);
$form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form);
$form = str_replace('__ThankYou__',$outputlangs->trans("ThankYou"),$form);
$form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
$frencharticle='';
if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1"><b>(Article 200-5 du Code Général des Impôts)</b></font><br>+ article 238 bis';
$form = str_replace('__FrenchArticle__',$frencharticle,$form);
// Sauve fichier sur disque
dol_syslog("html_cerfafr::write_file $file");

View File

@ -154,7 +154,15 @@ function don_create($db, $id, $message, $modele, $outputlangs)
global $conf, $langs;
$langs->load("bills");
$dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/";
$eror=0;
// Increase limit for PDF build
$err=error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
$srctemplatepath='';
// Set template to use
if (! dol_strlen($modele))
@ -170,22 +178,51 @@ function don_create($db, $id, $message, $modele, $outputlangs)
}
}
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp=explode(':',$modele,2);
if (! empty($tmp[1]))
{
$modele=$tmp[0];
$srctemplatepath=$tmp[1];
}
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array('/');
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
foreach(array('html','doc','pdf') as $prefix)
{
$file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php";
// On verifie l'emplacement du modele
$file=dol_buildpath($reldir."core/modules/dons/".$file,0);
if (file_exists($file))
{
$filefound=1;
$classname=$prefix.'_'.$modele;
break;
}
}
if ($filefound) break;
}
// Charge le modele
$file = $modele.".modules.php";
if (file_exists($dir.$file))
{
if ($filefound)
{
require_once $file;
$object=new Don($db);
$object->fetch($id);
require_once $dir.$file;
$classname = $modele;
$module = new $classname($db);
$obj = new $classname($db);
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output;
if ($module->write_file($object,$outputlangs) > 0)
if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0)
{
$outputlangs->charset_output=$sav_charset_output;
@ -198,7 +235,7 @@ function don_create($db, $id, $message, $modele, $outputlangs)
{
$outputlangs->charset_output=$sav_charset_output;
dol_syslog("Erreur dans don_create");
dol_print_error($db,$module->error);
dol_print_error($db,$obj->error);
return 0;
}
}

View File

@ -2,6 +2,7 @@
CHARSET=UTF-8
Donation=Donation
Donations=Donations
DonationRef=Donation ref.
Donor=Donor
Donors=Donors
AddDonation=Add a donation
@ -21,7 +22,13 @@ DonationStatusPromiseNotValidatedShort=Draft
DonationStatusPromiseValidatedShort=Validated
DonationStatusPaidShort=Received
ValidPromess=Validate promise
DonationReceipt=Donation receipt
BuildDonationReceipt=Build receipt
DonationsModels=Documents models for donation receipts
LastModifiedDonations=Last %s modified donations
SearchADonation=Search a donation
SearchADonation=Search a donation
DonationPaymentDate=Donation payment date
DonationPaymentMode=Donation payment mode
DonationRecipient=Donation recipient
ThankYou=Thank You
IConfirmDonationReception=The recipient declare reception, as a donation, of the following amount

View File

@ -2,6 +2,7 @@
CHARSET=UTF-8
Donation=Don
Donations=Dons
DonationRef=Réf. donation
Donor=Donateur
Donors=Donateurs
AddDonation=Ajouter don
@ -21,7 +22,13 @@ DonationStatusPromiseNotValidatedShort=Non validée
DonationStatusPromiseValidatedShort=Validée
DonationStatusPaidShort=Payé
ValidPromess=Valider promesse
DonationReceipt=Reçu de dons
BuildDonationReceipt=Créer reçu
DonationsModels=Modèle de document de bon de réception de dons
LastModifiedDonations=Les %s derniers dons modifiés
SearchADonation=Rechercher un don
SearchADonation=Rechercher un don
DonationPaymentDate=Date du versement
DonationPaymentMode=Mode de versement
DonationRecipient=Bénéficiaire des versements
ThankYou=Merci
IConfirmDonationReception=Le bénéficiaire reconnait avoir reçu au titre des versements ouvrant droit à réduction d'impôt, la somme de