graphique de la synthese
This commit is contained in:
parent
e14f08dd47
commit
79f29b1642
@ -5,13 +5,26 @@ require_once ('finance/synthese.lib.php');
|
||||
require_once ('Scores/WsScores.php');
|
||||
require_once ('ChartDirector/phpchartdir.php');
|
||||
|
||||
/**
|
||||
* La Classe finance gére les actions concernant la partie element financiés du menu
|
||||
*
|
||||
* Les Bilans.
|
||||
* La Synthese.
|
||||
* Les Ratios.
|
||||
* Les Etablissements bancaires.
|
||||
* Les Liasses fiscales.
|
||||
* Les cotations en bourses.
|
||||
*
|
||||
* @author Damien Lasserre
|
||||
*
|
||||
*/
|
||||
class FinanceController extends Zend_Controller_Action
|
||||
{
|
||||
private $ws;
|
||||
private $entreprise;
|
||||
private $dateFunction;
|
||||
private $imageCachePath;
|
||||
private $idSC;
|
||||
private $ws; // L'objet WSScores pour les requetes.
|
||||
private $entreprise; // Un stdClass pour quelques info sur la société.
|
||||
private $dateFunction; // Objet qui gére les dates.
|
||||
private $imageCachePath; // Chemin des images de graphique en cache.
|
||||
private $idSC; // Id unique Scores-et-decision ( URL ).
|
||||
|
||||
public function init()
|
||||
{
|
||||
@ -105,7 +118,7 @@ class FinanceController extends Zend_Controller_Action
|
||||
$this->view->assign('siren', $this->entreprise->siren);
|
||||
$this->view->assign('synthese', $bilanN);
|
||||
$this->view->assign('nameForGraphique', $bilanReference);
|
||||
self::analyseSyntheseGraphique($synthese, $bilanReference);
|
||||
self::analyseSyntheseGraphique($synthese->BilansInfos->item);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,21 +218,111 @@ class FinanceController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
|
||||
private function getValFromKey($stdClass, $key)
|
||||
{
|
||||
foreach($stdClass as $element) {
|
||||
if ($element->id == $key)
|
||||
return ($element->val/1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* En cours de developement
|
||||
*
|
||||
* @param unknown_type $synthese
|
||||
* @param unknown_type $bilanReference
|
||||
*/
|
||||
protected function analyseSyntheseGraphique($synthese, $bilanReference)
|
||||
protected function analyseSyntheseGraphique($data)
|
||||
{
|
||||
$referenceTab = array('r236', 'r235', 'r6', 'r146');
|
||||
$dataX = array();
|
||||
$filename = "test.png";
|
||||
|
||||
foreach($referenceTab as $id){
|
||||
self::getVal($id, $dataX[$id], $synthese);
|
||||
}
|
||||
//Tri des données par date et par ordre croissant
|
||||
foreach ($data as $key => $row) { $date[$key] = $row->dateCloture; }
|
||||
array_multisort($date, SORT_ASC, $data);
|
||||
|
||||
//Définition des valeurs pour le graph
|
||||
$dataBFR = array();
|
||||
$dataFR = array();
|
||||
$dataCA = array();
|
||||
$BFR = array();
|
||||
$i=0;
|
||||
$nbAnnees = 0;
|
||||
|
||||
//Parcourir les années
|
||||
foreach($data as $item){
|
||||
$anneeFin = substr($item->dateCloture,0,4);
|
||||
$moisFin = substr($item->dateCloture,4,2);
|
||||
$jourFin = substr($item->dateCloture,6,2);
|
||||
//Calcul de la date de début
|
||||
$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
|
||||
if(count($dataBFR['x']) < 5)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
//Affectation des ordonnées
|
||||
if(count($dataBFR['y']) < 5)
|
||||
$dataBFR['y'][$i] = $dataBFR['y'][$i+1] = self::getValFromKey($item->RatiosEntrep->item, 'r236');
|
||||
if(count($dataFR['y']) < 5)
|
||||
$dataFR['y'][$i] = $dataFR['y'][$i+1] = self::getValFromKey($item->RatiosEntrep->item, 'r235');
|
||||
if(count($dataCA['y']) < 5)
|
||||
$dataCA['y'][$i] = $dataCA['y'][$i+1] = self::getValFromKey($item->RatiosEntrep->item, 'r6');
|
||||
if(count($dataEBE['y']) < 5)
|
||||
$dataEBE['y'][$i] = $dataEBE['y'][$i+1] = self::getValFromKey($item->RatiosEntrep->item, 'r146');
|
||||
|
||||
$i+=2;
|
||||
}
|
||||
|
||||
$c = new XYChart(660, 350, 0xcccccc, 0x000000, 1);
|
||||
$c->addTitle("Synthèse *", "timesbi.ttf", 15, 0x000000);
|
||||
$c->addText(60, 320, "* Elements financier rapportés à 12 mois" );
|
||||
$c->setPlotArea(60, 80, 500, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
|
||||
$c->yAxis->setTitle("KEUROS","timesbi.ttf",10);
|
||||
$c->xAxis->setTitle( "<*block,valign=absmiddle*>Années<*/*>");
|
||||
$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
|
||||
$layer1 = $c->addStepLineLayer($dataFR['y'], 0x0000ff, "FONDS DE ROULEMENT");
|
||||
$layer1->setXData($dataFR['x']);
|
||||
$layer1->setLineWidth(2);
|
||||
|
||||
// Add a red (ff0000) step line layer to the chart and set the line width to 2 pixels
|
||||
$layer0 = $c->addStepLineLayer($dataBFR['y'], 0xff0000, "BESOIN EN FONDS DE ROULEMENT");
|
||||
$layer0->setXData($dataBFR['x']);
|
||||
$layer0->setLineWidth(2);
|
||||
|
||||
// Add a green (00ff00) step line layer to the chart and set the line width to 2 pixels
|
||||
$layer2 = $c->addStepLineLayer($dataCA['y'], 0x00ff00, "CHIFFRE D'AFFAIRES");
|
||||
$layer2->setXData($dataCA['x']);
|
||||
$layer2->setLineWidth(2);
|
||||
|
||||
// Add a black (000000) step line layer style dash to the chart and set the line width to 2 pixels
|
||||
$layer3 = $c->addStepLineLayer($dataEBE['y'], $c->dashLineColor(0x000000, DashLine), "EXCEDENT BRUT D'EXPLOITATION");
|
||||
$layer3->setXData($dataEBE['x']);
|
||||
$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);
|
||||
|
||||
if($c->makeChart($this->imageCachePath.$filename) === TRUE){
|
||||
$return = '<img src="./fichier/imgcache/'.$filename.'"/>';
|
||||
}else{
|
||||
$return = 'Impossible de générer le graphique';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------- */
|
||||
@ -356,7 +459,7 @@ class FinanceController extends Zend_Controller_Action
|
||||
{
|
||||
case 'EUR':
|
||||
return (number_format((round($valeur)/1000), 0, '', ' '));
|
||||
case '%':
|
||||
case '%' :
|
||||
return (round($valeur));
|
||||
case 'Jours':
|
||||
return ($valeur);
|
||||
@ -596,11 +699,11 @@ class FinanceController extends Zend_Controller_Action
|
||||
* Ont ajoute de nouveaux ratios a cette endroit
|
||||
* @var unknown_type
|
||||
*/
|
||||
$tableau = array('EquilibreFinancier' => array('r233' => '>', 'r234' => '>', 'r237' => '>', 'r238' => '>', 'r239' => '>', 'r240' => '>'),
|
||||
'Profitabilite' => array('r262' => '>', 'r263' => '>', 'r264' => '>', 'r265' => '>', 'r266' => '>'),
|
||||
'Liquidite' => array('r250' => '>', 'r251' => '>', 'r252' => '>'),
|
||||
'Endetement' => array('r241' => '<', 'r247' => '<', 'r248' => '<'),
|
||||
'Productivite' => array('r271' => '>', 'r278' => '<', 'r279' => '<', 'r281' => '<', 'r261' => '>', 'r267' => '>')
|
||||
$tableau = array('EquilibreFinancier' => array('r233' => '>', 'r234' => '>', 'r237' => '>', 'r238' => '>', 'r239' => '>', 'r240' => '>'),
|
||||
'Profitabilite' => array('r262' => '>', 'r263' => '>', 'r264' => '>', 'r265' => '>', 'r266' => '>'),
|
||||
'Liquidite' => array('r250' => '>', 'r251' => '>', 'r252' => '>'),
|
||||
'Endetement' => array('r241' => '<', 'r247' => '<', 'r248' => '<'),
|
||||
'Productivite' => array('r271' => '>', 'r278' => '<', 'r279' => '<', 'r281' => '<', 'r261' => '>', 'r267' => '>')
|
||||
);
|
||||
|
||||
$tab = array();
|
||||
@ -612,8 +715,7 @@ class FinanceController extends Zend_Controller_Action
|
||||
$date = $this->getRequest()->getParam('Date');
|
||||
$type = $this->getRequest()->getParam('typeBilan');
|
||||
$html = '';
|
||||
|
||||
$ratios = $this->ws->getRatios($this->entreprise->siren, 'ratios');
|
||||
$ratios = $this->ws->getRatios($this->entreprise->siren, 'ratios');
|
||||
|
||||
foreach($ratios->BilansInfos->item as $elements) {
|
||||
$tab[$elements->dateCloture][$elements->typeBilan] = $elements;
|
||||
@ -684,14 +786,14 @@ class FinanceController extends Zend_Controller_Action
|
||||
|
||||
/** La liste des type de bilan existant **/
|
||||
$liste = array ('N' => array(), 'S' => array(),
|
||||
'C' => array(), 'B' => array(),
|
||||
'A' => array());
|
||||
'C' => array(), 'B' => array(),
|
||||
'A' => array());
|
||||
/** Le nom des type pour le select */
|
||||
$type = array ('A' => 'Assurance', 'B' => 'Banque',
|
||||
'C' => 'Consolidé', 'N' => '');
|
||||
'C' => 'Consolidé', 'N' => '');
|
||||
/** Liste des unités que l'ont proposent **/
|
||||
$unit = array ('€' => 1, 'K€' => 1000,
|
||||
'M€' => 1000000);
|
||||
'M€' => 1000000);
|
||||
$liasse = array ();
|
||||
$date = $this->getRequest()->getParam('date');
|
||||
$siret = $this->getRequest()->getParam('siret');
|
||||
@ -703,12 +805,12 @@ class FinanceController extends Zend_Controller_Action
|
||||
$liste[$item->typeBilan][] = $item->dateExercice;
|
||||
|
||||
/** ont transforme les bilan de type S en N **/
|
||||
$NandS = array_merge($liste['N'], $liste['S']);
|
||||
$NandS = array_merge($liste['N'], $liste['S']);
|
||||
$liste['N'] = $NandS;unset($liste['S']);
|
||||
|
||||
if (!empty($date)) {
|
||||
$dateAndType = explode(':', $date);
|
||||
$liasses = $this->ws->getBilan($this->entreprise->siren, $dateAndType[0], $dateAndType[1], true);
|
||||
$liasses = $this->ws->getBilan($this->entreprise->siren, $dateAndType[0], $dateAndType[1], true);
|
||||
|
||||
$this->view->assign('dateCloture', $liasses->DATE_CLOTURE);
|
||||
$this->view->assign('dateCloturePre', $liasses->DATE_CLOTURE_PRE);
|
||||
@ -739,6 +841,10 @@ class FinanceController extends Zend_Controller_Action
|
||||
/* Gestion des bourses */
|
||||
/* ----------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Fonction qui gére la cotation en bourse.
|
||||
* Enter description here ...
|
||||
*/
|
||||
public function bourseAction()
|
||||
{
|
||||
$this->view->assign('bourse', $bourse);
|
||||
@ -747,6 +853,9 @@ class FinanceController extends Zend_Controller_Action
|
||||
/* --------------------------------------------------------------------------------------------------- */
|
||||
/* Gestion des etablissements bancaires */
|
||||
/* ----------------------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Fonction qui gére les etablissements bancaires.
|
||||
*/
|
||||
public function banqueAction()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user