28 require_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
29 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
48 $this->
name =
"cerfafr";
49 $this->
description = $langs->trans(
'DonationsReceiptModel').
' - fr_FR - Cerfa 11580*04';
76 public function write_file($don, $outputlangs, $currency =
'')
79 global $user, $conf, $langs, $mysoc;
82 $id = (!is_object($don) ? $don :
'');
84 if (!is_object($outputlangs)) $outputlangs = $langs;
87 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"donations"));
89 $currency = !empty($currency) ? $currency : $conf->currency;
91 if (!empty($conf->don->dir_output))
96 $don =
new Don($this->
db);
97 $ret = $don->fetch($id);
102 if (!empty($don->specimen))
104 $dir = $conf->don->dir_output;
105 $file = $dir.
"/SPECIMEN.html";
108 $dir = $conf->don->dir_output.
"/".$donref;
109 $file = $dir.
"/".$donref.
".html";
112 if (!file_exists($dir))
116 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
121 if (file_exists($dir))
123 $formclass =
new Form($this->
db);
127 if ($don->modepaiementid)
129 $formclass->load_cache_types_paiements();
130 $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid][
'label'];
131 }
else $paymentmode =
'';
133 if ($don->modepaymentcode ==
'CHQ') {
134 $ModePaiement =
'<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
135 } elseif ($don->modepaymentcode ==
'LIQ') {
136 $ModePaiement =
'<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
137 } elseif ($don->modepaymentcode ==
'VIR' || $don->modepaymentcode ==
'PRE' || $don->modepaymentcode ==
'CB') {
138 $ModePaiement =
'<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
140 $ModePaiement =
'<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
155 $donmodel = DOL_DOCUMENT_ROOT.
"/core/modules/dons/html_cerfafr.html";
156 $form = implode(
'', file($donmodel));
157 $form = str_replace(
'__REF__', $don->id, $form);
158 $form = str_replace(
'__DATE__',
dol_print_date($don->date,
'day',
false, $outputlangs), $form);
160 $form = str_replace(
'__AMOUNT__',
price($don->amount), $form);
161 $form = str_replace(
'__AMOUNTLETTERS__', $this->
amountToLetters($don->amount), $form);
162 $form = str_replace(
'__CURRENCY__', $outputlangs->transnoentitiesnoconv(
"Currency".$currency), $form);
163 $form = str_replace(
'__CURRENCYCODE__', $conf->currency, $form);
164 $form = str_replace(
'__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form);
165 $form = str_replace(
'__MAIN_INFO_SOCIETE_ADDRESS__', $mysoc->address, $form);
166 $form = str_replace(
'__MAIN_INFO_SOCIETE_ZIP__', $mysoc->zip, $form);
167 $form = str_replace(
'__MAIN_INFO_SOCIETE_TOWN__', $mysoc->town, $form);
168 $form = str_replace(
'__MAIN_INFO_SOCIETE_OBJECT__', $mysoc->object, $form);
169 $form = str_replace(
'__DONATOR_FIRSTNAME__', $don->firstname, $form);
170 $form = str_replace(
'__DONATOR_LASTNAME__', $don->lastname, $form);
171 $form = str_replace(
'__DONATOR_SOCIETE__', $don->societe, $form);
172 $form = str_replace(
'__DONATOR_STATUT__', $don->statut, $form);
173 $form = str_replace(
'__DONATOR_ADDRESS__', $don->address, $form);
174 $form = str_replace(
'__DONATOR_ZIP__', $don->zip, $form);
175 $form = str_replace(
'__DONATOR_TOWN__', $don->town, $form);
176 $form = str_replace(
'__PAYMENTMODE_LIB__ ', $paymentmode, $form);
177 $form = str_replace(
'__NOW__',
dol_print_date($now,
'day',
false, $outputlangs), $form);
178 $form = str_replace(
'__DonationRef__', $outputlangs->trans(
"DonationRef"), $form);
179 $form = str_replace(
'__DonationTitle__', $outputlangs->trans(
"DonationTitle"), $form);
180 $form = str_replace(
'__DonationReceipt__', $outputlangs->trans(
"DonationReceipt"), $form);
181 $form = str_replace(
'__DonationRecipient__', $outputlangs->trans(
"DonationRecipient"), $form);
182 $form = str_replace(
'__DonationDatePayment__', $outputlangs->trans(
"DonationDatePayment"), $form);
183 $form = str_replace(
'__PaymentMode__', $outputlangs->trans(
"PaymentMode"), $form);
185 $form = str_replace(
'__Name__', $outputlangs->trans(
"Name"), $form);
186 $form = str_replace(
'__Address__', $outputlangs->trans(
"Address"), $form);
187 $form = str_replace(
'__Zip__', $outputlangs->trans(
"Zip"), $form);
188 $form = str_replace(
'__Town__', $outputlangs->trans(
"Town"), $form);
189 $form = str_replace(
'__Object__', $outputlangs->trans(
"Object"), $form);
190 $form = str_replace(
'__Donor__', $outputlangs->trans(
"Donor"), $form);
191 $form = str_replace(
'__Date__', $outputlangs->trans(
"Date"), $form);
192 $form = str_replace(
'__Signature__', $outputlangs->trans(
"Signature"), $form);
193 $form = str_replace(
'__Message__', $outputlangs->trans(
"Message"), $form);
194 $form = str_replace(
'__IConfirmDonationReception__', $outputlangs->trans(
"IConfirmDonationReception"), $form);
195 $form = str_replace(
'__DonationMessage__', $conf->global->DONATION_MESSAGE, $form);
197 $form = str_replace(
'__ModePaiement__', $ModePaiement, $form);
200 if (preg_match(
'/fr/i', $outputlangs->defaultlang)) $frencharticle =
'<font size="+1">Article 200, 238 bis et 978 du code général des impôts (CGI)</font>';
201 $form = str_replace(
'__FrenchArticle__', $frencharticle, $form);
203 $frencheligibility =
'';
204 if (preg_match(
'/fr/i', $outputlangs->defaultlang)) $frencheligibility =
'Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
205 $form = str_replace(
'__FrenchEligibility__', $frencheligibility, $form);
208 if ($mysoc->country_code ==
'FR') {
209 if ($conf->global->DONATION_ART200 >= 1)
211 $art200 =
'<input type="checkbox" disabled="true" checked="checked" >200 du CGI';
213 $art200 =
'<input type="checkbox" disabled="true">200 du CGI';
216 $form = str_replace(
'__ARTICLE200__', $art200, $form);
219 if ($mysoc->country_code ==
'FR') {
220 if ($conf->global->DONATION_ART238 >= 1)
222 $art238 =
'<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI';
224 $art238 =
'<input type="checkbox" disabled="true">238 bis du CGI';
227 $form = str_replace(
'__ARTICLE238__', $art238, $form);
230 if ($mysoc->country_code ==
'FR') {
231 if ($conf->global->DONATION_ART978 >= 1)
233 $art978 =
'<input type="checkbox" disabled="true" checked="checked" >978 du CGI';
235 $art978 =
'<input type="checkbox" disabled="true">978 du CGI';
238 $form = str_replace(
'__ARTICLE978__', $art978, $form);
242 $handle = fopen($file,
"w");
243 fwrite($handle, $form);
245 if (!empty($conf->global->MAIN_UMASK))
246 @chmod($file, octdec($conf->global->MAIN_UMASK));
248 $this->result = array(
'fullpath'=>$file);
252 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
256 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"DON_OUTPUTDIR");
274 if (empty($devise1)) $dev1 =
'euros';
275 else $dev1 = $devise1;
276 if (empty($devise2)) $dev2 =
'centimes';
277 else $dev2 = $devise2;
278 $valeur_entiere = intval($montant);
279 $valeur_decimal = intval(round($montant - intval($montant), 2) * 100);
280 $dix_c = intval($valeur_decimal % 100 / 10);
281 $cent_c = intval($valeur_decimal % 1000 / 100);
282 $unite[1] = $valeur_entiere % 10;
283 $dix[1] = intval($valeur_entiere % 100 / 10);
284 $cent[1] = intval($valeur_entiere % 1000 / 100);
285 $unite[2] = intval($valeur_entiere % 10000 / 1000);
286 $dix[2] = intval($valeur_entiere % 100000 / 10000);
287 $cent[2] = intval($valeur_entiere % 1000000 / 100000);
288 $unite[3] = intval($valeur_entiere % 10000000 / 1000000);
289 $dix[3] = intval($valeur_entiere % 100000000 / 10000000);
290 $cent[3] = intval($valeur_entiere % 1000000000 / 100000000);
291 $chif = array(
'',
'un',
'deux',
'trois',
'quatre',
'cinq',
'six',
'sept',
'huit',
'neuf',
'dix',
'onze',
'douze',
'treize',
'quatorze',
'quinze',
'seize',
'dix sept',
'dix huit',
'dix neuf');
294 for ($i = 1; $i <= 3; $i++) {
300 $prim[$i] = $chif[$unite[$i]];
301 } elseif ($dix[$i] == 1) {
303 $prim[$i] = $chif[($unite[$i] + 10)];
304 } elseif ($dix[$i] == 2) {
305 if ($unite[$i] == 1) {
306 $secon[$i] =
'vingt et';
307 $prim[$i] = $chif[$unite[$i]];
309 $secon[$i] =
'vingt';
310 $prim[$i] = $chif[$unite[$i]];
312 } elseif ($dix[$i] == 3) {
313 if ($unite[$i] == 1) {
314 $secon[$i] =
'trente et';
315 $prim[$i] = $chif[$unite[$i]];
317 $secon[$i] =
'trente';
318 $prim[$i] = $chif[$unite[$i]];
320 } elseif ($dix[$i] == 4) {
321 if ($unite[$i] == 1) {
322 $secon[$i] =
'quarante et';
323 $prim[$i] = $chif[$unite[$i]];
325 $secon[$i] =
'quarante';
326 $prim[$i] = $chif[$unite[$i]];
328 } elseif ($dix[$i] == 5) {
329 if ($unite[$i] == 1) {
330 $secon[$i] =
'cinquante et';
331 $prim[$i] = $chif[$unite[$i]];
333 $secon[$i] =
'cinquante';
334 $prim[$i] = $chif[$unite[$i]];
336 } elseif ($dix[$i] == 6) {
337 if ($unite[$i] == 1) {
338 $secon[$i] =
'soixante et';
339 $prim[$i] = $chif[$unite[$i]];
341 $secon[$i] =
'soixante';
342 $prim[$i] = $chif[$unite[$i]];
344 } elseif ($dix[$i] == 7) {
345 if ($unite[$i] == 1) {
346 $secon[$i] =
'soixante et';
347 $prim[$i] = $chif[$unite[$i] + 10];
349 $secon[$i] =
'soixante';
350 $prim[$i] = $chif[$unite[$i] + 10];
352 } elseif ($dix[$i] == 8) {
353 if ($unite[$i] == 1) {
354 $secon[$i] =
'quatre-vingts et';
355 $prim[$i] = $chif[$unite[$i]];
357 $secon[$i] =
'quatre-vingt';
358 $prim[$i] = $chif[$unite[$i]];
360 } elseif ($dix[$i] == 9) {
361 if ($unite[$i] == 1) {
362 $secon[$i] =
'quatre-vingts et';
363 $prim[$i] = $chif[$unite[$i] + 10];
365 $secon[$i] =
'quatre-vingts';
366 $prim[$i] = $chif[$unite[$i] + 10];
369 if ($cent[$i] == 1) $trio[$i] =
'cent';
370 elseif ($cent[$i] != 0 || $cent[$i] !=
'') $trio[$i] = $chif[$cent[$i]].
' cents';
374 $chif2 = array(
'',
'dix',
'vingt',
'trente',
'quarante',
'cinquante',
'soixante',
'soixante-dix',
'quatre-vingts',
'quatre-vingts dix');
375 $secon_c = $chif2[$dix_c];
376 if ($cent_c == 1) $trio_c =
'cent';
377 elseif ($cent_c != 0 || $cent_c !=
'') $trio_c = $chif[$cent_c].
' cents';
379 if (($cent[3] == 0 || $cent[3] ==
'') && ($dix[3] == 0 || $dix[3] ==
'') && ($unite[3] == 1))
380 $somme = $trio[3].
' '.$secon[3].
' '.$prim[3].
' million ';
381 elseif (($cent[3] != 0 && $cent[3] !=
'') || ($dix[3] != 0 && $dix[3] !=
'') || ($unite[3] != 0 && $unite[3] !=
''))
382 $somme = $trio[3].
' '.$secon[3].
' '.$prim[3].
' millions ';
383 else $somme = $trio[3].
' '.$secon[3].
' '.$prim[3];
385 if (($cent[2] == 0 || $cent[2] ==
'') && ($dix[2] == 0 || $dix[2] ==
'') && ($unite[2] == 1))
386 $somme = $somme.
' mille ';
387 elseif (($cent[2] != 0 && $cent[2] !=
'') || ($dix[2] != 0 && $dix[2] !=
'') || ($unite[2] != 0 && $unite[2] !=
''))
388 $somme = $somme.$trio[2].
' '.$secon[2].
' '.$prim[2].
' milles ';
389 else $somme = $somme.$trio[2].
' '.$secon[2].
' '.$prim[2];
391 $somme = $somme.$trio[1].
' '.$secon[1].
' '.$prim[1];
393 $somme = $somme.
' '.$dev1.
' ';
395 if (($cent_c ==
'0' || $cent_c ==
'') && ($dix_c ==
'0' || $dix_c ==
''))
396 return $somme.
' et zéro '.$dev2;
397 else return $somme.$trio_c.
' '.$secon_c.
' '.$dev2;
amountToLetters($montant, $devise1= '', $devise2= '')
numbers to letters
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode= 'auto')
Return date for now.
isEnabled()
Return if a module can be used or not.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to generate document for subscriptions.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to manage donations.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Parent class of subscription templates.
write_file($don, $outputlangs, $currency= '')
Write the object to document file to disk.
__construct($db)
Constructor.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)