synthese qui marche

Optimisation du code a faire + le formulaire de gestion des type de bilan elle ne gere pour le moment que les bilan de type N...
This commit is contained in:
Damien LASSERRE 2011-04-29 15:46:59 +00:00
parent 36f8e3e8ce
commit 9f295ce6f2
3 changed files with 122 additions and 147 deletions

View File

@ -34,69 +34,57 @@ class FinanceController extends Zend_Controller_Action
/* ----------------------------------------------------------------------------------------------------*/
public function syntheseAction()
{
{
$syntheseReference = array();
$tabRatio = array(
'r5' => array('CHIFFRE D\'AFFAIRES', 1000, ' K€', 'r6'),
'r7' => array('RESULTAT COURANT AVANT IMPOTS', 1000, ' K€', 'r8'),
'r10' => array('RESULTAT NET', 1000, ' K€', 'r11'),
'r18' => array('FONDS PROPRES', 1000, ' K€', 'r19'),
'r22' => array('TOTAL BILAN', 1000,' K€', 'r23'),
'r231' => array('FONDS DE ROULEMENT', 1000, ' K€', 'r235'),
'r232' => array('BESOIN EN FONDS DE ROULEMENT', 1000, ' K€', 'r236'),
'r249' => array('TRESORERIE', 1000, ' K€','r254'),
'r24' => array('EFFECTIF', 1, ' Pers.', 'r24')
);
$bilanN = array();
$bilanC = array();
$bilanReference = array('r5' => array('evolution' => 'r6' , 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'CHIFFRE D\'AFFAIRES'),
'r7' => array('evolution' => 'r8' , 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'RESULTAT COURANT AVANT IMPOTS'),
'r10' => array('evolution' => 'r11' , 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'RESULTAT NET'),
'r18' => array('evolution' => 'r19' , 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'FONDS PROPRES'),
'r22' => array('evolution' => 'r23' , 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'TOTAL BILAN'),
'r231' => array('evolution' => 'r235', 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'FONDS DE ROULEMENT'),
'r232' => array('evolution' => 'r236', 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'BESOIN EN FONDS DE ROULEMENT'),
'r249' => array('evolution' => 'r254', 'unite' => 'EUR', 'operateur' => 1000, 'name' => 'TRESORERIE'),
'r24' => array('evolution' => 'r24' , 'unite' => 'Pers.', 'operateur' => 1, 'name' => 'EFFECTIF')
);
$request = $this->getRequest();
$synthese = $this->ws->getRatios(substr($request->getParam('siret'), 0, 9), 'synthese');
$this->view->assign('tabRatio', $tabRatio);
$results = $this->ws->getRatios(substr($this->getRequest()->getParam('siret'), 0, 9), 'synthese');
$this->view->assign('results', $results);
$this->view->assign('siret', $this->getRequest()->getParam('siret'));
$this->view->assign('bilanInfo', $results->RatiosInfos->item);
foreach ($results->BilansInfos as $items)
{
foreach ($items as $row) {
foreach ($row as $champ => $valeur) {
foreach($row->RatiosEntrepEvol as $champRatiosEntrepEvol => $RatiosEntrepEvol) {
if ($champ == 'dateCloture') {
$date = $valeur;
if (!array_key_exists($date, $syntheseReference))
$syntheseReference[$date] = array();
}
if($champ == 'duree')
$syntheseReference[$date][$champ] = $valeur;
if ($champ == 'typeBilan') {
$type = $valeur;
$syntheseReference[$date][$type] = array();
}
if($champ == 'RatiosEntrep') {
$rationEntrep = $champ;
foreach($tabRatio as $chm => $element) {
foreach($valeur->item as $itemElement) {
if ($chm == $itemElement->id) {
$var = $syntheseReference[$date][$type][$rationEntrep][] = new stdClass();
$var->val = number_format($itemElement->val/$element[1], 0, '', ' ') . ' ' .$element[2];
$var->label = $element[0];
foreach ($RatiosEntrepEvol as $itemRatiosEntrepEvol) {
if($itemRatiosEntrepEvol->id == $element[3]) {
$var->evol = $itemRatiosEntrepEvol->val;
(($itemRatiosEntrepEvol->val != 'NS') ? $var->evol .= ' %' : false);
}
}
}
}
}
}
}
}
foreach ($synthese->BilansInfos->item as $item) {
if ($item->typeBilan == 'N')
{
foreach ($item->RatiosEntrep->item as $RatiosEntrep) {
foreach ($bilanReference as $id => $params) {
if ($RatiosEntrep->id == $id)
{
$bilanN[$id]['name'] = $params['name'];
$bilanN[$id]['unite'] = $params['unite'];
if (count($bilanN[$id]['item']) <= 2) {
if (is_numeric($RatiosEntrep->val))
$valeur = number_format(($RatiosEntrep->val/$params['operateur']), 0, '', ' ');
$bilanN[$id]['item'][substr($item->dateCloture, 0, 4)]['ValEntrep'] = $valeur;
}
}
}
}
foreach ($item->RatiosEntrepEvol->item as $RatiosEntrepEvol) {
foreach ($bilanReference as $id => $params) {
if ($RatiosEntrepEvol->id == $params['evolution']) {
if (array_key_exists(substr($item->dateCloture, 0, 4), $bilanN[$id]['item']))
$bilanN[$id]['item'][substr($item->dateCloture, 0, 4)]['ValEntrepEvol'] = $RatiosEntrepEvol->val;
}
}
}
}
}
arsort($syntheseReference);
$i = count($syntheseReference);
$syntheseReference2 = array_slice($syntheseReference, $i-3, $i, true);
$this->view->assign('synthese', $syntheseReference2);
foreach ($bilanN as $id => $val)
ksort($bilanN[$id]['item']);
$this->view->assign('raisonSociale', $this->entreprise->nom);
$this->view->assign('siret', $request->getParam('siret'));
$this->view->assign('synthese', $bilanN);
}
public function bilansAction()
@ -128,6 +116,25 @@ class FinanceController extends Zend_Controller_Action
}
}
/**
* Permet de determiner si ont crée l'image ou s'il elle existe daja dans une periode de 8 heures MAX.
*
* @param nom de l'image $name
*/
protected function checkIfImageExist($name)
{
$path = APPLICATION_PATH.'/../cache/pages/imgcache/';
if (file_exists($path.$name.'.png')) {
$date = date('Ymdh', filemtime($path.$name.'.png'));
if($date + 8 > date('Ymdh'))
return (false);
else
return (true);
}
return (false);
}
/**
* 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.
@ -182,7 +189,8 @@ class FinanceController extends Zend_Controller_Action
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);
if (self::checkIfImageExist($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>';

View File

@ -1,67 +1,42 @@
<!-- En cours de dev ne pas modifier. -->
<?php $nb = 0; $type = 'N'?>
<pre>
</pre>
<div id="center">
<h1>Synthese</h1>
<table>
<tr>
<td width="30">&nbsp;</td>
<td class="StyleInfoLib" width="200">Numéro identifiant Siren</td>
<td class="StyleInfoData" width="330"><?php echo number_format(substr($this->siret, 0, 9), 0, '', ' ');?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td class="StyleInfoLib" width="200">Raison Sociale</td>
<td class="StyleInfoData" width="330"><?php echo $this->results->Nom;?></td>
</tr>
</table>
<table id="synthese" style="border:1px solid black" cellspacing="0" cellpadding="0">
<tr>
<?php $i = 0;?>
<td valign="bottom">
<table width="100%" id="synthese-in-table">
<?php foreach($this->synthese[key($this->synthese)]['N']['RatiosEntrep'] as $item):$nb++;?>
<tr>
<td class="head"><?php echo $item->label; ?></td>
</tr>
<?php endforeach;?>
</table>
</td>
<?php foreach ($this->synthese as $champDate => $date):?>
<td align="left">
<table width="100%" id="synthese-in-table">
<tr>
<th style="font-size:11px" class="StyleInfoLib"><?php echo $this->dateFunction->dateT('Ymd', 'd/m/Y', $champDate);?><br /><?php echo $date['duree'];?> Mois</th>
<?php if($i >= 1):?>
<th class="StyleInfoLib">Evolution</th>
<?php endif;?>
</tr>
<?php if(isset($date[$type])):?>
<?php foreach($date[$type]['RatiosEntrep'] as $item):?>
<tr>
<td class="StyleInfoData"><?php echo $item->val; ?></td>
<?php if($i >= 1):?>
<td class="StyleInfoData"><?php echo $item->evol; ?></td>
<?php endif;?>
</tr>
<?php endforeach;?>
<?php endif;?>
</table>
</td>
<?php $i++;?>
<?php endforeach;?>
<td valign="bottom">
<table>
<?php while ($nb >= 0):?>
<tr>
<td><img title="" src="/themes/default/images/finance/char_bar.png" /></td>
</tr>
<?php $nb--;?>
<?php endwhile;?>
</table>
</td>
</tr>
</table>
<h1>SYNTHÈSE</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>
</table>
<table id="synthese">
<thead>
<tr>
<?php foreach($this->synthese[key($this->synthese)]['item'] as $date => $val):?>
<?php if($i == 2 or $i == 1):?>
<th>Evolution</th>
<?php elseif($i == 0):?>
<th></th>
<?php endif;?>
<th><?php echo $date;?></th>
<?php $i++;?>
<?php endforeach;?>
<th>Evolution</th>
</tr>
</thead>
<?php foreach ($this->synthese as $element):?>
<tr>
<td class="head"><?php echo $element['name'];?></td>
<?php foreach ($element['item'] as $valeur):?>
<td class="right"><?php echo $valeur['ValEntrep'] .' '. $element['unite'];?></td>
<td class="right"><?php echo $valeur['ValEntrepEvol'];?> %</td>
<?php endforeach;?>
</tr>
<?php endforeach;?>
</table>
</div>
</div>

View File

@ -71,33 +71,37 @@
/*--------------------------------------------------------------------------------*/
#synthese .head
{
font-weight: bold;
}
#synthese-in-table th
#synthese th
{
background: none repeat scroll 0 0 #B9C9FE;
border: 1px solid #FFFFFF;
color: #003399;
font-size: 11px;
font-size: 13px;
font-weight: normal;
padding: 4px;
font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
padding: 4px;
}
#synthese-in-table td
#synthese td.right
{
padding: 4px;
text-align: right;
}
#synthese
{
border-collapse: collapse;
clear: both;
font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
font-size: 12px;
margin: 10px 0px 0;
padding: 2px;
text-align: left;
width: 100%;
font-family: arial,sans-serif;
font-size: 11px;
}
#synthese td
@ -105,27 +109,15 @@
background: none repeat scroll 0 0 #E8EDFF;
border: 1px solid #FFFFFF;
color: #666699;
padding: 4px;
}
#synthese-in-table tr:hover td
#synthese tr:hover td
{
background: none repeat scroll 0 0 #D0DAFD;
}
#synthese td.date
{
font-size: 11px;
}
#synthese .head
{
font-weight: bold;
}
#synthese td.right
{
text-align: right;
}
/*******************************/
.StyleInfoLib
{