extranet/www/pages/synthese.php
2009-04-21 07:46:21 +00:00

411 lines
15 KiB
PHP

<?php
if (!$_SESSION['connected']) die();
$tabInfo = $_SESSION['tabInfo'];
$siret=trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
if (strlen($siret)<>0 && strlen($siret)<>9 && strlen($siret)<>14) die('Paramètres incorrects !');
$idEntreprise=trim(preg_replace('/[^0-9]/', '', $_REQUEST['idEntreprise']))*1; // Si id=0 alors non communiqué
if (($siret*1)==0 && $idEntreprise==0) die('Paramètres incorrects !');
$siren=substr($siret,0,9);
$ratiosEntrep = array();
$ratiosInfos = array();
$bilansInfos = array();
$rationsEntrepEvol = array();
try {
$O = $client->getRatios($siren, 'synthese');
//$firephp->log((array)$O,'getRatios');
print '<!--';
print_r($O['result']);
print '-->';
$bilansInfos = $O['result']['BilansInfos'];
$ratiosInfos = $O['result']['RatiosInfos'];
$ratiosEntrep = $O['result']['RatiosEntrep'];
$ratiosEntrepEvol = $O['result']['RatiosEntrepEvol'];
}catch (SoapFault $fault) {
include_once(realpath(dirname(__FILE__).'/../../').'/includes/soaperror.php');
processSoapFault($client,$fault,$tabInfo);
die();
}
function dRatio($nAnnee,$nRatio){
global $ratiosEntrep;
global $ratiosInfos;
$ratio = $ratiosEntrep[$nAnnee][$nRatio];
if ($ratio=='NS') {
print 'NS';
}elseif($ratio==NULL){
print '-';
}else {
if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)>0) ){
print number_format($ratio/1000, 0, '', ' ').' K&euro;';
}elseif (($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)<0)) {
print number_format($ratio, 0, '', ' ').' &euro;';
}else{
print $ratio.' '.$ratiosInfos[$nRatio]['unite'];
}
}
}
function dEvol($nAnnee,$nRatio){
global $ratiosEntrepEvol;
$ratio = $ratiosEntrepEvol[$nAnnee][$nRatio];
if ($ratio=='NS') {
print 'NS';
}elseif($ratio==NULL){
print '-';
}else{
print $ratio.' %';
}
}
$nbrAnnees=count($bilansInfos)-1;
$i=0;
foreach($bilansInfos as $dateCloture){
//Données pour le graphique
if(isset($dateCloture['dateCloture'])){
$dataGraph[$i]['date'] = $dateCloture['dateCloture'];
$dataGraph[$i]['r236'] = $ratiosEntrep[$i]['r236']/1000;
$dataGraph[$i]['r235'] = $ratiosEntrep[$i]['r235']/1000;
$dataGraph[$i]['r6'] = $ratiosEntrep[$i]['r6']/1000;
$dataGraph[$i]['r146'] = $ratiosEntrep[$i]['r146']/1000;
}
if(isset($bilansInfos[$nbrAnnees-$i]['dateCloture'])){
//Données pour les graphiques évolutions
$evol_r5[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r6']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r6']/1000 : 0 )
);
$evol_r7[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r8']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r8']/1000 : 0 )
);
$evol_r10[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r11']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r11']/1000 : 0 )
);
$evol_r18[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r19']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r19']/1000 : 0 )
);
$evol_r22[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r23']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r23']/1000 : 0 )
);
$evol_r231[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r235']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r235']/1000 : 0 )
);
$evol_r232[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r236']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r236']/1000 : 0 )
);
$evol_r63[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r64']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r64']/1000 : 0 )
);
$evol_r24[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrep[$nbrAnnees-$i]['r24']!='NS') ? $ratiosEntrep[$nbrAnnees-$i]['r24'] : 0 )
);
}
$i++;
}
//Création du fichier image
//<img src="./graphs/synthese_graph_linecompare.php?d=<?=urlencode(serialize($dataGraph));>" />
//Générer un nom de fichier pour le cache et l'export des fichiers
if (($siret*1)==0 || ($siren*1)<100){
$fileName = $page2.'-'.$idEntreprise;
}else{
$fileName = $page2.'-'.$siret;
}
$fileName.= '-graph-linecompare.tmp';
$path = '../cache/';
file_put_contents($path.$fileName, serialize($dataGraph));
?>
<script type="text/javascript" src="./js/jquery.simpletip.js"></script>
<script type="text/javascript" src="./js/jtip.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#r5").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r5 > .tooltip").text()});
$("#r7").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r7 > .tooltip").text()});
$("#r10").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r10 > .tooltip").text()});
$("#r18").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r18 > .tooltip").text()});
$("#r22").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r22 > .tooltip").text()});
$("#r231").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r231 > .tooltip").text()});
$("#r232").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r232 > .tooltip").text()});
$("#r63").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r63 > .tooltip").text()});
$("#r24").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r24 > .tooltip").text()});
});
</script>
<link rel="stylesheet" type="text/css" href="./css/jtip.css" />
<style>
#container
{
width: 580px;
background-color: #FFFFFF;
}
#synthese
{
clear:both;
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 10px 0 0 0;
width: 580px;
text-align: left;
border-collapse: collapse;
}
#synthese thead th.rounded-company
{
background: #b9c9fe url('./img/synthese/left.png') left -1px no-repeat;
}
#synthese thead th.rounded-q5
{
background: #b9c9fe url('./img/synthese/right.png') right -1px no-repeat;
}
#synthese th
{
padding: 4px;
font-weight: normal;
font-size: 13px;
color: #039;
background: #b9c9fe;
border: 1px solid #fff;
}
#synthese th.date {
font-size: 11px;
}
#synthese td
{
padding: 4px;
background: #e8edff;
border: 1px solid #fff;
color: #669;
}
#synthese td.right {
text-align: right;
}
#synthese tfoot td.rounded-foot-left
{
background: #e8edff url('./img/synthese/botleft.png') left bottom no-repeat;
}
#synthese tfoot td.rounded-foot-right
{
background: #e8edff url('./img/synthese/botright.png') right bottom no-repeat;
}
#synthese tbody tr:hover td
{
background: #d0dafd;
}
#entete {
margin:1px;
}
#synthese .head {
font-weight:bold;
}
#graphInfo {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
margin-left:10px;
}
/* ----- add selectors here for font sizing ----- */
#JT_close_left, #JT_close_right{font-size: 12px;}
#JT_copy p, #JT_copy ul{font-size: 12px;}
p, label{font-size: 12px;}
ul{list-style: none;}
ul li{padding-top:3px;}
.tooltip{
display:none;
position: absolute;
padding: 10px 10px;
width: 300px;
z-index: 3;
color: #303030;
background-color: #f5f5b5;
border: 1px solid #DECA7E;
font-family: sans-serif;
font-weight:normal;
font-size: 12px;
line-height: 16px;
}
.info {
margin-left:10px;
cursor:help;
font-weight:bold;
}
</style>
<div id="container">
<div><img id="entete" src="./img/rub_synthese.png" width="577" height="36"></div>
<table width="580" 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="350" 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="350" class="StyleInfoData"><?=$tabInfo['entrep']['raisonSociale'];?></td>
</tr>
</table>
<?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>&nbsp;</th>
<th class="date">
<?php
if(isset($bilansInfos[2]['dateCloture'])) {
print substr($bilansInfos[2]['dateCloture'],6,2).'/'.substr($bilansInfos[2]['dateCloture'],4,2).'/'.substr($bilansInfos[2]['dateCloture'],0,4);?><br/><?php print $bilansInfos[2]['duree']; ?> mois
<?php }else{ print '-'; } ?>
</th>
<th class="date">
<?php
if(isset($bilansInfos[1]['dateCloture'])) {
print substr($bilansInfos[1]['dateCloture'],6,2).'/'.substr($bilansInfos[1]['dateCloture'],4,2).'/'.substr($bilansInfos[1]['dateCloture'],0,4);?><br/><?php print $bilansInfos[1]['duree']; ?> mois
<?php }else{ print '-'; } ?>
</th>
<th class="date">Evolution</th>
<th class="date">
<?php
if(isset($bilansInfos[0]['dateCloture'])) {
print substr($bilansInfos[0]['dateCloture'],6,2).'/'.substr($bilansInfos[0]['dateCloture'],4,2).'/'.substr($bilansInfos[0]['dateCloture'],0,4);?><br/><?php print $bilansInfos[0]['duree']; ?> mois
<?php }else{ print '-'; } ?>
</th>
<th class="date">Evolution</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td class="head"><a id="r5">CHIFFRE D'AFFAIRES<div class="tooltip"><?=$ratiosInfos['r5']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r5'); ?></td>
<td class="right"><?php dRatio(1,'r5'); ?></td>
<td class="right"><?php dEvol(1,'r6'); ?></td>
<td class="right"><?php dRatio(0,'r5'); ?></td>
<td class="right"><?php dEvol(0,'r6'); ?></td>
<td><a class="jTip" id="gr1" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r5))?>" name="CHIFFRE D'AFFAIRES :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r7">RESULTAT COURANT AVANT IMPOTS<div class="tooltip"><?=$ratiosInfos['r7']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r7'); ?></td>
<td class="right"><?php dRatio(1,'r7'); ?></td>
<td class="right"><?php dEvol(1,'r8'); ?></td>
<td class="right"><?php dRatio(0,'r7'); ?></td>
<td class="right"><?php dEvol(0,'r8'); ?></td>
<td><a class="jTip" id="gr7" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r7))?>" name="RESULTAT COURANT AVANT IMPOTS :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r10">RESULTAT NET<div class="tooltip"><?=$ratiosInfos['r10']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r10'); ?></td>
<td class="right"><?php dRatio(1,'r10'); ?></td>
<td class="right"><?php dEvol(1,'r11'); ?></td>
<td class="right"><?php dRatio(0,'r10'); ?></td>
<td class="right"><?php dEvol(0,'r11'); ?></td>
<td><a class="jTip" id="gr10" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r10))?>" name="RESULTAT NET :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r18">FONDS PROPRES<div class="tooltip"><?=$ratiosInfos['r18']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r18'); ?></td>
<td class="right"><?php dRatio(1,'r18'); ?></td>
<td class="right"><?php dEvol(1,'r19'); ?></td>
<td class="right"><?php dRatio(0,'r18'); ?></td>
<td class="right"><?php dEvol(0,'r19'); ?></td>
<td class="right"><a class="jTip" id="gr82" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r18))?>" name="FONDS PROPRES :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r22">TOTAL BILAN<div class="tooltip"><?=$ratiosInfos['r22']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r22'); ?></td>
<td class="right"><?php dRatio(1,'r22'); ?></td>
<td class="right"><?php dEvol(1,'r23'); ?></td>
<td class="right"><?php dRatio(0,'r22'); ?></td>
<td class="right"><?php dEvol(0,'r23'); ?></td>
<td><a class="jTip" id="gr22" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r22))?>" name="TOTAL BILAN :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r231">FONDS DE ROULEMENT<div class="tooltip"><?=$ratiosInfos['r231']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r231'); ?></td>
<td class="right"><?php dRatio(1,'r231'); ?></td>
<td class="right"><?php dEvol(1,'r235'); ?></td>
<td class="right"><?php dRatio(0,'r231'); ?></td>
<td class="right"><?php dEvol(0,'r235'); ?></td>
<td><a class="jTip" id="gr231" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r231))?>" name="FONDS DE ROULEMENT :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r232">BESOIN EN FONDS DE ROULEMENT<div class="tooltip"><?=$ratiosInfos['r232']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r232'); ?></td>
<td class="right"><?php dRatio(1,'r232'); ?></td>
<td class="right"><?php dEvol(1,'r236'); ?></td>
<td class="right"><?php dRatio(0,'r232'); ?></td>
<td class="right"><?php dEvol(0,'r236'); ?></td>
<td><a class="jTip" id="gr232" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r232))?>" name="BESOIN EN FONDS DE ROULEMENT :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r63">TRESORERIE<div class="tooltip"><?=$ratiosInfos['r63']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r63'); ?></td>
<td class="right"><?php dRatio(1,'r63'); ?></td>
<td class="right"><?php dEvol(1,'r64'); ?></td>
<td class="right"><?php dRatio(0,'r63'); ?></td>
<td class="right"><?php dEvol(0,'r64'); ?></td>
<td><a class="jTip" id="gr63" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r63))?>" name="TRESORERIE :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td class="head"><a id="r24">EFFECTIF<div class="tooltip"><?=$ratiosInfos['r24']['commentaires']?></div></a></td>
<td class="right"><?php dRatio(2,'r24'); ?></td>
<td class="right"><?php dRatio(1,'r24'); ?></td>
<td class="right"><?php dEvol(1,'r24'); ?></td>
<td class="right"><?php dRatio(0,'r24'); ?></td>
<td class="right"><?php dEvol(0,'r24'); ?></td>
<td><a class="jTip" id="gr24" href="./pages/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r24))?>&unite=<?=$ratiosInfos['r24']['unite']?>" name="EFFECTIF :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
</tbody>
</table>
<br/><br/>
<?php
if(count($dataGraph)<=1){
print "<div id=\"graphInfo\">Les informations sont insuffisantes pour générer le graphique de synthèse</div>";
}else{
?>
<img src="./graphs/synthese_graph_linecompare.php?d=<?=$fileName?>" />
<?php
}
?>
<br/><br/>
<?php
}
?>
</div>