extranet/www/pages/synthese.php

154 lines
5.1 KiB
PHP
Raw Normal View History

2009-03-25 09:37:17 +00:00
<?php
2009-03-25 18:32:45 +00:00
if (!$_SESSION['connected']) die();
2009-08-17 14:38:44 +00:00
require_once 'cache/cache.php';
require_once 'ratios/ratios.php';
2009-04-01 12:45:45 +00:00
2009-03-25 18:32:45 +00:00
$siret=trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
2009-03-30 16:27:40 +00:00
if (strlen($siret)<>0 && strlen($siret)<>9 && strlen($siret)<>14) die('Param<61>tres incorrects !');
2009-03-25 18:32:45 +00:00
$idEntreprise=trim(preg_replace('/[^0-9]/', '', $_REQUEST['idEntreprise']))*1; // Si id=0 alors non communiqu<71>
2009-03-30 16:27:40 +00:00
if (($siret*1)==0 && $idEntreprise==0) die('Param<61>tres incorrects !');
2009-03-25 18:32:45 +00:00
$siren=substr($siret,0,9);
isset($_REQUEST['ratio'])? $ratio=$_REQUEST['ratio'] : $ratio='';
if (($siret*1)==0 || ($siren*1)<100){ $fileName = $page2.'-'.$idEntreprise;
}else{ $fileName = $page2.'-'.$siret; }
if($ratio!=''){$fileName.='-'.$ratio;}
2009-08-17 14:38:44 +00:00
cache_filename($fileName);
$ratiosEntrep = array();
$ratiosInfos = array();
$bilansInfos = array();
$ratiosEntrepEvol = array();
2009-08-17 14:38:44 +00:00
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');
$firephp->log($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'];
2009-08-17 14:38:44 +00:00
cache_delete();
cache_add('ratiosEntrep',$ratiosEntrep);
cache_add('bilansInfos',$bilansInfos);
cache_add('ratiosInfos',$ratiosInfos);
cache_add('ratiosEntrepEvol',$ratiosEntrepEvol);
}catch (SoapFault $fault) {
require_once 'soaperror.php';
2009-08-17 14:38:44 +00:00
processSoapFault($client,$fault,$_SESSION['tabInfo']);
die();
2009-03-31 14:16:03 +00:00
}
2009-08-17 14:38:44 +00:00
}
2009-08-17 14:38:44 +00:00
//Liste des ratios pour le graphique g<>n<EFBFBD>ral
$tabRatioGraph = array( 0 => array('ratio'=>'r236', 'op' => 1000),
1 => array('ratio'=>'r235', 'op' => 1000),
2 => array('ratio'=>'r6', 'op' => 1000),
3 => array('ratio'=>'r146', 'op' => 1000));
//Liste des ratios <20> afficher
$tabRatio = array(
'r5' => array('evol'=>'r6', 'op' => 1000, 'titre'=>'CHIFFRE D\'AFFAIRES'),
'r7' => array('evol'=>'r8', 'op' => 1000, 'titre'=>'RESULTAT COURANT AVANT IMPOTS'),
'r10' => array('evol'=>'r11', 'op' => 1000, 'titre'=>'RESULTAT NET'),
'r18' => array('evol'=>'r19', 'op' => 1000, 'titre'=>'FONDS PROPRES'),
'r22' => array('evol'=>'r23', 'op' => 1000, 'titre'=>'TOTAL BILAN'),
'r231' => array('evol'=>'r235', 'op' => 1000, 'titre'=>'FONDS DE ROULEMENT'),
'r232' => array('evol'=>'r236', 'op' => 1000, 'titre'=>'BESOIN EN FONDS DE ROULEMENT'),
'r62' => array('evol'=>'r64', 'op' => 1000, 'titre'=>'TRESORERIE'),
'r24' => array('evol'=>'r24', 'op' => 1, 'titre'=>'EFFECTIF', 'unite' => 1),
);
//On souhaite n'afficher qu'un seul ratio, on r<>duit donc le tableau
if($ratio!=''){
$tabRatio = array( $ratio => $tabRatio[$ratio]);
}
$data = synthese_datagraph($bilansInfos, $ratiosEntrep, $tabRatioGraph, $tabRatio);
$dataGraph = $data['graph'];
$dataEvol = $data['evol'];
2009-08-17 14:38:44 +00:00
$firephp->log($dataEvol, 'evol');
2009-08-17 14:38:44 +00:00
?>
<div id="center">
<h1>SYNTH&Egrave;SE</h1>
<table width="570" border="0" align="left" bgcolor="#FFFFFF">
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Num&eacute;ro identifiant Siren</td>
<td width="340" class="StyleInfoData"><?=substr($siren,0,3).' '.substr($siren,3,3).' '.substr($siren,6,3)?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Raison Sociale</td>
<td width="340" class="StyleInfoData"><?=$_SESSION['tabInfo']['entrep']['raisonSociale'];?></td>
</tr>
</table>
2009-08-17 14:38:44 +00:00
<?php
if (count($ratiosEntrep)==0 || !isset($ratiosEntrep))
{
?>
<table>
<tr><td width="30">&nbsp;</td><td><b>Aucun bilan disponible pour cette entreprise !</b></td></tr>
</table>
<?php
}
else
{
?>
<table id="synthese">
<thead>
<tr>
<th align="center"><?php if($ratio!=''){?><a href="/?page=synthese&siret=<?=$_REQUEST['siret']?>&idEntreprise=<?=$_REQUEST['idEntreprise']?>" title="Retour <20> la page compl<70>te"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a><?php } ?></th>
<th class="date"><?php print synthese_formatdateCloture($bilansInfos, 2); ?></th>
<th class="date"><?php print synthese_formatdateCloture($bilansInfos, 1); ?></th>
<th class="date">Evolution</th>
<th class="date"><?php print synthese_formatdateCloture($bilansInfos, 0); ?></th>
<th class="date">Evolution</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
print synthese_tablerow($ratiosInfos, $dataEvol, $tabRatio)
?>
</tbody>
</table>
<br/>
<?php
//Affichage du graphique associ<63> au ratio s<>lectionn<6E>
if(count($tabRatio)==1){ ?>
<div id="titreEvol"><b>Evolution</b></div>
<?php
2009-08-17 14:38:44 +00:00
if(count($dataEvol[$ratio])<=1){
print "Les informations sont insuffisantes pour g<>n<EFBFBD>rer la courbe d'<27>volution";
}else{?>
<img id="imgEvol" src="./imgcache/<?=$fileName.'.png'?>" />
<?php
}
2009-08-17 14:38:44 +00:00
//Affichage du graphique g<>n<EFBFBD>ral
}else{
if(count($dataGraph)<=1){
print '<div id="graphInfo">Les informations sont insuffisantes pour g<>n<EFBFBD>rer le graphique de synth<74>se</div>';
}else{
print synthese_graph_linecompare($dataGraph, $fileName);
}
2009-08-17 14:38:44 +00:00
}
?>
<br/><br/>
<?php
2009-08-17 14:38:44 +00:00
}
?>
2009-08-17 14:38:44 +00:00
</div>