getRequest(); $this->siret = $request->getParam('siret'); $this->id = $request->getParam('id', 0); $this->imageCachePath = APPLICATION_PATH . '/../cache/pages/imgcache/'; $this->view->headLink()->appendStylesheet('/themes/default/styles/finance.css', 'all'); $this->view->headScript()->appendFile('/themes/default/scripts/finance.js', 'text/javascript'); } /* --------------------------------------------------------------------------------------------------- */ /* Fonction génériques */ /* ----------------------------------------------------------------------------------------------------*/ public function lignegraphAction() { $request = $this->getRequest(); $action = $request->getParam('actionName'); $OtherFunction = new OtherFunction(); switch ($action) { case 'synthese': $this->bilanReference = $OtherFunction->setSyntheseReference(); $id = $request->getParam('id'); $typeBilan = $request->getParam('typeBilan'); $parametres= array('bilanReference' => array($id => $this->bilanReference[$id]), 'siret' => $request->siret, 'otherView' => $request->getParam('idGraph'), 'typeBilan' => $typeBilan); $this->view->assign('actionName', $action); $this->view->assign('parametres', $parametres); break; } $this->bilanReference = $OtherFunction->setSyntheseReference(); } /* --------------------------------------------------------------------------------------------------- */ /* Gestion de la synthése avec les graphiques */ /* ----------------------------------------------------------------------------------------------------*/ /** * @todo faire le setLog. * */ public function rsyntheseAction() { $final = array(); $tabAnnee = array(); $OtherFunction = new OtherFunction(); $request = $this->getRequest(); $idsReference = $request->getParam('idsReference'); $autrePage = $this->getRequest()->getParam('apage'); //Récupération des informations if (empty($autrePage)) { $ws = new WsScores(); $synthese = $ws->getRatios(substr($request->getParam('siret'), 0, 9), 'synthese'); } else { $synthese = $this->getRequest()->getParam('infos'); } $this->bilanReference = $OtherFunction->setSyntheseReference(); $FinanceLib = new FinanceLib($this->siret, $this->id); if(count($synthese->BilansInfos->item) > 0) $FinanceLib->rsynthese($synthese, $idsReference, $tabAnnee, $final); $this->view->assign('commentaires', $this->bilanReference); $this->view->assign('annees', $tabAnnee); $this->view->assign('synthese', $final); } /** * cette fonction gére l'affichage des données pour la synthése avec les différents graphiques. * Il est possible de rajouter des champs dans le tableau bilanReference en respectant la synthaxe. */ public function syntheseAction() { $user = new Utilisateur(); if(!$user->checkPerm('INDISCORE2')) $this->_forward('perms', 'error'); $request = $this->getRequest(); $bilan = array(); $exist = $request->getParam('bilanReference'); $autrePage = $this->getRequest()->getParam('apage'); //Récupération des informations if (empty($autrePage)) { $ws = new WsScores(); $synthese = $ws->getRatios(substr($request->getParam('siret'), 0, 9), 'synthese'); } else { $synthese = $request->getParam('infos'); } $RatiosGraph = new RatiosGraph($this->siret, $this->id); $typeBilan = $this->getRequest()->getParam('typeBilan'); $OtherFunction = new OtherFunction(); $dateFunction = new WDate(); $FinanceLib = new FinanceLib($this->siret, $this->id); $entreprise = new SessionEntreprise($this->siret, $this->id); $graphique = new Graphique($this->imageCachePath); if(empty($typeBilan))$typeBilan = 'N'; // Dans le cas ou ont veut des id(s) spécifique(s). if(empty($exist)){ $this->bilanReference = $OtherFunction->setSyntheseReference(); $bilanReference = $this->bilanReference;} else $bilanReference = $request->getParam('bilanReference'); if(isset($synthese->BilansInfos->item)) { $bilan = $FinanceLib->synthese($synthese, $bilanReference, $typeBilan, $RatiosGraph); $this->view->assign('typeBilan', $typeBilan); $this->view->assign('synthese', $bilan); $this->view->assign('nameForGraphique', $bilanReference); $this->view->assign('affFormNormal', $OtherFunction->array_key_existValeur($synthese->BilansInfos->item, 'typeBilan', 'N')); $this->view->assign('affFormConsolide', $OtherFunction->array_key_existValeur($synthese->BilansInfos->item, 'typeBilan', 'C')); if(empty($this->bilanReference)) $this->view->assign('otherView', $request->getParam('otherView')); if(!empty($bilan)) $graphique->GraphiqueLineXY( $RatiosGraph->GraphiqueSyntheseAnalyse($synthese->BilansInfos->item, $typeBilan, $this->siret)); } else $this->view->assign('nothing', true); $this->view->assign('idSC', $this->id); $this->view->assign('raisonSociale', $entreprise->getRaisonSociale()); $this->view->assign('siret', $this->siret); $this->view->assign('siren', substr($this->siret, 0, 9)); $this->view->assign('dateFunction', $dateFunction); $this->view->assign('AutrePage', $request->getParam('apage')); } /* --------------------------------------------------------------------------------------------------- */ /* Gestion des bilans ACTIF/PASSIF/CR */ /* ----------------------------------------------------------------------------------------------------*/ /** * Permet d'afficher la version imprimable d'un graphique de ligne des bilans. * Passages des infos par url + protection htmlentites et url_encode. * * Enter description here ... */ public function onelinebilanAction() { $request = $this->getRequest(); $datas = $request->getParam('data'); $dates = $request->getParam('dates'); $name = $request->getParam('name'); $image = $request->getParam('image'); $siret = $request->getParam('siret'); $id = $request->getParam('id'); $entreprise = new SessionEntreprise($this->siret, $this->id); $datas = explode('|', $datas); $dates = explode('|', $dates); $this->view->assign('idSC', $this->id); $this->view->assign('siret', $this->siret); $this->view->assign('raisonSociale', $entreprise->getRaisonSociale()); $this->view->assign('image',$image); $this->view->assign('datas', $datas); $this->view->assign('dates', $dates); $this->view->assign('name', $name); } /** * Fonction qui affiche les bilan (actif, passif, SIG). * Le principe est d'utiliser le mapping de données. * */ public function bilanAction() { $user = new Utilisateur(); if(!$user->checkPerm('INDISCORE3')) $this->_forward('perms', 'error'); $actif = array(); $passif = array(); $SIG = array(); $date = array(); $duree = EOF; $request = $this->getRequest(); $listeBilan = array('actif', 'passif', 'sig'); $persoActif = $request->getParam('referenceActif'); $persoPassif = $request->getParam('referencePassif'); $persoSig = $request->getParam('referenceSig'); $OtherFunction = new OtherFunction(); $autrePage = $this->getRequest()->getParam('apage'); //Récupération des informations if (empty($autrePage)) { $ws = new WsScores(); $bilan = $ws->getRatios(substr($this->siret, 0, 9), 'ratios'); } else { $bilan = $this->getRequest()->getParam('infos'); } $dateFunction = new WDate(); $FinanceLib = new FinanceLib($this->siret, $this->id); //$bilan = array(); $typeBilan = ($this->getRequest()->isPost())?$this->getRequest()->getParam('typeBilan'):'N'; $entreprise = new SessionEntreprise($this->siret, $this->id); if (isset($bilan->BilansInfos->item)) { $referenceActif = $OtherFunction->referenceBilan('actif'); $referencePassif = $OtherFunction->referenceBilan('passif'); $referenceSIG = $OtherFunction->referenceBilan('sig'); $FinanceLib->constructElementForBilan($bilan, $referenceActif, $actif, $date, $duree, $typeBilan); $FinanceLib->constructElementForBilan($bilan, $referencePassif, $passif, $date, $duree, $typeBilan); $FinanceLib->constructElementForBilan($bilan, $referenceSIG, $SIG, $date, $duree, $typeBilan); $this->view->assign('referenceactif', $referenceActif); $this->view->assign('dateFunction', $dateFunction); $this->view->assign('referencepassif', $referencePassif); $this->view->assign('referencesig', $referenceSIG); $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); $this->view->assign('isChecked', 'checked="check"'); $this->view->assign('isNotChecked', 'false'); } $this->view->assign('dateFunction', $dateFunction); $this->view->assign('siret', $this->siret); $this->view->assign('typeBilan', $typeBilan); $this->view->assign('siren', substr($this->siret, 0, 9)); $this->view->assign('raisonSociale', $entreprise->getRaisonSociale()); $this->view->assign('AutrePage', $request->getParam('apage')); } /** * Permet de construire le graphique Actif * les parametre viennent de $this->getRequest(); */ public function actifgraphAction() { $RatioGraph = new RatiosGraph($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id')); $data = $this->getRequest()->getParam('valeur'); $i = $this->getRequest()->getParam('i'); $filename = $this->getRequest()->getParam('siren'); $date = $this->getRequest()->getParam('date'); $count = $this->getRequest()->getParam('count'); $labels = array('Immo. incorporelles', 'Immo. corporelles', 'Immo. financières', 'Stock et encours', 'Créances Clients', 'Autres créances', 'Trésorerie Active' ); $retour = $RatioGraph->GraphiqueBilan('actif', $data, $i, $filename, $date, $count, $labels); $this->view->assign('file', $retour->file); $this->view->assign('chartID', $retour->chartID); $this->view->assign('imageMap', $retour->imageMap); $this->view->assign('i', 'actif'.$retour->i); $this->view->assign('hide', $retour->hide); $this->render('printgraphbilan'); } /** * Permet de construire le graphique Passif * les parametre viennent de $this->getRequest(); */ public function passifgraphAction() { $RatioGraph = new RatiosGraph($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id')); $data = $this->getRequest()->getParam('valeur'); $i = $this->getRequest()->getParam('i'); $filename = $this->getRequest()->getParam('siren'); $date = $this->getRequest()->getParam('date'); $count = $this->getRequest()->getParam('count'); $labels = array('Fonds propres', 'Provisions Risques', 'Compte Courant', 'Dettes Financières', 'Dettes Fournisseurs', 'Dettes fiscales', 'Autres Dettes', 'Trésorerie Passive' ); $retour = $RatioGraph->GraphiqueBilan('passif', $data, $i, $filename, $date, $count, $labels); $this->view->assign('file', $retour->file); $this->view->assign('chartID', $retour->chartID); $this->view->assign('imageMap', $retour->imageMap); $this->view->assign('i', 'passif'.$retour->i); $this->view->assign('hide', $retour->hide); $this->render('printgraphbilan'); } /** * Construit le graphique SIG * les parametre viennent de $this->getRequest(); */ public function siggraphAction() { $RatioGraph = new RatiosGraph($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id')); $data = $this->getRequest()->getParam('valeur'); $i = $this->getRequest()->getParam('i'); $filename = $this->getRequest()->getParam('siren'); $date = $this->getRequest()->getParam('date'); $count = $this->getRequest()->getParam('count'); $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', ); $retour = $RatioGraph->GraphiqueBilan('sig', $data, $i, $filename, $date, $count, $labels); $this->view->assign('file', $retour->file); $this->view->assign('chartID', $retour->chartID); $this->view->assign('imageMap', $retour->imageMap); $this->view->assign('i', 'sig'.$retour->i); $this->view->assign('hide', $retour->hide); $this->render('printgraphbilan'); } /** * Construit et format les données puis envoie les info a la vue. * Fonction mére. */ public function linebilanAction() { $tb = array(); $OtherFunction = new OtherFunction(); $type = $this->getRequest()->getParam('type'); $Graphdate = $this->getRequest()->getParam('Graphdate'); $partial = $this->getRequest()->getParam('data'); $reference = $this->getRequest()->getParam('reference'); $referenceForeach = $this->getRequest()->getParam('referenceForeach'); $sig = $this->getRequest()->getParam('sig'); $siren = $this->getRequest()->getParam('siren'); $html = ''; $FinanceLib= new FinanceLib($this->siret, $this->id); foreach ($referenceForeach as $id => $valeur) { $this->htmlBilan .= $FinanceLib->LineBilan($this->tableauBilanGraphique, $this->_helper, $id, $Graphdate, $partial, $reference, $valeur, '/finance/printgraph/idGraph/bilan-'.$this->siret.'-'.$id.'.png',$siren , $sig); if($this->tableauBilanGraphique)$tb[] = $this->tableauBilanGraphique; } $this->view->assign('type', $type); $this->view->assign('html', $this->htmlBilan); $this->view->assign('valeur', $OtherFunction->formatElementGraphiquebilan($tb)); $this->view->assign('Graphdate', $Graphdate); $this->view->assign('siret', $this->siret); $this->view->assign('id', $this->id); } /* --------------------------------------------------------------------------------------------------- */ /* Gestion des ratios avec les graphiques */ /* ----------------------------------------------------------------------------------------------------*/ public function onelineratiosAction() { $request = $this->getRequest(); $siret = $request->getParam('siret'); $nom = $request->getParam('nom'); $dates = $request->getParam('dates'); $entre = $request->getParam('entreprise'); $secteur = $request->getParam('secteur'); $unite = $request->getParam('unite'); $position = $request->getParam('position'); $graphique = $request->getParam('graphique'); $entreprise = new SessionEntreprise($this->siret, $this->id); $this->view->assign('siret', $this->siret); $this->view->assign('id', $this->id); $this->view->assign('siren', substr($this->siret, 0, 9)); $this->view->assign('raisonSociale', $entreprise->getRaisonSociale()); $this->view->assign('dates', $dates); $this->view->assign('entreprise', $entre); $this->view->assign('secteur', $secteur); $this->view->assign('nom', urldecode($nom)); $this->view->assign('unite', urldecode($unite)); $this->view->assign('position', $position); $this->view->assign('graphique', $graphique); } /** * 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, $type) { $FinanceLib = new FinanceLib($this->siret, $this->id); $RatioGraph = new RatiosGraph($this->siret, $this->id); $OtherFunction = new OtherFunction(); 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) { $RatioGraph->createGraphique($ratios, $liste->id, $item->unite, $type); $html .= '