From 919fd78382f6f326b4fddce7c692257096bdf924 Mon Sep 17 00:00:00 2001 From: Damien LASSERRE Date: Thu, 19 May 2011 15:48:36 +0000 Subject: [PATCH] Modification des bilans + des news --- application/controllers/FinanceController.php | 166 ++++++++++++++++++ .../views/default/helpers/ActifGraph.php | 36 ---- .../views/default/helpers/LineBilan.php | 55 +++--- application/views/default/helpers/News.php | 58 ++++++ .../views/default/helpers/PassifGraph.php | 42 ----- .../views/default/helpers/SigGraph.php | 40 ----- .../bilansPartials/actif.partial.phtml | 25 ++- .../bilansPartials/passif.partial.phtml | 16 +- .../finance/bilansPartials/sig.partial.phtml | 17 +- .../scripts/finance/printgraphbilan.phtml | 4 + .../views/default/scripts/identite/news.phtml | 7 +- 11 files changed, 315 insertions(+), 151 deletions(-) delete mode 100644 application/views/default/helpers/ActifGraph.php create mode 100644 application/views/default/helpers/News.php delete mode 100644 application/views/default/helpers/PassifGraph.php delete mode 100644 application/views/default/helpers/SigGraph.php create mode 100644 application/views/default/scripts/finance/printgraphbilan.phtml diff --git a/application/controllers/FinanceController.php b/application/controllers/FinanceController.php index 3f75cc087..96656b425 100644 --- a/application/controllers/FinanceController.php +++ b/application/controllers/FinanceController.php @@ -455,7 +455,169 @@ class FinanceController extends Zend_Controller_Action } return ($tb); } + protected function selectTitleForGraphique($title) { + switch ($title) { + case 'actif': + return ('Composition de l\'actif'); + case 'passif': + return ('Composition du passif'); + case 'sig': + return (''); + } + } + protected function makeBigGraphiqueBilan($type, $data, $siren, $annee, $i, $unite) + { + $filename = $siren; + $file = $i.'-'.$filename.'-graph-actif.png'; + $w = 660; + $h = 243; + $x = round($w/2); + $y = round($h/2); + $radius = 90; + $c = new PieChart($w, $h); + $labels = array('Immo. incorporelles', 'Immo. corporelles', + 'Immo. financières', 'Stock et encours', + 'Créances Clients', 'Autres créances', + 'Trésorerie Active'); + + + $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); + $chart1URL = $c->makeSession("chart1"); // Gère le cache immédiat de la page ( F5 ). + $imageMap = $c->getHTMLImageMap("", "", "name='{label}' title='{label} ".$annee."
{value|0} ".$unite."' class='detailsgraphique'"); + $c->makeChart($this->imageCachePath.$file); + + $parametres = new stdClass(); + $parametres->file = $file; + $parametres->chart1URL = $chart1URL; + $parametres->imageMap = $imageMap; + $parametres->i = $i; + + return ($parametres); + } + + public function actifgraphAction() + { + $type = 'actif'; + $data = $this->getRequest()->getParam('data'); + $siren = $this->getRequest()->getParam('siren'); + $annee = $this->getRequest()->getParam('annee'); + $i = $this->getRequest()->getParam('i'); + + $parametres = self::makeBigGraphiqueBilan($type, $data, $siren, $annee, $i, 'K.euros'); + + $this->view->assign('file', $parametres->file); + $this->view->assign('chart1URL', $parametres->chart1URL); + $this->view->assign('imageMap', $parametres->imageMap); + $this->view->assign('i', $parametres->i); + + $this->render('printgraphbilan'); + } + + public function passifgraphAction() + { + $data = $this->getRequest()->getParam('data'); + $siren = $this->getRequest()->getParam('siren'); + $annee = $this->getRequest()->getParam('annee'); + $i = $this->getRequest()->getParam('i'); + + $filename = $siren; + $file = $i.'-'.$filename.'-graph-passif.png'; + $w = 660; + $h = 243; + $x = round($w/2); + $y = round($h/2); + $radius = 90; + $c = new PieChart($w, $h); + $labels = array('Fonds propres', + 'Provisions Risques', + 'Compte Courant', + 'Dettes Financières', + 'Dettes Fournisseurs', + 'Dettes fiscales', + 'Autres Dettes', + 'Trésorerie Passive' + ); + + $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); + # 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); + $chart1URL = $c->makeSession("chart1"); + $imageMap = $c->getHTMLImageMap("", "", "name='{label}' title='{label}
{value|0} K.Euros' class='detailsgraphique'"); + $c->makeChart($this->imageCachePath.$file); + + $this->view->assign('file', $file); + $this->view->assign('chart1URL', $chart1URL); + $this->view->assign('imageMap', $imageMap); + $this->view->assign('i', '2'.$i); + + $this->render('printgraphbilan'); + } + + public function siggraphAction() + { + $data = $this->getRequest()->getParam('data'); + $siren = $this->getRequest()->getParam('siren'); + $annee = $this->getRequest()->getParam('annee'); + $i = $this->getRequest()->getParam('i'); + + $filename = $siren; + $file = $i.'-'.$filename.'-graph-sig.png'; + $w = 660; + $h = 243; + $x = round($w/2); + $y = round($h/2); + $radius = 90; + $c = new PieChart($w, $h); + $labels = array('Achats de marchandises.', + 'Autres achats externes', + 'Charges de fonctionnement', + 'Amortissement et provisions', + 'Perte financière', + 'Impôts sociétés', + 'RÉSULTAT NET', + ); + $textBoxObj = $c->addTitle("Solde intermédiaire de gestion", "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); + $chart1URL = $c->makeSession("chart1"); + $imageMap = $c->getHTMLImageMap("", "", "name='{label}' title='{label}
{value|0} %' class='detailsgraphique'"); + $c->makeChart('../cache/pages/imgcache/'.$file); + $c->makeChart($this->imageCachePath.$file); + + $this->view->assign('file', $file); + $this->view->assign('chart1URL', $chart1URL); + $this->view->assign('imageMap', $imageMap); + $this->view->assign('i', '3'.$i); + + $this->render('printgraphbilan'); + } + /* --------------------------------------------------------------------------------------------------- */ /* Gestion des ratios avec les graphiques */ /* ----------------------------------------------------------------------------------------------------*/ @@ -916,6 +1078,10 @@ class FinanceController extends Zend_Controller_Action /** ont transforme les bilan de type S en N => !!!! ERREUR !!!! **/ $NandS = array_merge($liste['N'], $liste['S']); $liste['N'] = $NandS;unset($liste['S']); + /** + * Utiliser un système de masque pour mapper les données sur le rapport normal. + * Exemple : DL => 142 + */ if (!empty($date)) { $dateAndType = explode(':', $date); diff --git a/application/views/default/helpers/ActifGraph.php b/application/views/default/helpers/ActifGraph.php deleted file mode 100644 index 02d936195..000000000 --- a/application/views/default/helpers/ActifGraph.php +++ /dev/null @@ -1,36 +0,0 @@ -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); - $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); - $chart1URL = $c->makeSession("chart1"); // Gère le cache immédiat de la page ( F5 ). - $imageMap = $c->getHTMLImageMap("", "", "name='{label}' title='{label} ".$annee."
{value|0} K.Euros' class='detailsgraphique'"); - $c->makeChart('../cache/pages/imgcache/'.$file); - echo ''.$imageMap.''; - } -} \ No newline at end of file diff --git a/application/views/default/helpers/LineBilan.php b/application/views/default/helpers/LineBilan.php index b07d6b178..e97cb94df 100644 --- a/application/views/default/helpers/LineBilan.php +++ b/application/views/default/helpers/LineBilan.php @@ -16,9 +16,11 @@ Class Zend_View_Helper_LineBilan extends Zend_View_Helper_Abstract if($element != 'NS') { if ($element != 0 and $reference != 0) { return (round(($element * 100) / $reference, 2)); + } else { + return($element); } } - return (0); + return (false); } /** @@ -79,22 +81,25 @@ Class Zend_View_Helper_LineBilan extends Zend_View_Helper_Abstract return (false); } - public function specialSIG($id, $partial) - { - if ($id == 'r101') - return self::Tb(end($partial['r101']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r122']['item']), end($partial['r101']['item'])); - else if ($id == 'r122') - return self::Tb(end($partial['r122']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r130']['item']), end($partial['r101']['item'])); - else if ($id == 'r130') - return self::Tb(end($partial['r130']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r140']['item']), end($partial['r101']['item'])); - else if ($id == 'r140') - return self::Tb(end($partial['r140']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r150']['item']), end($partial['r101']['item'])); - else if ($id == 'r150') - return self::Tb(end($partial['r150']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r170']['item']), end($partial['r101']['item'])); - else if ($id == 'r170') - return self::Tb(end($partial['r170']['item']), end($partial['r101']['item'])) - self::Tb(end($partial['r199']['item']), end($partial['r101']['item'])); - else if ($id == 'r199') - return self::Tb(end($partial['r199']['item']), end($partial['r101']['item'])); + public function specialSIG($id, $element, $partial, $count) + { + if($element != 'NS') { + if ($id == 'r101') + return self::Tb($element, $element) - self::Tb($partial['r122']['item'][$count], $partial['r101']['item'][$count]); + else if ($id == 'r122') + return self::Tb($element, $partial['r101']['item'][$count]) - self::Tb($partial['r130']['item'][$count], $partial['r101']['item'][$count]); + else if ($id == 'r130') + return self::Tb($element, $partial['r101']['item'][$count]) - self::Tb($partial['r140']['item'][$count], $partial['r101']['item'][$count]); + else if ($id == 'r140') + return self::Tb($element, $partial['r101']['item'][$count]) - self::Tb($partial['r150']['item'][$count], $partial['r101']['item'][$count]); + else if ($id == 'r150') + return self::Tb($element, $partial['r101']['item'][$count]) - self::Tb($partial['r170']['item'][$count], $partial['r101']['item'][$count]); + else if ($id == 'r170') + return self::Tb($element, $partial['r101']['item'][$count]) - self::Tb($partial['r199']['item'][$count], $partial['r101']['item'][$count]); + else if ($id == 'r199') + return self::Tb($element, $partial['r101']['item'][$count]); + } else + return (null); } /** @@ -110,19 +115,23 @@ Class Zend_View_Helper_LineBilan extends Zend_View_Helper_Abstract */ public function LineBilan($id, $Graphdate, $partial, $reference, $url, $name, $tb_reference, $siren, $sig = false) { + $i = 0; $this->column = 0; echo ''; echo ''.$name.''; foreach($partial[$id]['item'] as $element) { if($element != 'NS'){ $GraphLine[] = $number = $element; }else{$number = 0; $GraphLine[] = 0;}; echo '' . (($element != 'NS') ? number_format($element, 0, '', ' ') . ' K€':$element).''; - if($sig)$gr = self::specialSIG($id, $partial); - if(self::createlementForGraphique($id))$gr = $number; + if($sig) { + $result = self::specialSIG($id, $element, $partial, $i); + if($result != null){ + $gr[] = $result;$i++; + } + } + else + if(self::createlementForGraphique($id))$gr[] = $number; } - if($id != 'r22' and $id != 'r101') - echo '' . self::Tb($element, (!$this->sig)?$partial[$tb_reference]['item'][key($partial[$tb_reference]['item'])]:$this->sig) . ''; - else - echo ''.self::Tb($element, (($this->sig)?$this->sig = $element:$element)).''; + echo ''.self::Tb(end($partial[$id]['item']), end($partial[$tb_reference]['item'])).''; self::GraphLineBilan($GraphLine, $id.'-'.$siren, $Graphdate); echo ''; echo ' 'Lundi', + 'Tue,' => 'Mardi', + 'Wed,' => 'Mercredi', + 'Thu,' => 'Jeudi', + 'Fri,' => 'Vendredi', + 'Sat,' => 'Samedi', + 'Sun,' => 'Dimanche' + ); + protected $mois = array ('Jan' => 'Janvier', + 'Feb' => 'Février', + 'Mar' => 'Mars', + 'Apr' => 'Avril', + 'May' => 'Mai', + 'Jun' => 'Juin', + 'Jul' => 'Juillet', + 'Aug' => 'Aout', + 'Sep' => 'Septembre', + 'Oct' => 'Octobre', + 'Nov' => 'Novembre', + 'Dev' => 'Décembre' + ); + + private function returnNumberMonth($moisRecherche) { + $i = 0; + foreach($this->mois as $mois => $valeur) { + if (($i + 1) == $moisRecherche) { + return ($mois); + } + $i++; + } + } + + public function News($date) + { + $elementDate = explode(' ',$date); + $today = explode('/', date('d/m/Y')); + + if ((self::returnNumberMonth($today[1]) == $elementDate[2]) and $today[0] == $elementDate[1]) + return ('Aujourd\'huit'); + + $dateFormate = ''; + + + foreach ($this->jours as $jour => $valeurFR) { + if ($jour == $elementDate[0]) + $dateFormate = $valeurFR; + } + $dateFormate .= ' '.$elementDate[1].' '; + foreach ($this->mois as $mois => $valeurFR) { + if ($mois == $elementDate[2]) + $dateFormate .= $valeurFR; + } + return ($dateFormate .= ' '.$elementDate[3]); + } +} \ No newline at end of file diff --git a/application/views/default/helpers/PassifGraph.php b/application/views/default/helpers/PassifGraph.php deleted file mode 100644 index 93fe43b97..000000000 --- a/application/views/default/helpers/PassifGraph.php +++ /dev/null @@ -1,42 +0,0 @@ -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); - # 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); - $chart1URL = $c->makeSession("chart1"); - $imageMap = $c->getHTMLImageMap("", "", "name='{label}' title='{label}
{value|0} K.Euros' class='detailsgraphique'"); - $c->makeChart('../cache/pages/imgcache/'.$file); - echo ''.$imageMap.''; - } -} \ No newline at end of file diff --git a/application/views/default/helpers/SigGraph.php b/application/views/default/helpers/SigGraph.php deleted file mode 100644 index f96dc311e..000000000 --- a/application/views/default/helpers/SigGraph.php +++ /dev/null @@ -1,40 +0,0 @@ -addTitle("Solde intermédiaire de gestion", "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); - $chart1URL = $c->makeSession("chart1"); - $imageMap = $c->getHTMLImageMap("", "", "name='{label}' title='{label}
{value|0} K.Euros' class='detailsgraphique'"); - $c->makeChart('../cache/pages/imgcache/'.$file); - echo ''.$imageMap.''; - } -} \ No newline at end of file diff --git a/application/views/default/scripts/finance/bilansPartials/actif.partial.phtml b/application/views/default/scripts/finance/bilansPartials/actif.partial.phtml index 0ff41ec8f..ee806faaa 100644 --- a/application/views/default/scripts/finance/bilansPartials/actif.partial.phtml +++ b/application/views/default/scripts/finance/bilansPartials/actif.partial.phtml @@ -1,14 +1,15 @@ actif['r22']['item']);?> - +

Bilan actif - passif

date as $date):?> - + @@ -21,5 +22,19 @@
Actif dateFunction->dateT('Ymd', 'd/m/Y', $date);?>
- +
dateFunction->dateT('Ymd', 'd/m/Y', $date);?>
+ duree;?> Mois
% T.B.
-actifGraph($tb, $this->siren.'-'.$this->typeBilan, $this, end($Graphdate));?> - + + + action('actifgraph', 'finance', null, array('data' => $valeur[$i], 'siren' => $this->siren.'-'.$this->typeBilan, 'annee' => end($Graphdate), 'i' => $i));?> + diff --git a/application/views/default/scripts/finance/bilansPartials/passif.partial.phtml b/application/views/default/scripts/finance/bilansPartials/passif.partial.phtml index d7156f3aa..e36e3e0f1 100644 --- a/application/views/default/scripts/finance/bilansPartials/passif.partial.phtml +++ b/application/views/default/scripts/finance/bilansPartials/passif.partial.phtml @@ -20,4 +20,18 @@ -passifGraph($tb, $this->siren.'-'.$this->typeBilan, $this);?> \ No newline at end of file + + + action('passifgraph', 'finance', null, array('data' => $valeur[$i], 'siren' => $this->siren.'-'.$this->typeBilan, 'annee' => end($Graphdate), 'i' => $i));?> + \ No newline at end of file diff --git a/application/views/default/scripts/finance/bilansPartials/sig.partial.phtml b/application/views/default/scripts/finance/bilansPartials/sig.partial.phtml index 740b20413..eec8e78e7 100644 --- a/application/views/default/scripts/finance/bilansPartials/sig.partial.phtml +++ b/application/views/default/scripts/finance/bilansPartials/sig.partial.phtml @@ -21,4 +21,19 @@ -sigGraph($tb, $this->siren.'-'.$this->typeBilan, $this);?> \ No newline at end of file + + + action('siggraph', 'finance', null, array('data' => $valeur[$i], 'siren' => $this->siren.'-'.$this->typeBilan, 'annee' => end($Graphdate), 'i' => $i));?> + \ No newline at end of file diff --git a/application/views/default/scripts/finance/printgraphbilan.phtml b/application/views/default/scripts/finance/printgraphbilan.phtml new file mode 100644 index 000000000..b249d00a1 --- /dev/null +++ b/application/views/default/scripts/finance/printgraphbilan.phtml @@ -0,0 +1,4 @@ + + + imageMap;?> + \ No newline at end of file diff --git a/application/views/default/scripts/identite/news.phtml b/application/views/default/scripts/identite/news.phtml index ed6586624..74852aebf 100644 --- a/application/views/default/scripts/identite/news.phtml +++ b/application/views/default/scripts/identite/news.phtml @@ -1,9 +1,10 @@
-

Actualités en directe

+

Information presse (Source Google News ©)

+
    items as $item):?> -
  1. - +
  2. + [ News($item['pubdate']);?> ]