diff --git a/application/controllers/FinanceController.php b/application/controllers/FinanceController.php index 8ac7355c1..95d3b4af7 100644 --- a/application/controllers/FinanceController.php +++ b/application/controllers/FinanceController.php @@ -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 .= ''; $html .= ''.$item->libelle.''; $html .= ''.self::parseUnite($item->unite, $element->val).' '.$item->unite.''; diff --git a/application/views/default/scripts/finance/synthese.phtml b/application/views/default/scripts/finance/synthese.phtml index 1bc9b85ef..7e2374fae 100644 --- a/application/views/default/scripts/finance/synthese.phtml +++ b/application/views/default/scripts/finance/synthese.phtml @@ -1,67 +1,42 @@ - - -
-
-
-

Synthese

- - - - - - - - - - - -
 Numéro identifiant Sirensiret, 0, 9), 0, '', ' ');?>
 Raison Socialeresults->Nom;?>
- - - - - synthese as $champDate => $date):?> - - - - - -
- - synthese[key($this->synthese)]['N']['RatiosEntrep'] as $item):$nb++;?> - - - - -
label; ?>
-
- - - - = 1):?> - - - - - - - - = 1):?> - - - - - -
dateFunction->dateT('Ymd', 'd/m/Y', $champDate);?>
Mois
Evolution
val; ?>evol; ?>
-
- - = 0):?> - - - - - -
-
+

SYNTHÈSE

+
+ + + + + + + + + + + +
Numéro identifiant Sirensiret;?>
Raison SocialeraisonSociale;?>
+ + + + synthese[key($this->synthese)]['item'] as $date => $val):?> + + + + + + + + + + + + synthese as $element):?> + + + + + + + + +
EvolutionEvolution
%
+
\ No newline at end of file diff --git a/public/themes/default/styles/finance.css b/public/themes/default/styles/finance.css index 147a522f2..edb80726e 100644 --- a/public/themes/default/styles/finance.css +++ b/public/themes/default/styles/finance.css @@ -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 {