diff --git a/application/controllers/FinanceController.php b/application/controllers/FinanceController.php index 6587c7821..eb35c8e02 100644 --- a/application/controllers/FinanceController.php +++ b/application/controllers/FinanceController.php @@ -15,6 +15,10 @@ class FinanceController extends Zend_Controller_Action public function init() { + define('FIRST_POSITION', 0); + define('SECOND_POSITION', 1); + define('THREE_POSITION', 2); + $this->entreprise = new stdClass(); $this->dateFunction = new WDate(); $this->ws = new WsScores(); @@ -24,13 +28,14 @@ class FinanceController extends Zend_Controller_Action $this->entreprise->naf = $entreprise->getNaf(); $this->imageCachePath = APPLICATION_PATH. '/../cache/pages/imgcache/'; $this->idSC = $this->getRequest()->getParam('id'); - $this->entreprise->siren = substr($this->getRequest()->getParam('siret'), 0, 9); + $this->entreprise->siren = substr($this->getRequest()->getParam('siret'), 0, 9); $this->view->assign('dateFunction', $this->dateFunction); $this->view->headLink() ->appendStylesheet('/themes/default/styles/finance.css', 'all'); $this->view->headScript() ->appendFile('/themes/default/scripts/finance.js', 'text/javascript'); + } @@ -213,41 +218,54 @@ class FinanceController extends Zend_Controller_Action self::getVal($id, $dataX[$id], $synthese); } - echo '
';
-	   print_r($dataX);exit;
 	}
 	
 /* --------------------------------------------------------------------------------------------------- */
 /*                                Gestion des bilans ACTIF/PASSIF/CR                                   */
 /* ----------------------------------------------------------------------------------------------------*/
-
-	protected function constructElementForBilan($bilan, $tableauDeReference, &$type, &$date)
-	{
+		
+	protected function constructElementForBilan($bilan, $tableauDeReference, &$type, &$date, &$duree, $typebilan)
+	{ 
     	foreach($bilan->BilansInfos->item as $element) {
-    	    if (@count($date) < 6) {
-    	        if(!in_array($element->dateCloture, $date))
-    	            $date[] = $element->dateCloture;
+    	    if($element->typeBilan == $typebilan)
+    	    {
+        	    if($duree == EOF)
+        	        $duree = $element->duree;
+        	    if (@count($date) < 5) {
+        	        if(!in_array($element->dateCloture, $date))
+        	            $date[] = $element->dateCloture;
+        	    }
+                foreach($element->RatiosEntrep->item as $item) {
+                    foreach($tableauDeReference as $id => $valeur) {
+        	             if ($item->id == $id) {  
+                             if (count($type[$id]['item']) < 5) {
+                                 if ($item->val > 0) {
+                                     $type[$id]['item'][$element->dateCloture] = $item->val / 1000;
+                                 }
+                                 else 
+                                     $type[$id]['item'][$element->dateCloture] = 0;
+                             }
+        	             }
+                    }  
+                }
     	    }
-            foreach($element->RatiosEntrep->item as $item) {
-                foreach($tableauDeReference as $id => $valeur) {
-    	             if ($item->id == $id) {
-    	                 if (count($type[$valeur]) < 6)
-    	                     $type[$valeur][$element->dateCloture] = $item->val;
-    	             }
-                }  
-            }
     	}
+	    foreach ($type as $id => $valeur) {
+	        $type[$id]['item'] = array_reverse($valeur['item']);
+	    }
+    	$date = array_reverse($date);
 	}
 	
-	public function bilansAction()
+	public function bilanAction()
 	{
 	    $actif           = array();
 	    $passif          = array();
 	    $SIG             = array();
 	    $date            = array();
-	    
-	    $referenceActif  = array('r59' => 'Actif Immobilisé Net', 'r51' => 'Incorporelles',
-                                 'r52' => 'Corporelles', 		  'r53' => 'Financières',
+	    $duree           = EOF;
+	    $listeBilan      = array('actif', 'passif', 'sig');
+	    $referenceActif  = array('r52' => 'Corporelles', 'r51' => 'Incorporelles',
+                                 'r59' => 'Actif Immobilisé Net', 		  'r53' => 'Financières',
                                  'r69' => 'Actif Circulant Net',  'r60' => 'Stock et encours',
                                  'r61' => 'Créances Clients', 	  'r62' => 'Autres Créances',
                                  'r00' => '', 					  'r63' => 'Trésorerie Active',
@@ -262,29 +280,44 @@ class FinanceController extends Zend_Controller_Action
                                  'r22' => 'TOTAL PASSIF'
 	    );
 	    $referenceSIG    = array('r101' => 'CHIFFRE D\'AFFAIRES HORS TAXE', 	 					  'r102' => '-Achat de marchandises, de matières premières',
-                                 'r110' => 'MARGE COMMERCIALE', 				 					  'r111' => '+Production vendue', 
-                                 'r112' => '+Production immobilisée et stockée', 					  'r120' => 'PRODUCTION DE L\'EXERCICE', 
-                                 'r121' =>'Variation de stock de marchandises et matières premières', 'r122' => 'MARGE BRUTE', 'r123' => '-Autres charges externes',
-                                 'r130' => 'VALEUR AJOUTÉE', 'r132' => '-Charges de personnel', 	  'r133' => '-Impôts, taxes & versements assimilés', 'r131' => '+Subventions d\'exploitation',
+                                 
+	    						 'r110' => 'MARGE COMMERCIALE', 				 					  'r111' => '+Production vendue', 
+                                 'r112' => '+Production immobilisée et stockée', 					  
+                                 
+                                 'r120' => 'PRODUCTION DE L\'EXERCICE', 
+                                 'r121' => 'Variation de stock de marchandises et matières premières',
+                                 
+                                 'r122' => 'MARGE BRUTE', 
+                                 'r123' => '-Autres charges externes',
+                                 
+                                 'r130' => 'VALEUR AJOUTÉE', 										  'r132' => 'Charges de personnel',
+								 'r133' => '-Impôts, taxes & versements assimilés',					  'r131' => '+Subventions d\'exploitation',
+                                 
                                  'r140' => 'EXCÉDENT BRUT D\'EXPLOITATION (EBE)', 					  'r141' => '+Autres produits d\'exploitation',
                                  'r142' => '-Autres charges d\'exploitation', 						  'r143' => '+Reprise sur dotations & transferts de charges',
                                  'r144' => '+70% Loyer de crédit bail', 							  'r145' => '-Dotations d\'exploitation & provisions d\'exploitation',
+                                 
                                  'r150' => 'RÉSULTAT D\'EXPLOITATION', 								  'r151' => '+Produits financiers',
                                  'r152' => '+30% Loyer de crédit bail', 							  'r153' => '+Charges financières',
+	    
                                  'r170' => 'RÉSULTAT COURANT AVANT IMPOTS', 						  'r171' => '+Produits exceptionnels',
                                  'r172' => '-Charges exceptionnelles', 								  'r181' => '-Impôts sur les bénéfices',
-                                 'r182' => '-Participation salariale', 								  'r199' => 'RÉSULTAT NET'
+                                 'r182' => '-Participation salariale', 								  
+                                 
+                                 'r199' => 'RÉSULTAT NET'
 	    );
 	    
 	    $bilan           = array();
-	    $typeBilan       = /*$this->getrequest()->getParam('typebilan')*/ 'N';
+	    $typeBilan       = /*$this->getrequest()->getParam('typebilan')*/ 'C';
 	    $bilan           = $this->ws->getRatios($this->entreprise->siren, 'ratios');
 
-	    self::constructElementForBilan($bilan, $referenceActif, $actif, $date);
-	    self::constructElementForBilan($bilan, $referencePassif, $passif, $date);
-	    self::constructElementForBilan($bilan, $referenceSIG, $SIG, $date);
-	    
+	    self::constructElementForBilan($bilan, $referenceActif, $actif, $date, $duree, $typeBilan);
+	    self::constructElementForBilan($bilan, $referencePassif, $passif, $date, $duree, $typeBilan);
+	    self::constructElementForBilan($bilan, $referenceSIG, $SIG, $date, $duree, $typeBilan);
+
+	    $this->view->assign('listeBilan', $listeBilan);
 	    $this->view->assign('date', $date);
+	    $this->view->assign('duree', $duree);
 	    $this->view->assign('actif', $actif);
 	    $this->view->assign('passif', $passif);
 	    $this->view->assign('sig', $SIG);
diff --git a/application/views/default/scripts/finance/bilan.phtml b/application/views/default/scripts/finance/bilan.phtml
new file mode 100644
index 000000000..ad29df327
--- /dev/null
+++ b/application/views/default/scripts/finance/bilan.phtml
@@ -0,0 +1,15 @@
+
+

Les bilans

+
+ listeBilan as $bilan):?> + partial('finance/bilansPartials/'.$bilan.'.partial.phtml', + array( + 'date' => $this->date, + 'duree' => $this->duree, + 'dateFunction' => $this->dateFunction, + $bilan => $this->$bilan + )); + ?>
+ +
+
\ No newline at end of file diff --git a/application/views/default/scripts/finance/bilans.phtml b/application/views/default/scripts/finance/bilans.phtml deleted file mode 100644 index 25035f07f..000000000 --- a/application/views/default/scripts/finance/bilans.phtml +++ /dev/null @@ -1,50 +0,0 @@ - - - - date as $date):?> - - - - actif as $name => $actif):?> - - - - - - - -
- - - - - date as $date):?> - - - - passif as $name => $passif):?> - - - - - - - -
- - - - - date as $date):?> - - - - sig as $name => $sig):?> - - - - - - - -
\ 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 new file mode 100644 index 000000000..48242be4b --- /dev/null +++ b/application/views/default/scripts/finance/bilansPartials/actif.partial.phtml @@ -0,0 +1,84 @@ +actif['r22']['item'])?> +

Bilan actif - passif

+ + + + + date as $date):?> + + + + + + + + actif['r59']['item'] as $element): ?> + + + + + + + actif['r51']['item'] as $element): ?> + + + + + + + actif['r52']['item'] as $element): ?> + + + + + + + actif['r53']['item'] as $element): ?> + + + + + + + actif['r69']['item'] as $element): ?> + + + + + + + actif['r60']['item'] as $element): ?> + + + + + + + actif['r61']['item'] as $element): ?> + + + + + + + actif['r62']['item'] as $element): ?> + + + + + + + actif['r63']['item'] as $element): ?> + + + + + + + actif['r22']['item'] as $element): ?> + + + + +
ActifdateFunction->dateT('Ymd', 'd/m/Y', $date);?>
+ duree;?> Mois
% T.B.
Actif Immobilisé Netactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Incorporellesactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Corporellesactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Financièresactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Actif Circulant Netactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Stock et encoursactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Créances Clientsactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Autres Créancesactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
Trésorerie Activeactif['r22']['item'][key($this->actif['r22']['item'])],2);?>
TOTAL ACTIF
\ No newline at end of file diff --git a/application/views/default/scripts/finance/bilansPartials/passif.partial.phtml b/application/views/default/scripts/finance/bilansPartials/passif.partial.phtml new file mode 100644 index 000000000..9063ce44e --- /dev/null +++ b/application/views/default/scripts/finance/bilansPartials/passif.partial.phtml @@ -0,0 +1,90 @@ +passif['r22']['item'])?> + + + + + date as $date):?> + + + + + + + + passif['r79']['item'] as $element): ?> + + + + + + + passif['r70']['item'] as $element): ?> + + + + + + + passif['r71']['item'] as $element): ?> + + + + + + + passif['r72']['item'] as $element): ?> + + + + + + + passif['r90']['item'] as $element): ?> + + + + + + + passif['r83']['item'] as $element): ?> + + + + + + + passif['r84']['item'] as $element): ?> + + + + + + + passif['r85']['item'] as $element): ?> + + + + + + + passif['r86']['item'] as $element): ?> + + + + + + + passif['r87']['item'] as $element): ?> + + + + + + + passif['r22']['item'] as $element): ?> + + + + +
PassifdateFunction->dateT('Ymd', 'd/m/Y', $date);?>
+ duree;?> Mois
% T.B.
Ressources Proprespassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Fonds Proprespassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Provisions Risquespassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Comptes Courantspassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Ressources Externespassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Dettes Financièrespassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Dettes Fournisseurspassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Dettes Fiscalespassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Autres Dettespassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
Trésorerie Passivepassif['r22']['item'][key($this->passif['r22']['item'])],2);?>
TOTAL PASSIF
\ 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 new file mode 100644 index 000000000..0a3a11d20 --- /dev/null +++ b/application/views/default/scripts/finance/bilansPartials/sig.partial.phtml @@ -0,0 +1,237 @@ +sig['r101']['item'])?> +

Soldes Intermédiaire de Gestion

+ + + + + date as $date):?> + + + + + + + + sig['r101']['item'] as $element): ?> + + + + + + + + sig['r102']['item'] as $element): ?> + + + + + + + sig['r110']['item'] as $element): ?> + + + + + + + + sig['r111']['item'] as $element): ?> + + + + + + + + sig['r112']['item'] as $element): ?> + + + + + + + sig['r120']['item'] as $element): ?> + + + + + + + + sig['r121']['item'] as $element): ?> + + + + + + + sig['r122']['item'] as $element): ?> + + + + + + + + sig['r123']['item'] as $element): ?> + + + + + + + sig['r130']['item'] as $element): ?> + + + + + + + + sig['r132']['item'] as $element): ?> + + + + + + + + sig['r133']['item'] as $element): ?> + + + + + + + + sig['r131']['item'] as $element): ?> + + + + + + + sig['r140']['item'] as $element): ?> + + + + + + + + sig['r141']['item'] as $element): ?> + + + + + + + + sig['r142']['item'] as $element): ?> + + + + + + + + sig['r143']['item'] as $element): ?> + + + + + + + + sig['r144']['item'] as $element): ?> + + + + + + + + sig['r145']['item'] as $element): ?> + + + + + + + sig['r150']['item'] as $element): ?> + + + + + + + + sig['r151']['item'] as $element): ?> + + + + + + + + sig['r152']['item'] as $element): ?> + + + + + + + + sig['r153']['item'] as $element): ?> + + + + + + + sig['r170']['item'] as $element): ?> + + + + + + + + sig['r171']['item'] as $element): ?> + + + + + + + + sig['r172']['item'] as $element): ?> + + + + + + + + sig['r181']['item'] as $element): ?> + + + + + + + + sig['r182']['item'] as $element): ?> + + + + + + + sig['r199']['item'] as $element): ?> + + + + +
SOLDES INTERMEDIAIRES DE GESTIONdateFunction->dateT('Ymd', 'd/m/Y', $date);?>
+ duree;?> Mois
% C.A.
CHIFFRE D'AFFAIRES HORS TAXE
-Achat de marchandises, de matières premières
MARGE COMMERCIALE
+Production vendue
+Production immobilisée et stockée
PRODUCTION DE L'EXERCICE
+Variation de stock de marchandises et matières premières
MARGE BRUTE
-Autres charges externes
VALEUR AJOUTÉE
-Charges de personnel
-Impôts, taxes & versements assimilés
+Subventions d'exploitation
EXCÉDENT BRUT D'EXPLOITATION (EBE)
+Autres produits d'exploitation
-Autres charges d'exploitation
+Reprise sur dotations & transferts de charges
+70% Loyer de crédit bail
-Dotations d'exploitation & provisions d'exploitation
RÉSULTAT D'EXPLOITATION
+Produits financiers
+30% Loyer de crédit bail
+ Charges financières
RÉSULTAT COURANT AVANT IMPOTS
+Produits exceptionnels
-Charges exceptionnelles
-Impôts sur les bénéfices
-Participation salariale
RÉSULTAT NET
\ No newline at end of file diff --git a/application/views/default/scripts/finance/liasse.phtml b/application/views/default/scripts/finance/liasse.phtml index f18cdb78c..6a97d33a7 100644 --- a/application/views/default/scripts/finance/liasse.phtml +++ b/application/views/default/scripts/finance/liasse.phtml @@ -63,21 +63,21 @@
champType == 'N' or $this->champType == 'S'):?> - partial('finance/partials/'.$partial.'.partial.phtml', + partial('finance/liassesPartials/'.$partial.'.partial.phtml', array('liasse' => $this->liasse, 'dateCloture' => $this->dateFunction->dateT('Ymd', 'd/m/Y', $this->dateCloture), 'dateCloturePre' => $this->dateFunction->dateT('Ymd', 'd/m/Y', $this->dateCloturePre), 'dureesMois' => $this->dureesMois, 'dureesMoisPre'=> $this->dureesMois)).'
';?> champType == 'B'):?> - partial('finance/partials/banque/'.$partial.'.partial.phtml', + partial('finance/liassesPartials/banque/'.$partial.'.partial.phtml', array('liasse' => $this->liasse, 'dateCloture' => $this->dateFunction->dateT('Ymd', 'd/m/Y', $this->dateCloture), 'dateCloturePre' => $this->dateFunction->dateT('Ymd', 'd/m/Y', $this->dateCloturePre), 'dureesMois' => $this->dureesMois, 'dureesMoisPre'=> $this->dureesMois)).'
';?> champType == 'A'):?> - partial('finance/partials/assurance/'.$partial.'.partial.phtml', + partial('finance/liassesPartials/assurance/'.$partial.'.partial.phtml', array('liasse' => $this->liasse, 'dateCloture' => $this->dateFunction->dateT('Ymd', 'd/m/Y', $this->dateCloture), 'dateCloturePre' => $this->dateFunction->dateT('Ymd', 'd/m/Y', $this->dateCloturePre), diff --git a/public/themes/default/styles/finance.css b/public/themes/default/styles/finance.css index edb80726e..fb40a8315 100644 --- a/public/themes/default/styles/finance.css +++ b/public/themes/default/styles/finance.css @@ -1,5 +1,18 @@ @CHARSET "UTF-8"; +.bilans {font-family:"Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-size:12px; margin: 10px 0 0 0; width:100%; text-align:left; border-collapse:collapse;} +.bilans th {padding:4px; font-weight:normal; font-size:11px; border:1px solid #000; color:#000; background:#b9c9fe; text-align:center; font-weight:bold;} +.bilans td {font-size:11px;padding:4px; border:1px solid #000; color:#000;} +.bilans td.graph {padding:0; margin:0;} +.bilans th.date {font-size:10px;} +.bilans td.right {text-align:right;} +.bilans td.center {text-align: center;} +.bilans td.italique {font-style:italic;} +.bilans tr.subhead td {font-size:11px;padding:4px; background:#b9c9fe; border: 1px solid #000; font-weight:bold; color:#000;} +.bilans tr.darkblue td {padding:4px; background:#00008c; border: 1px solid #000; font-weight:bold; color:#fff;} +.entete {margin:1px;} +.subentete {margin:2px;} + #ratios tr.subhead td { background: none repeat scroll 0 0 #B9C9FE;