2005-11-11 22:36:56 +00:00
< ? php
2012-07-11 08:14:56 +00:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2005 - 2006 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 12:43:12 +00:00
* Copyright ( C ) 2012 Regis Houssin < regis . houssin @ inodbox . com >
2012-12-29 00:13:31 +00:00
* Copyright ( C ) 2012 Marcos García < marcosgdf @ gmail . com >
2020-02-17 06:43:24 +00:00
* Copyright ( C ) 2014 - 2020 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2015-11-22 20:31:05 +00:00
* Copyright ( C ) 2015 Benoit Bruchard < benoitb21 @ gmail . com >
2005-11-11 22:36:56 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 14:36:08 +00:00
* the Free Software Foundation ; either version 3 of the License , or
2005-11-11 22:36:56 +00:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2005-11-11 22:36:56 +00:00
*/
/**
2015-03-22 14:27:05 +00:00
* \file htdocs / core / modules / dons / html_cerfafr . modules . php
2014-06-15 20:18:19 +00:00
* \ingroup don
* \brief Form of donation
2011-08-27 16:15:06 +00:00
*/
2015-03-22 07:20:19 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/modules/dons/modules_don.php' ;
2015-03-25 21:37:14 +00:00
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php' ;
2012-08-22 21:11:24 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2005-11-11 22:36:56 +00:00
/**
2012-02-16 17:39:22 +00:00
* Class to generate document for subscriptions
*/
2005-11-11 22:36:56 +00:00
class html_cerfafr extends ModeleDon
{
2017-10-07 11:09:31 +00:00
/**
* Constructor
*
2018-08-31 20:34:02 +00:00
* @ param DoliDb $db Database handler
2017-10-07 11:09:31 +00:00
*/
2019-03-01 18:24:06 +00:00
public function __construct ( $db )
2017-10-07 11:09:31 +00:00
{
2020-02-21 16:53:37 +00:00
global $conf , $langs ;
2005-11-11 22:36:56 +00:00
2017-10-07 11:09:31 +00:00
$this -> db = $db ;
$this -> name = " cerfafr " ;
2020-02-17 06:43:24 +00:00
$this -> description = $langs -> trans ( 'DonationsReceiptModel' ) . ' - fr_FR - Cerfa 11580*04' ;
2006-08-20 23:04:24 +00:00
2017-10-07 11:09:31 +00:00
// Dimension page for size A4
$this -> type = 'html' ;
}
2005-11-11 22:36:56 +00:00
2012-02-16 17:39:22 +00:00
/**
* Return if a module can be used or not
2012-07-11 08:14:56 +00:00
*
2012-02-16 17:39:22 +00:00
* @ return boolean true if module can be used
*/
2019-03-01 18:24:06 +00:00
public function isEnabled ()
2008-10-29 21:26:59 +00:00
{
return true ;
}
2009-02-10 22:07:31 +00:00
2019-03-01 18:24:06 +00:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2017-10-07 11:09:31 +00:00
/**
* Write the object to document file to disk
*
* @ param Don $don Donation object
* @ param Translate $outputlangs Lang object for output language
2017-03-19 14:37:07 +00:00
* @ param string $currency Currency code
2017-10-07 11:09:31 +00:00
* @ return int > 0 if OK , < 0 if KO
*/
2019-03-01 18:24:06 +00:00
public function write_file ( $don , $outputlangs , $currency = '' )
2017-10-07 11:09:31 +00:00
{
2018-09-02 21:44:53 +00:00
// phpcs:enable
2020-02-21 16:53:37 +00:00
global $user , $conf , $langs , $mysoc ;
2008-10-29 19:49:10 +00:00
2020-02-21 16:53:37 +00:00
$now = dol_now ();
$id = ( ! is_object ( $don ) ? $don : '' );
2009-02-10 22:07:31 +00:00
2020-02-21 16:53:37 +00:00
if ( ! is_object ( $outputlangs )) $outputlangs = $langs ;
2009-02-10 22:07:31 +00:00
2019-09-20 05:02:14 +00:00
// Load traductions files required by page
2018-09-18 09:09:56 +00:00
$outputlangs -> loadLangs ( array ( " main " , " dict " , " companies " , " bills " , " products " , " donations " ));
2009-04-29 18:02:50 +00:00
2017-03-19 14:37:07 +00:00
$currency = ! empty ( $currency ) ? $currency : $conf -> currency ;
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
if ( ! empty ( $conf -> don -> dir_output ))
2017-10-07 11:09:31 +00:00
{
2014-06-15 20:18:19 +00:00
// Definition of the object don (for upward compatibility)
2020-02-21 16:53:37 +00:00
if ( ! is_object ( $don ))
2017-10-07 11:09:31 +00:00
{
$don = new Don ( $this -> db );
2020-02-21 16:53:37 +00:00
$ret = $don -> fetch ( $id );
$id = $don -> id ;
2006-08-20 23:04:24 +00:00
}
2014-06-15 20:18:19 +00:00
// Definition of $dir and $file
2020-02-21 16:53:37 +00:00
if ( ! empty ( $don -> specimen ))
2006-08-20 23:04:24 +00:00
{
$dir = $conf -> don -> dir_output ;
2020-02-21 16:53:37 +00:00
$file = $dir . " /SPECIMEN.html " ;
2006-08-20 23:04:24 +00:00
}
else
{
2009-04-29 18:02:50 +00:00
$donref = dol_sanitizeFileName ( $don -> ref );
2020-02-21 16:53:37 +00:00
$dir = $conf -> don -> dir_output . " / " . $donref ;
$file = $dir . " / " . $donref . " .html " ;
2006-08-20 23:04:24 +00:00
}
2009-02-10 22:07:31 +00:00
2020-02-21 16:53:37 +00:00
if ( ! file_exists ( $dir ))
2017-10-07 11:09:31 +00:00
{
if ( dol_mkdir ( $dir ) < 0 )
{
2020-02-21 16:53:37 +00:00
$this -> error = $langs -> trans ( " ErrorCanNotCreateDir " , $dir );
2017-10-07 11:09:31 +00:00
return - 1 ;
}
}
2009-02-10 22:07:31 +00:00
2017-10-07 11:09:31 +00:00
if ( file_exists ( $dir ))
{
$formclass = new Form ( $this -> db );
2012-12-29 00:13:31 +00:00
2017-10-07 11:09:31 +00:00
// This is not the proper way to do it but $formclass->form_modes_reglement
// prints the translation instead of returning it
if ( $don -> modepaiementid )
{
$formclass -> load_cache_types_paiements ();
$paymentmode = $formclass -> cache_types_paiements [ $don -> modepaiementid ][ 'label' ];
}
else $paymentmode = '' ;
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
if ( $don -> modepaymentcode == 'CHQ' ) {
2017-10-05 23:46:48 +00:00
$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>' ;
2015-11-22 20:31:05 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $don -> modepaymentcode == 'LIQ' ) {
2017-10-05 23:46:48 +00:00
$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>' ;
2015-11-22 20:31:05 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $don -> modepaymentcode == 'VIR' || $don -> modepaymentcode == 'PRE' || $don -> modepaymentcode == 'CB' ) {
2017-10-05 23:46:48 +00:00
$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>' ;
2018-03-02 11:32:49 +00:00
}
else
2015-11-22 20:31:05 +00:00
{
2017-10-05 23:46:48 +00:00
$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>' ;
2015-11-22 20:31:05 +00:00
}
2018-03-02 11:32:49 +00:00
2016-01-10 06:35:00 +00:00
/*
2015-11-22 20:31:05 +00:00
if ( empty ( $don -> societe ))
{
2020-02-17 06:43:24 +00:00
$CodeDon = '<td width="33%"><input type="checkbox" disabled="true" checked="checked" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 978 du CGI</td>' ;
2015-11-22 20:31:05 +00:00
}
else
{
2020-02-17 06:43:24 +00:00
$CodeDon = '<td width="33%"><input type="checkbox" disabled="true" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" checked="checked" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 978 du CGI</td>' ;
2015-11-22 20:31:05 +00:00
}
2016-01-10 06:35:00 +00:00
*/
2018-03-02 11:32:49 +00:00
2017-10-07 11:09:31 +00:00
// Define contents
2020-02-21 16:53:37 +00:00
$donmodel = DOL_DOCUMENT_ROOT . " /core/modules/dons/html_cerfafr.html " ;
2017-10-07 11:09:31 +00:00
$form = implode ( '' , file ( $donmodel ));
2019-01-27 10:55:16 +00:00
$form = str_replace ( '__REF__' , $don -> id , $form );
$form = str_replace ( '__DATE__' , dol_print_date ( $don -> date , 'day' , false , $outputlangs ), $form );
2017-10-07 11:09:31 +00:00
//$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
2018-03-02 11:32:49 +00:00
$form = str_replace ( '__AMOUNT__' , price ( $don -> amount ), $form );
2019-01-27 10:55:16 +00:00
$form = str_replace ( '__AMOUNTLETTERS__' , $this -> amountToLetters ( $don -> amount ), $form );
$form = str_replace ( '__CURRENCY__' , $outputlangs -> transnoentitiesnoconv ( " Currency " . $currency ), $form );
$form = str_replace ( '__CURRENCYCODE__' , $conf -> currency , $form );
$form = str_replace ( '__MAIN_INFO_SOCIETE_NOM__' , $mysoc -> name , $form );
$form = str_replace ( '__MAIN_INFO_SOCIETE_ADDRESS__' , $mysoc -> address , $form );
$form = str_replace ( '__MAIN_INFO_SOCIETE_ZIP__' , $mysoc -> zip , $form );
$form = str_replace ( '__MAIN_INFO_SOCIETE_TOWN__' , $mysoc -> town , $form );
$form = str_replace ( '__MAIN_INFO_SOCIETE_OBJECT__' , $mysoc -> object , $form );
$form = str_replace ( '__DONATOR_FIRSTNAME__' , $don -> firstname , $form );
$form = str_replace ( '__DONATOR_LASTNAME__' , $don -> lastname , $form );
$form = str_replace ( '__DONATOR_SOCIETE__' , $don -> societe , $form );
$form = str_replace ( '__DONATOR_STATUT__' , $don -> statut , $form );
$form = str_replace ( '__DONATOR_ADDRESS__' , $don -> address , $form );
$form = str_replace ( '__DONATOR_ZIP__' , $don -> zip , $form );
$form = str_replace ( '__DONATOR_TOWN__' , $don -> town , $form );
$form = str_replace ( '__PAYMENTMODE_LIB__ ' , $paymentmode , $form );
$form = str_replace ( '__NOW__' , dol_print_date ( $now , 'day' , false , $outputlangs ), $form );
$form = str_replace ( '__DonationRef__' , $outputlangs -> trans ( " DonationRef " ), $form );
$form = str_replace ( '__DonationTitle__' , $outputlangs -> trans ( " DonationTitle " ), $form );
$form = str_replace ( '__DonationReceipt__' , $outputlangs -> trans ( " DonationReceipt " ), $form );
$form = str_replace ( '__DonationRecipient__' , $outputlangs -> trans ( " DonationRecipient " ), $form );
$form = str_replace ( '__DonationDatePayment__' , $outputlangs -> trans ( " DonationDatePayment " ), $form );
$form = str_replace ( '__PaymentMode__' , $outputlangs -> trans ( " PaymentMode " ), $form );
2016-01-10 06:35:00 +00:00
// $form = str_replace('__CodeDon__',$CodeDon,$form);
2019-01-27 10:55:16 +00:00
$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 ( '__Object__' , $outputlangs -> trans ( " Object " ), $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 ( '__Message__' , $outputlangs -> trans ( " Message " ), $form );
$form = str_replace ( '__IConfirmDonationReception__' , $outputlangs -> trans ( " IConfirmDonationReception " ), $form );
$form = str_replace ( '__DonationMessage__' , $conf -> global -> DONATION_MESSAGE , $form );
2015-05-18 20:25:51 +00:00
2019-01-27 10:55:16 +00:00
$form = str_replace ( '__ModePaiement__' , $ModePaiement , $form );
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
$frencharticle = '' ;
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>' ;
2019-01-27 10:55:16 +00:00
$form = str_replace ( '__FrenchArticle__' , $frencharticle , $form );
2015-05-18 20:25:51 +00:00
2020-02-21 16:53:37 +00:00
$frencheligibility = '' ;
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 :' ;
2019-01-27 10:55:16 +00:00
$form = str_replace ( '__FrenchEligibility__' , $frencheligibility , $form );
2015-05-18 20:25:51 +00:00
2020-02-21 16:53:37 +00:00
$art200 = '' ;
2019-01-27 10:55:16 +00:00
if ( preg_match ( '/fr/i' , $outputlangs -> defaultlang )) {
2015-05-18 20:25:51 +00:00
if ( $conf -> global -> DONATION_ART200 >= 1 )
2014-06-15 20:18:19 +00:00
{
2020-02-21 16:53:37 +00:00
$art200 = '<input type="checkbox" disabled="true" checked="checked" >200 du CGI' ;
2014-06-15 20:18:19 +00:00
}
else
{
2020-02-21 16:53:37 +00:00
$art200 = '<input type="checkbox" disabled="true">200 du CGI' ;
2014-06-15 20:18:19 +00:00
}
}
2019-01-27 10:55:16 +00:00
$form = str_replace ( '__ARTICLE200__' , $art200 , $form );
2014-06-15 20:18:19 +00:00
2020-02-21 16:53:37 +00:00
$art238 = '' ;
2019-01-27 10:55:16 +00:00
if ( preg_match ( '/fr/i' , $outputlangs -> defaultlang )) {
2015-05-18 20:25:51 +00:00
if ( $conf -> global -> DONATION_ART238 >= 1 )
2014-06-15 20:18:19 +00:00
{
2020-02-21 16:53:37 +00:00
$art238 = '<input type="checkbox" disabled="true" checked="checked" >238 bis du CGI' ;
2014-06-15 20:18:19 +00:00
}
else
{
2020-02-21 16:53:37 +00:00
$art238 = '<input type="checkbox" disabled="true">238 bis du CGI' ;
2014-06-15 20:18:19 +00:00
}
}
2019-01-27 10:55:16 +00:00
$form = str_replace ( '__ARTICLE238__' , $art238 , $form );
2015-05-18 20:25:51 +00:00
2020-02-21 16:53:37 +00:00
$art978 = '' ;
2019-01-27 10:55:16 +00:00
if ( preg_match ( '/fr/i' , $outputlangs -> defaultlang )) {
2020-02-17 06:43:24 +00:00
if ( $conf -> global -> DONATION_ART978 >= 1 )
2014-06-15 20:18:19 +00:00
{
2020-02-21 16:53:37 +00:00
$art978 = '<input type="checkbox" disabled="true" checked="checked" >978 du CGI' ;
2014-06-15 20:18:19 +00:00
}
else
{
2020-02-21 16:53:37 +00:00
$art978 = '<input type="checkbox" disabled="true">978 du CGI' ;
2014-06-15 20:18:19 +00:00
}
}
2020-02-17 06:43:24 +00:00
$form = str_replace ( '__ARTICLE978__' , $art978 , $form );
2015-05-18 20:25:51 +00:00
2014-06-15 20:18:19 +00:00
// Save file on disk
2017-10-07 11:09:31 +00:00
dol_syslog ( " html_cerfafr::write_file $file " );
2020-02-21 16:53:37 +00:00
$handle = fopen ( $file , " w " );
2019-01-27 10:55:16 +00:00
fwrite ( $handle , $form );
2017-10-07 11:09:31 +00:00
fclose ( $handle );
2020-02-21 16:53:37 +00:00
if ( ! empty ( $conf -> global -> MAIN_UMASK ))
2008-10-21 21:27:20 +00:00
@ chmod ( $file , octdec ( $conf -> global -> MAIN_UMASK ));
2009-02-10 22:07:31 +00:00
2017-08-18 21:16:40 +00:00
$this -> result = array ( 'fullpath' => $file );
2018-03-02 11:32:49 +00:00
2017-10-07 11:09:31 +00:00
return 1 ;
}
else
{
2020-02-21 16:53:37 +00:00
$this -> error = $langs -> trans ( " ErrorCanNotCreateDir " , $dir );
2017-10-07 11:09:31 +00:00
return 0 ;
}
}
else
{
2020-02-21 16:53:37 +00:00
$this -> error = $langs -> trans ( " ErrorConstantNotDefined " , " DON_OUTPUTDIR " );
2017-10-07 11:09:31 +00:00
return 0 ;
2006-08-20 23:04:24 +00:00
}
2017-10-07 11:09:31 +00:00
}
2005-11-11 22:36:56 +00:00
2018-09-02 14:18:08 +00:00
/**
* numbers to letters
*
* @ param mixed $montant amount
* @ param mixed $devise1 devise 1 ex : euro
* @ param mixed $devise2 devise 2 ex : centimes
* @ return string amount in letters
*/
2019-01-27 14:20:16 +00:00
private function amountToLetters ( $montant , $devise1 = '' , $devise2 = '' )
2018-09-02 14:18:08 +00:00
{
$unite = array ();
$dix = array ();
$cent = array ();
2020-02-21 16:53:37 +00:00
if ( empty ( $devise1 )) $dev1 = 'euros' ;
else $dev1 = $devise1 ;
if ( empty ( $devise2 )) $dev2 = 'centimes' ;
else $dev2 = $devise2 ;
$valeur_entiere = intval ( $montant );
$valeur_decimal = intval ( round ( $montant - intval ( $montant ), 2 ) * 100 );
$dix_c = intval ( $valeur_decimal % 100 / 10 );
$cent_c = intval ( $valeur_decimal % 1000 / 100 );
$unite [ 1 ] = $valeur_entiere % 10 ;
$dix [ 1 ] = intval ( $valeur_entiere % 100 / 10 );
$cent [ 1 ] = intval ( $valeur_entiere % 1000 / 100 );
$unite [ 2 ] = intval ( $valeur_entiere % 10000 / 1000 );
$dix [ 2 ] = intval ( $valeur_entiere % 100000 / 10000 );
$cent [ 2 ] = intval ( $valeur_entiere % 1000000 / 100000 );
$unite [ 3 ] = intval ( $valeur_entiere % 10000000 / 1000000 );
$dix [ 3 ] = intval ( $valeur_entiere % 100000000 / 10000000 );
$cent [ 3 ] = intval ( $valeur_entiere % 1000000000 / 100000000 );
$chif = array ( '' , 'un' , 'deux' , 'trois' , 'quatre' , 'cinq' , 'six' , 'sept' , 'huit' , 'neuf' , 'dix' , 'onze' , 'douze' , 'treize' , 'quatorze' , 'quinze' , 'seize' , 'dix sept' , 'dix huit' , 'dix neuf' );
$secon_c = '' ;
$trio_c = '' ;
for ( $i = 1 ; $i <= 3 ; $i ++ ) {
$prim [ $i ] = '' ;
$secon [ $i ] = '' ;
$trio [ $i ] = '' ;
if ( $dix [ $i ] == 0 ) {
$secon [ $i ] = '' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 1 ) {
$secon [ $i ] = '' ;
$prim [ $i ] = $chif [( $unite [ $i ] + 10 )];
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 2 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'vingt et' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2019-10-27 16:01:23 +00:00
} else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'vingt' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 3 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'trente et' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2019-10-27 16:01:23 +00:00
} else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'trente' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 4 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'quarante et' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'quarante' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 5 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'cinquante et' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'cinquante' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 6 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'soixante et' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'soixante' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 7 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'soixante et' ;
$prim [ $i ] = $chif [ $unite [ $i ] + 10 ];
2018-09-02 14:18:08 +00:00
}
else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'soixante' ;
$prim [ $i ] = $chif [ $unite [ $i ] + 10 ];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 8 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'quatre-vingts et' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'quatre-vingt' ;
$prim [ $i ] = $chif [ $unite [ $i ]];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
elseif ( $dix [ $i ] == 9 ) {
if ( $unite [ $i ] == 1 ) {
$secon [ $i ] = 'quatre-vingts et' ;
$prim [ $i ] = $chif [ $unite [ $i ] + 10 ];
2018-09-02 14:18:08 +00:00
}
else {
2020-02-21 16:53:37 +00:00
$secon [ $i ] = 'quatre-vingts' ;
$prim [ $i ] = $chif [ $unite [ $i ] + 10 ];
2018-09-02 14:18:08 +00:00
}
2017-10-07 11:09:31 +00:00
}
2020-02-21 16:53:37 +00:00
if ( $cent [ $i ] == 1 ) $trio [ $i ] = 'cent' ;
elseif ( $cent [ $i ] != 0 || $cent [ $i ] != '' ) $trio [ $i ] = $chif [ $cent [ $i ]] . ' cents' ;
2017-10-07 11:09:31 +00:00
}
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
$chif2 = array ( '' , 'dix' , 'vingt' , 'trente' , 'quarante' , 'cinquante' , 'soixante' , 'soixante-dix' , 'quatre-vingts' , 'quatre-vingts dix' );
$secon_c = $chif2 [ $dix_c ];
if ( $cent_c == 1 ) $trio_c = 'cent' ;
elseif ( $cent_c != 0 || $cent_c != '' ) $trio_c = $chif [ $cent_c ] . ' cents' ;
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
if (( $cent [ 3 ] == 0 || $cent [ 3 ] == '' ) && ( $dix [ 3 ] == 0 || $dix [ 3 ] == '' ) && ( $unite [ 3 ] == 1 ))
$somme = $trio [ 3 ] . ' ' . $secon [ 3 ] . ' ' . $prim [ 3 ] . ' million ' ;
elseif (( $cent [ 3 ] != 0 && $cent [ 3 ] != '' ) || ( $dix [ 3 ] != 0 && $dix [ 3 ] != '' ) || ( $unite [ 3 ] != 0 && $unite [ 3 ] != '' ))
$somme = $trio [ 3 ] . ' ' . $secon [ 3 ] . ' ' . $prim [ 3 ] . ' millions ' ;
2018-09-02 14:18:08 +00:00
else
2020-02-21 16:53:37 +00:00
$somme = $trio [ 3 ] . ' ' . $secon [ 3 ] . ' ' . $prim [ 3 ];
2018-09-02 14:18:08 +00:00
2020-02-21 16:53:37 +00:00
if (( $cent [ 2 ] == 0 || $cent [ 2 ] == '' ) && ( $dix [ 2 ] == 0 || $dix [ 2 ] == '' ) && ( $unite [ 2 ] == 1 ))
2018-09-02 14:18:08 +00:00
$somme = $somme . ' mille ' ;
2020-02-21 16:53:37 +00:00
elseif (( $cent [ 2 ] != 0 && $cent [ 2 ] != '' ) || ( $dix [ 2 ] != 0 && $dix [ 2 ] != '' ) || ( $unite [ 2 ] != 0 && $unite [ 2 ] != '' ))
$somme = $somme . $trio [ 2 ] . ' ' . $secon [ 2 ] . ' ' . $prim [ 2 ] . ' milles ' ;
2018-09-02 14:18:08 +00:00
else
2020-02-21 16:53:37 +00:00
$somme = $somme . $trio [ 2 ] . ' ' . $secon [ 2 ] . ' ' . $prim [ 2 ];
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
$somme = $somme . $trio [ 1 ] . ' ' . $secon [ 1 ] . ' ' . $prim [ 1 ];
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
$somme = $somme . ' ' . $dev1 . ' ' ;
2018-03-02 11:32:49 +00:00
2020-02-21 16:53:37 +00:00
if (( $cent_c == '0' || $cent_c == '' ) && ( $dix_c == '0' || $dix_c == '' ))
return $somme . ' et zéro ' . $dev2 ;
2018-09-02 14:18:08 +00:00
else
2020-02-21 16:53:37 +00:00
return $somme . $trio_c . ' ' . $secon_c . ' ' . $dev2 ;
2018-09-02 14:18:08 +00:00
}
2015-11-22 20:31:05 +00:00
}