extranet/www/pages/ratios.php

526 lines
19 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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);
isset($_REQUEST['bilan']) ? $bilan=$_REQUEST['bilan'] : $bilan=0 ;
$ratiosEntrep = array();
$ratiosInfos = array();
$bilansInfos = array();
$rationsEntrepEvol = array();
try {
$O = $client->getRatios($siren);
$bilansInfos = $O['result']['BilansInfos'];
$ratiosInfos = $O['result']['RatiosInfos'];
$ratiosEntrep = $O['result']['RatiosEntrep'];
$ratiosEntrepEvol = $O['result']['RatiosEntrepEvol'];
$ratiosSecteur = $O['result']['RatiosSecteur'];
print '<!--';
print_r($O['result']);
print '-->';
}catch (SoapFault $fault) {
include_once(realpath(dirname(__FILE__).'/../../').'/includes/soaperror.php');
processSoapFault($client,$fault,$tabInfo);
die();
}
function dPosition($nAnnee,$nRatio,$compare){
global $ratiosSecteur;
global $ratiosEntrep;
$ratioS = $ratiosSecteur[$nAnnee][$nRatio];
$ratioE = $ratiosEntrep[$nAnnee][$nRatio];
$ecart = 1/100;
if( $ratioS=='NS' || $ratioE=='NS' || $ratioS==NULL || $ratioE==NULL){
print '-';
}elseif($compare=='>'){
if( $ratioE+$ecart > $ratioS ){
print '<img src="./img/ratios_bon.png" />';
}elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){
print '-';
}else{
print '<img src="./img/ratios_mauvais.png" />';
}
}elseif($compare=='<'){
if($ratioE < $ratioS){
print '<img src="./img/ratios_bon.png" />';
}elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){
print '-';
}else{
print '<img src="./img/ratios_mauvais.png" />';
}
}
}
function dSecteur($nAnnee,$nRatio){
global $ratiosSecteur;
global $ratiosInfos;
$ratio = $ratiosSecteur[$nAnnee][$nRatio];
$return = '';
$formatRatio = TRUE;
if ($ratio=='NS') {
$return.= 'NS';
$formatRatio = FALSE;
}elseif(substr($ratio,0,1)=='<' ){
$return.= '< ';
$ratio = substr($ratio,1)*1;
}elseif(substr($ratio,0,1)=='>'){
$return.= '> ';
$ratio = substr($ratio,1)*1;
}elseif($ratio==NULL){
$return.= '-';
$formatRatio = FALSE;
}
if($formatRatio == TRUE) {
if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)>0) ){
$return.= number_format($ratio/1000, 0, '', ' ').' K&euro;';
}elseif (($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)<0)) {
$return.= number_format($ratio, 0, '', ' ').' &euro;';
}elseif (($ratiosInfos[$nRatio]['unite']=='Jours')) {
$return.= number_format($ratio, 0, '', ' ').' '.$ratiosInfos[$nRatio]['unite'];
}elseif (($ratiosInfos[$nRatio]['unite']=='AN')) {
$return.= round($ratio, 2).' '.$ratiosInfos[$nRatio]['unite'];
}elseif (($ratiosInfos[$nRatio]['unite']=='%')) {
$return.= round($ratio).' '.$ratiosInfos[$nRatio]['unite'];
}else{
$return.= $ratio.' '.$ratiosInfos[$nRatio]['unite'];
}
}
print $return;
}
function dRatio($nAnnee,$nRatio){
global $ratiosEntrep;
global $ratiosInfos;
$ratio = $ratiosEntrep[$nAnnee][$nRatio];
$return = '';
$formatRatio = TRUE;
if ($ratio=='NS') {
$return.= 'NS';
$formatRatio = FALSE;
}elseif(substr($ratio,0,1)=='<' ){
$return.= '< ';
$ratio = substr($ratio,1)*1;
}elseif(substr($ratio,0,1)=='>'){
$return.= '> ';
$ratio = substr($ratio,1)*1;
}elseif($ratio==NULL){
$return.= '-';
$formatRatio = FALSE;
}
if($formatRatio == TRUE) {
if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)>0) ){
$return.= number_format($ratio/1000, 0, '', ' ').' K&euro;';
}elseif (($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)<0)) {
$return.= number_format($ratio, 0, '', ' ').' &euro;';
}elseif (($ratiosInfos[$nRatio]['unite']=='Jours')) {
$return.= number_format($ratio, 0, '', ' ').' '.$ratiosInfos[$nRatio]['unite'];
}elseif (($ratiosInfos[$nRatio]['unite']=='AN')) {
$return.= round($ratio, 2).' '.$ratiosInfos[$nRatio]['unite'];
}elseif (($ratiosInfos[$nRatio]['unite']=='%')) {
$return.= round($ratio).' '.$ratiosInfos[$nRatio]['unite'];
}else{
$return.= $ratio.' '.$ratiosInfos[$nRatio]['unite'];
}
}
print $return;
}
?>
<script type="text/javascript" src="./js/jquery.simpletip.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#r235").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r235 > .tooltip").text()});
$("#r236").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r236 > .tooltip").text()});
$("#r233").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r233 > .tooltip").text()});
$("#r234").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r234 > .tooltip").text()});
$("#r237").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r237 > .tooltip").text()});
$("#r238").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r238 > .tooltip").text()});
$("#r239").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r239 > .tooltip").text()});
$("#r240").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r240 > .tooltip").text()});
$("#r262").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r262 > .tooltip").text()});
$("#r263").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r263 > .tooltip").text()});
$("#r264").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r264 > .tooltip").text()});
$("#r265").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r265 > .tooltip").text()});
$("#r266").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r266 > .tooltip").text()});
$("#r250").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r250 > .tooltip").text()});
$("#r251").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r251 > .tooltip").text()});
$("#r252").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r252 > .tooltip").text()});
$("#r244").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r244 > .tooltip").text()});
$("#r247").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r247 > .tooltip").text()});
$("#r248").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r248 > .tooltip").text()});
$("#r271").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r271 > .tooltip").text()});
$("#r278").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r278 > .tooltip").text()});
$("#r279").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r279 > .tooltip").text()});
$("#r281").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r281 > .tooltip").text()});
$("#r261").simpletip({ fixed: true, position: 'bottom', content: $(this).find("#r261 > .tooltip").text()});
});
</script>
<style>
#container
{
width: 580px;
background-color: #FFFFFF;
}
#ratios
{
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;
}
#ratios a {
color:#000000;
cursor:help;
}
#ratios th
{
padding: 8px;
font-weight: normal;
font-size: 13px;
color: #039;
background: #b9c9fe;
}
#ratios td
{
padding: 8px;
border: 1px solid #000;
color: #000;
}
#ratios td.center {
text-align: center;
}
#ratios td.italique {
font-style: italic ;
}
#ratios td.right {
text-align: right;
}
#ratios td.position {
text-align: center;
}
#ratios tr.subhead td
{
padding: 8px;
background: #b9c9fe;
border: 1px solid #000;
font-weight: bold;
color: #000;
}
#entete {
margin:1px;
}
#secteur{
margin-top:10px;
}
.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;
}
</style>
<div id="container">
<div><img id="entete" src="./img/rub_ratios.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>
<br/><br/>
<?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{
$firephp->log($tabInfo,'tabInfo');
?>
<br/><br/>
<table width="580" border="0" align="left" bgcolor="#FFFFFF">
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Secteur d'activité :</td>
<td width="350" class="StyleInfoData">
<?php print $tabInfo['entrep']['nafEn']; ?> - <?php print $tabInfo['entrep']['nafEnLib']; ?>
</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Millesime</td>
<td width="350" class="StyleInfoData">
<form name="selectBilan" method="post" action="index.php?<?=$_SERVER['QUERY_STRING'];?>">
<select name="bilan">
<?php
$countBilans = 0;
if(count($bilansInfos)>0){
foreach($bilansInfos as $bilanItem){
if(isset($bilanItem['dateCloture'])) {
?>
<option value="<?php print $countBilans;?>"<?php if($bilan==$countBilans){ print 'selected="selected"';} ?>><?php print substr($bilanItem['dateCloture'],6,2).'/'.substr($bilanItem['dateCloture'],4,2).'/'.substr($bilanItem['dateCloture'],0,4);?></option>
<?php
}
$countBilans++;
}
}else{ print '-'; }
?>
</select>
&nbsp;<a href="javascript:document.selectBilan.submit();">Modifier le millesime</a>
</form>
</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Durée du bilan</td>
<td width="350" class="StyleInfoData">
<?php
$firephp->log($bilan, 'bilan');
if(isset($bilansInfos[$bilan]['dateCloture'])) {
print $bilansInfos[$bilan]['duree']; ?> mois
<?php }else{ print '-'; } ?>
</td>
</tr>
</table>
<br/><br/>
<table id="ratios">
<tbody>
<tr class="subhead">
<td class="center italique">EQUILIBRE FINANCIER</td>
<td>Entreprise</td>
<td>Secteur</td>
<td>Position</td>
</tr>
<!--
<tr>
<td><a id="r235">FR (FONDS DE ROULEMENT)<div class="tooltip"><?=$ratiosInfos['r231']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r235'); ?></td>
<td class="right"><?php dSecteur($bilan,'r235'); ?></td>
<td class="position"><?php dPosition($bilan,'r235','>'); ?></td>
</tr>
<tr>
<td><a id="r236">BFR (Besoin en fonds de roulement)<div class="tooltip"><?=$ratiosInfos['r232']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r236'); ?></td>
<td class="right"><?php dSecteur($bilan,'r236'); ?></td>
<td class="position"><?php dPosition($bilan,'r236','<'); ?></td>
</tr>
-->
<tr>
<td><a id="r233">MARGE BRUTE D'AUTOFINANCEMENT (MBA) ou CAF<div class="tooltip"><?=$ratiosInfos['r233']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r233'); ?></td>
<td class="right"><?php dSecteur($bilan,'r233'); ?></td>
<td class="position"><?php dPosition($bilan,'r233','>'); ?></td>
</tr>
<tr>
<td><a id="r234">COUVERTURE du BFR (FR/BFR)<div class="tooltip"><?=$ratiosInfos['r234']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r234'); ?></td>
<td class="right"><?php dSecteur($bilan,'r234'); ?></td>
<td class="position"><?php dPosition($bilan,'r234','>'); ?></td>
</tr>
<tr>
<td><a id="r237">COUVERTURE des IMMOS NETTES <br/>capitaux permanents/immobilisations nettes<div class="tooltip"><?=$ratiosInfos['r237']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r237'); ?></td>
<td class="right"><?php dSecteur($bilan,'r237'); ?></td>
<td class="position"><?php dPosition($bilan,'r237','>'); ?></td>
</tr>
<tr>
<td><a id="r238">COUVERTURE du CA <br/>fond de roulement net global sur 12m x 360 / chiffre d'affaire<div class="tooltip"><?=$ratiosInfos['r238']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r238'); ?></td>
<td class="right"><?php dSecteur($bilan,'r238'); ?></td>
<td class="position"><?php dPosition($bilan,'r238','>'); ?></td>
</tr>
<tr>
<td><a id="r239">SOLVABILITE capitaux propres / ensemble des dettes<div class="tooltip"><?=$ratiosInfos['r239']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r239'); ?></td>
<td class="right"><?php dSecteur($bilan,'r239'); ?></td>
<td class="position"><?php dPosition($bilan,'r239','>'); ?></td>
</tr>
<tr>
<td><a id="r240">INDEPENDANCE FINANCIERE (Cap.propres/Capitaux permanents)<div class="tooltip"><?=$ratiosInfos['r240']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r240'); ?></td>
<td class="right"><?php dSecteur($bilan,'r240'); ?></td>
<td class="position"><?php dPosition($bilan,'r240','>'); ?></td>
</tr>
<tr class="subhead">
<td class="center italique">PROFITABILITE</td>
<td>Entreprise</td>
<td>Secteur</td>
<td>Position</td>
</tr>
<tr>
<td><a id="r262">RENTABILITE ECONOMIQUE (EBE/TOTAL bilan)<div class="tooltip"><?=$ratiosInfos['r262']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r262'); ?></td>
<td class="right"><?php dSecteur($bilan,'r262'); ?></td>
<td class="position"><?php dPosition($bilan,'r262','>'); ?></td>
</tr>
<tr>
<td><a id="r263">RENTABILITE FINANCIERE (Résult.Net/Cap.propres)<div class="tooltip"><?=$ratiosInfos['r263']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r263'); ?></td>
<td class="right"><?php dSecteur($bilan,'r263'); ?></td>
<td class="position"><?php dPosition($bilan,'r263','>'); ?></td>
</tr>
<tr>
<td><a id="r264">RENTABILITE COMMERCIALE (résultat net/CA)<div class="tooltip"><?=$ratiosInfos['r264']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r264'); ?></td>
<td class="right"><?php dSecteur($bilan,'r264'); ?></td>
<td class="position"><?php dPosition($bilan,'r264','>'); ?></td>
</tr>
<tr>
<td><a id="r265">CONTRIBUTION DU CAPITAL<br/>Capacité d'autofinancement sur 12 mois / capitaux permanents<div class="tooltip"><?=$ratiosInfos['r265']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r265'); ?></td>
<td class="right"><?php dSecteur($bilan,'r265'); ?></td>
<td class="position"><?php dPosition($bilan,'r265','>'); ?></td>
</tr>
<tr>
<td><a id="r266">CONTRIBUTION DE LA VA<br/>capacité d'autofinancement / valeur ajoutée<div class="tooltip"><?=$ratiosInfos['r266']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r266'); ?></td>
<td class="right"><?php dSecteur($bilan,'r266'); ?></td>
<td class="position"><?php dPosition($bilan,'r266','>'); ?></td>
</tr>
<tr class="subhead">
<td class="center italique">LIQUIDITE</td>
<td>Entreprise</td>
<td>Secteur</td>
<td>Position</td>
</tr>
<tr>
<td><a id="r250">LIQUIDITE IMMEDIATE : (Disponibilité/Dettes CT)<div class="tooltip"><?=$ratiosInfos['r250']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r250'); ?></td>
<td class="right"><?php dSecteur($bilan,'r250'); ?></td>
<td class="position"><?php dPosition($bilan,'r250','>'); ?></td>
</tr>
<tr>
<td><a id="r251">LIQUIDITE GENERALE : (Act.circulant net/Dettes CT)<div class="tooltip"><?=$ratiosInfos['r251']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r251'); ?></td>
<td class="right"><?php dSecteur($bilan,'r251'); ?></td>
<td class="position"><?php dPosition($bilan,'r251','>'); ?></td>
</tr>
<tr>
<td><a id="r252">LIQUIDITE REDUITE: Disponibilité et créances réelles /Dettes CT)<div class="tooltip"><?=$ratiosInfos['r252']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r252'); ?></td>
<td class="right"><?php dSecteur($bilan,'r252'); ?></td>
<td class="position"><?php dPosition($bilan,'r252','>'); ?></td>
</tr>
<tr class="subhead">
<td class="center italique">ENDETTEMENT</td>
<td>Entreprise</td>
<td>Secteur</td>
<td class="position">Position</td>
</tr>
<tr>
<td><a id="r244">ENDETTEMENT (dettes a + 1 an / capitaux propres)<div class="tooltip"><?=$ratiosInfos['r244']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r244'); ?></td>
<td class="right"><?php dSecteur($bilan,'r244'); ?></td>
<td class="position"><?php dPosition($bilan,'r244','<'); ?></td>
</tr>
<tr>
<td><a id="r247">CAPACITE DE REMBOURSEMENT (Dettes.bancaires.(+MT+LT+C.bail)/CAF)<div class="tooltip"><?=$ratiosInfos['r247']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r247'); ?></td>
<td class="right"><?php dSecteur($bilan,'r247'); ?></td>
<td class="position"><?php dPosition($bilan,'r247','<'); ?></td>
</tr>
<tr>
<td><a id="r248">FINANCEMENT DES STOCKS (dettes aux fournisseurs / stock)<div class="tooltip"><?=$ratiosInfos['r248']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r248'); ?></td>
<td class="right"><?php dSecteur($bilan,'r248'); ?></td>
<td class="position"><?php dPosition($bilan,'r248','<'); ?></td>
</tr>
<tr class="subhead">
<td class="center italique">PRODUCTIVITE</td>
<td>Entreprise</td>
<td>Secteur</td>
<td>Position</td>
</tr>
<tr>
<td><a id="r271">PRODUCTIVITE DE l'ACTIF<br/>chiffre d'affaire/actif comptable<div class="tooltip"><?=$ratiosInfos['r271']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r271'); ?></td>
<td class="right"><?php dSecteur($bilan,'r271'); ?></td>
<td class="position"><?php dPosition($bilan,'r271','>'); ?></td>
</tr>
<tr>
<td><a id="r278">DUREE CLIENT (Rotation clients en VJ TTC)<div class="tooltip"><?=$ratiosInfos['r278']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r278'); ?></td>
<td class="right"><?php dSecteur($bilan,'r278'); ?></td>
<td class="position"><?php dPosition($bilan,'r278','<'); ?></td>
</tr>
<tr>
<td><a id="r279">DUREE FOURNISSEUR (Rotation fournisseurs en JA TTC)<div class="tooltip"><?=$ratiosInfos['r279']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r279'); ?></td>
<td class="right"><?php dSecteur($bilan,'r279'); ?></td>
<td class="position"><?php dPosition($bilan,'r279','<'); ?></td>
</tr>
<tr>
<td><a id="r281">POIDS MASSE SALARIALE (Ch personnel/VA)<div class="tooltip"><?=$ratiosInfos['r281']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r281'); ?></td>
<td class="right"><?php dSecteur($bilan,'r281'); ?></td>
<td class="position"><?php dPosition($bilan,'r281','<'); ?></td>
</tr>
<tr>
<td><a id="r261">RENDEMENT (Production sur 12mois / effectif)<div class="tooltip"><?=$ratiosInfos['r261']['commentaires']?></div></a></td>
<td class="right"><?php dRatio($bilan,'r261'); ?></td>
<td class="right"><?php dSecteur($bilan,'r261'); ?></td>
<td class="position"><?php dPosition($bilan,'r261','>'); ?></td>
</tr>
</tbody>
</table> 
<?php
}
?>
</div>