Réintégration du code prenant en compte les types de bilans + utilisation du siren pour la mise en cache

This commit is contained in:
Michael RICOIS 2009-10-07 07:56:16 +00:00
parent 80b097bfc3
commit c39e3d7df2

View File

@ -35,8 +35,9 @@ function scoresws_annonces($siret, $siren, $idEntreprise, $vue, $idan)
//Générer un nom de fichier pour le cache et l'export des fichiers
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'annonces-'.$idEntreprise;
}else{ $fileName = 'annonces-'.$siret; }
}else{ $fileName = 'annonces-'.$siren; }
if($vue!=''){$fileName.= '-'.$idan;}
cache_filename($fileName);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) ){
$annonces = cache_get('annonces');
@ -72,7 +73,7 @@ function scoresws_synthese($siret, $siren, $idEntreprise)
isset($_REQUEST['ratio'])? $ratio=$_REQUEST['ratio'] : $ratio='';
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'synthese-'.$idEntreprise;
}else{ $fileName = 'synthese-'.$siret; }
}else{ $fileName = 'synthese-'.$siren; }
if($ratio!=''){$fileName.='-'.$ratio;}
cache_filename($fileName);
@ -94,6 +95,11 @@ function scoresws_synthese($siret, $siren, $idEntreprise)
$ratiosInfos = $O['result']['RatiosInfos'];
$ratiosEntrep = $O['result']['RatiosEntrep'];
$ratiosEntrepEvol = $O['result']['RatiosEntrepEvol'];
$format = ratiosRatios($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $ratiosInfos, $ratiosSecteur);
while ( list($key, $val) = each( $format ) )
{
${$key} = $val;
}
cache_delete();
cache_add('ratiosEntrep',$ratiosEntrep);
cache_add('bilansInfos',$bilansInfos);
@ -111,10 +117,10 @@ function scoresws_synthese($siret, $siren, $idEntreprise)
function scoresws_bilans($siret, $siren, $idEntreprise)
{
global $client, $ratiosEntrep, $firephp, $fileName;
global $client, $ratiosEntrep, $firephp;
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'bilans-'.$idEntreprise;
}else{ $fileName = 'bilans-'.$siret; }
}else{ $fileName = 'bilans-'.$siren; }
cache_filename($fileName);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) )
{
@ -125,7 +131,6 @@ function scoresws_bilans($siret, $siren, $idEntreprise)
$dataActif = cache_get('dataActif');
$dataPassif = cache_get('dataPassif');
$dataSIG = cache_get('dataSIG');
$return = array('bilansInfos'=> $bilansInfos, 'ratiosInfo'=>$ratiosInfos, 'ratiosEntrep'=>$ratiosEntrep, 'ratiosEntrepEvol'=>$ratiosEntrepEvol,'dataActif'=>$dataActif, 'dataPassif'=>$dataPassif, 'dataSIG'=>$dataSIG);
}
else
@ -136,61 +141,11 @@ function scoresws_bilans($siret, $siren, $idEntreprise)
$ratiosInfos = $O['result']['RatiosInfos'];
$ratiosEntrep = $O['result']['RatiosEntrep'];
$ratiosEntrepEvol = $O['result']['RatiosEntrepEvol'];
//Affichage des dates dans l'ordre décroissant
//Tri des tableaux
foreach ($bilansInfos as $key => $row) {
$bilansInfos[$key]['cle'] = $key;
$date[$key] = $row['dateCloture'];
$duree[$key] = $row['duree'];
$devise[$key] = $row['devise'];
$unite[$key] = $row['unite'];
$cle[$key] = $row['cle'];
$format = ratiosBilans($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $ratiosInfos);
while ( list($key, $val) = each( $format ) )
{
${$key} = $val;
}
array_multisort($date, SORT_DESC, $duree, SORT_DESC, $devise, SORT_DESC, $unite, SORT_DESC, $cle, SORT_DESC, $bilansInfos);
//Tri des autres tableaux
$tempRatiosEntrep = $ratiosEntrep;
$tempRatiosEntrepEvol = $ratiosEntrepEvol;
$tempRatiosSecteur = $ratiosSecteur;
$i = 0;
foreach ($bilansInfos as $row){
$ratiosEntrep[$i] = $tempRatiosEntrep[$row['cle']];
$ratiosEntrepEvol[$i] = $tempRatiosEntrepEvol[$row['cle']];
$ratiosSecteur[$i] = $tempRatiosSecteur[$row['cle']];
$i++;
}
//Fin de tri des tableaux
$dataActif = array( graphPercent('r51','r22'),
graphPercent('r52','r22'),
graphPercent('r53','r22'),
graphPercent('r60','r22'),
graphPercent('r61','r22'),
graphPercent('r62','r22'),
graphPercent('r63','r22'),
);
$firephp->log($dataActif, 'scorews - dataActif');
$dataPassif = array( graphPercent('r70','r22'),
graphPercent('r71','r22'),
graphPercent('r72','r22'),
graphPercent('r83','r22'),
graphPercent('r84','r22'),
graphPercent('r85','r22'),
graphPercent('r86','r22'),
graphPercent('r87','r22'),
);
$dataSIG = array( graphPercent('r101','r101')-graphPercent('r122','r101'),
graphPercent('r122','r101')-graphPercent('r130','r101'),
graphPercent('r130','r101')-graphPercent('r140','r101'),
graphPercent('r140','r101')-graphPercent('r150','r101'),
graphPercent('r150','r101')-graphPercent('r170','r101'),
graphPercent('r170','r101')-graphPercent('r199','r101'),
graphPercent('r199','r101'),
);
cache_delete();
cache_add('bilansInfos', $bilansInfos);
cache_add('ratiosInfos', $ratiosInfos);
@ -207,21 +162,17 @@ function scoresws_bilans($siret, $siren, $idEntreprise)
$return = false;
}
}
return $return;
}
function scoresws_ratios($siret, $siren, $idEntreprise)
{
global $client, $fileName, $bilansInfos, $ratiosSecteur, $ratiosEntrep, $ratiosInfos, $firephp;
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'ratios-'.$idEntreprise;
}else{ $fileName = 'ratios-'.$siret; }
$fileName.= '-0';
if($ratio!=''){$fileName.='-'.$ratio;}
cache_filename($fileName);
}else{ $fileName = 'ratios-'.$siren; }
cache_filename($fileName);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) )
{
$bilansInfos = cache_get('bilansInfos');
@ -232,7 +183,6 @@ function scoresws_ratios($siret, $siren, $idEntreprise)
$return = array('bilansInfos'=>$bilansInfos, 'ratiosEntrep'=>$ratiosEntrep, 'ratiosEntrepEvol'=>$ratiosEntrepEvol, 'ratiosInfos'=>$ratiosInfos,'ratiosSecteur'=>$ratiosSecteur);
}else{
cache_delete();
try {
$O = $client->getRatios($siren, 'bilan');
$bilansInfos = $O['result']['BilansInfos'];
@ -240,40 +190,18 @@ function scoresws_ratios($siret, $siren, $idEntreprise)
$ratiosEntrep = $O['result']['RatiosEntrep'];
$ratiosEntrepEvol = $O['result']['RatiosEntrepEvol'];
$ratiosSecteur = $O['result']['RatiosSecteur'];
//Affichage des dates dans l'ordre décroissant
//Tri des tableaux
foreach ($bilansInfos as $key => $row) {
$bilansInfos[$key]['cle'] = $key;
$date[$key] = $row['dateCloture'];
$duree[$key] = $row['duree'];
$devise[$key] = $row['devise'];
$unite[$key] = $row['unite'];
$cle[$key] = $row['cle'];
$format = ratiosRatios($bilansInfos, $ratiosEntrep, $ratiosEntrepEvol, $ratiosInfos, $ratiosSecteur);
while ( list($key, $val) = each( $format ) )
{
${$key} = $val;
}
array_multisort($date, SORT_DESC, $duree, SORT_DESC, $devise, SORT_DESC, $unite, SORT_DESC, $cle, SORT_DESC, $bilansInfos);
//Tri des autres tableaux
$tempRatiosEntrep = $ratiosEntrep;
$tempRatiosEntrepEvol = $ratiosEntrepEvol;
$tempRatiosSecteur = $ratiosSecteur;
$i = 0;
foreach ($bilansInfos as $row){
$ratiosEntrep[$i] = $tempRatiosEntrep[$row['cle']];
$ratiosEntrepEvol[$i] = $tempRatiosEntrepEvol[$row['cle']];
$ratiosSecteur[$i] = $tempRatiosSecteur[$row['cle']];
$i++;
}
//Fin de tri des tableaux
cache_delete();
cache_add('bilansInfos', $bilansInfos);
cache_add('ratiosEntrep', $ratiosEntrep);
cache_add('ratiosEntrepEvol', $ratiosEntrepEvol);
cache_add('ratiosInfos', $ratiosInfos);
cache_add('ratiosSecteur', $ratiosSecteur);
$return = array('bilansInfos'=>$bilansInfos, 'ratiosEntrep'=>$ratiosEntrep, 'ratiosEntrepEvol'=>$ratiosEntrepEvol, 'ratiosInfos'=>$ratiosInfos,'ratiosSecteur'=>$ratiosSecteur);
}catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
@ -283,13 +211,12 @@ function scoresws_ratios($siret, $siren, $idEntreprise)
return $return;
}
function scoresws_indiscore($siret, $siren, $idEntreprise)
{
global $client, $firephp;
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'indiscore-'.$idEntreprise;
}else{ $fileName = 'indiscore-'.$siret; }
}else{ $fileName = 'indiscore-'.$siren; }
cache_filename($fileName);