extranet/www/pages/synthese.php
Michael RICOIS dbb417888b
2009-03-30 16:41:42 +00:00

287 lines
11 KiB
PHP

<?php
if (!$_SESSION['connected']) die();
$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);
require_once 'index_auth.php';
$ratiosEntrep = array();
$ratiosInfos = array();
$bilansInfos = array();
$rationsEntrepEvol = array();
try {
$O = $client->getRatios($siren);
//$firephp->log((array)$O,'getRatios');
$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';
}else {
if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)>0) ){
print number_format($ratio/1000, 0, '', ' ').' K&euro;';
}elseif (($ratiosInfos[$nRatio]=='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];
print $ratio.' %';
}
$nbrAnnees=5;
$i=0;
foreach($bilansInfos as $dateCloture){
//Données pour le graphique
$dataGraph[$i]['date'] = $dateCloture['dateCloture'];
$dataGraph[$i]['r232'] = $ratiosEntrep[$nbrAnnees-$i]['r232'];
$dataGraph[$i]['r231'] = $ratiosEntrep[$nbrAnnees-$i]['r231'];
$dataGraph[$i]['r1'] = $ratiosEntrep[$nbrAnnees-$i]['r1'];
$dataGraph[$i]['r140'] = $ratiosEntrep[$nbrAnnees-$i]['r140'];
//Données pour les graphiques évolutions
if ($nbrAnnees-$i!=$nbrAnnees){
$evol_r1[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=> (($ratiosEntrepEvol[$nbrAnnees-$i]['r1']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r1']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r1'] : 0 )
);
$evol_r7[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=> (($ratiosEntrepEvol[$nbrAnnees-$i]['r7']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r7']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r7'] : 0 )
);
$evol_r10[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrepEvol[$nbrAnnees-$i]['r10']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r10']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r10'] : 0 )
);
$evol_r82[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrepEvol[$nbrAnnees-$i]['r82']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r82']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r82'] : 0 )
);
$evol_r22[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrepEvol[$nbrAnnees-$i]['r22']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r22']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r22'] : 0 )
);
$evol_r231[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrepEvol[$nbrAnnees-$i]['r231']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r231']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r231'] : 0 )
);
$evol_r232[] = array( 'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrepEvol[$nbrAnnees-$i]['r232']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r232']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r232'] : 0 )
);
$evol_r87[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrepEvol[$nbrAnnees-$i]['r87']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r87']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r87'] : 0 )
);
$evol_r24[] = array('date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
'value'=>(($ratiosEntrepEvol[$nbrAnnees-$i]['r24']!='NS')||($ratiosEntrep[$nbrAnnees-$i]['r24']!='NS') ? $ratiosEntrepEvol[$nbrAnnees-$i]['r24'] : 0 )
);
}
$i++;
}
//print_r($data);
?>
<script type="text/javascript" src="./js/jtip.js"></script>
<link rel="stylesheet" type="text/css" href="./css/jtip.css" />
<style>
#container
{
width: 580px;
background-color: #FFFFFF;
}
#synthese
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 0px;
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;
}
/* ----- 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;}
</style>
<div id="container">
<div><img id="entete" src="./img/rub_synthese.png" width="577" height="36"></div>
<table id="synthese">
<thead>
<tr>
<th>&nbsp;</th>
<th class="date"><?php print substr($bilansInfos[2]['dateCloture'],5,2).'/'.substr($bilansInfos[2]['dateCloture'],4,2).'/'.substr($bilansInfos[2]['dateCloture'],0,4);?><br/><?php print $bilansInfos[2]['duree']; ?> mois</th>
<th class="date"><?php print substr($bilansInfos[1]['dateCloture'],5,2).'/'.substr($bilansInfos[1]['dateCloture'],4,2).'/'.substr($bilansInfos[1]['dateCloture'],0,4);?><br/><?php print $bilansInfos[1]['duree']; ?> mois</th>
<th class="date">Evolution</th>
<th class="date"><?php print substr($bilansInfos[0]['dateCloture'],5,2).'/'.substr($bilansInfos[0]['dateCloture'],4,2).'/'.substr($bilansInfos[0]['dateCloture'],0,4);?><br/><?php print $bilansInfos[0]['duree']; ?> mois </th>
<th class="date">Evolution</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td>CHIFFRE D'AFFAIRES</td>
<td class="right"><?php dRatio(2,'r1'); ?></td>
<td class="right"><?php dRatio(1,'r1'); ?></td>
<td class="right"><?php dEvol(1,'r1'); ?></td>
<td class="right"><?php dRatio(0,'r1'); ?></td>
<td class="right"><?php dEvol(0,'r1'); ?></td>
<td><a class="jTip" id="r1" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r1))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>RESULTAT COURANT AVANT IMPOTS</td>
<td class="right"><?php dRatio(2,'r7'); ?></td>
<td class="right"><?php dRatio(1,'r7'); ?></td>
<td class="right"><?php dEvol(1,'r7'); ?></td>
<td class="right"><?php dRatio(0,'r7'); ?></td>
<td class="right"><?php dEvol(0,'r7'); ?></td>
<td><a class="jTip" id="r7" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r7))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>RESULTAT NET</td>
<td class="right"><?php dRatio(2,'r10'); ?></td>
<td class="right"><?php dRatio(1,'r10'); ?></td>
<td class="right"><?php dEvol(1,'r10'); ?></td>
<td class="right"><?php dRatio(0,'r10'); ?></td>
<td class="right"><?php dEvol(0,'r10'); ?></td>
<td><a class="jTip" id="r10" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r10))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>FONDS PROPRES</td>
<td class="right"><?php dRatio(2,'r82'); ?></td>
<td class="right"><?php dRatio(1,'r82'); ?></td>
<td class="right"><?php dEvol(1,'r82'); ?></td>
<td class="right"><?php dRatio(0,'r82'); ?></td>
<td class="right"><?php dEvol(0,'r82'); ?></td>
<td class="right"><a class="jTip" id="r82" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r82))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>TOTAL BILAN</td>
<td class="right"><?php dRatio(2,'r22'); ?></td>
<td class="right"><?php dRatio(1,'r22'); ?></td>
<td class="right"><?php dEvol(1,'r22'); ?></td>
<td class="right"><?php dRatio(0,'r22'); ?></td>
<td class="right"><?php dEvol(0,'r22'); ?></td>
<td><a class="jTip" id="r22" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r22))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>FONDS DE ROULEMENT</td>
<td class="right"><?php dRatio(2,'r231'); ?></td>
<td class="right"><?php dRatio(1,'r231'); ?></td>
<td class="right"><?php dEvol(1,'r231'); ?></td>
<td class="right"><?php dRatio(0,'r231'); ?></td>
<td class="right"><?php dEvol(0,'r231'); ?></td>
<td><a class="jTip" id="r231" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r231))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>BESOIN EN FONDS DE ROULEMENT</td>
<td class="right"><?php dRatio(2,'r232'); ?></td>
<td class="right"><?php dRatio(1,'r232'); ?></td>
<td class="right"><?php dEvol(1,'r232'); ?></td>
<td class="right"><?php dRatio(0,'r232'); ?></td>
<td class="right"><?php dEvol(0,'r232'); ?></td>
<td><a class="jTip" id="r232" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r232))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>TRESORERIE</td>
<td class="right"><?php dRatio(2,'r87'); ?></td>
<td class="right"><?php dRatio(1,'r87'); ?></td>
<td class="right"><?php dEvol(1,'r87'); ?></td>
<td class="right"><?php dRatio(0,'r87'); ?></td>
<td class="right"><?php dEvol(0,'r87'); ?></td>
<td><a class="jTip" id="r87" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r87))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
<tr>
<td>EFFECTIF</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="r24" href="./graphs/synthese_dgraph.php?width=375&data=<?=urlencode(serialize($evol_r24))?>" name="Evolution :"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>
</tr>
</tbody>
</table>
<img src="./graphs/synthese_graph_linecompare.php?data=<?=urlencode(serialize($dataGraph))?>" />
</div>