extranet/application/controllers/FinanceController.php

755 lines
32 KiB
PHP
Raw Normal View History

2011-02-21 08:45:13 +00:00
<?php
2011-06-13 15:42:55 +00:00
require_once 'common/dates.php';
require_once 'Scores/SessionEntreprise.php';
require_once 'Scores/Utilisateur.php';
require_once 'Scores/WsScores.php';
require_once 'Vendors/ChartDirector/phpchartdir.php';
require_once 'Vendors/ChartDirector/FinanceChart.php';
require_once 'Graphique/Graphique.lib.php';
2011-07-04 10:00:22 +00:00
require_once 'Finance/Liasse.php';
2011-06-13 15:42:55 +00:00
require_once 'Finance/RatiosGraph.lib.php';
2011-06-22 13:00:40 +00:00
require_once 'Finance/Finance.lib.php';
2011-06-13 15:42:55 +00:00
require_once 'Finance/OtherFunctions.lib.php';
2011-05-09 11:43:43 +00:00
/**
* La Classe finance gére les actions concernant la partie element financiés du menu
2011-05-18 12:22:08 +00:00
*
2011-05-09 11:43:43 +00:00
* Les Bilans.
* La Synthese.
* Les Ratios.
* Les Etablissements bancaires.
* Les Liasses fiscales.
* Les cotations en bourses.
2011-05-18 12:22:08 +00:00
*
2011-05-09 11:43:43 +00:00
* @author Damien Lasserre
*
*/
2011-02-21 08:45:13 +00:00
class FinanceController extends Zend_Controller_Action
2011-04-11 14:19:14 +00:00
{
2011-06-08 15:41:59 +00:00
protected $siret = null;
protected $id = 0;
private $imageCachePath;
2011-05-20 15:42:44 +00:00
private $tableauBilanGraphique;
private $htmlBilan;
private $bilanReference;
2011-04-19 15:59:50 +00:00
public function init()
{
$request = $this->getRequest();
2011-06-30 15:30:43 +00:00
$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');
2011-04-19 15:59:50 +00:00
}
/* --------------------------------------------------------------------------------------------------- */
/* Fonction génériques */
/* ----------------------------------------------------------------------------------------------------*/
2011-05-27 16:07:48 +00:00
public function lignegraphAction()
{
$request = $this->getRequest();
2011-05-27 16:07:48 +00:00
$action = $request->getParam('actionName');
2011-06-13 07:04:46 +00:00
$OtherFunction = new OtherFunction();
2011-05-27 16:07:48 +00:00
switch ($action) {
case 'synthese':
2011-06-13 07:04:46 +00:00
$this->bilanReference = $OtherFunction->setSyntheseReference();
2011-05-27 16:07:48 +00:00
$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();
2011-05-27 16:07:48 +00:00
}
/* --------------------------------------------------------------------------------------------------- */
/* Gestion de la synthése avec les graphiques */
/* ----------------------------------------------------------------------------------------------------*/
2011-04-19 15:59:50 +00:00
/**
* @todo faire le setLog.
*
*/
public function rsyntheseAction()
{
2011-06-13 07:04:46 +00:00
$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');
2011-06-29 12:44:20 +00:00
}
2011-06-13 07:04:46 +00:00
$this->bilanReference = $OtherFunction->setSyntheseReference();
2011-06-22 13:00:40 +00:00
$FinanceLib = new FinanceLib($this->siret, $this->id);
2011-06-13 07:04:46 +00:00
if(count($synthese->BilansInfos->item) > 0)
2011-06-22 13:00:40 +00:00
$FinanceLib->rsynthese($synthese, $idsReference, $tabAnnee, $final);
2011-06-13 15:42:55 +00:00
$this->view->assign('commentaires', $this->bilanReference);
$this->view->assign('annees', $tabAnnee);
$this->view->assign('synthese', $final);
}
2011-06-13 07:04:46 +00:00
/**
2011-05-06 15:26:56 +00:00
* 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.
*/
2011-04-19 15:59:50 +00:00
public function syntheseAction()
2011-05-04 14:18:22 +00:00
{
$user = new Utilisateur();
2011-07-04 08:31:42 +00:00
$request = $this->getRequest();
2011-05-27 16:07:48 +00:00
$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 {
2011-07-04 08:31:42 +00:00
$synthese = $request->getParam('infos');
}
$RatiosGraph = new RatiosGraph($this->siret, $this->id);
2011-05-27 16:07:48 +00:00
$typeBilan = $this->getRequest()->getParam('typeBilan');
2011-06-13 07:04:46 +00:00
$OtherFunction = new OtherFunction();
2011-06-13 15:42:55 +00:00
$dateFunction = new WDate();
2011-06-22 13:00:40 +00:00
$FinanceLib = new FinanceLib($this->siret, $this->id);
$entreprise = new SessionEntreprise($this->siret, $this->id);
$graphique = new Graphique($this->imageCachePath);
2011-05-27 16:07:48 +00:00
if(empty($typeBilan))$typeBilan = 'N';
2011-05-27 16:07:48 +00:00
// Dans le cas ou ont veut des id(s) spécifique(s).
if(empty($exist)){
2011-06-13 07:04:46 +00:00
$this->bilanReference = $OtherFunction->setSyntheseReference();
$bilanReference = $this->bilanReference;}
else $bilanReference = $request->getParam('bilanReference');
if(isset($synthese->BilansInfos->item)) {
2011-06-22 13:00:40 +00:00
$bilan = $FinanceLib->synthese($synthese, $bilanReference, $typeBilan, $RatiosGraph);
$this->view->assign('typeBilan', $typeBilan);
$this->view->assign('synthese', $bilan);
$this->view->assign('nameForGraphique', $bilanReference);
2011-06-13 07:04:46 +00:00
$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));
2011-06-13 15:42:55 +00:00
$this->view->assign('dateFunction', $dateFunction);
$this->view->assign('AutrePage', $request->getParam('apage'));
}
/* --------------------------------------------------------------------------------------------------- */
/* Gestion des bilans ACTIF/PASSIF/CR */
/* ----------------------------------------------------------------------------------------------------*/
2011-04-11 14:19:14 +00:00
2011-05-27 16:07:48 +00:00
/**
* Permet d'afficher la version imprimable d'un graphique de ligne des bilans.
* Passages des infos par url + protection htmlentites et url_encode.
*
2011-05-27 16:07:48 +00:00
* 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');
2011-06-30 15:30:43 +00:00
$siret = $request->getParam('siret');
$id = $request->getParam('id');
$entreprise = new SessionEntreprise($this->siret, $this->id);
2011-05-27 16:07:48 +00:00
$datas = explode('|', $datas);
$dates = explode('|', $dates);
$this->view->assign('idSC', $this->id);
$this->view->assign('siret', $this->siret);
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
2011-05-27 16:07:48 +00:00
$this->view->assign('image',$image);
$this->view->assign('datas', $datas);
$this->view->assign('dates', $dates);
$this->view->assign('name', $name);
}
2011-05-06 15:26:56 +00:00
/**
* Fonction qui affiche les bilan (actif, passif, SIG).
* Le principe est d'utiliser le mapping de données.
2011-05-18 12:22:08 +00:00
*
2011-05-06 15:26:56 +00:00
*/
public function bilanAction()
2011-04-19 15:59:50 +00:00
{
$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');
2011-05-27 16:07:48 +00:00
$persoActif = $request->getParam('referenceActif');
$persoPassif = $request->getParam('referencePassif');
$persoSig = $request->getParam('referenceSig');
2011-06-13 07:04:46 +00:00
$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');
}
2011-06-13 15:42:55 +00:00
$dateFunction = new WDate();
2011-06-22 13:00:40 +00:00
$FinanceLib = new FinanceLib($this->siret, $this->id);
//$bilan = array();
2011-05-18 12:22:08 +00:00
$typeBilan = ($this->getRequest()->isPost())?$this->getRequest()->getParam('typeBilan'):'N';
$entreprise = new SessionEntreprise($this->siret, $this->id);
if (isset($bilan->BilansInfos->item)) {
2011-06-13 07:04:46 +00:00
$referenceActif = $OtherFunction->referenceBilan('actif');
$referencePassif = $OtherFunction->referenceBilan('passif');
$referenceSIG = $OtherFunction->referenceBilan('sig');
2011-06-22 13:00:40 +00:00
$FinanceLib->constructElementForBilan($bilan, $referenceActif, $actif, $date, $duree, $typeBilan);
$FinanceLib->constructElementForBilan($bilan, $referencePassif, $passif, $date, $duree, $typeBilan);
$FinanceLib->constructElementForBilan($bilan, $referenceSIG, $SIG, $date, $duree, $typeBilan);
2011-06-13 07:04:46 +00:00
$this->view->assign('referenceactif', $referenceActif);
2011-06-13 15:42:55 +00:00
$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'));
}
2011-06-13 07:04:46 +00:00
2011-05-20 15:42:44 +00:00
/**
* Permet de construire le graphique Actif
* les parametre viennent de $this->getRequest();
*/
2011-05-19 15:48:36 +00:00
public function actifgraphAction()
{
2011-06-30 15:30:43 +00:00
$RatioGraph = new RatiosGraph($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id'));
2011-05-20 15:42:44 +00:00
$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'
);
2011-06-13 07:04:46 +00:00
$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');
2011-05-19 15:48:36 +00:00
}
2011-05-20 15:42:44 +00:00
/**
* Permet de construire le graphique Passif
* les parametre viennent de $this->getRequest();
*/
2011-05-19 15:48:36 +00:00
public function passifgraphAction()
{
2011-06-30 15:30:43 +00:00
$RatioGraph = new RatiosGraph($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id'));
2011-05-20 15:42:44 +00:00
$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',
2011-05-19 15:48:36 +00:00
'Provisions Risques',
'Compte Courant',
'Dettes Financières',
'Dettes Fournisseurs',
'Dettes fiscales',
'Autres Dettes',
'Trésorerie Passive'
);
2011-06-13 07:04:46 +00:00
$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');
2011-05-19 15:48:36 +00:00
}
2011-05-20 15:42:44 +00:00
/**
* Construit le graphique SIG
* les parametre viennent de $this->getRequest();
*/
2011-05-19 15:48:36 +00:00
public function siggraphAction()
{
2011-06-30 15:30:43 +00:00
$RatioGraph = new RatiosGraph($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id'));
2011-05-20 15:42:44 +00:00
$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.',
2011-05-19 15:48:36 +00:00
'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);
2011-06-13 07:04:46 +00:00
$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);
2011-05-20 15:42:44 +00:00
2011-06-13 07:04:46 +00:00
$this->render('printgraphbilan');
2011-05-20 15:42:44 +00:00
}
2011-06-13 07:04:46 +00:00
2011-05-20 15:42:44 +00:00
/**
* Construit et format les données puis envoie les info a la vue.
* Fonction mére.
*/
public function linebilanAction()
{
$tb = array();
2011-06-13 07:04:46 +00:00
$OtherFunction = new OtherFunction();
2011-05-20 15:42:44 +00:00
$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');
2011-06-13 07:04:46 +00:00
$html = '';
2011-06-22 13:00:40 +00:00
$FinanceLib= new FinanceLib($this->siret, $this->id);
2011-05-20 15:42:44 +00:00
foreach ($referenceForeach as $id => $valeur) {
2011-06-22 13:00:40 +00:00
$this->htmlBilan .= $FinanceLib->LineBilan($this->tableauBilanGraphique, $this->_helper, $id, $Graphdate, $partial, $reference, $valeur,
'/finance/printgraph/idGraph/bilan-'.$this->siret.'-'.$id.'.png',$siren , $sig);
2011-05-20 15:42:44 +00:00
if($this->tableauBilanGraphique)$tb[] = $this->tableauBilanGraphique;
}
$this->view->assign('type', $type);
$this->view->assign('html', $this->htmlBilan);
2011-06-13 07:04:46 +00:00
$this->view->assign('valeur', $OtherFunction->formatElementGraphiquebilan($tb));
2011-05-20 15:42:44 +00:00
$this->view->assign('Graphdate', $Graphdate);
2011-06-30 15:30:43 +00:00
$this->view->assign('siret', $this->siret);
$this->view->assign('id', $this->id);
2011-05-19 15:48:36 +00:00
}
/* --------------------------------------------------------------------------------------------------- */
/* 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)
{
2011-06-22 13:00:40 +00:00
$FinanceLib = new FinanceLib($this->siret, $this->id);
$RatioGraph = new RatiosGraph($this->siret, $this->id);
2011-06-13 07:04:46 +00:00
$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) {
2011-06-13 07:04:46 +00:00
$RatioGraph->createGraphique($ratios, $liste->id, $item->unite, $type);
$html .= '<tr class="ratiosTr">';
$html .= '<td class="tooltip" style="cursor:help;" title="'.$item->commentaires.'"><span id="help">'.$item->libelle.'</span></td>';
2011-06-13 07:04:46 +00:00
$html .= '<td class="right">'.$OtherFunction->parseUnite($item->unite, $element->val).' '.$item->unite.'</td>';
$html .= '<td class="right">'.$OtherFunction->parseUnite($item->unite, $liste->val).' '.$item->unite.'</td>';
$html .= '<td align="center">';
2011-06-13 07:04:46 +00:00
$html .= '<a href="'.
$this->view->url(array('controller' => 'finance',
'action' => 'onelineratios',
'siret' => $this->siret,
2011-06-13 07:04:46 +00:00
'nom' => urlencode($item->libelle),
'entreprise' => $OtherFunction->parseUnite($item->unite, $element->val),
'secteur' => $OtherFunction->parseUnite($item->unite, $liste->val),
'unite' => urlencode($item->unite),
'graphique' => 'ratios'.'-'.substr($this->siret, 0, 9).'-'.$liste->id.'-'.$type.'.png',
2011-06-22 13:00:40 +00:00
'position' => $FinanceLib->compareValeur($element->val, $liste->val, $val, true))).'" name="'.$item->libelle.'" class="rTip" rel="'.$this->view->url(array('controller' => 'finance',
2011-06-13 07:04:46 +00:00
'action' => 'printgraph',
2011-06-22 13:00:40 +00:00
'idGraph' => 'ratios'.'-'.substr($this->siret, 0, 9).'-'.$liste->id.'-'.$type.'.png')).'" >'.$FinanceLib->compareValeur($element->val, $liste->val, $val).'</a>';
$html .= '</td>';
$html .= '</tr>';
}
}
}
}
}
}
}
}
}
/**
* Apelle la view avec la balise image, j'ai désactivé le layout pour un affichage spécial.
*/
public function printgraphAction()
{
$this->_helper->layout()->disableLayout();
$filename = $this->getRequest()->getParam('idGraph');
$this->view->assign('filename', $filename);
}
/**
* Gestion de l'affichage des ratios.
*/
public function ratiosAction()
{
/**
* Ont ajoute de nouveaux ratios a cette endroit
* @var unknown_type
*/
$user = new Utilisateur();
if(!$user->checkPerm('INDISCORE3'))
$this->_forward('perms', 'error');
$tableau = array(
'EQUILIBRE FINANCIER' => array('r233' => '>', 'r234' => '>', 'r237' => '>', 'r238' => '>', 'r239' => '>', 'r240' => '>'),
'PROFITABILITE' => array('r262' => '>', 'r263' => '>', 'r264' => '>', 'r265' => '>', 'r266' => '>'),
'LIQUIDITE' => array('r250' => '>', 'r251' => '>', 'r252' => '>'),
'ENDETTEMENT' => array('r244' => '<', 'r247' => '<', 'r248' => '<'),
'PRODUCTIVITE' => array('r271' => '>', 'r278' => '<', 'r279' => '<', 'r281' => '<', 'r261' => '>', 'r267' => '>')
);
$tab = array();
$siret = $this->getRequest()->getParam('siret');
$id = $this->getRequest()->getParam('id');
$i = 0;
2011-05-13 16:33:21 +00:00
$i_view = 0;
$listeDate = array();
$request = $this->getRequest();
2011-05-18 12:22:08 +00:00
$html = '';
$autrePage = $this->getRequest()->getParam('apage');
//Récupération des informations
if (empty($autrePage)) {
$ws = new WsScores();
$ratios = $ws->getRatios(substr($this->siret, 0, 9), 'ratios');
} else {
$ratios = $this->getRequest()->getParam('infos');
2011-06-29 12:44:20 +00:00
}
2011-05-13 16:33:21 +00:00
$type = ($request->isPost())?$request->getParam('typeBilan'):'N';
2011-06-13 07:04:46 +00:00
$OtherFunction = new OtherFunction();
2011-06-13 15:42:55 +00:00
$dateFunction = new WDate();
$entreprise = new SessionEntreprise($this->siret, $this->id);
if(isset($ratios->BilansInfos->item)) {
2011-06-13 07:04:46 +00:00
$date = $OtherFunction->getSwitchFormRatios($ratios, $type, $request->getParam('Date'))->dateCloture;
foreach($ratios->BilansInfos->item as $elements) {
$tab[$elements->dateCloture][$elements->typeBilan] = $elements;
$i++;
}
foreach ($tab as $champDate => $valeur)
$listeDate[] = $champDate;
if (isset($date)) {
if (!empty($date)) {
foreach ($tableau as $name => $valeur) {
$html .= '<thead><tr class="subhead">
<td class="center italique">'.$name.'</td>
<td>Entreprise</td>
<td>Secteur</td>
<td>Position</td>
</tr></thead>';
$html.= '<tbody>';
foreach ($tab[$date][$type]->RatiosEntrep->item as $element)
self::printElementRatio($tableau, $name, $element, $html, $ratios, $date, $type);
$html.= '</tbody>';
}
}
}
$this->view->assign('typeBilan', $type);
$this->view->assign('Date', $date);
$this->view->assign('i', $i_view);
$this->view->assign('html', $html);
$this->view->assign('id', $id);
$this->view->assign('ratios', $tab);
}
/** Gestion de la vue **/
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('siret', $siret);
$this->view->assign('naf', $entreprise->getNaf());
2011-06-13 15:42:55 +00:00
$this->view->assign('dateFunction', $dateFunction);
$this->view->assign('AutrePage', $request->getParam('apage'));
}
2011-05-18 12:22:08 +00:00
/**
* Export d'une liasse au format XLS
*/
2011-05-18 13:04:29 +00:00
public function liassexlsAction()
{
2011-05-23 09:51:37 +00:00
//@todo : Gestion des unités dans l'export XLS
2011-05-18 13:35:56 +00:00
$this->_helper->layout()->disableLayout();
2011-05-18 13:04:29 +00:00
$request = $this->getRequest();
$unite = $request->getParam('unit', '€');
$type = $request->getParam('type', '');
$date = $request->getParam('date', '');
$entreprise = new SessionEntreprise($this->siret, $this->id);
2011-05-18 13:04:29 +00:00
switch($type)
{
case 'C':
case 'N':
$model = 'liasse_2050';
break;
case 'S':
$model = 'liasse_2033';
break;
}
2011-07-04 08:31:42 +00:00
$ws = new WsScores();
$liasses = $ws->getBilan(substr($this->siret, 0, 9), $date, $type, '');
$data = array();
$data['DATE_CLOTURE'] = $liasses->DATE_CLOTURE;
2011-05-23 09:51:37 +00:00
$data['DATE_CLOTURE_PRE'] = $liasses->DATE_CLOTURE_PRE;
$data['DUREE_MOIS'] = $liasses->DUREE_MOIS;
$data['DUREE_MOIS_PRE'] = $liasses->DUREE_MOIS_PRE;
foreach ($liasses->POSTES->item as $element)
$data[$element->id] = $element->val;
2011-05-18 13:35:56 +00:00
$path = APPLICATION_PATH . '/../cache/liasse/';
$file = 'liasse-'.substr($this->siret, 0, 9).'-'.$this->id.'-'.$type.$date.'.xls';
2011-05-18 13:35:56 +00:00
2011-06-07 09:48:57 +00:00
require_once 'Finance/LiasseXLS.php';
2011-05-18 13:04:29 +00:00
$liasse = new LiasseXLS($model);
$liasse->dataModel(substr($this->siret, 0, 9), $entreprise->getRaisonSociale(), $data);
2011-05-18 13:04:29 +00:00
$liasse->dataFile($file);
2011-05-18 13:35:56 +00:00
if( file_exists($path.$file) ){
2011-06-29 12:44:20 +00:00
$ws = new WsScores();
$ws->setLog('liassexls', $siren, 0, '');
2011-05-18 13:35:56 +00:00
$this->view->assign('file', $file);
2011-05-18 13:04:29 +00:00
}
2011-05-18 12:22:08 +00:00
}
2011-05-06 15:26:56 +00:00
/**
2011-05-18 13:04:29 +00:00
* Affichage des liasses.
* @todo :
* ATTENTION LES BILANS SIMPLIFIES ONT ETE RETIRE ALORS QU'IL FAUT LES TRAITER
* NE PAS FAIRE COMME DANS LES RATIOS
2011-07-04 10:02:31 +00:00
* Sélection des unités non fonctionnel
* Sélection de la dernière date, est ce que l'on est sur que c'est la dernière en fonction du type
* Class LiasseList pour la gestion de la liste
2011-05-06 15:26:56 +00:00
*/
2011-04-19 15:59:50 +00:00
public function liasseAction()
{
$user = new Utilisateur();
2011-07-04 08:31:42 +00:00
2011-05-13 16:33:21 +00:00
/** Les ancres pour les liens **/
2011-06-13 07:04:46 +00:00
$ancres = array(
2011-05-18 13:04:29 +00:00
'C' => array('actif', 'passif', 'compteDeResultat'),
'N' => array('actif', 'passif', 'compteDeResultat', 'immobilisations',
'amortissements', 'provisions', 'creancesDettes', 'affectation'),
'A' => array('actif', 'passif', 'compteDeResultat'),
'B' => array('actif', 'passif', 'compteDeResultat')
2011-04-26 13:39:19 +00:00
);
/** La liste des type de bilan existant **/
2011-05-18 15:10:54 +00:00
$liste = array (
2011-05-18 13:04:29 +00:00
'N' => array(),
'S' => array(),
'C' => array(),
'B' => array(),
'A' => array());
2011-04-26 13:39:19 +00:00
/** Le nom des type pour le select */
2011-05-18 15:10:54 +00:00
$type = array (
2011-05-18 13:04:29 +00:00
'A' => 'Assurance',
'B' => 'Banque',
'C' => 'Consolidé',
'S' => 'Simplifié',
2011-05-18 13:04:29 +00:00
'N' => ''
);
2011-04-26 13:39:19 +00:00
/** Liste des unités que l'ont proposent **/
2011-06-13 07:04:46 +00:00
$unit = array (
2011-07-04 10:00:22 +00:00
'€' => 1,
'K€' => 1000,
'M€' => 1000000
2011-05-18 13:04:29 +00:00
);
2011-04-26 13:39:19 +00:00
$liasse = array ();
2011-05-13 16:33:21 +00:00
$request = $this->getRequest();
2011-07-04 08:31:42 +00:00
2011-07-04 10:00:22 +00:00
$unite = $request->getParam('unit','K€');
2011-07-04 08:36:22 +00:00
$ws = new WsScores();
$listBilan = $ws->getListeBilans(substr($this->siret, 0, 9));
2011-07-04 10:00:22 +00:00
$date = $request->getParam('date',$listBilan->result->item[0]->dateExercice.':'.$listBilan->result->item[0]->typeBilan);
$entreprise = new SessionEntreprise($this->siret, $this->id);
if($listBilan->nbReponses > 0) {
2011-07-04 10:00:22 +00:00
$dateFunction = new WDate();
foreach ($listBilan->result->item as $item)
$liste[$item->typeBilan][] = $item->dateExercice;
2011-07-04 08:49:06 +00:00
if (!empty($date)) {
$dateAndType = explode(':', $date);
2011-07-04 10:00:22 +00:00
$info = $ws->getBilan(substr($this->siret, 0, 9), $dateAndType[0], $dateAndType[1], true);
$infoLiasse = new Liasse($info);
$this->view->assign('dateCloture', $infoLiasse->getInfo('dateCloture'));
$this->view->assign('dateCloturePre', $infoLiasse->getInfo('dateCloturePre'));
$this->view->assign('dureesMois', $infoLiasse->getInfo('dureeMois'));
$this->view->assign('dureesMoisPre', $infoLiasse->getInfo('dureeMoisPre'));
$this->view->assign('date', $dateAndType[0]);
$this->view->assign('champType', $dateAndType[1]);
2011-07-04 10:00:22 +00:00
$this->view->assign('liasse', $infoLiasse->getPostes());
//Gestion export de la liasse au format XLS
$user = new Utilisateur();
if (in_array($user->getIdClient(), array(1,86))
&& in_array($dateAndType[1],array('C', 'N', 'S')) ) {
2011-07-04 08:49:06 +00:00
$this->view->assign('exportxls', true);
}
}
$this->view->assign('dateFunction', $dateFunction);
$this->view->assign('ancres', $ancres);
$this->view->assign('liste', $liste);
$this->view->assign('id', $id);
$this->view->assign('type', $type);
$this->view->assign('unit', $unit);
}
2011-04-26 13:39:19 +00:00
/** Partie vue **/
$this->view->haveLiasse = ($listBilan->nbReponses > 0)?true:false;
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('siren', substr($this->siret, 0, 9));
2011-07-04 08:49:06 +00:00
$this->view->assign('siret', $this->siret);
2011-04-19 15:59:50 +00:00
}
2011-05-09 11:43:43 +00:00
/**
* Fonction qui gére la cotation en bourse.
*/
2011-04-19 15:59:50 +00:00
public function bourseAction()
{
2011-06-08 15:41:59 +00:00
$siren = substr($this->siret, 0, 9);
$sessionEntreprise = new SessionEntreprise($this->siret, $this->id);
$ws = new WsScores();
$InfosBourse = $ws->getInfosBourse($siren);
Zend_Registry::get('firebug')->info($InfosBourse);
$this->view->assign('InfosBourse', $InfosBourse);
2011-06-08 15:41:59 +00:00
$this->view->assign('id', $this->id);
$this->view->assign('siret', $this->siret);
$this->view->assign('raisonSociale', $sessionEntreprise->getRaisonSociale());
$this->view->assign('siren', $siren);
2011-04-19 15:59:50 +00:00
}
2011-05-09 11:43:43 +00:00
/**
* Fonction qui gére les etablissements bancaires.
*/
2011-04-19 15:59:50 +00:00
public function banqueAction()
{
$autrePage = $this->getRequest()->getParam('apage');
//Récupération des informations
if (empty($autrePage)) {
$ws = new WsScores();
$banque = $ws->getBanques(substr($this->siret, 0, 9));
} else {
$banque = $this->getRequest()->getParam('infos');
}
$entreprise = new SessionEntreprise($this->siret, $this->id);
$this->view->assign('banques', $banque->result->item);
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('siren', substr($this->siret, 0, 9));
2011-04-19 15:59:50 +00:00
}
2011-04-11 14:19:14 +00:00
}