183 lines
3.8 KiB
PHP
183 lines
3.8 KiB
PHP
<?php
|
|
function bilanSimplifie2Normal($bilanRS) {
|
|
$tabBS2BN=array('AH'=>'010',
|
|
'AI'=>'012',
|
|
'AJ'=>'014',
|
|
'AK'=>'016',
|
|
'AT'=>'028',
|
|
'AU'=>'030',
|
|
'BH'=>'040',
|
|
'BI'=>'042',
|
|
'BJ'=>'044',
|
|
'BK'=>'048',
|
|
'BT'=>'060',
|
|
'BU'=>'062',
|
|
'BV'=>'064',
|
|
'BW'=>'066',
|
|
'BX'=>'068',
|
|
'BY'=>'070',
|
|
'BZ'=>'072',
|
|
'CA'=>'074',
|
|
'CD'=>'080',
|
|
'CE'=>'082',
|
|
'CF'=>'084',
|
|
'CG'=>'086',
|
|
'CH'=>'092',
|
|
'CI'=>'094',
|
|
'CJ'=>'096',
|
|
'CK'=>'098',
|
|
'CO'=>'110',
|
|
'1A'=>'112',
|
|
'DA'=>'120',
|
|
'DC'=>'124',
|
|
'DD'=>'126',
|
|
'DF'=>'130',
|
|
'DG'=>'132',
|
|
'DH'=>'134',
|
|
'DI'=>'136',
|
|
'DK'=>'140',
|
|
'DL'=>'142',
|
|
'DR'=>'154',
|
|
'DP'=>'154',
|
|
'DU'=>'156',
|
|
'DV'=>'169',
|
|
'DW'=>'164',
|
|
'DX'=>'166',
|
|
'EA'=>'172-169',
|
|
'EB'=>'174',
|
|
'EC'=>'176',
|
|
'EE'=>'180',
|
|
'EH'=>'156-195',
|
|
'FA'=>'210-209',
|
|
'FB'=>'209',
|
|
'FC'=>'210',
|
|
'FD'=>'214-215',
|
|
'FE'=>'215',
|
|
'FF'=>'214',
|
|
'FH'=>'217',
|
|
'FI'=>'218',
|
|
'FK'=>'209+215+217',
|
|
'FL'=>'210+214+218',
|
|
'FM'=>'222',
|
|
'FN'=>'224',
|
|
'FO'=>'226',
|
|
'FQ'=>'230',
|
|
'FR'=>'232',
|
|
'FS'=>'234',
|
|
'FT'=>'236',
|
|
'FU'=>'238',
|
|
'FV'=>'240',
|
|
'FW'=>'242',
|
|
'FX'=>'244',
|
|
'FY'=>'250',
|
|
'FZ'=>'252',
|
|
'GA'=>'254',
|
|
'GE'=>'262',
|
|
'GF'=>'264',
|
|
'GG'=>'270',
|
|
'GP'=>'280',
|
|
'GU'=>'294',
|
|
'GW'=>'270+280+294',
|
|
'HD'=>'290',
|
|
'HH'=>'300',
|
|
'HI'=>'290-300',
|
|
'HK'=>'306',
|
|
'HL'=>'232+280+290',
|
|
'HM'=>'264+294+300+306',
|
|
'HN'=>'310',
|
|
'YY'=>'374',
|
|
'YZ'=>'378',
|
|
'YP'=>'376',
|
|
);
|
|
|
|
$bilanRN=array();
|
|
foreach ($tabBS2BN as $posteRN => $formule) {
|
|
if (preg_match('/\+|\-/', $formule)) {
|
|
$tabTmp=preg_split('/\+|\-/', $formule, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
|
//$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];
|
|
}
|
|
if ($bilanRS['240']<>0) {
|
|
$bilanRN['BL']=$bilanRS['050'];
|
|
$bilanRN['BM']=$bilanRS['052'];
|
|
} else {
|
|
$bilanRN['BN']=$bilanRS['050'];
|
|
$bilanRN['BO']=$bilanRS['052'];
|
|
}
|
|
|
|
if ($bilanRS['070']<>0 || $bilanRS['074']<>0 || $bilanRS['052']<>0 || $bilanRS['062']<>0)
|
|
$bilanRN['GC']=$bilanRS['256'];
|
|
elseif ($bilanRS['070']==0 && $bilanRS['074']==0 && $bilanRS['052']==0 && $bilanRS['062']==0 && $bilanRS['254']<>0)
|
|
$bilanRN['GD']=$bilanRS['256'];
|
|
|
|
if ($bilanRS['584']<>0) {
|
|
$bilanRN['HB']=$bilanRS['584'];
|
|
$bilanRN['HA']=$bilanRS['290']-$bilanRS['584'];
|
|
} else
|
|
$bilanRN['HA']=$bilanRS['290'];
|
|
|
|
if ($bilanRS['582']<>0) {
|
|
$bilanRN['HF']=$bilanRS['582'];
|
|
$bilanRN['HE']=$bilanRS['582']-$bilanRS['300'];
|
|
} else
|
|
$bilanRN['HE']=$bilanRS['300'];
|
|
|
|
return $bilanRN;
|
|
}
|
|
|
|
function bilanMonnaie($value, $unite = '')
|
|
{
|
|
switch($unite)
|
|
{
|
|
case 'K':
|
|
$div = 1000;
|
|
break;
|
|
case 'M':
|
|
$div = 1000*1000;
|
|
break;
|
|
default:
|
|
case '':
|
|
$div = 1;
|
|
break;
|
|
}
|
|
if(isset($value) && !empty($value)){
|
|
return number_format($value/$div, 0, '', ' ');
|
|
}else{
|
|
return '-';
|
|
}
|
|
}
|
|
|
|
function dMontant(&$tab, $montant, $unite = '')
|
|
{
|
|
if ($montant == '' || isset($tab[$montant]) == false) {
|
|
return '';
|
|
}
|
|
switch ($unite) {
|
|
case 'K':
|
|
$div = 1000;
|
|
break;
|
|
case 'M':
|
|
$div = 1000000;
|
|
break;
|
|
default:
|
|
$div = 1;
|
|
}
|
|
return number_format($tab[$montant] / $div, 0, '', ' ');
|
|
}
|