2013-11-05 11:18:30 +00:00
< ? php
require_once 'framework/common/curl.php' ;
require_once 'framework/common/dates.php' ;
require_once 'Metier/partenaires/classMGreffes.php' ;
2014-10-20 13:14:32 +00:00
class MBilans
{
/**
* Siren de l ' entité
* @ var string
*/
public $siren ;
2014-04-22 08:05:59 +00:00
2013-11-05 11:18:30 +00:00
public $dernierExerciceDepose = 0 ;
2014-04-22 08:05:59 +00:00
2013-11-05 11:18:30 +00:00
public $dernierExerciceDeposeLe = 0 ;
2014-04-22 08:05:59 +00:00
2014-10-20 13:14:32 +00:00
/**
* Stockage mémoire
* @ var array
*/
protected $Bilans = array ();
2015-02-03 13:11:18 +00:00
/**
* Tableau de conversion basique pour la méthode bilanSimplifie2Normal
* @ var array
*/
protected $tabBS2BN = array (
2014-03-26 15:56:50 +00:00
//2033 ACTIF PASSIF
2014-03-19 13:10:31 +00:00
'AH' => '010' ,
'AI' => '012' ,
'AI1' => '013' ,
'AI2' => 'N00' ,
'AJ' => '014' ,
'AK' => '016' ,
'AK1' => '017' ,
'AK2' => 'N01' ,
'AT' => '028' ,
'AU' => '030' ,
'AU1' => '031' ,
'AU2' => 'N02' ,
'BH' => '040' ,
'BI' => '042' ,
'BI1' => '043' ,
'BI2' => 'N03' ,
'BJ' => '044' ,
'BK' => '048' ,
'BK1' => '049' ,
'BK2' => 'N04' ,
'BT' => '060' ,
'BU' => '062' ,
'BU1' => '063' ,
'BU2' => 'N06' ,
'BV' => '064' ,
'BW' => '066' ,
'BW1' => '067' ,
'BW2' => 'N07' ,
'BX' => '068' ,
'BY' => '070' ,
'BY1' => '071' ,
'BY2' => 'N08' ,
'BZ' => '072' ,
'CA' => '074' ,
'CA1' => '075' ,
'CA2' => 'N09' ,
'CD' => '080' ,
'CE' => '082' ,
'CE1' => '083' ,
'CE2' => 'N10' ,
'CF' => '084' ,
'CG' => '086' ,
'CG1' => '087' ,
'CG2' => 'N11' ,
'CH' => '092' ,
'CI' => '094' ,
'CI1' => '095' ,
'CI2' => 'N13' ,
'CJ' => '096' ,
'CK' => '098' ,
'CK1' => '099' ,
'CK2' => 'N14' ,
'CO' => '110' ,
'1A' => '112' ,
'1A1' => '113' ,
'1A2' => 'N15' ,
'DA' => '120' ,
'DA1' => 'N16' ,
'DC' => '124' ,
2014-03-26 15:56:50 +00:00
'DC1' => 'N17' ,
2014-03-19 13:10:31 +00:00
'DD' => '126' ,
2014-03-26 15:56:50 +00:00
'DD1' => 'N18' ,
2014-03-19 13:10:31 +00:00
'DF' => '130' ,
2014-03-26 15:56:50 +00:00
'DF1' => 'N19' ,
2014-03-19 13:10:31 +00:00
'DG' => '132' ,
2014-03-26 15:56:50 +00:00
'DG1' => 'N20' ,
2014-03-19 13:10:31 +00:00
'DH' => '134' ,
2014-03-26 15:56:50 +00:00
'DH1' => 'N21' ,
2014-03-19 13:10:31 +00:00
'DI' => '136' ,
2014-03-26 15:56:50 +00:00
'DI1' => 'N22' ,
2014-03-19 13:10:31 +00:00
'DK' => '140' ,
2014-03-26 15:56:50 +00:00
'DK1' => 'N23' ,
2014-03-19 13:10:31 +00:00
'DL' => '142' ,
2014-03-26 15:56:50 +00:00
'DL1' => 'N24' ,
2014-03-19 13:10:31 +00:00
'DR' => '154' ,
2014-03-26 15:56:50 +00:00
'DR1' => 'N25' ,
2014-03-19 13:10:31 +00:00
'DU' => '156' ,
2014-03-26 15:56:50 +00:00
'DU1' => 'N26' ,
2014-03-19 13:10:31 +00:00
'DW' => '164' ,
2014-03-26 15:56:50 +00:00
'DW1' => 'N27' ,
2014-03-19 13:10:31 +00:00
'DX' => '166' ,
2014-03-26 15:56:50 +00:00
'DX1' => 'N28' ,
2014-03-19 13:10:31 +00:00
'EA' => '172' ,
2014-03-26 15:56:50 +00:00
'EA1' => 'N29' ,
2014-03-19 13:10:31 +00:00
'EB' => '174' ,
2014-03-26 15:56:50 +00:00
'EB1' => 'N30' ,
2014-03-19 13:10:31 +00:00
'EC' => '176' ,
2014-03-26 15:56:50 +00:00
'EC1' => 'N31' ,
2014-03-19 13:10:31 +00:00
'EE' => '180' ,
2014-03-26 15:56:50 +00:00
'EE1' => 'N32' ,
2014-03-19 13:10:31 +00:00
'EH' => '156-195' ,
//2033 CDR
'FA' => '210-209' ,
'FB' => '209' ,
'FC' => '210' ,
2014-03-26 15:56:50 +00:00
'FC1' => 'N33' ,
2014-03-19 13:10:31 +00:00
'FD' => '214-215' ,
'FE' => '215' ,
'FF' => '214' ,
2014-03-26 15:56:50 +00:00
'FF1' => 'N34' ,
2014-03-19 13:10:31 +00:00
2014-03-26 15:56:50 +00:00
'FG' => '218-217' ,
2014-03-19 13:10:31 +00:00
'FH' => '217' ,
'FI' => '218' ,
2014-03-26 15:56:50 +00:00
'FI1' => 'N35' ,
2014-03-19 13:10:31 +00:00
2014-03-26 15:56:50 +00:00
'FJ' => '210+214+218-209-215-217' ,
2014-03-19 13:10:31 +00:00
'FK' => '209+215+217' ,
'FL' => '210+214+218' ,
'FL1' => 'N33+N34+N35' ,
'FM' => '222' ,
2014-03-26 15:56:50 +00:00
'FM1' => 'N36' ,
2014-03-19 13:10:31 +00:00
'FN' => '224' ,
'FN' => 'N37' ,
'FO' => '226' ,
'FO' => 'N38' ,
'FQ' => '230' ,
'FQ' => 'N39' ,
'FR' => '232' ,
2014-03-26 15:56:50 +00:00
'FR1' => 'N40' ,
2014-03-19 13:10:31 +00:00
'FS' => '234' ,
2014-03-26 15:56:50 +00:00
'FS1' => 'N41' ,
2014-03-19 13:10:31 +00:00
'FT' => '236' ,
2014-03-26 15:56:50 +00:00
'FT1' => 'N42' ,
2014-03-19 13:10:31 +00:00
'FU' => '238' ,
2014-03-26 15:56:50 +00:00
'FU1' => 'N43' ,
2014-03-19 13:10:31 +00:00
'FV' => '240' ,
2014-03-26 15:56:50 +00:00
'FV1' => 'N44' ,
2014-03-19 13:10:31 +00:00
'FW' => '242' ,
2014-03-26 15:56:50 +00:00
'FW1' => 'N45' ,
2014-03-19 13:10:31 +00:00
'FX' => '244' ,
2014-03-26 15:56:50 +00:00
'FX1' => 'N46' ,
2014-03-19 13:10:31 +00:00
'FY' => '250' ,
2014-03-26 15:56:50 +00:00
'FY1' => 'N47' ,
2014-03-19 13:10:31 +00:00
'FZ' => '252' ,
2014-03-26 15:56:50 +00:00
'FZ1' => 'N48' ,
2014-03-19 13:10:31 +00:00
'GA' => '254' ,
2014-03-26 15:56:50 +00:00
'GA1' => 'N49' ,
2014-03-19 13:10:31 +00:00
'GE' => '262' ,
2014-03-26 15:56:50 +00:00
'GE1' => 'N50' ,
2014-03-19 13:10:31 +00:00
'GF' => '264' ,
2014-03-26 15:56:50 +00:00
'GF1' => 'N52' ,
2014-03-19 13:10:31 +00:00
'GG' => '270' ,
2014-03-26 15:56:50 +00:00
'GG1' => 'N53' ,
2014-03-19 13:10:31 +00:00
'GP' => '280' ,
2014-03-26 15:56:50 +00:00
'GP1' => 'N54' ,
2014-03-19 13:10:31 +00:00
'GU' => '294' ,
2014-03-26 15:56:50 +00:00
'GU1' => 'N56' ,
2014-03-19 13:10:31 +00:00
2014-03-26 15:56:50 +00:00
'GV' => '280-294' , //GP-GU
'GV1' => 'N54-N56' , //GP1-GU1
2014-06-25 11:43:29 +00:00
'GW' => '270+280-294' , //GG+GH-GI+GV ???
'GW1' => 'N53+N54-N56' ,
2014-03-19 13:10:31 +00:00
'HD' => '290' ,
2014-03-26 15:56:50 +00:00
'HD1' => 'N55' ,
2014-03-19 13:10:31 +00:00
'HH' => '300' ,
2014-03-26 15:56:50 +00:00
'HH1' => 'N57' ,
2014-03-19 13:10:31 +00:00
'HI' => '290-300' ,
2014-03-26 15:56:50 +00:00
'HI1' => 'N55-N57' ,
2014-03-19 13:10:31 +00:00
'HK' => '306' ,
2014-03-26 15:56:50 +00:00
'HK1' => 'N58' ,
2014-03-19 13:10:31 +00:00
'HL' => '232+280+290' ,
2014-03-26 15:56:50 +00:00
'HL1' => 'N40+N54+N55' ,
2014-03-19 13:10:31 +00:00
'HM' => '264+294+300+306' ,
2014-03-26 15:56:50 +00:00
'HM1' => 'N52+N56+N57+N58' ,
2014-03-19 13:10:31 +00:00
'HN' => '310' ,
2014-03-26 15:56:50 +00:00
'HN1' => 'N59' ,
2014-03-19 13:10:31 +00:00
'YY' => '374' ,
'YZ' => '378' ,
'YP' => '376' ,
2013-11-05 11:18:30 +00:00
);
2014-04-22 08:05:59 +00:00
protected $iDb ;
/**
* MBilans
* @ param string $siren
* @ param string $db
*/
public function __construct ( $siren , $db = null )
{
if ( $db === null ) {
$this -> iDb = new WDB ();
} else {
$this -> iDb = $db ;
}
$this -> siren = $siren ;
2013-11-05 11:18:30 +00:00
}
/**
* Liste les bilans disponibles au format numérique ( et non PDF image ) pour une entreprise
* @ param boolean $accesPartenaire
* Accès autorisé aux partenaires distant si le bilan est absenr
* @ param number $nbMaxBilans
* Nombre de bilans maximums retournés
* @ return array
*/
2014-04-22 08:05:59 +00:00
public function listeBilans ( $accesPartenaire = false , $nbMaxBilans = 0 )
2013-11-05 11:18:30 +00:00
{
2014-04-22 08:05:59 +00:00
$classWDate = new WDate ();
2013-11-05 11:18:30 +00:00
$dateDerDepot = 0 ;
$tabRet = $tabRet3 = array ();
if ( $nbMaxBilans > 0 ) $limit = " LIMIT 0, $nbMaxBilans " ;
else $limit = '' ;
2014-04-22 08:05:59 +00:00
$ret = $this -> iDb -> select (
'bilans' ,
'typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire' ,
" siren=' $this->siren ' ORDER BY dateExercice DESC $limit " , false , MYSQL_ASSOC );
2013-11-05 11:18:30 +00:00
if ( count ( $ret ) > 0 ) {
$dateDerExercice = $ret [ 0 ][ 'dateExercice' ] * 1 ;
}
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren en base", print_r($ret, true));
2014-04-22 08:05:59 +00:00
$ret2 = $this -> iDb -> select (
'bodacc_detail' ,
'Bodacc_Date_Parution, dateEffet, typeEven' ,
" siren=' $this->siren ' AND Rubrique='comptes' ORDER BY dateEffet DESC " , false , MYSQL_ASSOC );
2013-11-05 11:18:30 +00:00
if ( count ( $ret2 ) > 0 ) {
$dateDerDepot = $classWDate -> dateT ( 'Y-m-d' , 'Ymd' , $ret2 [ 0 ][ 'dateEffet' ]) * 1 ;
if ( $dateDerDepot <> 0 ) {
$this -> dernierExerciceDepose = $classWDate -> dateT ( 'Y-m-d' , 'd/m/Y' , $ret2 [ 0 ][ 'dateEffet' ]);
$this -> dernierExerciceDeposeLe = $classWDate -> dateT ( 'Y-m-d' , 'd/m/Y' , $ret2 [ 0 ][ 'Bodacc_Date_Parution' ]);
}
}
2014-04-22 08:05:59 +00:00
if ( $accesPartenaire ) {
2015-01-20 16:32:59 +00:00
$iGreffe = new MGreffes ( $this -> iDb );
2014-04-22 08:05:59 +00:00
$tabRet = $tabRet2 = $iGreffe -> getListeBilans ( $this -> siren );
} else {
2013-11-05 11:18:30 +00:00
$tabRet = $tabRet2 = array ();
}
$tabTri = array ();
if ( count ( $tabRet ) > 0 ) {
foreach ( $tabRet as $millesime => $bil ) {
$typeBilan = substr ( $millesime , 0 , 1 );
$dateExercice = $classWDate -> dateT ( 'd/m/Y' , 'Ymd' , substr ( $millesime , 1 , 10 ));
$tabTri [ '' . $dateExercice . '-' . $typeBilan ] = $millesime ;
}
}
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après accès partenaire", print_r($tabRet2, true));
if ( count ( $ret ) > 0 ) {
foreach ( $ret as $i => $bil ) {
$millesime = $classWDate -> dateT ( 'Ymd' , 'd/m/Y' , $bil [ 'dateExercice' ]);
$tabRet [ '' . $bil [ 'typeBilan' ] . $millesime ] = array (
'dateProvPartenaire' => $bil [ 'dateProvPartenaire' ],
'dateInsert' => strtr ( $bil [ 'dateInsert' ], array ( ' ' => '' , ':' => '' , '-' => '' )),
'typeBilan' => $bil [ 'typeBilan' ], // NEW
'dureeExercice' => $bil [ 'dureeExercice' ], // NEW
'dateExercice' => $bil [ 'dateExercice' ],
'millesime' => substr ( $bil [ 'dateExercice' ], 0 , 4 ),
'dateExercicePre' => $bil [ 'dateExercicePre' ],
'dureeExercicePre' => $bil [ 'dureeExercicePre' ],
'monnaie' => $bil [ 'monnaieOrigine' ],
'source' => $bil [ 'partenaire' ],
);
$tabTri [ '' . $bil [ 'dateExercice' ] . '-' . $bil [ 'typeBilan' ]] = $bil [ 'typeBilan' ] . $millesime ;
}
krsort ( $tabTri );
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren avant le tri", print_r($tabTri, true));
$exercicePre = $typePre = $tmpPre = false ;
$refPre = '' ;
$strInfos = '' ;
foreach ( $tabTri as $tmp => $typeMillesime ) {
$exercice = substr ( $tmp , 0 , 8 );
$type = substr ( $tmp , 9 , 1 );
$ref = $tabRet [ '' . $typeMillesime ][ 'ref' ];
if ( $exercice == $exercicePre && $type == 'N' && $typePre == 'S' && $refPre == '' ) {
// Suppression du bilan RN de la liste si Réel Normal et Réel Simplifiés présents en base
unset ( $tabTri [ $tmp ]);
$strInfos .= " Suppression de ' $tmp ' " . EOL ;
}
elseif ( $exercice == $exercicePre && $type == 'N' && $typePre == 'S' && $refPre <> '' ) {
// Suppression du bilan RS de la liste si Réel Normal Présent en base et réel simplifié non encore en base
if ( $tmpPre <> false ) {
unset ( $tabTri [ $tmpPre ]);
$strInfos .= " Suppression de ' $tmpPre ' " . EOL ;
}
}
$exercicePre = $exercice ;
$typePre = $type ;
$refPre =@ trim ( $ref );
$tmpPre = $tmp ;
}
krsort ( $tabTri );
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri", print_r($tabTri, true).EOL.$strInfos.EOL);
$tabRet3 = array ();
foreach ( $tabTri as $tmp => $typeMillesime )
$tabRet3 [ '' . $typeMillesime ] = $tabRet [ '' . $typeMillesime ];
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri / retour", print_r($tabRet3, true));
}
return $tabRet3 ;
}
2014-10-20 13:14:32 +00:00
/**
* Retourne un bilan disponible au format numérique pour une entreprise
* @ param string $millesime
* Date de cloture du bilan au format d / m / Y
* @ param string $typeBilan
* Type de bilan ( N = Réel Normal , S = Réel Simplifié , C = Consolidé , A = Assurance , B = Banque )
* @ param number $refPart
* Référence du bilan chez le partenaire ( si $accesPartenaire = true )
* @ param string $accesPartenaire
* Accès autorisé aux partenaires distant si le bilan est absent
* @ return array
*/
2014-04-22 08:05:59 +00:00
public function getBilan ( $millesime = '' , $typeBilan = 'N' , $refPart = 0 , $accesPartenaire = false )
2013-11-05 11:18:30 +00:00
{
2014-10-20 13:14:32 +00:00
//Get bilan in memory
if ( count ( $this -> Bilans ) > 0 && array_key_exists ( $typeBilan . $millesime , $this -> Bilans ))
{
return $this -> Bilans [ $typeBilan . $millesime ];
}
2013-11-05 11:18:30 +00:00
2014-10-20 13:14:32 +00:00
$classWDate = new WDate ();
$millesimeDB = $classWDate -> dateT ( 'd/m/Y' , 'Ymd' , $millesime );
2013-11-05 11:18:30 +00:00
if ( $accesPartenaire )
2014-10-20 13:14:32 +00:00
{
2013-11-05 11:18:30 +00:00
// On ne veut pas de bilans "Téléchargés" directement sur Internet
$strSansBilansWeb = ' AND partenaire<>7 ' ;
2014-10-20 13:14:32 +00:00
}
2013-11-05 11:18:30 +00:00
else
2014-10-20 13:14:32 +00:00
{
2013-11-05 11:18:30 +00:00
$strSansBilansWeb = '' ;
2014-10-20 13:14:32 +00:00
}
$bilan = null ;
2013-11-05 11:18:30 +00:00
2015-01-20 16:32:59 +00:00
$iGreffe = new MGreffes ( $this -> iDb );
2014-10-20 13:14:32 +00:00
$ret = $this -> iDb -> select ( 'bilans' ,
'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire, id, confidentiel, dateInsert' ,
" siren=' $this->siren ' AND typeBilan=' $typeBilan ' AND dateExercice=' $millesimeDB ' $strSansBilansWeb " , false , MYSQL_ASSOC );
if ( count ( $ret ) == 0 && $accesPartenaire )
{
if ( $refPart == '' || $refPart == 0 )
{
2014-04-22 08:05:59 +00:00
$tabTmp = $iGreffe -> getListeBilans ( $this -> siren );
2014-10-20 13:14:32 +00:00
foreach ( $tabTmp as $idx => $bil )
{
2013-11-05 11:18:30 +00:00
$typeBil = substr ( $idx , 0 , 1 );
$millBil = substr ( $idx , 1 , 10 );
2014-10-20 13:14:32 +00:00
if ( $typeBil == $typeBilan && $millBil == $millesime )
{
2013-11-05 11:18:30 +00:00
$refPart = $bil [ 'ref' ];
break ;
}
}
}
2014-04-22 08:05:59 +00:00
$tabBilan = $iGreffe -> getBilan ( $this -> siren , $refPart );
2013-11-05 11:18:30 +00:00
if ( $tabBilan )
{
$strPostes = '' ;
2014-10-20 13:14:32 +00:00
foreach ( $tabBilan [ 'POSTES' ] as $poste => $valeur ) {
2013-11-05 11:18:30 +00:00
$strPostes .= " $poste = $valeur ; " ;
2014-10-20 13:14:32 +00:00
}
2013-11-05 11:18:30 +00:00
$tabInsert = array (
2015-01-05 16:18:25 +00:00
'siren' => $this -> siren ,
'dateProvPartenaire' => $tabBilan [ 'DATE_FRAICHE_BILAN' ],
'dateExercice' => $classWDate -> dateT ( 'd/m/Y' , 'Ymd' , $tabBilan [ 'DATE_CLOTURE' ]),
'dateExercicePre' => $classWDate -> dateT ( 'd/m/Y' , 'Ymd' , $tabBilan [ 'DATE_CLOTURE_PRE' ]),
'dureeExercice' => $tabBilan [ 'DUREE_MOIS' ],
'dureeExercicePre' => $tabBilan [ 'DUREE_MOIS_PRE' ],
'monnaie' => $tabBilan [ 'MONNAIE' ],
'typeBilan' => $tabBilan [ 'TYPE_BILAN' ],
'monnaieOrigine' => $tabBilan [ 'MONNAIE_ORI' ],
'unite' => $tabBilan [ 'MONNAIE_LIV_UNITE' ],
'postes' => $strPostes ,
'partenaire' => $tabBilan [ 'SOURCE' ],
2013-11-05 11:18:30 +00:00
);
2014-10-20 13:14:32 +00:00
if ( ! $this -> iDb -> insert ( 'bilans' , $tabInsert , true )) {
2014-04-22 08:05:59 +00:00
$this -> iDb -> update ( 'bilans' , $tabInsert , " siren=' $this->siren ' AND typeBilan=' $typeBilan ' AND dateExercice=' $millesimeDB ' " );
2014-10-20 13:14:32 +00:00
}
2013-11-05 11:18:30 +00:00
2014-10-20 13:14:32 +00:00
$ret = $this -> iDb -> select ( 'bilans' , 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire, id, confidentiel, dateInsert' , " siren=' $this->siren ' AND typeBilan=' $typeBilan ' AND dateExercice=' $millesimeDB ' " , true );
if ( count ( $ret ) > 0 ) {
$bilan = $ret [ 0 ];
}
2013-11-05 11:18:30 +00:00
}
2014-10-20 13:14:32 +00:00
} else {
$bilan = $ret [ 0 ];
2013-11-05 11:18:30 +00:00
}
2014-10-20 13:14:32 +00:00
$tabBilan = $tabBilanPre = $bilanPre = array ();
if ( $bilan !== null )
{
$tabBilan [ 'SIREN' ] = $this -> siren ;
$tabBilan [ 'DATE_FRAICHE_BILAN' ] = $bilan [ 'dateProvPartenaire' ]; // SSAAMMJJ
$tabBilan [ 'DATE_CLOTURE' ] = $bilan [ 'dateExercice' ]; // SSAAMMJJ
$tabBilan [ 'DATE_CLOTURE_PRE' ] = $bilan [ 'dateExercicePre' ]; // SSAAMMJJ
$tabBilan [ 'DUREE_MOIS' ] = $bilan [ 'dureeExercice' ];
$tabBilan [ 'DUREE_MOIS_PRE' ] = $bilan [ 'dureeExercicePre' ];
$tabBilan [ 'MONNAIE' ] = $bilan [ 'monnaie' ];
$tabBilan [ 'CONSOLIDE' ] = $bilan [ 'typeBilan' ]; // C = Bilan consolidé
$tabBilan [ 'MONNAIE_ORI' ] = $bilan [ 'monnaieOrigine' ];
$tabBilan [ 'MONNAIE_LIV_UNITE' ] = $bilan [ 'unite' ];
$tabBilan [ 'SOURCE' ] = $bilan [ 'partenaire' ];
$tabBilan [ 'ID_BILAN_SD' ] = $bilan [ 'id' ];
$tabBilan [ 'DATE_BILAN_SD' ] = $bilan [ 'dateInsert' ];
$tabBilan [ 'TOP_CONFIDENTIEL' ] = $bilan [ 'confidentiel' ];
// Devise et Unité
if ( $bilan [ 'monnaie' ] == 'EUR' ) $monnaie = '€' ; else $monnaie = $bilan [ 'monnaie' ];
switch ( strtoupper ( $bilan [ 'unite' ])) {
case 'K' : $unite = 'K' ; break ;
case 'U' :
case ' ' :
case '' : $unite = '' ; break ;
case 'M' : $unite = 'M' ; break ;
default : die ( 'Unite Bilan (' . $bilan [ 'unite' ] . ') non prise en charge !' ); break ;
}
$tabBilan [ 'devise' ] = /*$unite.*/ $monnaie ;
/** Remplissage du tableau des postes du Bilan avec prise en compte de l'unité de la monnaie **/
$tabTmp = explode ( ';' , $bilan [ 'postes' ]);
foreach ( $tabTmp as $i => $strTmp ) {
$tabTmp2 = explode ( '=' , $strTmp );
if ( isset ( $tabTmp2 [ 1 ])) {
if ( ( $unite == 'K' || $unite == 'M' ) && ! in_array ( $tabTmp2 [ 0 ], array (
'YP' , 'YP1' , '376' , // Effectifs 2033 et 2050
'M2G' , 'M2H' , // Autres effectifs
'ZK' , 'ZK1' , // Taux
'IJ' , 'JG' , 'JH' , 'JJ' , 'ZR' , // pour holding/ste mere
'XP' // Numero de centre de gestion agréé
) ) ) {
if ( $unite == 'K' ) {
$tabBilan [ $tabTmp2 [ 0 ]] = $tabTmp2 [ 1 ] * 1000 ;
} else if ( $unite == 'M' ) {
$tabBilan [ $tabTmp2 [ 0 ]] = $tabTmp2 [ 1 ] * 1000000 ;
}
} else {
$tabBilan [ $tabTmp2 [ 0 ]] = $tabTmp2 [ 1 ];
}
}
}
2013-11-05 11:18:30 +00:00
2014-10-20 13:14:32 +00:00
/** Calcul des valeures NET si l'information est absente en base **/
2014-03-19 13:10:31 +00:00
if ( $tabBilan [ 'CONSOLIDE' ] == 'N' || $tabBilan [ 'CONSOLIDE' ] == 'C' )
{
2014-10-20 13:14:32 +00:00
if ( ! isset ( $tabBilan [ 'AA2' ]) && isset ( $tabBilan [ 'AA' ])) $tabBilan [ 'AA2' ] = $tabBilan [ 'AA' ];
if ( ! isset ( $tabBilan [ 'AC1' ]) && ( isset ( $tabBilan [ 'AB' ]) || isset ( $tabBilan [ 'AC' ]))) $tabBilan [ 'AC1' ] = $tabBilan [ 'AB' ] - $tabBilan [ 'AC' ];
if ( ! isset ( $tabBilan [ 'AE1' ]) && ( isset ( $tabBilan [ 'AD' ]) || isset ( $tabBilan [ 'AE' ]))) $tabBilan [ 'AE1' ] = $tabBilan [ 'AD' ] - $tabBilan [ 'AE' ];
if ( ! isset ( $tabBilan [ 'AG1' ]) && ( isset ( $tabBilan [ 'AF' ]) || isset ( $tabBilan [ 'AG' ]))) $tabBilan [ 'AG1' ] = $tabBilan [ 'AF' ] - $tabBilan [ 'AG' ];
if ( ! isset ( $tabBilan [ 'AI1' ]) && ( isset ( $tabBilan [ 'AH' ]) || isset ( $tabBilan [ 'AI' ]))) $tabBilan [ 'AI1' ] = $tabBilan [ 'AH' ] - $tabBilan [ 'AI' ];
if ( ! isset ( $tabBilan [ 'AK1' ]) && ( isset ( $tabBilan [ 'AJ' ]) || isset ( $tabBilan [ 'AK' ]))) $tabBilan [ 'AK1' ] = $tabBilan [ 'AJ' ] - $tabBilan [ 'AK' ];
if ( ! isset ( $tabBilan [ 'AM1' ]) && ( isset ( $tabBilan [ 'AL' ]) || isset ( $tabBilan [ 'AM' ]))) $tabBilan [ 'AM1' ] = $tabBilan [ 'AL' ] - $tabBilan [ 'AM' ];
if ( ! isset ( $tabBilan [ 'AO1' ]) && ( isset ( $tabBilan [ 'AN' ]) || isset ( $tabBilan [ 'AO' ]))) $tabBilan [ 'AO1' ] = $tabBilan [ 'AN' ] - $tabBilan [ 'AO' ];
if ( ! isset ( $tabBilan [ 'AQ1' ]) && ( isset ( $tabBilan [ 'AP' ]) || isset ( $tabBilan [ 'AQ' ]))) $tabBilan [ 'AQ1' ] = $tabBilan [ 'AP' ] - $tabBilan [ 'AQ' ];
if ( ! isset ( $tabBilan [ 'AS1' ]) && ( isset ( $tabBilan [ 'AR' ]) || isset ( $tabBilan [ 'AS' ]))) $tabBilan [ 'AS1' ] = $tabBilan [ 'AR' ] - $tabBilan [ 'AS' ];
if ( ! isset ( $tabBilan [ 'AU1' ]) && ( isset ( $tabBilan [ 'AT' ]) || isset ( $tabBilan [ 'AU' ]))) $tabBilan [ 'AU1' ] = $tabBilan [ 'AT' ] - $tabBilan [ 'AU' ];
if ( ! isset ( $tabBilan [ 'AW1' ]) && ( isset ( $tabBilan [ 'AV' ]) || isset ( $tabBilan [ 'AW' ]))) $tabBilan [ 'AW1' ] = $tabBilan [ 'AV' ] - $tabBilan [ 'AW' ];
if ( ! isset ( $tabBilan [ 'AY1' ]) && ( isset ( $tabBilan [ 'AX' ]) || isset ( $tabBilan [ 'AY' ]))) $tabBilan [ 'AY1' ] = $tabBilan [ 'AX' ] - $tabBilan [ 'AY' ];
if ( ! isset ( $tabBilan [ 'CT1' ]) && ( isset ( $tabBilan [ 'CS' ]) || isset ( $tabBilan [ 'CT' ]))) $tabBilan [ 'CT1' ] = $tabBilan [ 'CS' ] - $tabBilan [ 'CT' ];
if ( ! isset ( $tabBilan [ 'CV1' ]) && ( isset ( $tabBilan [ 'CU' ]) || isset ( $tabBilan [ 'CV' ]))) $tabBilan [ 'CV1' ] = $tabBilan [ 'CU' ] - $tabBilan [ 'CV' ];
if ( ! isset ( $tabBilan [ 'BC1' ]) && ( isset ( $tabBilan [ 'BB' ]) || isset ( $tabBilan [ 'BC' ]))) $tabBilan [ 'BC1' ] = $tabBilan [ 'BB' ] - $tabBilan [ 'BC' ];
if ( ! isset ( $tabBilan [ 'BE1' ]) && ( isset ( $tabBilan [ 'BD' ]) || isset ( $tabBilan [ 'BE' ]))) $tabBilan [ 'BE1' ] = $tabBilan [ 'BD' ] - $tabBilan [ 'BE' ];
if ( ! isset ( $tabBilan [ 'BG1' ]) && ( isset ( $tabBilan [ 'BF' ]) || isset ( $tabBilan [ 'BG' ]))) $tabBilan [ 'BG1' ] = $tabBilan [ 'BF' ] - $tabBilan [ 'BG' ];
if ( ! isset ( $tabBilan [ 'BI1' ]) && ( isset ( $tabBilan [ 'BH' ]) || isset ( $tabBilan [ 'BI' ]))) $tabBilan [ 'BI1' ] = $tabBilan [ 'BH' ] - $tabBilan [ 'BI' ];
if ( ! isset ( $tabBilan [ 'BK1' ]) && ( isset ( $tabBilan [ 'BJ' ]) || isset ( $tabBilan [ 'BK' ]))) $tabBilan [ 'BK1' ] = $tabBilan [ 'BJ' ] - $tabBilan [ 'BK' ];
if ( ! isset ( $tabBilan [ 'BM1' ]) && ( isset ( $tabBilan [ 'BL' ]) || isset ( $tabBilan [ 'BM' ]))) $tabBilan [ 'BM1' ] = $tabBilan [ 'BL' ] - $tabBilan [ 'BM' ];
if ( ! isset ( $tabBilan [ 'BO1' ]) && ( isset ( $tabBilan [ 'BN' ]) || isset ( $tabBilan [ 'BO' ]))) $tabBilan [ 'BO1' ] = $tabBilan [ 'BN' ] - $tabBilan [ 'BO' ];
if ( ! isset ( $tabBilan [ 'BQ1' ]) && ( isset ( $tabBilan [ 'BP' ]) || isset ( $tabBilan [ 'BQ' ]))) $tabBilan [ 'BQ1' ] = $tabBilan [ 'BP' ] - $tabBilan [ 'BQ' ];
if ( ! isset ( $tabBilan [ 'BS1' ]) && ( isset ( $tabBilan [ 'BR' ]) || isset ( $tabBilan [ 'BS' ]))) $tabBilan [ 'BS1' ] = $tabBilan [ 'BR' ] - $tabBilan [ 'BS' ];
if ( ! isset ( $tabBilan [ 'BU1' ]) && ( isset ( $tabBilan [ 'BT' ]) || isset ( $tabBilan [ 'BU' ]))) $tabBilan [ 'BU1' ] = $tabBilan [ 'BT' ] - $tabBilan [ 'BU' ];
if ( ! isset ( $tabBilan [ 'BW1' ]) && ( isset ( $tabBilan [ 'BV' ]) || isset ( $tabBilan [ 'BW' ]))) $tabBilan [ 'BW1' ] = $tabBilan [ 'BV' ] - $tabBilan [ 'BW' ];
if ( ! isset ( $tabBilan [ 'BY1' ]) && ( isset ( $tabBilan [ 'BX' ]) || isset ( $tabBilan [ 'BY' ]))) $tabBilan [ 'BY1' ] = $tabBilan [ 'BX' ] - $tabBilan [ 'BY' ];
if ( ! isset ( $tabBilan [ 'CA1' ]) && ( isset ( $tabBilan [ 'BZ' ]) || isset ( $tabBilan [ 'CA' ]))) $tabBilan [ 'CA1' ] = $tabBilan [ 'BZ' ] - $tabBilan [ 'CA' ];
if ( ! isset ( $tabBilan [ 'CC1' ]) && ( isset ( $tabBilan [ 'CB' ]) || isset ( $tabBilan [ 'CC' ]))) $tabBilan [ 'CC1' ] = $tabBilan [ 'CB' ] - $tabBilan [ 'CC' ];
if ( ! isset ( $tabBilan [ 'CE1' ]) && ( isset ( $tabBilan [ 'CD' ]) || isset ( $tabBilan [ 'CE' ]))) $tabBilan [ 'CE1' ] = $tabBilan [ 'CD' ] - $tabBilan [ 'CE' ];
if ( ! isset ( $tabBilan [ 'CG1' ]) && ( isset ( $tabBilan [ 'CF' ]) || isset ( $tabBilan [ 'CG' ]))) $tabBilan [ 'CG1' ] = $tabBilan [ 'CF' ] - $tabBilan [ 'CG' ];
if ( ! isset ( $tabBilan [ 'CI1' ]) && ( isset ( $tabBilan [ 'CH' ]) || isset ( $tabBilan [ 'CI' ]))) $tabBilan [ 'CI1' ] = $tabBilan [ 'CH' ] - $tabBilan [ 'CI' ];
if ( ! isset ( $tabBilan [ 'CK1' ]) && ( isset ( $tabBilan [ 'CJ' ]) || isset ( $tabBilan [ 'CK' ]))) $tabBilan [ 'CK1' ] = $tabBilan [ 'CJ' ] - $tabBilan [ 'CK' ];
if ( ! isset ( $tabBilan [ 'CL2' ]) && isset ( $tabBilan [ 'CL' ])) $tabBilan [ 'CL2' ] = $tabBilan [ 'CL' ];
if ( ! isset ( $tabBilan [ 'CM2' ]) && isset ( $tabBilan [ 'CM' ])) $tabBilan [ 'CM2' ] = $tabBilan [ 'CM' ];
if ( ! isset ( $tabBilan [ 'CN2' ]) && isset ( $tabBilan [ 'CN' ])) $tabBilan [ 'CN2' ] = $tabBilan [ 'CN' ];
if ( ! isset ( $tabBilan [ '1A1' ]) && ( isset ( $tabBilan [ 'CO' ]) || isset ( $tabBilan [ '1A' ]))) $tabBilan [ '1A1' ] = $tabBilan [ 'CO' ] - $tabBilan [ '1A' ];
2014-03-19 13:10:31 +00:00
}
elseif ( $tabBilan [ 'CONSOLIDE' ] == 'S' )
{
2014-10-20 13:14:32 +00:00
//if (!isset($tabBilan['AC1']) && (isset($tabBilan['AB'])||isset($tabBilan['AC']))) $tabBilan['AC1']=$tabBilan['AB']-$tabBilan['AC'];
if ( ! isset ( $tabBilan [ '013' ]) && ( isset ( $tabBilan [ '010' ]) || isset ( $tabBilan [ '012' ]))) $tabBilan [ '013' ] = $tabBilan [ '010' ] - $tabBilan [ '012' ];
if ( ! isset ( $tabBilan [ '017' ]) && ( isset ( $tabBilan [ '014' ]) || isset ( $tabBilan [ '016' ]))) $tabBilan [ '017' ] = $tabBilan [ '014' ] - $tabBilan [ '016' ];
if ( ! isset ( $tabBilan [ '031' ]) && ( isset ( $tabBilan [ '028' ]) || isset ( $tabBilan [ '030' ]))) $tabBilan [ '031' ] = $tabBilan [ '028' ] - $tabBilan [ '030' ];
if ( ! isset ( $tabBilan [ '043' ]) && ( isset ( $tabBilan [ '040' ]) || isset ( $tabBilan [ '042' ]))) $tabBilan [ '043' ] = $tabBilan [ '040' ] - $tabBilan [ '042' ];
if ( ! isset ( $tabBilan [ '049' ]) && ( isset ( $tabBilan [ '044' ]) || isset ( $tabBilan [ '048' ]))) $tabBilan [ '049' ] = $tabBilan [ '044' ] - $tabBilan [ '048' ];
if ( ! isset ( $tabBilan [ '053' ]) && ( isset ( $tabBilan [ '050' ]) || isset ( $tabBilan [ '052' ]))) $tabBilan [ '053' ] = $tabBilan [ '050' ] - $tabBilan [ '052' ];
if ( ! isset ( $tabBilan [ '063' ]) && ( isset ( $tabBilan [ '060' ]) || isset ( $tabBilan [ '062' ]))) $tabBilan [ '063' ] = $tabBilan [ '060' ] - $tabBilan [ '062' ];
if ( ! isset ( $tabBilan [ '067' ]) && ( isset ( $tabBilan [ '064' ]) || isset ( $tabBilan [ '066' ]))) $tabBilan [ '067' ] = $tabBilan [ '064' ] - $tabBilan [ '066' ];
if ( ! isset ( $tabBilan [ '071' ]) && ( isset ( $tabBilan [ '068' ]) || isset ( $tabBilan [ '070' ]))) $tabBilan [ '071' ] = $tabBilan [ '068' ] - $tabBilan [ '070' ];
if ( ! isset ( $tabBilan [ '075' ]) && ( isset ( $tabBilan [ '072' ]) || isset ( $tabBilan [ '074' ]))) $tabBilan [ '075' ] = $tabBilan [ '072' ] - $tabBilan [ '074' ];
if ( ! isset ( $tabBilan [ '083' ]) && ( isset ( $tabBilan [ '080' ]) || isset ( $tabBilan [ '082' ]))) $tabBilan [ '083' ] = $tabBilan [ '080' ] - $tabBilan [ '082' ];
if ( ! isset ( $tabBilan [ '087' ]) && ( isset ( $tabBilan [ '084' ]) || isset ( $tabBilan [ '086' ]))) $tabBilan [ '087' ] = $tabBilan [ '084' ] - $tabBilan [ '086' ];
if ( ! isset ( $tabBilan [ '091' ]) && ( isset ( $tabBilan [ '088' ]) || isset ( $tabBilan [ '090' ]))) $tabBilan [ '091' ] = $tabBilan [ '088' ] - $tabBilan [ '090' ];
if ( ! isset ( $tabBilan [ '095' ]) && ( isset ( $tabBilan [ '092' ]) || isset ( $tabBilan [ '094' ]))) $tabBilan [ '095' ] = $tabBilan [ '092' ] - $tabBilan [ '094' ];
if ( ! isset ( $tabBilan [ '099' ]) && ( isset ( $tabBilan [ '096' ]) || isset ( $tabBilan [ '098' ]))) $tabBilan [ '099' ] = $tabBilan [ '096' ] - $tabBilan [ '098' ];
if ( ! isset ( $tabBilan [ '113' ]) && ( isset ( $tabBilan [ '110' ]) || isset ( $tabBilan [ '112' ]))) $tabBilan [ '113' ] = $tabBilan [ '110' ] - $tabBilan [ '112' ];
2014-03-19 13:10:31 +00:00
}
2014-10-20 13:14:32 +00:00
/** Y a t'il suffisament d'informations sur le bilan précédent **/
if ( $bilan [ 'dateExercicePre' ] * 1 == 0 || $bilan [ 'dureeExercicePre' ] * 1 == 0
|| ( ( $tabBilan [ 'FL1' ] * 1 == 0 || $tabBilan [ 'EE1' ] * 1 == 0 ) && ( $tabBilan [ 'CONSOLIDE' ] == 'N' || $tabBilan [ 'CONSOLIDE' ] == 'C' ) ) // Réel Normal ou Consolidé
|| ( ( $tabBilan [ 'NA3' ] * 1 == 0 || $tabBilan [ 'NP3' ] * 1 == 0 ) && ( $tabBilan [ 'CONSOLIDE' ] == 'A' || $tabBilan [ 'CONSOLIDE' ] == 'B' ) ) // Banque ou Assurance
|| ( ( $tabBilan [ 'N15' ] * 1 == 0 || $tabBilan [ 'N32' ] * 1 == 0 ) && $tabBilan [ 'CONSOLIDE' ] == 'S' ) // Réel Simplifié
) {
/** Il n'y a aucune information sur le bilan précédent **/
$ret = $this -> iDb -> select ( 'bilans' , 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes' , " siren=' $this->siren ' AND typeBilan=' $typeBilan ' AND dateExercice<' $millesimeDB ' ORDER BY dateExercice DESC LIMIT 0,1 " , true );
$bilanPre = $ret [ 0 ];
$tabBilan [ 'DATE_CLOTURE_PRE' ] = $bilanPre [ 'dateExercice' ]; // SSAAMMJJ
$tabBilan [ 'DUREE_MOIS_PRE' ] = $bilanPre [ 'dureeExercice' ];
if ( $bilanPre [ 'monnaie' ] == 'EUR' ) {
$monnaiePre = '€' ;
} else {
$monnaiePre = $bilanPre [ 'monnaie' ];
}
switch ( strtoupper ( $bilanPre [ 'unite' ])) {
case 'K' : $unitePre = 'K' ; break ;
case 'U' :
case ' ' :
case '' : $unitePre = '' ; break ;
case 'M' : $unitePre = 'M' ; break ;
default : die ( 'Unite Bilan (' . $bilanPre [ 'unite' ] . ') non prise en charge !' ); break ;
}
$tabBilanPre [ 'devise' ] = $monnaiePre ;
$tabTmp = explode ( ';' , $bilanPre [ 'postes' ]);
foreach ( $tabTmp as $i => $strTmp ) {
$tabTmp2 = explode ( '=' , $strTmp );
if ( isset ( $tabTmp2 [ 1 ])) {
if ( ( $unite == 'K' || $unite == 'M' ) && ! in_array ( $tabTmp2 [ 0 ], array (
'YP' , 'YP1' , '376' , // Effectifs 2033 et 2050
'M2G' , 'M2H' , // Autres effectifs
'ZK' , 'ZK1' , // Taux
'IJ' , 'JG' , 'JH' , 'JJ' , 'ZR' , // pour holding/ste mere
'XP' // Numero de centre de gestion agréé
) ) ) {
if ( $unite == 'K' ) {
$tabBilanPre [ $tabTmp2 [ 0 ]] = $tabTmp2 [ 1 ] * 1000 ;
} else if ( $unite == 'M' ) {
$tabBilanPre [ $tabTmp2 [ 0 ]] = $tabTmp2 [ 1 ] * 1000000 ;
}
} else {
$tabBilanPre [ $tabTmp2 [ 0 ]] = $tabTmp2 [ 1 ];
}
}
}
/** Calcul des valeures NET N-1 si l'information est absente du bilan N-1 en base **/
if ( $tabBilan [ 'CONSOLIDE' ] == 'N' || $tabBilan [ 'CONSOLIDE' ] == 'C' )
{
if ( ! isset ( $tabBilanPre [ 'AA2' ]) && isset ( $tabBilanPre [ 'AA' ])) $tabBilanPre [ 'AA2' ] = $tabBilanPre [ 'AA' ];
if ( ! isset ( $tabBilanPre [ 'AC1' ]) && ( isset ( $tabBilanPre [ 'AB' ]) || isset ( $tabBilanPre [ 'AC' ]))) $tabBilanPre [ 'AC1' ] = $tabBilanPre [ 'AB' ] - $tabBilanPre [ 'AC' ];
if ( ! isset ( $tabBilanPre [ 'AE1' ]) && ( isset ( $tabBilanPre [ 'AD' ]) || isset ( $tabBilanPre [ 'AE' ]))) $tabBilanPre [ 'AE1' ] = $tabBilanPre [ 'AD' ] - $tabBilanPre [ 'AE' ];
if ( ! isset ( $tabBilanPre [ 'AG1' ]) && ( isset ( $tabBilanPre [ 'AF' ]) || isset ( $tabBilanPre [ 'AG' ]))) $tabBilanPre [ 'AG1' ] = $tabBilanPre [ 'AF' ] - $tabBilanPre [ 'AG' ];
if ( ! isset ( $tabBilanPre [ 'AI1' ]) && ( isset ( $tabBilanPre [ 'AH' ]) || isset ( $tabBilanPre [ 'AI' ]))) $tabBilanPre [ 'AI1' ] = $tabBilanPre [ 'AH' ] - $tabBilanPre [ 'AI' ];
if ( ! isset ( $tabBilanPre [ 'AK1' ]) && ( isset ( $tabBilanPre [ 'AJ' ]) || isset ( $tabBilanPre [ 'AK' ]))) $tabBilanPre [ 'AK1' ] = $tabBilanPre [ 'AJ' ] - $tabBilanPre [ 'AK' ];
if ( ! isset ( $tabBilanPre [ 'AM1' ]) && ( isset ( $tabBilanPre [ 'AL' ]) || isset ( $tabBilanPre [ 'AM' ]))) $tabBilanPre [ 'AM1' ] = $tabBilanPre [ 'AL' ] - $tabBilanPre [ 'AM' ];
if ( ! isset ( $tabBilanPre [ 'AO1' ]) && ( isset ( $tabBilanPre [ 'AN' ]) || isset ( $tabBilanPre [ 'AO' ]))) $tabBilanPre [ 'AO1' ] = $tabBilanPre [ 'AN' ] - $tabBilanPre [ 'AO' ];
if ( ! isset ( $tabBilanPre [ 'AQ1' ]) && ( isset ( $tabBilanPre [ 'AP' ]) || isset ( $tabBilanPre [ 'AQ' ]))) $tabBilanPre [ 'AQ1' ] = $tabBilanPre [ 'AP' ] - $tabBilanPre [ 'AQ' ];
if ( ! isset ( $tabBilanPre [ 'AS1' ]) && ( isset ( $tabBilanPre [ 'AR' ]) || isset ( $tabBilanPre [ 'AS' ]))) $tabBilanPre [ 'AS1' ] = $tabBilanPre [ 'AR' ] - $tabBilanPre [ 'AS' ];
if ( ! isset ( $tabBilanPre [ 'AU1' ]) && ( isset ( $tabBilanPre [ 'AT' ]) || isset ( $tabBilanPre [ 'AU' ]))) $tabBilanPre [ 'AU1' ] = $tabBilanPre [ 'AT' ] - $tabBilanPre [ 'AU' ];
if ( ! isset ( $tabBilanPre [ 'AW1' ]) && ( isset ( $tabBilanPre [ 'AV' ]) || isset ( $tabBilanPre [ 'AW' ]))) $tabBilanPre [ 'AW1' ] = $tabBilanPre [ 'AV' ] - $tabBilanPre [ 'AW' ];
if ( ! isset ( $tabBilanPre [ 'AY1' ]) && ( isset ( $tabBilanPre [ 'AX' ]) || isset ( $tabBilanPre [ 'AY' ]))) $tabBilanPre [ 'AY1' ] = $tabBilanPre [ 'AX' ] - $tabBilanPre [ 'AY' ];
if ( ! isset ( $tabBilanPre [ 'CT1' ]) && ( isset ( $tabBilanPre [ 'CS' ]) || isset ( $tabBilanPre [ 'CT' ]))) $tabBilanPre [ 'CT1' ] = $tabBilanPre [ 'CS' ] - $tabBilanPre [ 'CT' ];
if ( ! isset ( $tabBilanPre [ 'CV1' ]) && ( isset ( $tabBilanPre [ 'CU' ]) || isset ( $tabBilanPre [ 'CV' ]))) $tabBilanPre [ 'CV1' ] = $tabBilanPre [ 'CU' ] - $tabBilanPre [ 'CV' ];
if ( ! isset ( $tabBilanPre [ 'BC1' ]) && ( isset ( $tabBilanPre [ 'BB' ]) || isset ( $tabBilanPre [ 'BC' ]))) $tabBilanPre [ 'BC1' ] = $tabBilanPre [ 'BB' ] - $tabBilanPre [ 'BC' ];
if ( ! isset ( $tabBilanPre [ 'BE1' ]) && ( isset ( $tabBilanPre [ 'BD' ]) || isset ( $tabBilanPre [ 'BE' ]))) $tabBilanPre [ 'BE1' ] = $tabBilanPre [ 'BD' ] - $tabBilanPre [ 'BE' ];
if ( ! isset ( $tabBilanPre [ 'BG1' ]) && ( isset ( $tabBilanPre [ 'BF' ]) || isset ( $tabBilanPre [ 'BG' ]))) $tabBilanPre [ 'BG1' ] = $tabBilanPre [ 'BF' ] - $tabBilanPre [ 'BG' ];
if ( ! isset ( $tabBilanPre [ 'BI1' ]) && ( isset ( $tabBilanPre [ 'BH' ]) || isset ( $tabBilanPre [ 'BI' ]))) $tabBilanPre [ 'BI1' ] = $tabBilanPre [ 'BH' ] - $tabBilanPre [ 'BI' ];
if ( ! isset ( $tabBilanPre [ 'BK1' ]) && ( isset ( $tabBilanPre [ 'BJ' ]) || isset ( $tabBilanPre [ 'BK' ]))) $tabBilanPre [ 'BK1' ] = $tabBilanPre [ 'BJ' ] - $tabBilanPre [ 'BK' ];
if ( ! isset ( $tabBilanPre [ 'BM1' ]) && ( isset ( $tabBilanPre [ 'BL' ]) || isset ( $tabBilanPre [ 'BM' ]))) $tabBilanPre [ 'BM1' ] = $tabBilanPre [ 'BL' ] - $tabBilanPre [ 'BM' ];
if ( ! isset ( $tabBilanPre [ 'BO1' ]) && ( isset ( $tabBilanPre [ 'BN' ]) || isset ( $tabBilanPre [ 'BO' ]))) $tabBilanPre [ 'BO1' ] = $tabBilanPre [ 'BN' ] - $tabBilanPre [ 'BO' ];
if ( ! isset ( $tabBilanPre [ 'BQ1' ]) && ( isset ( $tabBilanPre [ 'BP' ]) || isset ( $tabBilanPre [ 'BQ' ]))) $tabBilanPre [ 'BQ1' ] = $tabBilanPre [ 'BP' ] - $tabBilanPre [ 'BQ' ];
if ( ! isset ( $tabBilanPre [ 'BS1' ]) && ( isset ( $tabBilanPre [ 'BR' ]) || isset ( $tabBilanPre [ 'BS' ]))) $tabBilanPre [ 'BS1' ] = $tabBilanPre [ 'BR' ] - $tabBilanPre [ 'BS' ];
if ( ! isset ( $tabBilanPre [ 'BU1' ]) && ( isset ( $tabBilanPre [ 'BT' ]) || isset ( $tabBilanPre [ 'BU' ]))) $tabBilanPre [ 'BU1' ] = $tabBilanPre [ 'BT' ] - $tabBilanPre [ 'BU' ];
if ( ! isset ( $tabBilanPre [ 'BW1' ]) && ( isset ( $tabBilanPre [ 'BV' ]) || isset ( $tabBilanPre [ 'BW' ]))) $tabBilanPre [ 'BW1' ] = $tabBilanPre [ 'BV' ] - $tabBilanPre [ 'BW' ];
if ( ! isset ( $tabBilanPre [ 'BY1' ]) && ( isset ( $tabBilanPre [ 'BX' ]) || isset ( $tabBilanPre [ 'BY' ]))) $tabBilanPre [ 'BY1' ] = $tabBilanPre [ 'BX' ] - $tabBilanPre [ 'BY' ];
if ( ! isset ( $tabBilanPre [ 'CA1' ]) && ( isset ( $tabBilanPre [ 'BZ' ]) || isset ( $tabBilanPre [ 'CA' ]))) $tabBilanPre [ 'CA1' ] = $tabBilanPre [ 'BZ' ] - $tabBilanPre [ 'CA' ];
if ( ! isset ( $tabBilanPre [ 'CC1' ]) && ( isset ( $tabBilanPre [ 'CB' ]) || isset ( $tabBilanPre [ 'CC' ]))) $tabBilanPre [ 'CC1' ] = $tabBilanPre [ 'CB' ] - $tabBilanPre [ 'CC' ];
if ( ! isset ( $tabBilanPre [ 'CE1' ]) && ( isset ( $tabBilanPre [ 'CD' ]) || isset ( $tabBilanPre [ 'CE' ]))) $tabBilanPre [ 'CE1' ] = $tabBilanPre [ 'CD' ] - $tabBilanPre [ 'CE' ];
if ( ! isset ( $tabBilanPre [ 'CG1' ]) && ( isset ( $tabBilanPre [ 'CF' ]) || isset ( $tabBilanPre [ 'CG' ]))) $tabBilanPre [ 'CG1' ] = $tabBilanPre [ 'CF' ] - $tabBilanPre [ 'CG' ];
if ( ! isset ( $tabBilanPre [ 'CI1' ]) && ( isset ( $tabBilanPre [ 'CH' ]) || isset ( $tabBilanPre [ 'CI' ]))) $tabBilanPre [ 'CI1' ] = $tabBilanPre [ 'CH' ] - $tabBilanPre [ 'CI' ];
if ( ! isset ( $tabBilanPre [ 'CK1' ]) && ( isset ( $tabBilanPre [ 'CJ' ]) || isset ( $tabBilanPre [ 'CK' ]))) $tabBilanPre [ 'CK1' ] = $tabBilanPre [ 'CJ' ] - $tabBilanPre [ 'CK' ];
if ( ! isset ( $tabBilanPre [ 'CL2' ]) && isset ( $tabBilanPre [ 'CL' ])) $tabBilanPre [ 'CL2' ] = $tabBilanPre [ 'CL' ];
if ( ! isset ( $tabBilanPre [ 'CM2' ]) && isset ( $tabBilanPre [ 'CM' ])) $tabBilanPre [ 'CM2' ] = $tabBilanPre [ 'CM' ];
if ( ! isset ( $tabBilanPre [ 'CN2' ]) && isset ( $tabBilanPre [ 'CN' ])) $tabBilanPre [ 'CN2' ] = $tabBilanPre [ 'CN' ];
if ( ! isset ( $tabBilanPre [ '1A1' ]) && ( isset ( $tabBilanPre [ 'CO' ]) || isset ( $tabBilanPre [ '1A' ]))) $tabBilanPre [ '1A1' ] = $tabBilanPre [ 'CO' ] - $tabBilanPre [ '1A' ];
/** Reprises des valeures N-1 si l'information est absente en base **/
// Actif
if ( ! isset ( $tabBilan [ 'AA3' ]) && isset ( $tabBilanPre [ 'AA2' ])) $tabBilan [ 'AA3' ] = $tabBilanPre [ 'AA2' ];
if ( ! isset ( $tabBilan [ 'AC2' ]) && isset ( $tabBilanPre [ 'AC1' ])) $tabBilan [ 'AC2' ] = $tabBilanPre [ 'AC1' ];
if ( ! isset ( $tabBilan [ 'AE2' ]) && isset ( $tabBilanPre [ 'AE1' ])) $tabBilan [ 'AE2' ] = $tabBilanPre [ 'AE1' ];
if ( ! isset ( $tabBilan [ 'AG2' ]) && isset ( $tabBilanPre [ 'AG1' ])) $tabBilan [ 'AG2' ] = $tabBilanPre [ 'AG1' ];
if ( ! isset ( $tabBilan [ 'AI2' ]) && isset ( $tabBilanPre [ 'AI1' ])) $tabBilan [ 'AI2' ] = $tabBilanPre [ 'AI1' ];
if ( ! isset ( $tabBilan [ 'AK2' ]) && isset ( $tabBilanPre [ 'AK1' ])) $tabBilan [ 'AK2' ] = $tabBilanPre [ 'AK1' ];
if ( ! isset ( $tabBilan [ 'AM2' ]) && isset ( $tabBilanPre [ 'AM1' ])) $tabBilan [ 'AM2' ] = $tabBilanPre [ 'AM1' ];
if ( ! isset ( $tabBilan [ 'AO2' ]) && isset ( $tabBilanPre [ 'AO1' ])) $tabBilan [ 'AO2' ] = $tabBilanPre [ 'AO1' ];
if ( ! isset ( $tabBilan [ 'AQ2' ]) && isset ( $tabBilanPre [ 'AQ1' ])) $tabBilan [ 'AQ2' ] = $tabBilanPre [ 'AQ1' ];
if ( ! isset ( $tabBilan [ 'AS2' ]) && isset ( $tabBilanPre [ 'AS1' ])) $tabBilan [ 'AS2' ] = $tabBilanPre [ 'AS1' ];
if ( ! isset ( $tabBilan [ 'AU2' ]) && isset ( $tabBilanPre [ 'AU1' ])) $tabBilan [ 'AU2' ] = $tabBilanPre [ 'AU1' ];
if ( ! isset ( $tabBilan [ 'AW2' ]) && isset ( $tabBilanPre [ 'AW1' ])) $tabBilan [ 'AW2' ] = $tabBilanPre [ 'AW1' ];
if ( ! isset ( $tabBilan [ 'AY2' ]) && isset ( $tabBilanPre [ 'AY1' ])) $tabBilan [ 'AY2' ] = $tabBilanPre [ 'AY1' ];
if ( ! isset ( $tabBilan [ 'CT2' ]) && isset ( $tabBilanPre [ 'CT1' ])) $tabBilan [ 'CT2' ] = $tabBilanPre [ 'CT1' ];
if ( ! isset ( $tabBilan [ 'CV2' ]) && isset ( $tabBilanPre [ 'CV1' ])) $tabBilan [ 'CV2' ] = $tabBilanPre [ 'CV1' ];
if ( ! isset ( $tabBilan [ 'BC2' ]) && isset ( $tabBilanPre [ 'BC1' ])) $tabBilan [ 'BC2' ] = $tabBilanPre [ 'BC1' ];
if ( ! isset ( $tabBilan [ 'BE2' ]) && isset ( $tabBilanPre [ 'BE1' ])) $tabBilan [ 'BE2' ] = $tabBilanPre [ 'BE1' ];
if ( ! isset ( $tabBilan [ 'BG2' ]) && isset ( $tabBilanPre [ 'BG1' ])) $tabBilan [ 'BG2' ] = $tabBilanPre [ 'BG1' ];
if ( ! isset ( $tabBilan [ 'BI2' ]) && isset ( $tabBilanPre [ 'BI1' ])) $tabBilan [ 'BI2' ] = $tabBilanPre [ 'BI1' ];
if ( ! isset ( $tabBilan [ 'BK2' ]) && isset ( $tabBilanPre [ 'BK1' ])) $tabBilan [ 'BK2' ] = $tabBilanPre [ 'BK1' ];
if ( ! isset ( $tabBilan [ 'BM2' ]) && isset ( $tabBilanPre [ 'BM1' ])) $tabBilan [ 'BM2' ] = $tabBilanPre [ 'BM1' ];
if ( ! isset ( $tabBilan [ 'BO2' ]) && isset ( $tabBilanPre [ 'BO1' ])) $tabBilan [ 'BO2' ] = $tabBilanPre [ 'BO1' ];
if ( ! isset ( $tabBilan [ 'BQ2' ]) && isset ( $tabBilanPre [ 'BQ1' ])) $tabBilan [ 'BQ2' ] = $tabBilanPre [ 'BQ1' ];
if ( ! isset ( $tabBilan [ 'BS2' ]) && isset ( $tabBilanPre [ 'BS1' ])) $tabBilan [ 'BS2' ] = $tabBilanPre [ 'BS1' ];
if ( ! isset ( $tabBilan [ 'BU2' ]) && isset ( $tabBilanPre [ 'BU1' ])) $tabBilan [ 'BU2' ] = $tabBilanPre [ 'BU1' ];
if ( ! isset ( $tabBilan [ 'BW2' ]) && isset ( $tabBilanPre [ 'BW1' ])) $tabBilan [ 'BW2' ] = $tabBilanPre [ 'BW1' ];
if ( ! isset ( $tabBilan [ 'BY2' ]) && isset ( $tabBilanPre [ 'BY1' ])) $tabBilan [ 'BY2' ] = $tabBilanPre [ 'BY1' ];
if ( ! isset ( $tabBilan [ 'CA2' ]) && isset ( $tabBilanPre [ 'CA1' ])) $tabBilan [ 'CA2' ] = $tabBilanPre [ 'CA1' ];
if ( ! isset ( $tabBilan [ 'CC2' ]) && isset ( $tabBilanPre [ 'CC1' ])) $tabBilan [ 'CC2' ] = $tabBilanPre [ 'CC1' ];
if ( ! isset ( $tabBilan [ 'CE2' ]) && isset ( $tabBilanPre [ 'CE1' ])) $tabBilan [ 'CE2' ] = $tabBilanPre [ 'CE1' ];
if ( ! isset ( $tabBilan [ 'CG2' ]) && isset ( $tabBilanPre [ 'CG1' ])) $tabBilan [ 'CG2' ] = $tabBilanPre [ 'CG1' ];
if ( ! isset ( $tabBilan [ 'CI2' ]) && isset ( $tabBilanPre [ 'CI1' ])) $tabBilan [ 'CI2' ] = $tabBilanPre [ 'CI1' ];
if ( ! isset ( $tabBilan [ 'CK2' ]) && isset ( $tabBilanPre [ 'CK1' ])) $tabBilan [ 'CK2' ] = $tabBilanPre [ 'CK1' ];
if ( ! isset ( $tabBilan [ 'CL3' ]) && isset ( $tabBilanPre [ 'CL2' ])) $tabBilan [ 'CL3' ] = $tabBilanPre [ 'CL2' ];
if ( ! isset ( $tabBilan [ 'CM3' ]) && isset ( $tabBilanPre [ 'CM2' ])) $tabBilan [ 'CM3' ] = $tabBilanPre [ 'CM2' ];
if ( ! isset ( $tabBilan [ 'CN3' ]) && isset ( $tabBilanPre [ 'CN2' ])) $tabBilan [ 'CN3' ] = $tabBilanPre [ 'CN2' ];
if ( ! isset ( $tabBilan [ '1A2' ]) && isset ( $tabBilanPre [ '1A1' ])) $tabBilan [ '1A2' ] = $tabBilanPre [ '1A1' ];
// Passif
if ( ! isset ( $tabBilan [ 'DA1' ]) && isset ( $tabBilanPre [ 'DA' ])) $tabBilan [ 'DA1' ] = $tabBilanPre [ 'DA' ];
if ( ! isset ( $tabBilan [ 'DB1' ]) && isset ( $tabBilanPre [ 'DB' ])) $tabBilan [ 'DB1' ] = $tabBilanPre [ 'DB' ];
if ( ! isset ( $tabBilan [ 'DC1' ]) && isset ( $tabBilanPre [ 'DC' ])) $tabBilan [ 'DC1' ] = $tabBilanPre [ 'DC' ];
if ( ! isset ( $tabBilan [ 'DD1' ]) && isset ( $tabBilanPre [ 'DD' ])) $tabBilan [ 'DD1' ] = $tabBilanPre [ 'DD' ];
if ( ! isset ( $tabBilan [ 'DE1' ]) && isset ( $tabBilanPre [ 'DE' ])) $tabBilan [ 'DE1' ] = $tabBilanPre [ 'DE' ];
if ( ! isset ( $tabBilan [ 'DF1' ]) && isset ( $tabBilanPre [ 'DF' ])) $tabBilan [ 'DF1' ] = $tabBilanPre [ 'DF' ];
if ( ! isset ( $tabBilan [ 'DG1' ]) && isset ( $tabBilanPre [ 'DG' ])) $tabBilan [ 'DG1' ] = $tabBilanPre [ 'DG' ];
if ( ! isset ( $tabBilan [ 'DH1' ]) && isset ( $tabBilanPre [ 'DH' ])) $tabBilan [ 'DH1' ] = $tabBilanPre [ 'DH' ];
if ( ! isset ( $tabBilan [ 'DI1' ]) && isset ( $tabBilanPre [ 'DI' ])) $tabBilan [ 'DI1' ] = $tabBilanPre [ 'DI' ];
if ( ! isset ( $tabBilan [ 'DJ1' ]) && isset ( $tabBilanPre [ 'DJ' ])) $tabBilan [ 'DJ1' ] = $tabBilanPre [ 'DJ' ];
if ( ! isset ( $tabBilan [ 'DK1' ]) && isset ( $tabBilanPre [ 'DK' ])) $tabBilan [ 'DK1' ] = $tabBilanPre [ 'DK' ];
if ( ! isset ( $tabBilan [ 'DL1' ]) && isset ( $tabBilanPre [ 'DL' ])) $tabBilan [ 'DL1' ] = $tabBilanPre [ 'DL' ];
if ( ! isset ( $tabBilan [ 'DM1' ]) && isset ( $tabBilanPre [ 'DM' ])) $tabBilan [ 'DM1' ] = $tabBilanPre [ 'DM' ];
if ( ! isset ( $tabBilan [ 'DN1' ]) && isset ( $tabBilanPre [ 'DN' ])) $tabBilan [ 'DN1' ] = $tabBilanPre [ 'DN' ];
if ( ! isset ( $tabBilan [ 'DO1' ]) && isset ( $tabBilanPre [ 'DO' ])) $tabBilan [ 'DO1' ] = $tabBilanPre [ 'DO' ];
if ( ! isset ( $tabBilan [ 'DP1' ]) && isset ( $tabBilanPre [ 'DP' ])) $tabBilan [ 'DP1' ] = $tabBilanPre [ 'DP' ];
if ( ! isset ( $tabBilan [ 'DQ1' ]) && isset ( $tabBilanPre [ 'DQ' ])) $tabBilan [ 'DQ1' ] = $tabBilanPre [ 'DQ' ];
if ( ! isset ( $tabBilan [ 'DR1' ]) && isset ( $tabBilanPre [ 'DR' ])) $tabBilan [ 'DR1' ] = $tabBilanPre [ 'DR' ];
if ( ! isset ( $tabBilan [ 'DS1' ]) && isset ( $tabBilanPre [ 'DS' ])) $tabBilan [ 'DS1' ] = $tabBilanPre [ 'DS' ];
if ( ! isset ( $tabBilan [ 'DT1' ]) && isset ( $tabBilanPre [ 'DT' ])) $tabBilan [ 'DT1' ] = $tabBilanPre [ 'DT' ];
if ( ! isset ( $tabBilan [ 'DU1' ]) && isset ( $tabBilanPre [ 'DU' ])) $tabBilan [ 'DU1' ] = $tabBilanPre [ 'DU' ];
if ( ! isset ( $tabBilan [ 'DV1' ]) && isset ( $tabBilanPre [ 'DV' ])) $tabBilan [ 'DV1' ] = $tabBilanPre [ 'DV' ];
if ( ! isset ( $tabBilan [ 'DW1' ]) && isset ( $tabBilanPre [ 'DW' ])) $tabBilan [ 'DW1' ] = $tabBilanPre [ 'DW' ];
if ( ! isset ( $tabBilan [ 'DX1' ]) && isset ( $tabBilanPre [ 'DX' ])) $tabBilan [ 'DX1' ] = $tabBilanPre [ 'DX' ];
if ( ! isset ( $tabBilan [ 'DY1' ]) && isset ( $tabBilanPre [ 'DY' ])) $tabBilan [ 'DY1' ] = $tabBilanPre [ 'DY' ];
if ( ! isset ( $tabBilan [ 'DZ1' ]) && isset ( $tabBilanPre [ 'DZ' ])) $tabBilan [ 'DZ1' ] = $tabBilanPre [ 'DZ' ];
if ( ! isset ( $tabBilan [ 'EA1' ]) && isset ( $tabBilanPre [ 'EA' ])) $tabBilan [ 'EA1' ] = $tabBilanPre [ 'EA' ];
if ( ! isset ( $tabBilan [ 'EB1' ]) && isset ( $tabBilanPre [ 'EB' ])) $tabBilan [ 'EB1' ] = $tabBilanPre [ 'EB' ];
if ( ! isset ( $tabBilan [ 'EC1' ]) && isset ( $tabBilanPre [ 'EC' ])) $tabBilan [ 'EC1' ] = $tabBilanPre [ 'EC' ];
if ( ! isset ( $tabBilan [ 'ED1' ]) && isset ( $tabBilanPre [ 'ED' ])) $tabBilan [ 'ED1' ] = $tabBilanPre [ 'ED' ];
if ( ! isset ( $tabBilan [ 'EE1' ]) && isset ( $tabBilanPre [ 'EE' ])) $tabBilan [ 'EE1' ] = $tabBilanPre [ 'EE' ];
if ( ! isset ( $tabBilan [ '1B1' ]) && isset ( $tabBilanPre [ '1B' ])) $tabBilan [ '1B1' ] = $tabBilanPre [ '1B' ];
if ( ! isset ( $tabBilan [ '1C1' ]) && isset ( $tabBilanPre [ '1C' ])) $tabBilan [ '1C1' ] = $tabBilanPre [ '1C' ];
if ( ! isset ( $tabBilan [ '1D1' ]) && isset ( $tabBilanPre [ '1D' ])) $tabBilan [ '1D1' ] = $tabBilanPre [ '1D' ];
if ( ! isset ( $tabBilan [ '1E1' ]) && isset ( $tabBilanPre [ '1E' ])) $tabBilan [ '1E1' ] = $tabBilanPre [ '1E' ];
if ( ! isset ( $tabBilan [ 'EF1' ]) && isset ( $tabBilanPre [ 'EF' ])) $tabBilan [ 'EF1' ] = $tabBilanPre [ 'EF' ];
if ( ! isset ( $tabBilan [ 'EG1' ]) && isset ( $tabBilanPre [ 'EG' ])) $tabBilan [ 'EG1' ] = $tabBilanPre [ 'EG' ];
if ( ! isset ( $tabBilan [ 'EH1' ]) && isset ( $tabBilanPre [ 'EH' ])) $tabBilan [ 'EH1' ] = $tabBilanPre [ 'EH' ];
// Compte de Résultats
if ( ! isset ( $tabBilan [ 'FC1' ]) && isset ( $tabBilanPre [ 'FC' ])) $tabBilan [ 'FC1' ] = $tabBilanPre [ 'FC' ];
if ( ! isset ( $tabBilan [ 'FF1' ]) && isset ( $tabBilanPre [ 'FF' ])) $tabBilan [ 'FF1' ] = $tabBilanPre [ 'FF' ];
if ( ! isset ( $tabBilan [ 'FI1' ]) && isset ( $tabBilanPre [ 'FI' ])) $tabBilan [ 'FI1' ] = $tabBilanPre [ 'FI' ];
if ( ! isset ( $tabBilan [ 'FL1' ]) && isset ( $tabBilanPre [ 'FL' ])) $tabBilan [ 'FL1' ] = $tabBilanPre [ 'FL' ];
if ( ! isset ( $tabBilan [ 'FM1' ]) && isset ( $tabBilanPre [ 'FM' ])) $tabBilan [ 'FM1' ] = $tabBilanPre [ 'FM' ];
if ( ! isset ( $tabBilan [ 'FN1' ]) && isset ( $tabBilanPre [ 'FN' ])) $tabBilan [ 'FN1' ] = $tabBilanPre [ 'FN' ];
if ( ! isset ( $tabBilan [ 'FO1' ]) && isset ( $tabBilanPre [ 'FO' ])) $tabBilan [ 'FO1' ] = $tabBilanPre [ 'FO' ];
if ( ! isset ( $tabBilan [ 'FP1' ]) && isset ( $tabBilanPre [ 'FP' ])) $tabBilan [ 'FP1' ] = $tabBilanPre [ 'FP' ];
if ( ! isset ( $tabBilan [ 'FQ1' ]) && isset ( $tabBilanPre [ 'FQ' ])) $tabBilan [ 'FQ1' ] = $tabBilanPre [ 'FQ' ];
if ( ! isset ( $tabBilan [ 'FR1' ]) && isset ( $tabBilanPre [ 'FR' ])) $tabBilan [ 'FR1' ] = $tabBilanPre [ 'FR' ];
if ( ! isset ( $tabBilan [ 'FS1' ]) && isset ( $tabBilanPre [ 'FS' ])) $tabBilan [ 'FS1' ] = $tabBilanPre [ 'FS' ];
if ( ! isset ( $tabBilan [ 'FT1' ]) && isset ( $tabBilanPre [ 'FT' ])) $tabBilan [ 'FT1' ] = $tabBilanPre [ 'FT' ];
if ( ! isset ( $tabBilan [ 'FU1' ]) && isset ( $tabBilanPre [ 'FU' ])) $tabBilan [ 'FU1' ] = $tabBilanPre [ 'FU' ];
if ( ! isset ( $tabBilan [ 'FV1' ]) && isset ( $tabBilanPre [ 'FV' ])) $tabBilan [ 'FV1' ] = $tabBilanPre [ 'FV' ];
if ( ! isset ( $tabBilan [ 'FW1' ]) && isset ( $tabBilanPre [ 'FW' ])) $tabBilan [ 'FW1' ] = $tabBilanPre [ 'FW' ];
if ( ! isset ( $tabBilan [ 'FX1' ]) && isset ( $tabBilanPre [ 'FX' ])) $tabBilan [ 'FX1' ] = $tabBilanPre [ 'FX' ];
if ( ! isset ( $tabBilan [ 'FY1' ]) && isset ( $tabBilanPre [ 'FY' ])) $tabBilan [ 'FY1' ] = $tabBilanPre [ 'FY' ];
if ( ! isset ( $tabBilan [ 'FZ1' ]) && isset ( $tabBilanPre [ 'FZ' ])) $tabBilan [ 'FZ1' ] = $tabBilanPre [ 'FZ' ];
if ( ! isset ( $tabBilan [ 'GA1' ]) && isset ( $tabBilanPre [ 'GA' ])) $tabBilan [ 'GA1' ] = $tabBilanPre [ 'GA' ];
if ( ! isset ( $tabBilan [ 'GB1' ]) && isset ( $tabBilanPre [ 'GB' ])) $tabBilan [ 'GB1' ] = $tabBilanPre [ 'GB' ];
if ( ! isset ( $tabBilan [ 'GC1' ]) && isset ( $tabBilanPre [ 'GC' ])) $tabBilan [ 'GC1' ] = $tabBilanPre [ 'GC' ];
if ( ! isset ( $tabBilan [ 'GD1' ]) && isset ( $tabBilanPre [ 'GD' ])) $tabBilan [ 'GD1' ] = $tabBilanPre [ 'GD' ];
if ( ! isset ( $tabBilan [ 'GE1' ]) && isset ( $tabBilanPre [ 'GE' ])) $tabBilan [ 'GE1' ] = $tabBilanPre [ 'GE' ];
if ( ! isset ( $tabBilan [ 'GF1' ]) && isset ( $tabBilanPre [ 'GF' ])) $tabBilan [ 'GF1' ] = $tabBilanPre [ 'GF' ];
if ( ! isset ( $tabBilan [ 'GG1' ]) && isset ( $tabBilanPre [ 'GG' ])) $tabBilan [ 'GG1' ] = $tabBilanPre [ 'GG' ];
if ( ! isset ( $tabBilan [ 'GH1' ]) && isset ( $tabBilanPre [ 'GH' ])) $tabBilan [ 'GH1' ] = $tabBilanPre [ 'GH' ];
if ( ! isset ( $tabBilan [ 'GI1' ]) && isset ( $tabBilanPre [ 'GI' ])) $tabBilan [ 'GI1' ] = $tabBilanPre [ 'GI' ];
if ( ! isset ( $tabBilan [ 'GJ1' ]) && isset ( $tabBilanPre [ 'GJ' ])) $tabBilan [ 'GJ1' ] = $tabBilanPre [ 'GJ' ];
if ( ! isset ( $tabBilan [ 'GK1' ]) && isset ( $tabBilanPre [ 'GK' ])) $tabBilan [ 'GK1' ] = $tabBilanPre [ 'GK' ];
if ( ! isset ( $tabBilan [ 'GL1' ]) && isset ( $tabBilanPre [ 'GL' ])) $tabBilan [ 'GL1' ] = $tabBilanPre [ 'GL' ];
if ( ! isset ( $tabBilan [ 'GM1' ]) && isset ( $tabBilanPre [ 'GM' ])) $tabBilan [ 'GM1' ] = $tabBilanPre [ 'GM' ];
if ( ! isset ( $tabBilan [ 'GN1' ]) && isset ( $tabBilanPre [ 'GN' ])) $tabBilan [ 'GN1' ] = $tabBilanPre [ 'GN' ];
if ( ! isset ( $tabBilan [ 'GO1' ]) && isset ( $tabBilanPre [ 'GO' ])) $tabBilan [ 'GO1' ] = $tabBilanPre [ 'GO' ];
if ( ! isset ( $tabBilan [ 'GP1' ]) && isset ( $tabBilanPre [ 'GP' ])) $tabBilan [ 'GP1' ] = $tabBilanPre [ 'GP' ];
if ( ! isset ( $tabBilan [ 'GQ1' ]) && isset ( $tabBilanPre [ 'GQ' ])) $tabBilan [ 'GQ1' ] = $tabBilanPre [ 'GQ' ];
if ( ! isset ( $tabBilan [ 'GR1' ]) && isset ( $tabBilanPre [ 'GR' ])) $tabBilan [ 'GR1' ] = $tabBilanPre [ 'GR' ];
if ( ! isset ( $tabBilan [ 'GS1' ]) && isset ( $tabBilanPre [ 'GS' ])) $tabBilan [ 'GS1' ] = $tabBilanPre [ 'GS' ];
if ( ! isset ( $tabBilan [ 'GT1' ]) && isset ( $tabBilanPre [ 'GT' ])) $tabBilan [ 'GT1' ] = $tabBilanPre [ 'GT' ];
if ( ! isset ( $tabBilan [ 'GU1' ]) && isset ( $tabBilanPre [ 'GU' ])) $tabBilan [ 'GU1' ] = $tabBilanPre [ 'GU' ];
if ( ! isset ( $tabBilan [ 'GV1' ]) && isset ( $tabBilanPre [ 'GV' ])) $tabBilan [ 'GV1' ] = $tabBilanPre [ 'GV' ];
if ( ! isset ( $tabBilan [ 'GW1' ]) && isset ( $tabBilanPre [ 'GW' ])) $tabBilan [ 'GW1' ] = $tabBilanPre [ 'GW' ];
if ( ! isset ( $tabBilan [ 'HA1' ]) && isset ( $tabBilanPre [ 'HA' ])) $tabBilan [ 'HA1' ] = $tabBilanPre [ 'HA' ];
if ( ! isset ( $tabBilan [ 'HB1' ]) && isset ( $tabBilanPre [ 'HB' ])) $tabBilan [ 'HB1' ] = $tabBilanPre [ 'HB' ];
if ( ! isset ( $tabBilan [ 'HC1' ]) && isset ( $tabBilanPre [ 'HC' ])) $tabBilan [ 'HC1' ] = $tabBilanPre [ 'HC' ];
if ( ! isset ( $tabBilan [ 'HD1' ]) && isset ( $tabBilanPre [ 'HD' ])) $tabBilan [ 'HD1' ] = $tabBilanPre [ 'HD' ];
if ( ! isset ( $tabBilan [ 'HE1' ]) && isset ( $tabBilanPre [ 'HE' ])) $tabBilan [ 'HE1' ] = $tabBilanPre [ 'HE' ];
if ( ! isset ( $tabBilan [ 'HF1' ]) && isset ( $tabBilanPre [ 'HF' ])) $tabBilan [ 'HF1' ] = $tabBilanPre [ 'HF' ];
if ( ! isset ( $tabBilan [ 'HG1' ]) && isset ( $tabBilanPre [ 'HG' ])) $tabBilan [ 'HG1' ] = $tabBilanPre [ 'HG' ];
if ( ! isset ( $tabBilan [ 'HH1' ]) && isset ( $tabBilanPre [ 'HH' ])) $tabBilan [ 'HH1' ] = $tabBilanPre [ 'HH' ];
if ( ! isset ( $tabBilan [ 'HI1' ]) && isset ( $tabBilanPre [ 'HI' ])) $tabBilan [ 'HI1' ] = $tabBilanPre [ 'HI' ];
if ( ! isset ( $tabBilan [ 'HJ1' ]) && isset ( $tabBilanPre [ 'HJ' ])) $tabBilan [ 'HJ1' ] = $tabBilanPre [ 'HJ' ];
if ( ! isset ( $tabBilan [ 'HK1' ]) && isset ( $tabBilanPre [ 'HK' ])) $tabBilan [ 'HK1' ] = $tabBilanPre [ 'HK' ];
if ( ! isset ( $tabBilan [ 'HL1' ]) && isset ( $tabBilanPre [ 'HL' ])) $tabBilan [ 'HL1' ] = $tabBilanPre [ 'HL' ];
if ( ! isset ( $tabBilan [ 'HM1' ]) && isset ( $tabBilanPre [ 'HM' ])) $tabBilan [ 'HM1' ] = $tabBilanPre [ 'HM' ];
if ( ! isset ( $tabBilan [ 'HN1' ]) && isset ( $tabBilanPre [ 'HN' ])) $tabBilan [ 'HN1' ] = $tabBilanPre [ 'HN' ];
if ( ! isset ( $tabBilan [ 'HO1' ]) && isset ( $tabBilanPre [ 'HO' ])) $tabBilan [ 'HO1' ] = $tabBilanPre [ 'HO' ];
if ( ! isset ( $tabBilan [ 'HY1' ]) && isset ( $tabBilanPre [ 'HY' ])) $tabBilan [ 'HY1' ] = $tabBilanPre [ 'HY' ];
if ( ! isset ( $tabBilan [ '1G1' ]) && isset ( $tabBilanPre [ '1G' ])) $tabBilan [ '1G1' ] = $tabBilanPre [ '1G' ];
if ( ! isset ( $tabBilan [ 'HP1' ]) && isset ( $tabBilanPre [ 'HP' ])) $tabBilan [ 'HP1' ] = $tabBilanPre [ 'HP' ];
if ( ! isset ( $tabBilan [ 'HQ1' ]) && isset ( $tabBilanPre [ 'HQ' ])) $tabBilan [ 'HQ1' ] = $tabBilanPre [ 'HQ' ];
if ( ! isset ( $tabBilan [ '1H1' ]) && isset ( $tabBilanPre [ '1H' ])) $tabBilan [ '1H1' ] = $tabBilanPre [ '1H' ];
if ( ! isset ( $tabBilan [ '1J1' ]) && isset ( $tabBilanPre [ '1J' ])) $tabBilan [ '1J1' ] = $tabBilanPre [ '1J' ];
if ( ! isset ( $tabBilan [ '1K1' ]) && isset ( $tabBilanPre [ '1K' ])) $tabBilan [ '1K1' ] = $tabBilanPre [ '1K' ];
if ( ! isset ( $tabBilan [ 'HX1' ]) && isset ( $tabBilanPre [ 'HX' ])) $tabBilan [ 'HX1' ] = $tabBilanPre [ 'HX' ];
if ( ! isset ( $tabBilan [ 'A11' ]) && isset ( $tabBilanPre [ 'A1' ])) $tabBilan [ 'A11' ] = $tabBilanPre [ 'A1' ];
if ( ! isset ( $tabBilan [ 'A21' ]) && isset ( $tabBilanPre [ 'A2' ])) $tabBilan [ 'A21' ] = $tabBilanPre [ 'A2' ];
if ( ! isset ( $tabBilan [ 'A31' ]) && isset ( $tabBilanPre [ 'A3' ])) $tabBilan [ 'A31' ] = $tabBilanPre [ 'A3' ];
if ( ! isset ( $tabBilan [ 'A41' ]) && isset ( $tabBilanPre [ 'A4' ])) $tabBilan [ 'A41' ] = $tabBilanPre [ 'A4' ];
}
elseif ( $tabBilan [ 'CONSOLIDE' ] == 'S' )
{
// Calcul des chiffres net N-1 si absent 2033
if ( ! isset ( $tabBilanPre [ '013' ]) && ( isset ( $tabBilanPre [ '010' ]) || isset ( $tabBilanPre [ '012' ]))) $tabBilanPre [ '013' ] = $tabBilanPre [ '010' ] - $tabBilanPre [ '012' ];
if ( ! isset ( $tabBilanPre [ '017' ]) && ( isset ( $tabBilanPre [ '014' ]) || isset ( $tabBilanPre [ '016' ]))) $tabBilanPre [ '017' ] = $tabBilanPre [ '014' ] - $tabBilanPre [ '016' ];
if ( ! isset ( $tabBilanPre [ '031' ]) && ( isset ( $tabBilanPre [ '028' ]) || isset ( $tabBilanPre [ '030' ]))) $tabBilanPre [ '031' ] = $tabBilanPre [ '028' ] - $tabBilanPre [ '030' ];
if ( ! isset ( $tabBilanPre [ '043' ]) && ( isset ( $tabBilanPre [ '040' ]) || isset ( $tabBilanPre [ '042' ]))) $tabBilanPre [ '043' ] = $tabBilanPre [ '040' ] - $tabBilanPre [ '042' ];
if ( ! isset ( $tabBilanPre [ '049' ]) && ( isset ( $tabBilanPre [ '044' ]) || isset ( $tabBilanPre [ '048' ]))) $tabBilanPre [ '049' ] = $tabBilanPre [ '044' ] - $tabBilanPre [ '048' ];
if ( ! isset ( $tabBilanPre [ '053' ]) && ( isset ( $tabBilanPre [ '050' ]) || isset ( $tabBilanPre [ '052' ]))) $tabBilanPre [ '053' ] = $tabBilanPre [ '050' ] - $tabBilanPre [ '052' ];
if ( ! isset ( $tabBilanPre [ '063' ]) && ( isset ( $tabBilanPre [ '060' ]) || isset ( $tabBilanPre [ '062' ]))) $tabBilanPre [ '063' ] = $tabBilanPre [ '060' ] - $tabBilanPre [ '062' ];
if ( ! isset ( $tabBilanPre [ '067' ]) && ( isset ( $tabBilanPre [ '064' ]) || isset ( $tabBilanPre [ '066' ]))) $tabBilanPre [ '067' ] = $tabBilanPre [ '064' ] - $tabBilanPre [ '066' ];
if ( ! isset ( $tabBilanPre [ '071' ]) && ( isset ( $tabBilanPre [ '068' ]) || isset ( $tabBilanPre [ '070' ]))) $tabBilanPre [ '071' ] = $tabBilanPre [ '068' ] - $tabBilanPre [ '070' ];
if ( ! isset ( $tabBilanPre [ '075' ]) && ( isset ( $tabBilanPre [ '072' ]) || isset ( $tabBilanPre [ '074' ]))) $tabBilanPre [ '075' ] = $tabBilanPre [ '072' ] - $tabBilanPre [ '074' ];
if ( ! isset ( $tabBilanPre [ '083' ]) && ( isset ( $tabBilanPre [ '080' ]) || isset ( $tabBilanPre [ '082' ]))) $tabBilanPre [ '083' ] = $tabBilanPre [ '080' ] - $tabBilanPre [ '082' ];
if ( ! isset ( $tabBilanPre [ '087' ]) && ( isset ( $tabBilanPre [ '084' ]) || isset ( $tabBilanPre [ '086' ]))) $tabBilanPre [ '087' ] = $tabBilanPre [ '084' ] - $tabBilanPre [ '086' ];
if ( ! isset ( $tabBilanPre [ '091' ]) && ( isset ( $tabBilanPre [ '088' ]) || isset ( $tabBilanPre [ '090' ]))) $tabBilanPre [ '091' ] = $tabBilanPre [ '088' ] - $tabBilanPre [ '090' ];
if ( ! isset ( $tabBilanPre [ '095' ]) && ( isset ( $tabBilanPre [ '092' ]) || isset ( $tabBilanPre [ '094' ]))) $tabBilanPre [ '095' ] = $tabBilanPre [ '092' ] - $tabBilanPre [ '094' ];
if ( ! isset ( $tabBilanPre [ '099' ]) && ( isset ( $tabBilanPre [ '096' ]) || isset ( $tabBilanPre [ '098' ]))) $tabBilanPre [ '099' ] = $tabBilanPre [ '096' ] - $tabBilanPre [ '098' ];
if ( ! isset ( $tabBilanPre [ '113' ]) && ( isset ( $tabBilanPre [ '110' ]) || isset ( $tabBilanPre [ '112' ]))) $tabBilanPre [ '113' ] = $tabBilanPre [ '110' ] - $tabBilanPre [ '112' ];
// Récupération des chiffres N-1 si absent du bilan N
// ACTIF 2033
if ( ! isset ( $tabBilan [ 'N00' ]) && isset ( $tabBilanPre [ '013' ])) $tabBilan [ 'N00' ] = $tabBilanPre [ '013' ];
if ( ! isset ( $tabBilan [ 'N01' ]) && isset ( $tabBilanPre [ '017' ])) $tabBilan [ 'N01' ] = $tabBilanPre [ '017' ];
if ( ! isset ( $tabBilan [ 'N02' ]) && isset ( $tabBilanPre [ '031' ])) $tabBilan [ 'N02' ] = $tabBilanPre [ '031' ];
if ( ! isset ( $tabBilan [ 'N03' ]) && isset ( $tabBilanPre [ '043' ])) $tabBilan [ 'N03' ] = $tabBilanPre [ '043' ];
if ( ! isset ( $tabBilan [ 'N04' ]) && isset ( $tabBilanPre [ '049' ])) $tabBilan [ 'N04' ] = $tabBilanPre [ '049' ];
if ( ! isset ( $tabBilan [ 'N05' ]) && isset ( $tabBilanPre [ '053' ])) $tabBilan [ 'N05' ] = $tabBilanPre [ '053' ];
if ( ! isset ( $tabBilan [ 'N06' ]) && isset ( $tabBilanPre [ '063' ])) $tabBilan [ 'N06' ] = $tabBilanPre [ '063' ];
if ( ! isset ( $tabBilan [ 'N07' ]) && isset ( $tabBilanPre [ '067' ])) $tabBilan [ 'N07' ] = $tabBilanPre [ '067' ];
if ( ! isset ( $tabBilan [ 'N08' ]) && isset ( $tabBilanPre [ '071' ])) $tabBilan [ 'N08' ] = $tabBilanPre [ '071' ];
if ( ! isset ( $tabBilan [ 'N09' ]) && isset ( $tabBilanPre [ '075' ])) $tabBilan [ 'N09' ] = $tabBilanPre [ '075' ];
if ( ! isset ( $tabBilan [ 'N10' ]) && isset ( $tabBilanPre [ '083' ])) $tabBilan [ 'N10' ] = $tabBilanPre [ '083' ];
if ( ! isset ( $tabBilan [ 'N11' ]) && isset ( $tabBilanPre [ '087' ])) $tabBilan [ 'N11' ] = $tabBilanPre [ '087' ];
if ( ! isset ( $tabBilan [ 'N12' ]) && isset ( $tabBilanPre [ '091' ])) $tabBilan [ 'N12' ] = $tabBilanPre [ '091' ];
if ( ! isset ( $tabBilan [ 'N13' ]) && isset ( $tabBilanPre [ '095' ])) $tabBilan [ 'N13' ] = $tabBilanPre [ '095' ];
if ( ! isset ( $tabBilan [ 'N14' ]) && isset ( $tabBilanPre [ '099' ])) $tabBilan [ 'N14' ] = $tabBilanPre [ '099' ];
if ( ! isset ( $tabBilan [ 'N15' ]) && isset ( $tabBilanPre [ '113' ])) $tabBilan [ 'N15' ] = $tabBilanPre [ '113' ];
// PASSIF 2033
if ( ! isset ( $tabBilan [ 'N16' ]) && isset ( $tabBilanPre [ '120' ])) $tabBilan [ 'N16' ] = $tabBilanPre [ '120' ];
if ( ! isset ( $tabBilan [ 'N17' ]) && isset ( $tabBilanPre [ '124' ])) $tabBilan [ 'N17' ] = $tabBilanPre [ '124' ];
if ( ! isset ( $tabBilan [ 'N18' ]) && isset ( $tabBilanPre [ '126' ])) $tabBilan [ 'N18' ] = $tabBilanPre [ '126' ];
if ( ! isset ( $tabBilan [ 'N19' ]) && isset ( $tabBilanPre [ '130' ])) $tabBilan [ 'N19' ] = $tabBilanPre [ '130' ];
if ( ! isset ( $tabBilan [ 'N20' ]) && isset ( $tabBilanPre [ '132' ])) $tabBilan [ 'N20' ] = $tabBilanPre [ '132' ];
if ( ! isset ( $tabBilan [ 'N21' ]) && isset ( $tabBilanPre [ '134' ])) $tabBilan [ 'N21' ] = $tabBilanPre [ '134' ];
if ( ! isset ( $tabBilan [ 'N22' ]) && isset ( $tabBilanPre [ '136' ])) $tabBilan [ 'N22' ] = $tabBilanPre [ '136' ];
if ( ! isset ( $tabBilan [ 'N23' ]) && isset ( $tabBilanPre [ '140' ])) $tabBilan [ 'N23' ] = $tabBilanPre [ '140' ];
if ( ! isset ( $tabBilan [ 'N24' ]) && isset ( $tabBilanPre [ '142' ])) $tabBilan [ 'N24' ] = $tabBilanPre [ '142' ];
if ( ! isset ( $tabBilan [ 'N25' ]) && isset ( $tabBilanPre [ '154' ])) $tabBilan [ 'N25' ] = $tabBilanPre [ '154' ];
if ( ! isset ( $tabBilan [ 'N26' ]) && isset ( $tabBilanPre [ '156' ])) $tabBilan [ 'N26' ] = $tabBilanPre [ '156' ];
if ( ! isset ( $tabBilan [ 'N27' ]) && isset ( $tabBilanPre [ '164' ])) $tabBilan [ 'N27' ] = $tabBilanPre [ '164' ];
if ( ! isset ( $tabBilan [ 'N28' ]) && isset ( $tabBilanPre [ '166' ])) $tabBilan [ 'N28' ] = $tabBilanPre [ '166' ];
if ( ! isset ( $tabBilan [ 'N29' ]) && isset ( $tabBilanPre [ '172' ])) $tabBilan [ 'N29' ] = $tabBilanPre [ '172' ];
if ( ! isset ( $tabBilan [ 'N30' ]) && isset ( $tabBilanPre [ '174' ])) $tabBilan [ 'N30' ] = $tabBilanPre [ '174' ];
if ( ! isset ( $tabBilan [ 'N31' ]) && isset ( $tabBilanPre [ '176' ])) $tabBilan [ 'N31' ] = $tabBilanPre [ '176' ];
if ( ! isset ( $tabBilan [ 'N32' ]) && isset ( $tabBilanPre [ '180' ])) $tabBilan [ 'N32' ] = $tabBilanPre [ '180' ];
// COMPTE DE RESULTAT 2033
if ( ! isset ( $tabBilan [ 'N33' ]) && isset ( $tabBilanPre [ '210' ])) $tabBilan [ 'N33' ] = $tabBilanPre [ '210' ];
if ( ! isset ( $tabBilan [ 'N34' ]) && isset ( $tabBilanPre [ '214' ])) $tabBilan [ 'N34' ] = $tabBilanPre [ '214' ];
if ( ! isset ( $tabBilan [ 'N35' ]) && isset ( $tabBilanPre [ '218' ])) $tabBilan [ 'N35' ] = $tabBilanPre [ '218' ];
if ( ! isset ( $tabBilan [ 'N36' ]) && isset ( $tabBilanPre [ '222' ])) $tabBilan [ 'N36' ] = $tabBilanPre [ '222' ];
if ( ! isset ( $tabBilan [ 'N37' ]) && isset ( $tabBilanPre [ '224' ])) $tabBilan [ 'N37' ] = $tabBilanPre [ '224' ];
if ( ! isset ( $tabBilan [ 'N38' ]) && isset ( $tabBilanPre [ '226' ])) $tabBilan [ 'N38' ] = $tabBilanPre [ '226' ];
if ( ! isset ( $tabBilan [ 'N39' ]) && isset ( $tabBilanPre [ '230' ])) $tabBilan [ 'N39' ] = $tabBilanPre [ '230' ];
if ( ! isset ( $tabBilan [ 'N40' ]) && isset ( $tabBilanPre [ '232' ])) $tabBilan [ 'N40' ] = $tabBilanPre [ '232' ];
if ( ! isset ( $tabBilan [ 'N41' ]) && isset ( $tabBilanPre [ '234' ])) $tabBilan [ 'N41' ] = $tabBilanPre [ '234' ];
if ( ! isset ( $tabBilan [ 'N42' ]) && isset ( $tabBilanPre [ '236' ])) $tabBilan [ 'N42' ] = $tabBilanPre [ '236' ];
if ( ! isset ( $tabBilan [ 'N43' ]) && isset ( $tabBilanPre [ '238' ])) $tabBilan [ 'N43' ] = $tabBilanPre [ '238' ];
if ( ! isset ( $tabBilan [ 'N44' ]) && isset ( $tabBilanPre [ '240' ])) $tabBilan [ 'N44' ] = $tabBilanPre [ '240' ];
if ( ! isset ( $tabBilan [ 'N45' ]) && isset ( $tabBilanPre [ '242' ])) $tabBilan [ 'N45' ] = $tabBilanPre [ '242' ];
if ( ! isset ( $tabBilan [ 'N46' ]) && isset ( $tabBilanPre [ '244' ])) $tabBilan [ 'N46' ] = $tabBilanPre [ '244' ];
if ( ! isset ( $tabBilan [ 'N47' ]) && isset ( $tabBilanPre [ '250' ])) $tabBilan [ 'N47' ] = $tabBilanPre [ '250' ];
if ( ! isset ( $tabBilan [ 'N48' ]) && isset ( $tabBilanPre [ '252' ])) $tabBilan [ 'N48' ] = $tabBilanPre [ '252' ];
if ( ! isset ( $tabBilan [ 'N49' ]) && isset ( $tabBilanPre [ '254' ])) $tabBilan [ 'N49' ] = $tabBilanPre [ '254' ];
if ( ! isset ( $tabBilan [ 'N50' ]) && isset ( $tabBilanPre [ '256' ])) $tabBilan [ 'N50' ] = $tabBilanPre [ '256' ];
if ( ! isset ( $tabBilan [ 'N51' ]) && isset ( $tabBilanPre [ '262' ])) $tabBilan [ 'N51' ] = $tabBilanPre [ '262' ];
if ( ! isset ( $tabBilan [ 'N52' ]) && isset ( $tabBilanPre [ '264' ])) $tabBilan [ 'N52' ] = $tabBilanPre [ '264' ];
if ( ! isset ( $tabBilan [ 'N53' ]) && isset ( $tabBilanPre [ '270' ])) $tabBilan [ 'N53' ] = $tabBilanPre [ '270' ];
if ( ! isset ( $tabBilan [ 'N54' ]) && isset ( $tabBilanPre [ '280' ])) $tabBilan [ 'N54' ] = $tabBilanPre [ '280' ];
if ( ! isset ( $tabBilan [ 'N55' ]) && isset ( $tabBilanPre [ '290' ])) $tabBilan [ 'N55' ] = $tabBilanPre [ '290' ];
if ( ! isset ( $tabBilan [ 'N56' ]) && isset ( $tabBilanPre [ '294' ])) $tabBilan [ 'N56' ] = $tabBilanPre [ '294' ];
if ( ! isset ( $tabBilan [ 'N57' ]) && isset ( $tabBilanPre [ '300' ])) $tabBilan [ 'N57' ] = $tabBilanPre [ '300' ];
if ( ! isset ( $tabBilan [ 'N58' ]) && isset ( $tabBilanPre [ '306' ])) $tabBilan [ 'N58' ] = $tabBilanPre [ '306' ];
if ( ! isset ( $tabBilan [ 'N59' ]) && isset ( $tabBilanPre [ '310' ])) $tabBilan [ 'N59' ] = $tabBilanPre [ '310' ];
}
elseif ( $tabBilan [ 'CONSOLIDE' ] == 'A' || $tabBilan [ 'CONSOLIDE' ] == 'B' )
{
// BANQUES
if ( ! isset ( $tabBilan [ 'NA1' ]) && isset ( $tabBilanPre [ 'AA1' ])) $tabBilan [ 'NA1' ] = $tabBilanPre [ 'AA1' ];
if ( ! isset ( $tabBilan [ 'NA2' ]) && isset ( $tabBilanPre [ 'AA2' ])) $tabBilan [ 'NA2' ] = $tabBilanPre [ 'AA2' ];
if ( ! isset ( $tabBilan [ 'NA3' ]) && isset ( $tabBilanPre [ 'AA3' ])) $tabBilan [ 'NA3' ] = $tabBilanPre [ 'AA3' ];
if ( ! isset ( $tabBilan [ 'NP1' ]) && isset ( $tabBilanPre [ 'AP1' ])) $tabBilan [ 'NP1' ] = $tabBilanPre [ 'AP1' ];
if ( ! isset ( $tabBilan [ 'NP2' ]) && isset ( $tabBilanPre [ 'AP2' ])) $tabBilan [ 'NP2' ] = $tabBilanPre [ 'AP2' ];
if ( ! isset ( $tabBilan [ 'NP3' ]) && isset ( $tabBilanPre [ 'AP3' ])) $tabBilan [ 'NP3' ] = $tabBilanPre [ 'AP3' ];
if ( ! isset ( $tabBilan [ 'NP4' ]) && isset ( $tabBilanPre [ 'AP4' ])) $tabBilan [ 'NP4' ] = $tabBilanPre [ 'AP4' ];
if ( ! isset ( $tabBilan [ 'NP5' ]) && isset ( $tabBilanPre [ 'AP5' ])) $tabBilan [ 'NP5' ] = $tabBilanPre [ 'AP5' ];
if ( ! isset ( $tabBilan [ 'NP6' ]) && isset ( $tabBilanPre [ 'AP6' ])) $tabBilan [ 'NP6' ] = $tabBilanPre [ 'AP6' ];
if ( ! isset ( $tabBilan [ 'NP7' ]) && isset ( $tabBilanPre [ 'AP7' ])) $tabBilan [ 'NP7' ] = $tabBilanPre [ 'AP7' ];
if ( ! isset ( $tabBilan [ 'NP8' ]) && isset ( $tabBilanPre [ 'AP8' ])) $tabBilan [ 'NP8' ] = $tabBilanPre [ 'AP8' ];
if ( ! isset ( $tabBilan [ 'NP9' ]) && isset ( $tabBilanPre [ 'AP9' ])) $tabBilan [ 'NP9' ] = $tabBilanPre [ 'AP9' ];
if ( ! isset ( $tabBilan [ 'NR1' ]) && isset ( $tabBilanPre [ 'AR1' ])) $tabBilan [ 'NR1' ] = $tabBilanPre [ 'AR1' ];
if ( ! isset ( $tabBilan [ 'NR2' ]) && isset ( $tabBilanPre [ 'AR2' ])) $tabBilan [ 'NR2' ] = $tabBilanPre [ 'AR2' ];
if ( ! isset ( $tabBilan [ 'NR3' ]) && isset ( $tabBilanPre [ 'AR3' ])) $tabBilan [ 'NR3' ] = $tabBilanPre [ 'AR3' ];
// ASSURANCE
if ( ! isset ( $tabBilan [ 'NR4' ]) && isset ( $tabBilanPre [ 'AR4' ])) $tabBilan [ 'AR4' ] = $tabBilanPre [ 'AR4' ];
}
2014-03-19 13:10:31 +00:00
}
2014-10-20 13:14:32 +00:00
//Put Result in memory
$this -> Bilans [ $typeBilan . $millesime ] = $tabBilan ;
2014-03-19 13:10:31 +00:00
}
2014-10-20 13:14:32 +00:00
2014-03-19 13:10:31 +00:00
return $tabBilan ;
}
/**
* Conversion des bilans Simplifiés en Réels Normal
* @ param $bilanRS array Bilan au format réel simplifé ( 2033 )
* @ return array Bilan au format réel Normal ( 2050 )
*/
2014-04-22 08:05:59 +00:00
public function bilanSimplifie2Normal ( $bilanRS )
2014-03-19 13:10:31 +00:00
{
$bilanRN = array ();
2013-11-05 11:18:30 +00:00
foreach ( $this -> tabBS2BN as $posteRN => $formule ) {
if ( preg_match ( '/\+|\-/' , $formule )) {
2015-02-03 13:11:18 +00:00
$tabTmp = preg_split ( '/\+|\-/' , $formule , - 1 , PREG_SPLIT_OFFSET_CAPTURE );
2013-11-05 11:18:30 +00:00
//$bilanRN[$posteRN]=0;
$scalc = '' ;
foreach ( $tabTmp as $i => $tab ) {
if ( $i == 0 ) {
$bilanRN [ $posteRN ] = $bilanRS [ $tab [ 0 ]];
$scalc .= $bilanRS [ $tab [ 0 ]];
}
else {
$signe = $formule [ $tab [ 1 ] - 1 ];
$scalc .= $signe ;
if ( $signe == '+' ) $bilanRN [ $posteRN ] += $bilanRS [ $tab [ 0 ]];
elseif ( $signe == '-' ) $bilanRN [ $posteRN ] -= $bilanRS [ $tab [ 0 ]];
$scalc .= $bilanRS [ $tab [ 0 ]];
}
}
$bilanRN [ $posteRN ] = $bilanRN [ $posteRN ];
}
else $bilanRN [ $posteRN ] = $bilanRS [ $formule ];
}
2015-02-03 13:11:18 +00:00
//Variation de stock (matières premières et approvisionnement)
if ( is_numeric ( $bilanRS [ '240' ]) && $bilanRS [ '240' ] != 0 ) {
$bilanRN [ 'BL' ] = $bilanRS [ '050' ];
$bilanRN [ 'BM' ] = $bilanRS [ '052' ];
$bilanRN [ 'BM1' ] = $bilanRS [ '053' ];
$bilanRN [ 'BM2' ] = $bilanRS [ 'N05' ];
unset ( $bilanRN [ 'BN' ]);
unset ( $bilanRN [ 'BO' ]);
unset ( $bilanRN [ 'BO1' ]);
unset ( $bilanRN [ 'BO2' ]);
2013-11-05 11:18:30 +00:00
} else {
2015-02-03 13:11:18 +00:00
unset ( $bilanRN [ 'BL' ]);
unset ( $bilanRN [ 'BM' ]);
unset ( $bilanRN [ 'BM1' ]);
unset ( $bilanRN [ 'BM2' ]);
$bilanRN [ 'BN' ] = $bilanRS [ '050' ];
$bilanRN [ 'BO' ] = $bilanRS [ '052' ];
$bilanRN [ 'BO1' ] = $bilanRS [ '053' ];
$bilanRN [ 'BO2' ] = $bilanRS [ 'N05' ];
2013-11-05 11:18:30 +00:00
}
2015-02-03 13:11:18 +00:00
if ( is_numeric ( $bilanRS [ '070' ]) && $bilanRS [ '070' ] != 0
|| is_numeric ( $bilanRS [ '074' ]) && $bilanRS [ '074' ] != 0
|| is_numeric ( $bilanRS [ '052' ]) && $bilanRS [ '052' ] != 0
|| is_numeric ( $bilanRS [ '062' ]) && $bilanRS [ '062' ] != 0 ) {
$bilanRN [ 'GC' ] = $bilanRS [ '256' ];
} elseif ( $bilanRS [ '070' ] == 0
&& $bilanRS [ '074' ] == 0
&& $bilanRS [ '052' ] == 0
&& $bilanRS [ '062' ] == 0
&& intval ( $bilanRS [ '254' ]) > 0 ) {
$bilanRN [ 'GD' ] = $bilanRS [ '256' ];
2014-03-19 13:10:31 +00:00
}
2013-11-05 11:18:30 +00:00
2015-02-03 13:11:18 +00:00
if ( is_numeric ( $bilanRS [ '584' ]) && $bilanRS [ '584' ] != 0 ) {
$bilanRN [ 'HB' ] = $bilanRS [ '584' ];
$bilanRN [ 'HA' ] = $bilanRS [ '290' ] - $bilanRS [ '584' ];
2014-03-19 13:10:31 +00:00
} else {
2015-02-03 13:11:18 +00:00
$bilanRN [ 'HA' ] = $bilanRS [ '290' ];
2014-03-19 13:10:31 +00:00
}
2013-11-05 11:18:30 +00:00
2015-02-03 13:11:18 +00:00
if ( is_numeric ( $bilanRS [ '582' ]) && $bilanRS [ '582' ] != 0 ) {
$bilanRN [ 'HF' ] = $bilanRS [ '582' ];
$bilanRN [ 'HE' ] = $bilanRS [ '582' ] - $bilanRS [ '300' ];
2014-03-19 13:10:31 +00:00
} else {
2015-02-03 13:11:18 +00:00
$bilanRN [ 'HE' ] = $bilanRS [ '300' ];
2014-03-19 13:10:31 +00:00
}
2013-11-05 11:18:30 +00:00
return $bilanRN ;
}
2015-02-03 13:11:18 +00:00
}