Les Ratios :

- Création de l'action des ratios
- Création du tableau des ratios
- Création des comparateur de données (+ / -)
- Créatin des graphiques relatifs aux différents ratios
- Création de l'image dans le cache avec l'appelle du controle cahce.

/ Reste a fair la verification de présence de l'image dans le cache sur une durée de 8 heures /
This commit is contained in:
Damien LASSERRE 2011-04-29 10:28:32 +00:00
parent f6ce5b23a8
commit 047472b07c
60 changed files with 6313 additions and 32 deletions

View File

@ -2,30 +2,36 @@
require_once ('common/dates.php');
require_once ('Scores/SessionEntreprise.php');
require_once ('finance/synthese.lib.php');
require_once ('Scores/WsScores.php');
require_once('ChartDirector/lib/phpchartdir.php');
/**
* En cours de DEV ne pas modifier le fichier.
*
* @author divx
*
*/
class FinanceController extends Zend_Controller_Action
{
private $ws;
private $entreprise;
private $dateFunction;
private $graphiqueRatio = array();
public function init()
{
$this->entreprise = new stdClass();
$this->dateFunction = new WDate();
$this->entreprise = new stdClass();
$this->dateFunction = new WDate();
$this->ws = new WsScores();
$entreprise = new SessionEntreprise($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id'));
$this->entreprise->nom = $entreprise->getRaisonSociale();
$this->entreprise->siret = $this->getRequest()->getParam('siret');
$this->entreprise->naf = $entreprise->getNaf();
$this->view->headLink()->appendStylesheet('/themes/default/styles/finance.css', 'all');
require_once ('Scores/WsScores.php');
$this->ws = new WsScores();
$entreprise = new SessionEntreprise($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id'));
$this->view->headScript()
->appendFile('/themes/default/scripts/finance.js', 'text/javascript');
$this->view->assign('dateFunction', $this->dateFunction);
$this->entreprise->nom = $entreprise->getRaisonSociale();
}
/* --------------------------------------------------------------------------------------------------- */
/* Gestion de la synthése avec le graphique */
/* ----------------------------------------------------------------------------------------------------*/
public function syntheseAction()
{
@ -48,8 +54,6 @@ class FinanceController extends Zend_Controller_Action
$this->view->assign('results', $results);
$this->view->assign('siret', $this->getRequest()->getParam('siret'));
$this->view->assign('bilanInfo', $results->RatiosInfos->item);
// echo '<pre>'; print_r($results);exit;
echo '<pre>';$a = new Synthese($results->BilansInfos, $results->RatiosInfos);exit;
foreach ($results->BilansInfos as $items)
{
foreach ($items as $row) {
@ -97,16 +101,302 @@ class FinanceController extends Zend_Controller_Action
public function bilansAction()
{
/*$bilan = $this->ws->getBilan(substr($this->entreprise->siret, 0, 9), $millesime, $typeBilan, $ref);
$this->view->assign('bilan', */
}
public function ratiosAction()
/* --------------------------------------------------------------------------------------------------- */
/* Gestion des ratios avec les graphiques */
/* ----------------------------------------------------------------------------------------------------*/
/**
* Permet de formater correctement les données.
*
* @param type d'unite $unite
* @param la valeur a transcrire $valeur
*/
protected function parseUnite($unite, $valeur)
{
echo '<pre>';
//print_r($this->ws->getRatios(substr($this->getRequest()->getParam('siret'), 0, 9), 'ratios'));
echo '</pre>';
switch ($unite)
{
case 'EUR':
return (number_format((round($valeur)/1000), 0, '', ' '));
case '%':
return (round($valeur));
case 'Jours':
return ($valeur);
default:
return ($valeur);
}
}
/**
* Cette fonction permet de comparer les donnée entre elles pour determiner l'evolution
* positive ou négative, ( j'ai respecté les consigne apppliqué préalablement sur l'ancien Extranet.
*
* @param Objet $valeurEnt
* @param Objet $valeurSec
* @param string (le signe de comparaison) $compare
*/
protected function compareValeur($valeurEnt, $valeurSec, $compare)
{
$ecart = 1/100;
if( $valeurSec=='NS' || $valeurEnt == 'NS' || $valeurSec==NULL || $valeurEnt==NULL) {
return ('-');
} else if ($compare == '>') {
if (($valeurEnt + $ecart) > $valeurSec) {
$return = '<img src="/themes/default/images/finance/ratios_bon.png" />';
} elseif( ($valeurSec - ($valeurSec * $ecart)) < $valeurEnt && ($valeurSec + ($valeurSec * $ecart)) > $valeurEnt) {
$return = '-';
} else {
$return = '<img src="/themes/default/images/finance/ratios_mauvais.png" />';
}
} else if ($compare == '<') {
if (($valeurEnt + $ecart) > $valeurSec) {
$return = '<img src="/themes/default/images/finance/ratios_bon.png" />';
} elseif( ($valeurSec - ($valeurSec * $ecart)) < $valeurEnt && ($valeurSec + ($valeurSec * $ecart)) > $valeurEnt) {
$return = '-';
} else {
$return = '<img src="/themes/default/images/finance/ratios_mauvais.png" />';
}
}
return ($return);
}
/**
* Permet d'afficher les elements par block avec un titre.
*
* @param Le tableau de reference des ID a afficher $tableau
* @param Le nom du block en traitement $name
* @param Les elements de Ratios $element
* @param L'adresse de la variable $html
* @param l'object ratio $ratios
* @param la date du block $date
*/
protected function printElementRatio($tableau, $name, $element, &$html, $ratios, $date)
{
foreach($tableau[$name] as $row => $val) {
if ($row == $element->id) {
foreach ($ratios->RatiosInfos->item as $item) {
if ($item->id == $element->id) {
foreach ($ratios->RatiosSecteur->item as $Secteur) {
if (substr($date, 0, 4) == $Secteur->annee) {
foreach ($Secteur->liste->item as $liste) {
if ($item->id == $liste->id) {
self::createGraphique($ratios, $liste->id, $item->unite, $liste->id);
$html .= '<tr>';
$html .= '<td>'.$item->libelle.'</td>';
$html .= '<td class="right">'.self::parseUnite($item->unite, $element->val).' '.$item->unite.'</td>';
$html .= '<td class="right">'.self::parseUnite($item->unite, $liste->val).' '.$item->unite.'</td>';
$html .= '<td align="center">';
$html .= '<a name="'.$item->libelle.'" class="rTip" rel="'.$this->view->url(array('controller' => 'finance',
'action' => 'printgraph',
'idGraph' => $liste->id.'.png')).'" href="">'.self::compareValeur($element->val, $liste->val, $val).'</a>';
$html .= '</td>';
$html .= '</tr>';
}
}
}
}
}
}
}
}
}
/**
* Apelle la view avec la balise image, j'ai désactivé le layout pour un affichage spécial.
*/
public function printgraphAction()
{
$this->_helper->layout()->disableLayout();
$filename = $this->getRequest()->getParam('idGraph');
$this->view->assign('filename', $filename);
}
/**
* Permet de mettres les clefs du tableau sous forme indexé pour ChartDirector
* @param array $tableau
*/
protected function initTableau($tableau)
{
$i = 0;
foreach($tableau as $date => $valeur){
$tableau[$i] = $valeur;
unset($tableau[$date]);
$i++;
}
return ($tableau);
}
/**
* Permet de calculer avec les unité fournies ( exemple 1 000 000 = 1 000 000 / 1000 (EUR) )
*
* @param la valeur $valeur
* @param l'unité $unite
*/
protected function setUnite($valeur, $unite)
{
switch ($unite) {
case 'EUR':
return ($valeur = $valeur / 1000);
}
}
/**
* Cette fonction permet de créer les abscisses pour les données, en l'ocurence elle gére Entreprise et Secteur
*
* @param le type de courbe $type
* @param l'unité de l'information $unite
* @param l'object ratio $ratio
* @param le tableau a formater $dataX
* @param id de l'element courant $id
* @param l'adresse du tableau de label $labelX
*/
protected function createAbscisse($type, $unite, $ratio, $dataX, $id, &$labelX = null)
{
$i = 0;
if ($type == 'RatiosEntrep') {
foreach ($ratio->BilansInfos->item as $element) {
if ($i >= 5)
break;
if (is_array($labelX))
$labelX[] = substr($element->dateCloture, 0, 4);
//$dataX[substr($element->dateCloture, 0, 4)] = array();
foreach ($element->RatiosEntrep->item as $ratioEntre) {
if ($ratioEntre->id == $id) {
$dataX[substr($element->dateCloture, 0, 4)] = self::setUnite($ratioEntre->val, $unite);$i++;
}
}
}
}
if ($type == 'RatiosSecteur') {
foreach ($ratio->RatiosSecteur->item as $element) {
if($i >= 5)
break;
foreach($element->liste->item as $item) {
if ($item->id == $id) {
$dataX[$element->annee] = self::setUnite($item->val, $unite);$i++;
}
}
}
}
if (is_array($labelX))
sort($labelX);
ksort($dataX);
$dataX = self::initTableau($dataX);
return ($dataX);
}
/**
* Cette fonction crée le graphique et le stock dans cache/imgcache.
*
* @param l'objet ratio $ratio
* @param id de l'element courant $id
* @param l'unité courante $unite
* @param l'id qui servira de nom pour l'image $filename
*/
protected function createGraphique($ratio, $id, $unite, $filename)
{
$labelX = array();
$labelY = array();
$dataX1 = array();
$dataX2 = array();
$path = APPLICATION_PATH. '/../cache/pages/imgcache/';
$file = $filename.'.png';
$dataX1 = self::createAbscisse('RatiosEntrep', $unite, $ratio, $dataX1, $id, $labelX);
$dataX2 = self::createAbscisse('RatiosSecteur', $unite, $ratio, $dataX2, $id);
$c = new XYChart(350, 250);
$c->setPlotArea(55, 10, 280, 200);
$c->yAxis->setTitle($unite);
$c->xAxis->setTitle("Années");
$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($labelY);
$c->yAxis->setLabelStep(10);
$c->xAxis->setLabels($labelX);
$c->makeChart($path.$file);
$return = '/fichier/imgcache/'.$file;
return ($return);
}
/**
* Gestion de l'affichage des ratios.
*/
public function ratiosAction()
{
/**
* 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' => '>')
);
$tab = array();
$siret = $this->getRequest()->getParam('siret');
$id = $this->getRequest()->getParam('id');
$i = 0;
$listeDate = array();
$request = $this->getRequest();
$date = $this->getRequest()->getParam('Date');
$type = $this->getRequest()->getParam('typeBilan');
$html = '';
$ratios = $this->ws->getRatios(substr($this->getRequest()->getParam('siret'), 0, 9), 'ratios');
//echo '<pre>';print_r($ratios);echo '</pre>';exit;
foreach($ratios->BilansInfos->item as $elements) {
//if ($i > 5)break;
$tab[$elements->dateCloture][$elements->typeBilan] = $elements;
$i++;
}
foreach ($tab as $champDate => $valeur)
$listeDate[] = $champDate;
if (isset($date)) {
if (!empty($date)) {
foreach ($tableau as $name => $valeur) {
$html .= '<tr class="subhead">
<td align="center">'.$name.'</td>
<td>Entreprise</td>
<td>Secteur</td>
<td>Position</td>
</tr>';
foreach ($tab[$date][$type]->RatiosEntrep->item as $element)
self::printElementRatio($tableau, $name, $element, $html, $ratios, $date);
}
}
}
$i = 0;
/** Gestion de la vue **/
$this->view->assign('i', $i);
$this->view->assign('html', $html);
$this->view->assign('raisonSociale', $this->entreprise->nom);
$this->view->assign('siret', $siret);
$this->view->assign('id', $id);
$this->view->assign('ratios', $tab);
$this->view->assign('naf', $this->entreprise->naf);
}
/* --------------------------------------------------------------------------------------------------- */
/* Gestion des liasses fiscales */
/* ----------------------------------------------------------------------------------------------------*/
private function selectInUnit($tab, $unite)
{
foreach($tab as $champ => $val) {
@ -118,8 +408,6 @@ class FinanceController extends Zend_Controller_Action
public function liasseAction()
{
$this->view->headScript()
->appendFile('/themes/default/scripts/finance.js', 'text/javascript');
$ancres = array('C' => array('actif', 'passif', 'compteDeResultat'),
'N' => array('actif', 'passif', 'compteDeResultat', 'immobilisations',
'amortissements', 'provisions', 'creancesDettes',
@ -169,10 +457,7 @@ class FinanceController extends Zend_Controller_Action
$this->view->assign('champType', $t[1]);
$this->view->assign('liasse', $liasse);
}
/** Partie vue **/
$this->view->assign('ancres', $ancres);
$this->view->assign('typeFeuille', $typeFeuille);
@ -183,12 +468,19 @@ class FinanceController extends Zend_Controller_Action
$this->view->assign('type', $type);
$this->view->assign('unit', $unit);
}
/* --------------------------------------------------------------------------------------------------- */
/* Gestion des bourses */
/* ----------------------------------------------------------------------------------------------------*/
public function bourseAction()
{
}
/* --------------------------------------------------------------------------------------------------- */
/* Gestion des etablissements bancaires */
/* ----------------------------------------------------------------------------------------------------*/
public function banqueAction()
{

View File

@ -0,0 +1 @@
<img src="/fichier/imgcache/<?php echo $this->filename ?>" />

View File

@ -1 +1,69 @@
<?php
<div id="center">
<h1>Les Rations</h1>
<div class="paragraph">
<table class="identite">
<tr>
<td width="30"></td>
<td class="StyleInfoLib" width="200">Numéro identifiant Siren</td>
<td class="StyleInfoData" width="340"><?php echo $this->siret;?></td>
</tr>
<tr>
<td width="30"></td>
<td class="StyleInfoLib" width="200">Raison Sociale</td>
<td class="StyleInfoData" width="340"><?php echo $this->raisonSociale;?></td>
</tr>
<tr>
<td width="30"></td>
<td class="StyleInfoLib" width="200">Secteur d'activité </td>
<td class="StyleInfoData" width="340"><?php echo $this->naf;?></td>
</tr>
</table>
<table class="identite">
<form method="POST" action="#">
<tr>
<td width="30"></td>
<td width="200" class="StyleInfoLib">Type de bilans</td>
<td width="340" class="StyleInfoData">
<input onclick="submit();" <?php echo (isset($_POST['typeBilan']))?(($_POST['typeBilan'] == ('N'))? 'checked="true"': false): false;?> type="radio" name="typeBilan" value="N"/> <i>Réel normal ou Simplifié</i>
<input onclick="submit();" <?php echo (isset($_POST['typeBilan']))?(($_POST['typeBilan'] == ('C'))? 'checked="true"': false): false;?> type="radio" name="typeBilan" value="C"/> <i>Consolidé</i>
</td>
</tr>
</form>
<?php if(isset($_POST['typeBilan'])):?>
<form method="POST" action="<?php echo $this->url(array('controller' => 'finance',
'action' => 'ratios',
'siret' => $this->siret,
'id' => $this->id));?>">
<input type="hidden" name="typeBilan" value="<?php echo $_POST['typeBilan']?>" />
<tr>
<td width="30"></td>
<td width="200" class="StyleInfoLib">Millésime</td>
<td width="340" class="StyleInfoData">
<select name="Date">
<?php foreach ($this->ratios as $date => $element):?>
<?php if($this->i > 5) break?>
<?php if ($element[$_POST['typeBilan']]->typeBilan == $_POST['typeBilan']):?>
<option <?php echo (isset($_POST['Date']))?(($_POST['Date'] == ($date))? 'selected': false): false;?> value="<?php echo $date;?>">
<?php echo $this->dateFunction->dateT('Ymd', 'd/m/Y', $date);?>
<?php if($_POST['typeBilan'] == 'C'):?>
Consolidé
<?php endif;?>
</option>
<?php endif;?>
<?php $this->i++;?>
<?php endforeach;?>
</select>
<input type="submit" value="Ok" />
</td>
</tr>
</form>
<?php endif;?>
</table>
</div>
<h2>Ratios</h2>
<div class="paragraph">
<table id="ratios" style="border-collapse:collapse">
<?php echo $this->html;?>
</table>
</div>
</div>

14
config/configuration.ini Executable file
View File

@ -0,0 +1,14 @@
[mail]
method =
port =
support =
contact =
[wkhtmltopdf]
arch = "amd64"
[path]
data = APPLICATION_PATH "/../../data"
log = "log"
pdf = "pdf"
logos = "logos"

View File

@ -0,0 +1 @@
DEVP-2AGF-AAFD-GAEY-BF6F-829C

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -46,6 +46,12 @@ class SessionEntreprise
return $session->fj;
}
public function getNaf()
{
$session = Zend_Registry::get($this->index);
return ($session->nafEn);
}
protected function getInfoEntrep($siret, $id = 0)
{
require_once 'Scores/WsScores.php';

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -7,7 +7,30 @@ $(document).ready( function()
$(".content").slideUp();
var contenu_aff = $(this).attr("title");
$("#" + contenu_aff).slideDown();
}
);
}
);
});
$('.rTip').each(function()
{
$(this).qtip(
{
content: {
text: 'Chargement...',
url: $(this).attr('rel'),
title: { text: $(this).attr('name')}
},
position: {
corner: {
target: 'leftMiddle',
tooltip: 'rightMiddle'
}
},
show: { solo: true},
style: {
tip: true,
border: { width: 1, radius: 0 },
name: 'light',
width: 400
}
});
});
});

View File

@ -1,5 +1,45 @@
@CHARSET "UTF-8";
#ratios tr.subhead td
{
background: none repeat scroll 0 0 #B9C9FE;
border: 1px solid #000000;
color: #000000;
font-weight: bold;
padding: 8px;
}
#ratio
{
clear: both;
font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
font-size: 12px;
margin: 10px 0 0;
text-align: left;
width: 100%;
}
#ratios tr.subhead td
{
background: none repeat scroll 0 0 #B9C9FE;
border: 1px solid #000000;
color: #000000;
font-weight: bold;
padding: 8px;
}
#ratios td
{
border: 1px solid #000000;
color: #000000;
padding: 8px;
}
#ratios td.right
{
text-align: right;
}
#LiasseTable
{