2009-05-28 14:40:58 +00:00
|
|
|
|
<?php
|
2009-06-03 08:23:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Retourne le r<EFBFBD>sultat du webservice.
|
|
|
|
|
* @param string $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
* @param string $type
|
|
|
|
|
* Le type de ratio demand<EFBFBD>.
|
|
|
|
|
* @return array
|
|
|
|
|
* Retourne le tableau structur<EFBFBD>.
|
2009-06-29 13:15:25 +00:00
|
|
|
|
*/
|
2009-06-03 08:23:01 +00:00
|
|
|
|
function getRatios($siren, $type){}
|
2009-05-28 14:40:58 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne le tableau pour l'affichage des graphiques d'<EFBFBD>volution.
|
|
|
|
|
* @param string $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
* @return array
|
|
|
|
|
* Retourne le tableau structur<EFBFBD>.
|
2009-06-29 13:15:25 +00:00
|
|
|
|
*/
|
2009-05-28 14:40:58 +00:00
|
|
|
|
function dGraph($nRatio){
|
|
|
|
|
global $bilansInfos;
|
|
|
|
|
global $ratiosSecteur;
|
|
|
|
|
global $ratiosEntrep;
|
|
|
|
|
global $ratiosInfos;
|
|
|
|
|
$evol = array();
|
|
|
|
|
$nbrAnnees=count($bilansInfos)-1;
|
|
|
|
|
$i=0;
|
|
|
|
|
foreach($bilansInfos as $dateCloture){
|
|
|
|
|
if(isset($bilansInfos[$nbrAnnees-$i]['dateCloture'])){
|
|
|
|
|
$div = 1;
|
|
|
|
|
$ratioE = $ratiosEntrep[$nbrAnnees-$i][$nRatio];
|
|
|
|
|
$ratioS = $ratiosSecteur[$nbrAnnees-$i][$nRatio];
|
2009-06-29 13:15:25 +00:00
|
|
|
|
if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratioE)/1000)>0) ){
|
2009-05-28 14:40:58 +00:00
|
|
|
|
$unite = 'KEURO';
|
|
|
|
|
$div = 1000;
|
|
|
|
|
}else{
|
|
|
|
|
$unite = $ratiosInfos[$nRatio]['unite'];
|
2009-06-29 13:15:25 +00:00
|
|
|
|
}
|
2009-05-28 14:40:58 +00:00
|
|
|
|
//Donn<6E>es pour les graphiques <20>volutions
|
|
|
|
|
$data[] = array(
|
2009-06-29 13:15:25 +00:00
|
|
|
|
'date'=>$bilansInfos[$nbrAnnees-$i]['dateCloture'],
|
2009-05-28 14:40:58 +00:00
|
|
|
|
'entreprise'=>(($ratioE!='NS') ? $ratioE/$div : 0 ),
|
2009-06-29 13:15:25 +00:00
|
|
|
|
'secteur'=>(($ratioS!='NS') ? $ratioS/$div : 0 ),
|
2009-05-28 14:40:58 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
2009-06-29 13:15:25 +00:00
|
|
|
|
$i++;
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
2009-06-29 13:15:25 +00:00
|
|
|
|
$evol = array('data' => $data, 'unite' => $unite);
|
|
|
|
|
return $evol;
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Affiche la position de l'entit<EFBFBD> en comparant son ratio avec le ratio secteur.
|
|
|
|
|
* @param int $nAnnee
|
|
|
|
|
* Le n<EFBFBD> de l'ann<EFBFBD>e <EFBFBD> compar<EFBFBD>.
|
|
|
|
|
* @param string $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
* @param string $compare
|
|
|
|
|
* < ou > pour d<EFBFBD>finir si le ratio doit <EFBFBD>tre sup<EFBFBD>rieur ou inf<EFBFBD>rieur au ratio secteur
|
|
|
|
|
*/
|
|
|
|
|
function dPosition($nAnnee,$nRatio,$compare){
|
|
|
|
|
global $ratiosSecteur;
|
|
|
|
|
global $ratiosEntrep;
|
|
|
|
|
$ratioS = $ratiosSecteur[$nAnnee][$nRatio];
|
|
|
|
|
$ratioE = $ratiosEntrep[$nAnnee][$nRatio];
|
|
|
|
|
$ecart = 1/100;
|
2009-06-29 13:15:25 +00:00
|
|
|
|
|
2009-05-28 14:40:58 +00:00
|
|
|
|
if( $ratioS=='NS' || $ratioE=='NS' || $ratioS==NULL || $ratioE==NULL){
|
2009-06-16 07:47:53 +00:00
|
|
|
|
$return = '-';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}elseif($compare=='>'){
|
2009-06-29 13:15:25 +00:00
|
|
|
|
if( $ratioE+$ecart > $ratioS ){
|
2009-06-16 07:47:53 +00:00
|
|
|
|
$return = '<img src="./img/ratios_bon.png" />';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){
|
2009-06-16 07:47:53 +00:00
|
|
|
|
$return = '-';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}else{
|
2009-06-16 07:47:53 +00:00
|
|
|
|
$return = '<img src="./img/ratios_mauvais.png" />';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
}elseif($compare=='<'){
|
2009-06-29 13:15:25 +00:00
|
|
|
|
if($ratioE < $ratioS){
|
2009-06-16 07:47:53 +00:00
|
|
|
|
$return = '<img src="./img/ratios_bon.png" />';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){
|
2009-06-16 07:47:53 +00:00
|
|
|
|
$return = '-';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}else{
|
2009-06-16 07:47:53 +00:00
|
|
|
|
$return = '<img src="./img/ratios_mauvais.png" />';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-16 07:47:53 +00:00
|
|
|
|
return $return;
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Affiche le ratio secteur.
|
|
|
|
|
* @param int $nAnnee
|
|
|
|
|
* Le n<EFBFBD> de l'ann<EFBFBD>e.
|
|
|
|
|
* @param string $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
*/
|
|
|
|
|
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;
|
2009-06-29 13:15:25 +00:00
|
|
|
|
}elseif(substr($ratio,0,1)=='>'){
|
2009-05-28 14:40:58 +00:00
|
|
|
|
$return.= '> ';
|
|
|
|
|
$ratio = substr($ratio,1)*1;
|
|
|
|
|
}elseif($ratio==NULL){
|
|
|
|
|
$return.= '-';
|
|
|
|
|
$formatRatio = FALSE;
|
|
|
|
|
}
|
2009-06-29 13:15:25 +00:00
|
|
|
|
|
2009-05-28 14:40:58 +00:00
|
|
|
|
if($formatRatio == TRUE) {
|
2009-06-29 13:15:25 +00:00
|
|
|
|
if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)>0) ){
|
2009-05-28 14:40:58 +00:00
|
|
|
|
$return.= number_format($ratio/1000, 0, '', ' ').' K€';
|
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)<0)) {
|
|
|
|
|
$return.= number_format($ratio, 0, '', ' ').' €';
|
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='Jours')) {
|
|
|
|
|
$return.= number_format($ratio, 0, '', ' ').' '.$ratiosInfos[$nRatio]['unite'];
|
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='AN')) {
|
2009-06-29 13:15:25 +00:00
|
|
|
|
$return.= round($ratio, 2).' '.$ratiosInfos[$nRatio]['unite'];
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='%')) {
|
2009-06-29 13:15:25 +00:00
|
|
|
|
$return.= round($ratio).' '.$ratiosInfos[$nRatio]['unite'];
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}else{
|
|
|
|
|
$return.= $ratio.' '.$ratiosInfos[$nRatio]['unite'];
|
2009-06-29 13:15:25 +00:00
|
|
|
|
}
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
2009-06-16 07:47:53 +00:00
|
|
|
|
return $return;
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Affiche le ratio de l'entit<EFBFBD>.
|
|
|
|
|
* @param int $nAnnee
|
|
|
|
|
* Le n<EFBFBD> de l'ann<EFBFBD>e.
|
|
|
|
|
* @param string $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
*/
|
2009-06-29 13:15:25 +00:00
|
|
|
|
function dRatio($nAnnee,$nRatio){
|
2009-05-28 14:40:58 +00:00
|
|
|
|
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;
|
2009-06-29 13:15:25 +00:00
|
|
|
|
}elseif(substr($ratio,0,1)=='>'){
|
2009-05-28 14:40:58 +00:00
|
|
|
|
$return.= '> ';
|
|
|
|
|
$ratio = substr($ratio,1)*1;
|
|
|
|
|
}elseif($ratio==NULL){
|
|
|
|
|
$return.= '-';
|
|
|
|
|
$formatRatio = FALSE;
|
|
|
|
|
}
|
2009-06-29 13:15:25 +00:00
|
|
|
|
|
2009-05-28 14:40:58 +00:00
|
|
|
|
if($formatRatio == TRUE) {
|
2009-06-29 13:15:25 +00:00
|
|
|
|
if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)>0) ){
|
2009-05-28 14:40:58 +00:00
|
|
|
|
$return.= number_format($ratio/1000, 0, '', ' ').' K€';
|
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratio)/1000)<0)) {
|
|
|
|
|
$return.= number_format($ratio, 0, '', ' ').' €';
|
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='Jours')) {
|
|
|
|
|
$return.= number_format($ratio, 0, '', ' ').' '.$ratiosInfos[$nRatio]['unite'];
|
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='AN')) {
|
2009-06-29 13:15:25 +00:00
|
|
|
|
$return.= round($ratio, 2).' '.$ratiosInfos[$nRatio]['unite'];
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}elseif (($ratiosInfos[$nRatio]['unite']=='%')) {
|
2009-06-29 13:15:25 +00:00
|
|
|
|
$return.= round($ratio).' '.$ratiosInfos[$nRatio]['unite'];
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}else{
|
|
|
|
|
$return.= $ratio.' '.$ratiosInfos[$nRatio]['unite'];
|
2009-06-29 13:15:25 +00:00
|
|
|
|
}
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
2009-06-15 14:53:37 +00:00
|
|
|
|
return $return;
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Affiche l'<27>volution d'un ratio.
|
|
|
|
|
* @param int $nAnnee
|
|
|
|
|
* Le n<EFBFBD> de l'ann<EFBFBD>e.
|
|
|
|
|
* @param string $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
*/
|
|
|
|
|
function dEvol($nAnnee,$nRatio){
|
|
|
|
|
global $ratiosEntrepEvol;
|
|
|
|
|
$ratio = $ratiosEntrepEvol[$nAnnee][$nRatio];
|
|
|
|
|
if ($ratio=='NS') {
|
2009-06-15 14:53:37 +00:00
|
|
|
|
return 'NS';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}elseif($ratio==NULL){
|
2009-06-15 14:53:37 +00:00
|
|
|
|
return '-';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}else{
|
2009-06-15 14:53:37 +00:00
|
|
|
|
return $ratio.' %';
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne le pourcentage d'un ratio par rapport au total pour les graphiques .
|
|
|
|
|
* @param sting $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
* @param string $totalRatio
|
|
|
|
|
* Le n<EFBFBD> du ratio total
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
function graphPercent($nRatio,$totalRatio){
|
|
|
|
|
global $ratiosEntrep;
|
|
|
|
|
$ratio = isset($ratiosEntrep[0][$nRatio]) ? $ratiosEntrep[0][$nRatio] : 0;
|
|
|
|
|
$totalRatio = $ratiosEntrep[0][$totalRatio];
|
|
|
|
|
if ( ($ratio!='NS' || $ratio!=NULL) && ($totalRatio!=0 || $totalRatio!='NS')){
|
|
|
|
|
return $ratio*100/$totalRatio;
|
|
|
|
|
}else{
|
|
|
|
|
return 0;
|
2009-06-29 13:15:25 +00:00
|
|
|
|
}
|
2009-05-28 14:40:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Affiche le pourcentage d'un ratio par rapport au total.
|
|
|
|
|
* @param sting $nRatio
|
|
|
|
|
* Le n<EFBFBD> de ratio.
|
|
|
|
|
* @param string $totalRatio
|
|
|
|
|
* Le n<EFBFBD> du ratio total
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
function dPercent($nAnnee,$nRatio,$totalRatio){
|
|
|
|
|
global $ratiosEntrep;
|
|
|
|
|
$ratio = $ratiosEntrep[$nAnnee][$nRatio];
|
|
|
|
|
$totalRatio = $ratiosEntrep[$nAnnee][$totalRatio];
|
|
|
|
|
if ($ratio=='NS') {
|
|
|
|
|
print 'NS';
|
|
|
|
|
}elseif($ratio==NULL){
|
|
|
|
|
print '-';
|
|
|
|
|
}else {
|
|
|
|
|
if ($totalRatio!=0 || $totalRatio!='NS'){
|
|
|
|
|
$percent = $ratio*100/$totalRatio;
|
|
|
|
|
}else{
|
|
|
|
|
$percent = 0;
|
|
|
|
|
}
|
|
|
|
|
print round($percent, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Formatte le commentaire pour l'afficher dans l'infobulle.
|
|
|
|
|
* Place un retour <EFBFBD> la ligne si le texte parait plus long que le bloc d'affichage
|
|
|
|
|
* Transforme les entit<EFBFBD>s HTML
|
|
|
|
|
* Transforme le \n par des <br/>
|
|
|
|
|
* @param string $text
|
|
|
|
|
* Commentaire .
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function wrapComment($text){
|
2009-05-28 16:52:15 +00:00
|
|
|
|
$fontSize = 2;
|
2009-05-28 14:40:58 +00:00
|
|
|
|
$blockSize = 500;
|
|
|
|
|
$newtext = wordwrap($text, $blockSize/$fontSize , "\n");
|
|
|
|
|
$newtext = htmlentities($newtext);
|
|
|
|
|
$newtext = nl2br($newtext);
|
|
|
|
|
return $newtext;
|
|
|
|
|
}
|
|
|
|
|
?>
|