Traitement des bilans simplifiés

This commit is contained in:
Michael RICOIS 2009-10-13 07:27:32 +00:00
parent 0584854fea
commit 99253dad29

View File

@ -270,22 +270,23 @@ function countBilans($bilansInfos, $typeBilan='')
{
$numBilanC = 0;
$numBilanN = 0;
$numBilanS = 0;
if(count($bilansInfos)>0)
{
foreach($bilansInfos as $key => $item)
{
if($item['typeBilan']=='C') { $numBilanC++; }
if($item['typeBilan']=='N') { $numBilanN++; }
if($item['typeBilan']=='N') { $numBilanN++; }
if($item['typeBilan']=='S') { $numBilanS++; }
}
}
$numBilanN = $numBilanN+$numBilanS;
if($typeBilan=='')
{
if($numBilanN>0){ $typeBilan = 'N'; }
if($numBilanN==0 && $numBilanC>0){ $typeBilan = 'C'; }
}
$numBilan = array( 'N'=>$numBilanN , 'C'=>$numBilanC );
$numBilan = array( 'N'=>$numBilanN , 'C'=>$numBilanC);
return array($typeBilan, $numBilan);
}
@ -302,14 +303,47 @@ function countBilans($bilansInfos, $typeBilan='')
*/
function filtreTypeBilans($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $dataActif, $dataPassif, $dataSIG, $typeBilan)
{
global $firephp;
if(count($bilansInfos)>0)
{
//Eliminer les doublons, on garde en priorités les bilans de type S
$tabBilanS = array();
$tabBilanN = array();
foreach($bilansInfos as $key => $item)
{
if($item['typeBilan']=='S'){ $tabBilanS[$item['dateCloture']] = 1; }
}
//Suppression des doublons + les types S deviennent des types N
$index = 0;
foreach($bilansInfos as $key => $item)
{
$date = $item['dateCloture'];
$type = $item['typeBilan'];
if($type=='N' && array_key_exists($date,$tabBilanS))
{
array_splice($bilansInfos, $index, 1);
array_splice($ratiosEntrep, $index, 1);
array_splice($ratiosEntrepEvol, $index, 1);
if(count($dataActif)>0) array_splice($dataActif, $index, 1);
if(count($dataPassif)>0) array_splice($dataPassif, $index, 1);
if(count($dataSIG)>0) array_splice($dataSIG, $index, 1);
$index--;
}
$index++;
}
$index=0;
foreach($bilansInfos as $key => $item)
{
if($item['typeBilan']=='S'){ $bilansInfos[$index]['typeBilan']='N'; }
$index++;
}
//En fonction du type de bilan sélectionné
//on filtre les bilans avant de les envoyer sur l'affichage
$index = 0;
foreach($bilansInfos as $key => $item)
{
if($item['typeBilan']!=$typeBilan)
if($item['typeBilan']!=$typeBilan )
{
array_splice($bilansInfos, $index, 1);
array_splice($ratiosEntrep, $index, 1);
@ -320,7 +354,7 @@ function filtreTypeBilans($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $dataA
$index--;
}
$index++;
}
}
}
return array($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $dataActif, $dataPassif, $dataSIG);
}