extranet/includes/scoresws/scoresws.php
2009-09-24 09:26:55 +00:00

314 lines
11 KiB
PHP

<?php
require_once 'cache/cache.php';
function scoresws_identite($siret, $siren, $idEntreprise)
{
global $client, $firephp;
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'identite-'.$idEntreprise;
}else{ $fileName = 'identite-'.$siret; }
cache_filename($fileName);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) )
{
$return = cache_get('etab');
}else{
$return = null;
try {
$O = $client->getIdentite($siret, $idEntreprise);
$return = $O['result'];
cache_delete();
cache_add('etab', $return);
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
$return = false;
}
}
return $return;
}
function scoresws_annonces($siret, $siren, $idEntreprise, $vue, $idan)
{
global $client, $firephp;
//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; }
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');
$return = $annonces;
}else{
if ($vue=='bodacc' || $_REQUEST['source']==1) $filtre=1;
elseif ($vue=='balo') $filtre=2;
elseif ($vue=='asso') $filtre=3;
else $filtre=0;
if ($_SESSION['tabInfo']['entrep']['fj']>9000 && $_SESSION['tabInfo']['entrep']['fj']<9999 && $siren==0)
{
$filtre=3;
}
try {
$O = $client->getAnnonces($siren, $filtre, $idan);
$annonces = $O['result'];
cache_delete();
cache_add('annonces', $annonces);
$return = $annonces;
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
$return = false;
}
}
return $return;
}
function scoresws_synthese($siret, $siren, $idEntreprise)
{
global $client, $firephp, $fileName;
isset($_REQUEST['ratio'])? $ratio=$_REQUEST['ratio'] : $ratio='';
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'synthese-'.$idEntreprise;
}else{ $fileName = 'synthese-'.$siret; }
if($ratio!=''){$fileName.='-'.$ratio;}
cache_filename($fileName);
$ratiosEntrep = array();
$ratiosInfos = array();
$bilansInfos = array();
$ratiosEntrepEvol = array();
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) ){
$ratiosEntrep = cache_get('ratiosEntrep');
$ratiosInfos = cache_get('ratiosInfos');
$bilansInfos = cache_get('bilansInfos');
$ratiosEntrepEvol = cache_get('ratiosEntrepEvol');
$return = array('bilansInfos'=>$bilansInfos, 'ratiosInfos'=>$ratiosInfos, 'ratiosEntrep'=>$ratiosEntrep, 'ratiosEntrepEvol'=>$ratiosEntrepEvol);
}else{
try {
$O = $client->getRatios($siren, 'synthese');
$bilansInfos = $O['result']['BilansInfos'];
$ratiosInfos = $O['result']['RatiosInfos'];
$ratiosEntrep = $O['result']['RatiosEntrep'];
$ratiosEntrepEvol = $O['result']['RatiosEntrepEvol'];
cache_delete();
cache_add('ratiosEntrep',$ratiosEntrep);
cache_add('bilansInfos',$bilansInfos);
cache_add('ratiosInfos',$ratiosInfos);
cache_add('ratiosEntrepEvol',$ratiosEntrepEvol);
$return = array('bilansInfos'=>$bilansInfos, 'ratiosInfos'=>$ratiosInfos, 'ratiosEntrep'=>$ratiosEntrep, 'ratiosEntrepEvol'=>$ratiosEntrepEvol);
}catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
$return = false;
}
}
return $return;
}
function scoresws_bilans($siret, $siren, $idEntreprise)
{
global $client, $ratiosEntrep, $firephp, $fileName;
if (($siret*1)==0 || ($siren*1)<100){ $fileName = 'bilans-'.$idEntreprise;
}else{ $fileName = 'bilans-'.$siret; }
cache_filename($fileName);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) )
{
$bilansInfos = cache_get('bilansInfos');
$ratiosInfos = cache_get('ratiosInfos');
$ratiosEntrep = cache_get('ratiosEntrep');
$ratiosEntrepEvol = cache_get('ratiosEntrepEvol');
$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
{
try {
$O = $client->getRatios($siren, 'bilan');
$bilansInfos = $O['result']['BilansInfos'];
$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'];
}
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);
cache_add('ratiosEntrep', $ratiosEntrep);
cache_add('ratiosEntrepEvol', $ratiosEntrepEvol);
cache_add('dataActif', $dataActif);
cache_add('dataPassif', $dataPassif);
cache_add('dataSIG', $dataSIG);
$return = array('bilansInfos'=> $bilansInfos, 'ratiosInfo'=>$ratiosInfos, 'ratiosEntrep'=>$ratiosEntrep, 'ratiosEntrepEvol'=>$ratiosEntrepEvol,'dataActif'=>$dataActif, 'dataPassif'=>$dataPassif, 'dataSIG'=>$dataSIG);
}catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
$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);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) )
{
$bilansInfos = cache_get('bilansInfos');
$ratiosEntrep = cache_get('ratiosEntrep');
$ratiosEntrepEvol = cache_get('ratiosEntrepEvol');
$ratiosInfos = cache_get('ratiosInfos');
$ratiosSecteur = cache_get('ratiosSecteur');
$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'];
$ratiosInfos = $O['result']['RatiosInfos'];
$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'];
}
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_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']);
$return = false;
}
}
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; }
cache_filename($fileName);
if( cache_exist() && !( preg_match('/saisie/i', $_SESSION['tabInfo']['droits']) || $_SESSION['tabInfo']['mode_edition']==1 ) ){
$etab = cache_get('etab');
$return = $etab;
}else{
try {
$O = $client->getIndiscore($siren);
$etab = $O['result'];
cache_delete();
cache_add('etab', $etab);
$return = $etab;
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$_SESSION['tabInfo']);
$return = false;
}
}
return $return;
}