2009-05-28 14:40:58 +00:00
< ? php
2009-06-15 14:52:23 +00:00
require_once realpath ( dirname ( __FILE__ )) . '/functions.php' ;
2009-10-23 13:34:42 +00:00
function formatRatios ( $bilansInfos , $ratiosEntrep , $ratiosEntrepEvol , $ratiosInfos , $ratiosSecteur )
2009-10-08 15:50:08 +00:00
{
2010-02-10 17:27:03 +00:00
//Suppression des éléments ne possédant pas de date de cloture
2009-10-08 15:50:08 +00:00
$index = 0 ;
foreach ( $bilansInfos as $bilansInfo )
{
if ( ! isset ( $bilansInfo [ 'dateCloture' ]))
{
unset ( $bilansInfos [ $index ]);
unset ( $ratiosEntrep [ $index ]);
unset ( $ratiosEntrepEvol [ $index ]);
unset ( $ratiosInfos [ $index ]);
unset ( $ratiosSecteur [ $index ]);
}
$index ++ ;
}
2010-02-10 17:27:03 +00:00
//Tri des tableaux par ordre décroissant suivant la date de cloture
//Transformation du tableau sous forme clé => valeur
2009-10-08 15:50:08 +00:00
foreach ( $bilansInfos as $key => $row ) {
$bilansInfos [ $key ][ 'cle' ] = $key ;
$date [ $key ] = $row [ 'dateCloture' ];
$duree [ $key ] = $row [ 'duree' ];
$devise [ $key ] = $row [ 'devise' ];
$unite [ $key ] = $row [ 'unite' ];
$cle [ $key ] = $row [ 'cle' ];
}
2010-02-10 17:27:03 +00:00
//Tri du tableau de référence suivant la date de cloture
2009-10-08 15:50:08 +00:00
array_multisort ( $date , SORT_DESC , $duree , SORT_DESC , $devise , SORT_DESC , $unite , SORT_DESC , $cle , SORT_DESC , $bilansInfos );
//Tri des autres tableaux
$tempRatiosEntrep = $ratiosEntrep ;
$tempRatiosEntrepEvol = $ratiosEntrepEvol ;
$tempRatiosSecteur = $ratiosSecteur ;
$i = 0 ;
2009-10-23 13:34:42 +00:00
foreach ( $bilansInfos as $row )
{
2009-10-08 15:50:08 +00:00
$ratiosEntrep [ $i ] = $tempRatiosEntrep [ $row [ 'cle' ]];
$ratiosEntrepEvol [ $i ] = $tempRatiosEntrepEvol [ $row [ 'cle' ]];
$ratiosSecteur [ $i ] = $tempRatiosSecteur [ $row [ 'cle' ]];
2009-10-23 13:34:42 +00:00
2010-02-10 17:27:03 +00:00
//Génération données graphique actif
2009-10-23 13:34:42 +00:00
$dataActif [ $i ] = array (
graphPercent ( $i , 'r51' , 'r22' ),
graphPercent ( $i , 'r52' , 'r22' ),
graphPercent ( $i , 'r53' , 'r22' ),
graphPercent ( $i , 'r60' , 'r22' ),
graphPercent ( $i , 'r61' , 'r22' ),
graphPercent ( $i , 'r62' , 'r22' ),
graphPercent ( $i , 'r63' , 'r22' ),
);
2010-02-10 17:27:03 +00:00
//Génération données graphique passif
2009-10-23 13:34:42 +00:00
$dataPassif [ $i ] = array (
graphPercent ( $i , 'r70' , 'r22' ),
graphPercent ( $i , 'r71' , 'r22' ),
graphPercent ( $i , 'r72' , 'r22' ),
graphPercent ( $i , 'r83' , 'r22' ),
graphPercent ( $i , 'r84' , 'r22' ),
graphPercent ( $i , 'r85' , 'r22' ),
graphPercent ( $i , 'r86' , 'r22' ),
graphPercent ( $i , 'r87' , 'r22' ),
);
2010-02-10 17:27:03 +00:00
//Génération données graphique SIG
2009-10-23 13:34:42 +00:00
$dataSIG [ $i ] = array (
graphPercent ( $i , 'r101' , 'r101' ) - graphPercent ( $i , 'r122' , 'r101' ),
graphPercent ( $i , 'r122' , 'r101' ) - graphPercent ( $i , 'r130' , 'r101' ),
graphPercent ( $i , 'r130' , 'r101' ) - graphPercent ( $i , 'r140' , 'r101' ),
graphPercent ( $i , 'r140' , 'r101' ) - graphPercent ( $i , 'r150' , 'r101' ),
graphPercent ( $i , 'r150' , 'r101' ) - graphPercent ( $i , 'r170' , 'r101' ),
graphPercent ( $i , 'r170' , 'r101' ) - graphPercent ( $i , 'r199' , 'r101' ),
graphPercent ( $i , 'r199' , 'r101' ),
);
2009-10-08 15:50:08 +00:00
$i ++ ;
}
//Fin de tri des tableaux
return array (
'bilansInfos' => $bilansInfos ,
'ratiosEntrep' => $ratiosEntrep ,
'ratiosEntrepEvol' => $ratiosEntrepEvol ,
2009-10-23 13:34:42 +00:00
'ratiosSecteur' => $ratiosSecteur ,
2009-10-08 15:50:08 +00:00
'ratiosInfos' => $ratiosInfos ,
'dataActif' => $dataActif ,
'dataPassif' => $dataPassif ,
'dataSIG' => $dataSIG
);
}
2009-06-12 16:48:50 +00:00
/**
2010-02-10 17:27:03 +00:00
* Retourne un tableau de données formatés pour les graphiques .
2009-06-12 16:48:50 +00:00
* @ param array $bilansInfo
* Le tableau des bilans
* @ param array $ratiosEntrep
* Le tableau des ratios entreprise
2009-10-13 16:36:27 +00:00
* @ param string $ratio
2010-02-10 17:27:03 +00:00
* Le ratio selectionné
2009-06-12 16:48:50 +00:00
* @ return array
2010-02-10 17:27:03 +00:00
* Retourne un tableau structuré composé de dataGraph , et de dataEvol .
2009-06-18 13:22:31 +00:00
*/
2009-10-13 16:36:27 +00:00
function synthese_datagraph ( $bilansInfos , $ratiosEntrep , $ratio )
2009-10-08 15:50:08 +00:00
{
2009-06-16 07:47:53 +00:00
global $firephp ;
2009-06-15 14:52:23 +00:00
$dataGraph = array ();
$dataEvol = array ();
2009-10-13 16:36:27 +00:00
$tabRatioGraph = syntheseRatioGraph ();
$tabRatioGraphEvol = syntheseRatio ( $ratio );
2009-06-15 14:52:23 +00:00
$nbrAnnees = count ( $bilansInfos ) - 1 ;
$i = 0 ;
2009-10-13 16:36:27 +00:00
foreach ( $bilansInfos as $dateCloture )
{
2010-02-10 17:27:03 +00:00
//Données pour le graphique
2009-10-13 16:36:27 +00:00
if ( isset ( $dateCloture [ 'dateCloture' ]))
{
2009-06-15 14:52:23 +00:00
$dataGraph [ $i ][ 'date' ] = $dateCloture [ 'dateCloture' ];
2009-08-20 16:54:17 +00:00
$dataGraph [ $i ][ 'duree' ] = $dateCloture [ 'duree' ];
2009-10-13 16:36:27 +00:00
foreach ( $tabRatioGraph as $item )
{
2009-06-15 14:52:23 +00:00
$dataGraph [ $i ][ $item [ 'ratio' ]] = $ratiosEntrep [ $i ][ $item [ 'ratio' ]] / $item [ 'op' ];
2009-06-18 13:22:31 +00:00
}
2009-06-15 14:52:23 +00:00
}
2010-02-10 17:27:03 +00:00
//Données pour les graphiques évolutions
2009-06-15 14:52:23 +00:00
if ( isset ( $bilansInfos [ $nbrAnnees - $i ][ 'dateCloture' ])){
2009-06-16 07:47:53 +00:00
foreach ( $tabRatioGraphEvol as $ratio => $info ){
$dataEvol [ $ratio ][] = array (
2009-06-15 14:52:23 +00:00
'date' => $bilansInfos [ $nbrAnnees - $i ][ 'dateCloture' ],
2009-06-16 07:47:53 +00:00
'value' => (( $ratiosEntrep [ $nbrAnnees - $i ][ $ratio ] != 'NS' ) ? $ratiosEntrep [ $nbrAnnees - $i ][ $ratio ] / $info [ 'op' ] : 0 )
2009-06-15 14:52:23 +00:00
);
}
}
2009-06-18 13:22:31 +00:00
$i ++ ;
}
2009-06-15 14:52:23 +00:00
return array ( " graph " => $dataGraph , " evol " => $dataEvol );
}
2009-05-28 14:40:58 +00:00
2009-10-15 15:09:54 +00:00
/**
2010-02-10 17:27:03 +00:00
* Retourne un tableau de données formatés pour les graphiques .
2009-10-15 15:09:54 +00:00
* @ param array $bilansInfo
* Le tableau des bilans
* @ param array $ratiosEntrep
* Le tableau des ratios entreprise
* @ param string $ratio
2010-02-10 17:27:03 +00:00
* Le ratio selectionné
2009-10-15 15:09:54 +00:00
* @ return array
2010-02-10 17:27:03 +00:00
* Retourne un tableau structuré composé de dataGraph , et de dataEvol .
2009-10-15 15:09:54 +00:00
*/
function synthese_datagraphmin ( $bilansInfos , $ratiosEntrep )
{
global $firephp ;
$dataGraph = array ();
$dataEvol = array ();
$tabRatioGraphEvol = syntheseRatioMin ();
$nbrAnnees = count ( $bilansInfos ) - 1 ;
$i = 0 ;
foreach ( $bilansInfos as $dateCloture )
{
2010-02-10 17:27:03 +00:00
//Données pour les graphiques évolutions
2009-10-15 15:09:54 +00:00
if ( isset ( $bilansInfos [ $nbrAnnees - $i ][ 'dateCloture' ])){
foreach ( $tabRatioGraphEvol as $ratio => $info ){
$dataEvol [ $ratio ][] = array (
'date' => $bilansInfos [ $nbrAnnees - $i ][ 'dateCloture' ],
'value' => (( $ratiosEntrep [ $nbrAnnees - $i ][ $ratio ] != 'NS' ) ? $ratiosEntrep [ $nbrAnnees - $i ][ $ratio ] / $info [ 'op' ] : 0 )
);
}
}
$i ++ ;
}
return array ( " graph " => $dataGraph , " evol " => $dataEvol );
}
2009-06-15 14:52:23 +00:00
/**
2010-02-10 17:27:03 +00:00
* Formatte chaîne contenant la date formaté .
2009-06-15 14:52:23 +00:00
* @ param array $bilansInfo
* Le tableau des bilans
* @ param array $nAnnee
2010-02-10 17:27:03 +00:00
* Le numéro de l ' année
2009-06-15 14:52:23 +00:00
* @ return string
2010-02-10 17:27:03 +00:00
* Retourne la date formaté .
2009-06-18 13:22:31 +00:00
*/
2009-06-15 14:52:23 +00:00
function synthese_formatdateCloture ( $bilansInfos , $nAnnee ){
if ( isset ( $bilansInfos [ $nAnnee ][ 'dateCloture' ])) {
print substr ( $bilansInfos [ $nAnnee ][ 'dateCloture' ], 6 , 2 ) . '/' . substr ( $bilansInfos [ $nAnnee ][ 'dateCloture' ], 4 , 2 ) . '/' . substr ( $bilansInfos [ $nAnnee ][ 'dateCloture' ], 0 , 4 ) . '<br/>' . $bilansInfos [ $nAnnee ][ 'duree' ] . ' mois' ;
} else { print '-' ; }
}
/**
2010-02-10 17:27:03 +00:00
* Retourne une chaîne contenant les ligne d ' un tableau html .
2009-06-15 14:52:23 +00:00
* @ param array $ratiosInfos
2009-06-18 13:22:31 +00:00
* Le tableau des informations ratios
2009-06-15 14:52:23 +00:00
* @ param array $dataEvol
2010-02-10 17:27:03 +00:00
* Le tableau des données évolution
2009-06-15 14:52:23 +00:00
* @ param array $tabRatio
2010-02-10 17:27:03 +00:00
* Un tableau des ratios à utiliser pour générer les lignes
2009-06-15 14:52:23 +00:00
* @ return string
2010-02-10 17:27:03 +00:00
* Retourne une chaîne .
2009-06-18 13:22:31 +00:00
*/
2009-10-13 16:36:27 +00:00
function synthese_tablerow ( $ratiosInfos , $dataEvol , $ratio )
2009-10-08 13:20:51 +00:00
{
global $siret , $siren , $idEntreprise , $typeBilan , $firephp ;
2009-10-06 08:31:48 +00:00
2009-10-13 16:36:27 +00:00
$tabRatio = syntheseRatio ( $ratio );
2009-10-06 08:31:48 +00:00
if (( $siret * 1 ) == 0 || ( $siren * 1 ) < 100 ){ $fileName = 'synthese-' . $idEntreprise ;
2010-03-01 11:43:21 +00:00
} else { $fileName = 'synthese-' . $siret ; }
2009-10-06 08:31:48 +00:00
$fileName .= '-' . $typeBilan ;
2009-10-08 13:20:51 +00:00
$firephp -> log ( $fileName , 'SyntheseTablerow - filename' );
2009-06-15 14:52:23 +00:00
$row = '' ;
2009-10-02 14:39:29 +00:00
foreach ( $tabRatio as $ratio => $info )
{
2009-06-15 14:52:23 +00:00
$row .= '<tr>' . " \n " .
2009-06-18 13:22:31 +00:00
' <td class="head"><a tooltip="' . wrapComment ( $ratiosInfos [ $ratio ][ 'commentaires' ]) . '">' . $info [ 'titre' ] . '</a></td>' . " \n " .
2009-06-15 14:52:23 +00:00
' <td class="right">' . dRatio ( 2 , $ratio ) . '</td>' . " \n " .
' <td class="right">' . dRatio ( 1 , $ratio ) . '</td>' . " \n " .
' <td class="right">' . dEvol ( 1 , $info [ 'evol' ]) . '</td>' . " \n " .
' <td class="right">' . dRatio ( 0 , $ratio ) . '</td>' . " \n " .
' <td class="right">' . dEvol ( 0 , $info [ 'evol' ]) . '</td>' . " \n " ;
2009-06-18 13:22:31 +00:00
if ( count ( $tabRatio ) != 1 ){
2009-09-24 16:05:13 +00:00
$class = 'class="sTip"' ;
2009-10-06 08:31:48 +00:00
$href = '/?page=synthese&siret=' . $_REQUEST [ 'siret' ] . '&idEntreprise=' . $_REQUEST [ 'idEntreprise' ] . '&ratio=' . $ratio ;
2009-06-29 09:07:20 +00:00
$unite = '' ;
if ( isset ( $info [ 'unite' ]) && $info [ 'unite' ] == 1 ){
$unite = $ratiosInfos [ $info [ 'evol' ]][ 'unite' ];
}
$rel = './pages/synthese_dgraph.php?widht=375&f=' . synthese_graphEvol ( $dataEvol [ $ratio ], $unite , $ratio , $fileName );
2009-06-15 14:52:23 +00:00
} else {
2009-06-18 13:22:31 +00:00
$class = '' ;
$href = '#' ;
$ref = '' ;
}
$row .= ' <td><a ' . $class . ' href="' . $href . '" rel="' . $rel ;
$row .= '" name="' . $info [ 'titre' ] . '"><img src="./img/synthese/chart_bar.png" alt="Visionner le graphique"></a></td>' . " \n " ;
$row .= '</tr>' . " \n " ;
2009-06-15 14:52:23 +00:00
}
return $row ;
}
2009-05-28 14:40:58 +00:00
2009-10-15 15:09:54 +00:00
/**
2010-02-10 17:27:03 +00:00
* Retourne une chaîne contenant les ligne d ' un tableau html .
2009-10-15 15:09:54 +00:00
* @ param array $ratiosInfos
* Le tableau des informations ratios
* @ param array $dataEvol
2010-02-10 17:27:03 +00:00
* Le tableau des données évolution
2009-10-15 15:09:54 +00:00
* @ param array $tabRatio
2010-02-10 17:27:03 +00:00
* Un tableau des ratios à utiliser pour générer les lignes
2009-10-15 15:09:54 +00:00
* @ return string
2010-02-10 17:27:03 +00:00
* Retourne une chaîne .
2009-10-15 15:09:54 +00:00
*/
function synthese_tablerowmin ( $ratiosInfos , $dataEvol )
{
global $siret , $siren , $idEntreprise , $typeBilan , $firephp ;
$tabRatio = syntheseRatioMin ();
if (( $siret * 1 ) == 0 || ( $siren * 1 ) < 100 ){ $fileName = 'synthese-' . $idEntreprise ;
2010-03-01 11:43:21 +00:00
} else { $fileName = 'synthese-' . $siret ; }
2009-10-15 15:09:54 +00:00
$fileName .= '-' . $typeBilan ;
$row = '' ;
foreach ( $tabRatio as $ratio => $info )
{
$row .= '<tr>' . " \n " ;
$row .= ' <td class="head"><a tooltip="' . wrapComment ( $ratiosInfos [ $ratio ][ 'commentaires' ]) . '">' . $info [ 'titre' ] . '</a></td>' . " \n " ;
$row .= ' <td class="right">' . dRatio ( 2 , $ratio ) . '</td>' . " \n " ;
2009-12-04 17:17:09 +00:00
$row .= ' <td class="right" title="' . $info [ 'total_info' ] . '">' . dTotal ( 2 , $ratio , $info [ 'total' ]) . ' %</td>' . " \n " ;
2009-10-15 15:09:54 +00:00
$row .= ' <td class="right">' . dRatio ( 1 , $ratio ) . '</td>' . " \n " ;
2009-12-04 17:17:09 +00:00
$row .= ' <td class="right" title="' . $info [ 'total_info' ] . '">' . dTotal ( 1 , $ratio , $info [ 'total' ]) . ' %</td>' . " \n " ;
2009-10-15 15:09:54 +00:00
$row .= ' <td class="right">' . dRatio ( 0 , $ratio ) . '</td>' . " \n " ;
2009-12-04 17:17:09 +00:00
$row .= ' <td class="right" title="' . $info [ 'total_info' ] . '">' . dTotal ( 0 , $ratio , $info [ 'total' ]) . ' %</td>' . " \n " ;
2009-10-15 15:09:54 +00:00
$row .= '</tr>' . " \n " ;
}
return $row ;
}
2009-06-18 13:22:31 +00:00
/**
2010-02-10 17:27:03 +00:00
* Retourne l 'url de la page d' appel du graphique avec tous ces paramètres .
2009-06-18 13:22:31 +00:00
* @ param array $data
2010-02-10 17:27:03 +00:00
* Les données du tableau
2009-06-18 13:22:31 +00:00
* @ return string
2010-02-10 17:27:03 +00:00
* Retourne une chaîne .
2009-06-18 13:22:31 +00:00
*/
2009-06-29 09:07:20 +00:00
function synthese_graphEvol ( $data , $unite , $ratio , $filename ){
require_once 'phpchartdir/phpchartdir.php' ;
2009-10-08 13:20:51 +00:00
global $firephp ;
2009-06-29 09:07:20 +00:00
$unite = ( $_REQUEST [ 'unite' ] != '' ? $unite : 'KEUROS' );
if ( count ( $data ) <= 1 ){
$return = 0 ;
} else {
2009-10-02 14:39:29 +00:00
foreach ( $data as $value )
{
2009-06-29 09:07:20 +00:00
$dataX [] = $value [ 'value' ];
$labelsX [] = substr ( $value [ 'date' ], 0 , 4 );
}
$i =- 100 ;
while ( $i > 100 ){ $labelsY [] = $i ;}
# Create a XYChart object of size 250 x 250 pixels
$c = new XYChart ( 350 , 250 );
$c -> setPlotArea ( 55 , 10 , 280 , 200 );
$c -> yAxis -> setTitle ( $unite );
2010-02-10 17:27:03 +00:00
$c -> xAxis -> setTitle ( " Années " );
2009-06-29 09:07:20 +00:00
$c -> xAxis -> setWidth ( 2 );
$c -> yAxis -> setWidth ( 2 );
$c -> addLineLayer ( $dataX );
# Set the labels.
$c -> yAxis -> setLabels ( $labelsY );
$c -> yAxis -> setLabelStep ( 10 );
$c -> xAxis -> setLabels ( $labelsX );
$path = PATH_SITE . '/cache/imgcache/' ;
$file = $filename . '-' . $ratio . '.png' ;
if ( $c -> makeChart ( $path . $file ) === TRUE ){ $return = $file ; }
else { $return = FALSE ; }
}
return $return ;
2009-06-29 08:17:31 +00:00
}
2009-10-08 13:20:51 +00:00
function synthese_graph_linecompare ( $data ){
global $siret , $siren , $idEntreprise , $typeBilan ;
2009-10-06 08:31:48 +00:00
2009-10-08 13:20:51 +00:00
if (( $siret * 1 ) == 0 || ( $siren * 1 ) < 100 ){ $filename = 'synthese-' . $idEntreprise ;
2010-03-01 11:43:21 +00:00
} else { $filename = 'synthese-' . $siret ; }
2009-10-06 08:31:48 +00:00
$filename .= '-' . $typeBilan ;
2009-06-29 08:17:31 +00:00
//Graphique style linecompare / CA / FR / BFR
require_once 'phpchartdir/phpchartdir.php' ;
2010-02-10 17:27:03 +00:00
//Tri des données par date et par ordre croissant
2009-07-20 08:29:58 +00:00
foreach ( $data as $key => $row ) { $date [ $key ] = $row [ 'date' ]; }
array_multisort ( $date , SORT_ASC , $data );
2010-02-10 17:27:03 +00:00
//Définition des valeurs pour le graph
2009-06-29 08:17:31 +00:00
$dataBFR = array ();
$dataFR = array ();
$dataCA = array ();
$i = 0 ;
2010-02-10 17:27:03 +00:00
//Parcourir les années
2009-06-29 08:17:31 +00:00
foreach ( $data as $item ){
2009-08-20 16:54:17 +00:00
$anneeFin = substr ( $item [ 'date' ], 0 , 4 );
$moisFin = substr ( $item [ 'date' ], 4 , 2 );
$jourFin = substr ( $item [ 'date' ], 6 , 2 );
2010-02-10 17:27:03 +00:00
//Calcul de la date de début
2009-08-20 16:54:17 +00:00
$dateDebut = date ( " Ymd " , mktime ( 0 , 0 , 0 , $moisFin - $item [ 'duree' ], $jourFin , $anneeFin ));
$anneeDebut = substr ( $dateDebut , 0 , 4 );
$moisDebut = substr ( $dateDebut , 4 , 2 );
$jourDebut = substr ( $dateDebut , 6 , 2 );
//Affectation des abscisses
$dataBFR [ 'x' ][ $i ] = $dataFR [ 'x' ][ $i ] = $dataCA [ 'x' ][ $i ] = $dataEBE [ 'x' ][ $i ] = chartTime (( int ) $anneeDebut , ( int ) $moisDebut , ( int ) $jourDebut );
$dataBFR [ 'x' ][ $i + 1 ] = $dataFR [ 'x' ][ $i + 1 ] = $dataCA [ 'x' ][ $i + 1 ] = $dataEBE [ 'x' ][ $i + 1 ] = chartTime (( int ) $anneeFin , ( int ) $moisFin , ( int ) $jourFin );
2010-02-10 17:27:03 +00:00
//Affectation des ordonnées
2009-07-20 08:29:58 +00:00
$dataBFR [ 'y' ][ $i ] = $dataBFR [ 'y' ][ $i + 1 ] = $item [ 'r236' ];
$dataFR [ 'y' ][ $i ] = $dataFR [ 'y' ][ $i + 1 ] = $item [ 'r235' ];
$dataCA [ 'y' ][ $i ] = $dataCA [ 'y' ][ $i + 1 ] = $item [ 'r6' ];
$dataEBE [ 'y' ][ $i ] = $dataEBE [ 'y' ][ $i + 1 ] = $item [ 'r146' ];
$i += 2 ;
2009-06-29 08:17:31 +00:00
}
2009-08-10 16:54:43 +00:00
$c = new XYChart ( 570 , 350 , 0xcccccc , 0x000000 , 1 );
2010-02-10 17:27:03 +00:00
$c -> addTitle ( " Synthèse * " , " timesbi.ttf " , 15 , 0x000000 );
$c -> addText ( 60 , 320 , " * Elements financier rapportés à 12 mois " );
2009-06-29 08:17:31 +00:00
$c -> setPlotArea ( 60 , 80 , 500 , 200 , 0xffffff , - 1 , - 1 , 0xcccccc , 0xcccccc );
$c -> yAxis -> setTitle ( " KEUROS " , " timesbi.ttf " , 10 );
2010-02-10 17:27:03 +00:00
$c -> xAxis -> setTitle ( " <*block,valign=absmiddle*>Années<*/*> " );
2009-06-29 08:17:31 +00:00
$c -> xAxis -> setWidth ( 2 );
$c -> yAxis -> setWidth ( 2 );
// Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9 pts
// Arial Bold font. Set the background and border color to Transparent.
$legendObj = $c -> addLegend ( 55 , 30 , false , " times.ttf " , 9 );
$legendObj -> setBackground ( Transparent );
// Add a blue (0000ff) step line layer to the chart and set the line width to 2 pixels
2009-07-20 08:29:58 +00:00
$layer1 = $c -> addStepLineLayer ( $dataFR [ 'y' ], 0x0000ff , " FONDS DE ROULEMENT " );
$layer1 -> setXData ( $dataFR [ 'x' ]);
2009-06-29 08:17:31 +00:00
$layer1 -> setLineWidth ( 2 );
// Add a red (ff0000) step line layer to the chart and set the line width to 2 pixels
2009-07-20 08:29:58 +00:00
$layer0 = $c -> addStepLineLayer ( $dataBFR [ 'y' ], 0xff0000 , " BESOIN EN FONDS DE ROULEMENT " );
$layer0 -> setXData ( $dataBFR [ 'x' ]);
2009-06-29 08:17:31 +00:00
$layer0 -> setLineWidth ( 2 );
// Add a green (00ff00) step line layer to the chart and set the line width to 2 pixels
2009-07-20 08:29:58 +00:00
$layer2 = $c -> addStepLineLayer ( $dataCA [ 'y' ], 0x00ff00 , " CHIFFRE D'AFFAIRES " );
$layer2 -> setXData ( $dataCA [ 'x' ]);
2009-06-29 08:17:31 +00:00
$layer2 -> setLineWidth ( 2 );
// Add a black (000000) step line layer style dash to the chart and set the line width to 2 pixels
2009-07-20 08:29:58 +00:00
$layer3 = $c -> addStepLineLayer ( $dataEBE [ 'y' ], $c -> dashLineColor ( 0x000000 , DashLine ), " EXCEDENT BRUT D'EXPLOITATION " );
$layer3 -> setXData ( $dataEBE [ 'x' ]);
2009-06-29 08:17:31 +00:00
$layer3 -> setLineWidth ( 2 );
# If the FR line gets above the BFR line, color to area between the lines red (ff0000)
$c -> addInterLineLayer ( $layer0 -> getLine ( 0 ), $layer1 -> getLine ( 0 ), 0xff0000 , Transparent );
# If the FR line gets below the lower BFR line, color to area between the lines light green (8099ff99)
$c -> addInterLineLayer ( $layer0 -> getLine ( 0 ), $layer1 -> getLine ( 0 ), Transparent , 0x8044ff44 );
$path = PATH_SITE . '/cache/imgcache/' ;
2009-10-06 08:31:48 +00:00
$file = $filename . '-linecompare.png' ;
2009-06-29 08:17:31 +00:00
if ( $c -> makeChart ( $path . $file ) === TRUE ){
$return = '<img src="./imgcache/' . $file . '"/>' ;
} else {
2010-02-10 17:27:03 +00:00
$return = 'Impossible de générer le graphique' ;
2009-06-29 08:17:31 +00:00
}
return $return ;
2009-06-18 13:22:31 +00:00
}
2009-06-29 08:17:31 +00:00
2009-06-16 07:47:53 +00:00
/**
2010-02-10 17:27:03 +00:00
* Retourne une chaîne contenant la ligne d ' un tableau html .
2009-06-16 07:47:53 +00:00
* @ param array $ratiosInfos
* Le tableau des information ratios
* @ param array $dataEvol
2010-02-10 17:27:03 +00:00
* Le tableau des données évolution
2009-06-16 07:47:53 +00:00
* @ param array $tabRatio
2010-02-10 17:27:03 +00:00
* Un tableau des ratios à utiliser pour le générer les lignes
2009-06-16 07:47:53 +00:00
* @ return string
2010-02-10 17:27:03 +00:00
* Retourne une chaîne .
2009-06-18 13:22:31 +00:00
*/
2009-10-13 16:36:27 +00:00
function ratios_tablerow ( $ratiosInfos , $bilan , $ratio = '' ){
2010-03-01 11:43:21 +00:00
global $siret , $siren , $idEntreprise , $typeBilan ;
2009-06-18 13:22:31 +00:00
2009-10-13 16:36:27 +00:00
$tabRatio = array (
0 => array ( 'titre' => 'EQUILIBRE FINANCIER' ),
1 => array ( 'titre' => 'MARGE BRUTE D\'AUTOFINANCEMENT' , 'stitre' => '(MBA ou CAF)' , 'ratio' => 'r233' , 'parent' => 0 , 'position' => '>' ),
2 => array ( 'titre' => 'COUVERTURE du BFR ' , 'stitre' => '(FR/BFR)' , 'ratio' => 'r234' , 'parent' => 0 , 'position' => '>' ),
3 => array ( 'titre' => 'COUVERTURE des IMMOS NETTES ' , 'stitre' => '(Capitaux permanents / Immobilisations nettes)' , 'ratio' => 'r237' , 'parent' => 0 , 'position' => '>' ),
4 => array ( 'titre' => 'COUVERTURE du CA ' , 'stitre' => '(Fond de roulement net global sur 12m x 360 / Chiffre d\'affaire)' , 'ratio' => 'r238' , 'parent' => 0 , 'position' => '>' ),
5 => array ( 'titre' => 'SOLVABILITE ' , 'stitre' => '(Capitaux propres / Ensemble des dettes)' , 'ratio' => 'r239' , 'parent' => 0 , 'position' => '>' ),
6 => array ( 'titre' => 'INDEPENDANCE FINANCIERE ' , 'stitre' => '(Cap.propres/Capitaux permanents)' , 'ratio' => 'r240' , 'parent' => 0 , 'position' => '>' ),
7 => array ( 'titre' => 'PROFITABILITE' ),
8 => array ( 'titre' => 'RENTABILITE ECONOMIQUE ' , 'stitre' => '(EBE/TOTAL bilan)' , 'ratio' => 'r262' , 'parent' => 7 , 'position' => '>' ),
2010-02-10 17:27:03 +00:00
9 => array ( 'titre' => 'RENTABILITE FINANCIERE ' , 'stitre' => '(Résult.Net/Cap.propres)' , 'ratio' => 'r263' , 'parent' => 7 , 'position' => '>' ),
10 => array ( 'titre' => 'RENTABILITE COMMERCIALE ' , 'stitre' => '(Résultat net/CA)' , 'ratio' => 'r264' , 'parent' => 7 , 'position' => '>' ),
11 => array ( 'titre' => 'CONTRIBUTION DU CAPITAL' , 'stitre' => '(Capacité d\'autofinancement sur 12 mois / Capitaux permanents)' , 'ratio' => 'r265' , 'parent' => 7 , 'position' => '>' ),
12 => array ( 'titre' => 'CONTRIBUTION DE LA VA' , 'stitre' => '(Capacité d\'autofinancement / Valeur ajoutée)' , 'ratio' => 'r266' , 'parent' => 7 , 'position' => '>' ),
2009-10-13 16:36:27 +00:00
13 => array ( 'titre' => 'LIQUIDITE' ),
2010-02-10 17:27:03 +00:00
14 => array ( 'titre' => 'LIQUIDITE IMMEDIATE' , 'stitre' => '(Disponibilité / Dettes CT)' , 'ratio' => 'r250' , 'parent' => 13 , 'position' => '>' ),
2009-10-13 16:36:27 +00:00
15 => array ( 'titre' => 'LIQUIDITE GENERALE' , 'stitre' => '(Act.circulant net/Dettes CT)' , 'ratio' => 'r251' , 'parent' => 13 , 'position' => '>' ),
2010-02-10 17:27:03 +00:00
16 => array ( 'titre' => 'LIQUIDITE REDUITE' , 'stitre' => '(Disponibilité et créances réelles /Dettes CT)' , 'ratio' => 'r252' , 'parent' => 13 , 'position' => '>' ),
2009-10-13 16:36:27 +00:00
17 => array ( 'titre' => 'ENDETTEMENT' ),
18 => array ( 'titre' => 'ENDETTEMENT ' , 'stitre' => '(Dettes a + 1 an / Capitaux propres)' , 'ratio' => 'r244' , 'parent' => 17 , 'position' => '<' ),
19 => array ( 'titre' => 'CAPACITE DE REMBOURSEMENT' , 'stitre' => '(Dettes.bancaires.(+MT+LT+C.bail)/CAF)' , 'ratio' => 'r247' , 'parent' => 17 , 'position' => '<' ),
20 => array ( 'titre' => 'FINANCEMENT DES STOCKS' , 'stitre' => '(Dettes aux fournisseurs / Stock)' , 'ratio' => 'r248' , 'parent' => 17 , 'position' => '<' ),
21 => array ( 'titre' => 'PRODUCTIVITE' ),
22 => array ( 'titre' => 'PRODUCTIVITE DE L\'ACTIF' , 'stitre' => '(Chiffre d\'affaire / Actif comptable)' , 'ratio' => 'r271' , 'parent' => 21 , 'position' => '>' ),
23 => array ( 'titre' => 'DUREE CLIENT' , 'stitre' => '(Rotation clients en VJ TTC)' , 'ratio' => 'r278' , 'parent' => 21 , 'position' => '<' ),
24 => array ( 'titre' => 'DUREE FOURNISSEUR' , 'stitre' => '(Rotation fournisseurs en JA TTC)' , 'ratio' => 'r279' , 'parent' => 21 , 'position' => '<' ),
25 => array ( 'titre' => 'POIDS MASSE SALARIALE' , 'stitre' => '(Ch personnel / VA)' , 'ratio' => 'r281' , 'parent' => 21 , 'position' => '<' ),
26 => array ( 'titre' => 'RENDEMENT' , 'stitre' => '(Production sur 12mois / Effectif)' , 'ratio' => 'r261' , 'parent' => 21 , 'position' => '>' ),
27 => array ( 'titre' => 'PRODUCTIVITE' , 'stitre' => '(CA / Effectif)' , 'ratio' => 'r267' , 'parent' => 21 , 'position' => '>' ),
);
2009-10-02 17:26:29 +00:00
if (( $siret * 1 ) == 0 || ( $siren * 1 ) < 100 ){ $fileName = 'ratios-' . $idEntreprise ;
} else { $fileName = 'ratios-' . $siret ; }
$fileName .= '-' . $typeBilan ;
foreach ( $tabRatio as $item )
{
2009-06-18 13:22:31 +00:00
if ( $ratio == '' ){
2009-06-16 07:47:53 +00:00
if ( isset ( $item [ 'ratio' ])){
2009-06-18 13:22:31 +00:00
$row .= '<tr>' . " \n " ;
$row .= ' <td><a tooltip="' . wrapComment ( $ratiosInfos [ $item [ 'ratio' ]][ 'commentaires' ]) . '">' . $item [ 'titre' ] . '<br/>' . $item [ 'stitre' ] . '</a></td>' . " \n " ;
$row .= ' <td class="right">' . dRatio ( $bilan , $item [ 'ratio' ]) . '</td>' . " \n " ;
$row .= ' <td class="right">' . dSecteur ( $bilan , $item [ 'ratio' ]) . '</td>' . " \n " ;
$row .= ' <td class="position">' ;
2009-09-24 16:05:13 +00:00
$row .= '<a class="rTip" href="/?page=ratios&siret=' . $_REQUEST [ 'siret' ] . '&idEntreprise=' . $_REQUEST [ 'idEntreprise' ] . '&ratio=' . $item [ 'ratio' ] . '" rel="./pages/ratios_dgraph.php?width=375&f=' . ratios_graph ( $item [ 'ratio' ], dGraph ( $item [ 'ratio' ]), $fileName ) . '" name="' . $item [ 'titre' ] . '">' . " \n " ;
2009-07-02 10:11:25 +00:00
$row .= dPosition ( $bilan , $item [ 'ratio' ], $item [ 'position' ]);
2009-06-18 13:22:31 +00:00
$row .= '</a>' ;
$row .= '</td>' . " \n " ;
$row .= '</tr>' . " \n " ;
2009-06-16 07:47:53 +00:00
} else {
2009-06-18 13:22:31 +00:00
$row .= '<tr class="subhead">' . " \n " ;
$row .= ' <td class="center italique">' . $item [ 'titre' ] . '</td>' . " \n " ;
$row .= ' <td>Entreprise</td>' . " \n " ;
$row .= ' <td>Secteur</td>' . " \n " ;
$row .= ' <td>Position</td>' . " \n " ;
$row .= '</tr>' . " \n " ;
}
} elseif ( $ratio == $item [ 'ratio' ]){
2009-06-16 07:47:53 +00:00
$row .= '<tr class="subhead">' . " \n " .
' <td class="center italique">' . $tabRatio [ $item [ 'parent' ]][ 'titre' ] . '</td>' . " \n " .
' <td>Entreprise</td>' . " \n " .
' <td>Secteur</td>' . " \n " .
' <td>Position</td>' . " \n " .
2009-06-18 13:22:31 +00:00
'</tr>' . " \n " ;
2009-06-16 07:47:53 +00:00
$row .= '<tr>' . " \n " .
' <td><a tooltip="' . wrapComment ( $ratiosInfos [ $item [ 'ratio' ]][ 'commentaires' ]) . '">' . $item [ 'titre' ] . '<br/>' . $item [ 'stitre' ] . '</a></td>' . " \n " .
' <td class="right">' . dRatio ( $bilan , $item [ 'ratio' ]) . '</td>' . " \n " .
' <td class="right">' . dSecteur ( $bilan , $item [ 'ratio' ]) . '</td>' . " \n " .
' <td class="position">' . " \n " .
2009-06-18 13:22:31 +00:00
' <a href="#" name="' . $item [ 'titre' ] . '">' . " \n " .
2009-07-02 10:11:25 +00:00
dPosition ( $bilan , $item [ 'ratio' ], $item [ 'position' ]) . " \n " .
2009-06-16 07:47:53 +00:00
' </a>' . " \n " .
' </td>' . " \n " .
'</tr>' . " \n " ;
}
}
return $row ;
}
2009-06-23 06:54:46 +00:00
/**
* Enregistre le graphique bilan actif sous forme d ' image .
* @ param array $data
2010-02-10 17:27:03 +00:00
* Tableau structuré des données
2009-06-23 06:54:46 +00:00
* @ param array $filename
2010-02-10 17:27:03 +00:00
* Le nom de fichier généré
2009-06-23 06:54:46 +00:00
* @ return string
* Retourne un message d 'erreur ou le code HTML d' affichage .
*/
function bilans_graph_actif ( $data , $filename ){
require_once 'phpchartdir/phpchartdir.php' ;
$w = 570 ;
$h = 210 ;
$x = round ( $w / 2 );
$y = round ( $h / 2 );
$radius = 90 ;
$c = new PieChart ( $w , $h );
$labels = array ( 'Immo. incorporelles' ,
'Immo. corporelles' ,
2010-02-10 17:27:03 +00:00
'Immo. financières' ,
2009-06-23 06:54:46 +00:00
'Stock et encours' ,
2010-02-10 17:27:03 +00:00
'Créances Clients' ,
'Autres créances' ,
'Trésorerie Active' );
2009-06-23 06:54:46 +00:00
$textBoxObj = $c -> addTitle ( " Composition de l'actif " , " timesbi.ttf " , 15 );
$c -> setPieSize ( $x , $y , $radius );
$c -> setLabelLayout ( SideLayout );
$t = $c -> setLabelStyle ();
$t -> setBackground ( SameAsMainColor , Transparent , glassEffect ());
$t -> setRoundedCorners ( 5 );
# Set the border color of the sector the same color as the fill color. Set the line # color of the join line to black (0x0)
$c -> setLineColor ( SameAsMainColor , 0x000000 );
$c -> setStartAngle ( 135 );
$c -> setLabelFormat ( " <*block,valign=absmiddle*> { label} <*font=timesbi.ttf,size=0*>( { percent|0}%) " );
$c -> setData ( $data , $labels );
$c -> set3D ( 20 );
$path = PATH_SITE . '/cache/imgcache/' ;
2009-10-08 15:50:08 +00:00
$file = $filename . '-graph-actif.png' ;
2009-06-23 06:54:46 +00:00
if ( $c -> makeChart ( $path . $file ) === TRUE ){
$return = '<img src="./imgcache/' . $file . '"/>' ;
} else {
2010-02-10 17:27:03 +00:00
$return = 'Impossible de générer le graphique' ;
2009-06-23 06:54:46 +00:00
}
return $return ;
}
2009-06-16 07:47:53 +00:00
2009-06-23 06:54:46 +00:00
/**
* Enregistre le graphique bilan SIG sous forme d ' image .
* @ param array $data
2010-02-10 17:27:03 +00:00
* Tableau structuré des données
2009-06-23 06:54:46 +00:00
* @ param array $filename
2010-02-10 17:27:03 +00:00
* Le nom de fichier généré
2009-06-23 06:54:46 +00:00
* @ return string
* Retourne un message d 'erreur ou le code HTML d' affichage .
*/
function bilans_graph_sig ( $data , $filename ){
require_once 'phpchartdir/phpchartdir.php' ;
$w = 570 ;
$h = 210 ;
$x = round ( $w / 2 );
$y = round ( $h / 2 );
$radius = 70 ;
$c = new PieChart ( $w , $h );
$labels = array ( 'Achats de marchandises.' ,
'Autres achats externes' ,
'Charges de fonctionnement' ,
'Amortissement et provisions' ,
2010-02-10 17:27:03 +00:00
'Perte financière' ,
'Impôts sociétés' ,
'RÉSULTAT NET' ,
2009-06-23 06:54:46 +00:00
);
2010-02-10 17:27:03 +00:00
$textBoxObj = $c -> addTitle ( " Solde Intermédiaire de Gestion " , " timesbi.ttf " , 15 );
2009-06-23 06:54:46 +00:00
$c -> setPieSize ( $x , $y , $radius );
$c -> setLabelLayout ( SideLayout );
$t = $c -> setLabelStyle ();
$t -> setBackground ( SameAsMainColor , Transparent , glassEffect ());
$t -> setRoundedCorners ( 5 );
$c -> setLineColor ( SameAsMainColor , 0x000000 );
$c -> setLabelFormat ( " <*block,valign=absmiddle*> { label} <*font=arial.ttf,size=0*>( { percent|0}%) " );
$c -> setStartAngle ( 135 );
$c -> setData ( $data , $labels );
$c -> set3D ( 20 );
$path = PATH_SITE . '/cache/imgcache/' ;
2009-10-08 15:50:08 +00:00
$file = $filename . '-graph-sig.png' ;
2009-06-23 06:54:46 +00:00
if ( $c -> makeChart ( $path . $file ) === TRUE ){
$return = '<img src="./imgcache/' . $file . '"/>' ;
} else {
2010-02-10 17:27:03 +00:00
$return = 'Impossible de générer le graphique' ;
2009-06-23 06:54:46 +00:00
}
return $return ;
}
2009-06-16 07:47:53 +00:00
2009-06-23 06:54:46 +00:00
/**
* Enregistre le graphique bilan passif sous forme d ' image .
* @ param array $data
2010-02-10 17:27:03 +00:00
* Tableau structuré des données
2009-06-23 06:54:46 +00:00
* @ param array $filename
2010-02-10 17:27:03 +00:00
* Le nom de fichier généré
2009-06-23 06:54:46 +00:00
* @ return string
* Retourne un message d 'erreur ou le code HTML d' affichage .
*/
function bilans_graph_passif ( $data , $filename ){
require_once 'phpchartdir/phpchartdir.php' ;
$w = 570 ;
$h = 210 ;
$x = round ( $w / 2 );
$y = round ( $h / 2 );
$radius = 90 ;
$c = new PieChart ( $w , $h );
$labels = array ( 'Fonds propres' ,
'Provisions Risques' ,
'Compte Courant' ,
2010-02-10 17:27:03 +00:00
'Dettes Financières' ,
2009-06-23 06:54:46 +00:00
'Dettes Fournisseurs' ,
'Dettes fiscales' ,
'Autres Dettes' ,
2010-02-10 17:27:03 +00:00
'Trésorerie Passive' );
2009-06-23 06:54:46 +00:00
$textBoxObj = $c -> addTitle ( " Composition du passif " , " timesbi.ttf " , 15 );
$c -> setPieSize ( $x , $y , $radius );
$c -> setLabelLayout ( SideLayout );
$t = $c -> setLabelStyle ();
$t -> setBackground ( SameAsMainColor , Transparent , glassEffect ());
$t -> setRoundedCorners ( 5 );
$c -> setLineColor ( SameAsMainColor , 0x000000 );
$c -> setStartAngle ( 135 );
$c -> setLabelFormat ( " <*block,valign=absmiddle*> { label} <*font=timesbi.ttf,size=0*>( { percent|0}%) " );
$c -> setData ( $data , $labels );
$c -> set3D ( 20 );
$path = PATH_SITE . '/cache/imgcache/' ;
2009-10-08 15:50:08 +00:00
$file = $filename . '-graph-passif.png' ;
2009-06-23 06:54:46 +00:00
if ( $c -> makeChart ( $path . $file ) === TRUE ){
$return = '<img src="./imgcache/' . $file . '"/>' ;
} else {
2010-02-10 17:27:03 +00:00
$return = 'Impossible de générer le graphique' ;
2009-06-23 06:54:46 +00:00
}
return $return ;
}
2009-06-23 15:16:21 +00:00
/**
2010-02-10 17:27:03 +00:00
* Enregistre le graphique évolution .
2009-06-23 15:16:21 +00:00
* @ param array $data
2010-02-10 17:27:03 +00:00
* Tableau structuré des données
2009-06-23 15:16:21 +00:00
* @ param array $filename
2010-02-10 17:27:03 +00:00
* Le nom de fichier généré
2009-06-23 15:16:21 +00:00
* @ return string
* Retourne un message d 'erreur ou le code HTML d' affichage .
*/
2010-03-01 11:43:21 +00:00
function ratios_graph ( $ratio , $data , $filename )
{
2009-06-29 13:15:25 +00:00
$path = PATH_SITE . '/cache/imgcache/' ;
if ( $ratio != '' ){
$file = $filename . '-' . $ratio . '.png' ;
2009-06-23 15:16:21 +00:00
} else {
2009-06-29 13:15:25 +00:00
$file = $filename . '.png' ;
}
if ( file_exists ( $path . $file )){
$return = $file ;
} else {
require_once 'phpchartdir/phpchartdir.php' ;
if ( count ( $data ) <= 1 ){
$return = 0 ;
} else {
foreach ( $data [ 'data' ] as $value ){
$dataX1 [] = $value [ 'entreprise' ];
$dataX2 [] = $value [ 'secteur' ];
$labelsX [] = substr ( $value [ 'date' ], 0 , 4 );
}
$i =- 100 ; while ( $i > 100 ){ $labelsY [] = $i ;}
$c = new XYChart ( 350 , 250 );
$c -> setPlotArea ( 55 , 10 , 280 , 200 );
$c -> yAxis -> setTitle ( $data [ 'unite' ]);
2010-02-10 17:27:03 +00:00
$c -> xAxis -> setTitle ( " Années " );
2009-06-29 13:15:25 +00:00
$c -> xAxis -> setWidth ( 2 );
$c -> yAxis -> setWidth ( 2 );
$legendObj = $c -> addLegend ( 50 , 10 , false , " times.ttf " , 9 );
$legendObj -> setBackground ( Transparent );
$c -> addLineLayer ( $dataX1 , 0x0000ff , " Entreprise " );
$c -> addLineLayer ( $dataX2 , 0x008C00 , " Secteur " );
$c -> yAxis -> setLabels ( $labelsY );
$c -> yAxis -> setLabelStep ( 10 );
$c -> xAxis -> setLabels ( $labelsX );
if ( $c -> makeChart ( $path . $file ) === TRUE ){ $return = $file ; }
else { $return = FALSE ; }
2009-06-23 15:16:21 +00:00
}
}
return $return ;
}
2009-05-28 14:40:58 +00:00
?>