1430 lines
52 KiB
PHP
1430 lines
52 KiB
PHP
<?php
|
|
class FinanceController extends Zend_Controller_Action
|
|
{
|
|
protected $siret = null;
|
|
protected $id = 0;
|
|
|
|
public function init()
|
|
{
|
|
require_once 'Scores/WsScores.php';
|
|
|
|
$request = $this->getRequest();
|
|
$this->siret = $request->getParam('siret');
|
|
$this->id = $request->getParam('id', 0);
|
|
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/finance.js', 'text/javascript');
|
|
}
|
|
|
|
public function indexAction()
|
|
{
|
|
$this->forward('index', 'index');
|
|
}
|
|
|
|
/**
|
|
* Affichage de la synthese
|
|
*/
|
|
public function syntheseAction()
|
|
{
|
|
$user = new Scores_Utilisateur();
|
|
$session = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
|
|
$request = $this->getRequest();
|
|
$typeBilan = $request->getParam('typeBilan', 'N');
|
|
$ratio = $request->getParam('ratio', '');
|
|
$autrePage = $request->getParam('apage');
|
|
|
|
//Récupération des informations
|
|
if (empty($autrePage)) {
|
|
$this->view->headTitle()->prepend("Synthese financière");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
$ws = new WsScores();
|
|
$infos = $ws->getRatios(substr($this->siret, 0, 9), 'synthese');
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $request->getParam('infos');
|
|
}
|
|
|
|
$tabRatio = array(
|
|
'r5' => array('evol'=>'r6', 'op' => 1000, 'titre'=>'CHIFFRE D\'AFFAIRES'),
|
|
'r7' => array('evol'=>'r8', 'op' => 1000, 'titre'=>'RESULTAT COURANT AVANT IMPOTS'),
|
|
'r10' => array('evol'=>'r11', 'op' => 1000, 'titre'=>'RESULTAT NET'),
|
|
'r18' => array('evol'=>'r19', 'op' => 1000, 'titre'=>'FONDS PROPRES'),
|
|
'r22' => array('evol'=>'r23', 'op' => 1000, 'titre'=>'TOTAL BILAN'),
|
|
'r231' => array('evol'=>'r235', 'op' => 1000, 'titre'=>'FONDS DE ROULEMENT'),
|
|
'r232' => array('evol'=>'r236', 'op' => 1000, 'titre'=>'BESOIN EN FONDS DE ROULEMENT'),
|
|
'r249' => array('evol'=>'r254', 'op' => 1000, 'titre'=>'TRESORERIE'),
|
|
'r24' => array('evol'=>'r24', 'op' => 1, 'titre'=>'EFFECTIF', 'unite' => 1),
|
|
);
|
|
|
|
$tabRatioGraph = array(
|
|
0 => array('ratio'=>'r236', 'op' => 1000),
|
|
1 => array('ratio'=>'r235', 'op' => 1000),
|
|
2 => array('ratio'=>'r6', 'op' => 1000),
|
|
3 => array('ratio'=>'r146', 'op' => 1000)
|
|
);
|
|
|
|
if($ratio!=''){
|
|
$tabRatio = array( $ratio => $tabRatio[$ratio] );
|
|
}
|
|
|
|
//Formattage des données
|
|
$ratiosData = new Scores_Finance_Ratios_Data($infos);
|
|
|
|
$nbBilanN = $ratiosData->getNbBilan('N');
|
|
$nbBilanC = $ratiosData->getNbBilan('C');
|
|
|
|
if ($typeBilan == 'N' && $nbBilanN==0){
|
|
$typeBilan = 'C';
|
|
}
|
|
|
|
if ($nbBilanN!=0 || $nbBilanC!=0)
|
|
{
|
|
foreach($tabRatio as $idRatio => $valRatio){
|
|
$tabRatio[$idRatio]['comment'] = $ratiosData->wrapComment($idRatio);
|
|
}
|
|
$this->view->assign('tabRatio', $tabRatio);
|
|
|
|
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
|
|
$annees = array_keys($infosAnnee);
|
|
sort($annees);
|
|
if (count($annees)>1){
|
|
//Générer les différents graphiques d'évolutions
|
|
$ratiosGraph = new Scores_Finance_Ratios_Graph($this->siret, $this->id);
|
|
$tabGraphEvol = array();
|
|
foreach($tabRatio as $idRatio => $infoRatio){
|
|
$dataGraphEvol = array();
|
|
foreach($annees as $annee){
|
|
$dataGraphEvol[] = array(
|
|
'date' => $annee,
|
|
'value' => ($ratiosData->getRatiosEntrep($typeBilan, $annee, $idRatio)!='NS') ?
|
|
$ratiosData->getRatiosEntrep($typeBilan, $annee, $idRatio)/$infoRatio['op'] : 0
|
|
);
|
|
}
|
|
$tabGraphEvol[$idRatio] = $ratiosGraph->syntheseGraphEvol($dataGraphEvol, $idRatio, $unite);
|
|
}
|
|
|
|
//Générer le graphique de comparaison
|
|
$dataGraph = array();
|
|
$i=0;
|
|
foreach($annees as $annee){
|
|
$dataGraph[$i]['date'] = $infosAnnee[$annee]->dateCloture;
|
|
$dataGraph[$i]['duree'] = $infosAnnee[$annee]->duree;
|
|
foreach($tabRatioGraph as $item){
|
|
$dataGraph[$i][$item['ratio']] = $ratiosData->getRatiosEntrep($typeBilan, $annee, $item['ratio'])/$item['op'];
|
|
}
|
|
$i++;
|
|
}
|
|
$graphLineCompare = $ratiosGraph->syntheseGraphLineCompare($dataGraph, $typeBilan);
|
|
$this->view->assign('graph', true);
|
|
} else {
|
|
$this->view->assign('graph', false);
|
|
}
|
|
|
|
|
|
//On prend les 3 derniers bilans pour l'affichage
|
|
$nbMaxBilan = 3;
|
|
rsort($annees);
|
|
$annees = array_slice($annees, 0, $nbMaxBilan);
|
|
sort($annees);
|
|
$tabResult = array();
|
|
foreach($annees as $annee){
|
|
$data = array();
|
|
$dataEvol = array();
|
|
//Formatter les données
|
|
foreach($tabRatio as $idRatio => $valRatio){
|
|
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
|
|
$dataEvol[$idRatio] = $ratiosData->dEvol($typeBilan, $annee, $valRatio['evol']);
|
|
}
|
|
$date = new Zend_Date($annee, 'yyyyMMdd');
|
|
$tabResult[] = array(
|
|
'dateCloture' => $date->toString('dd/MM/yyyy'),
|
|
'duree' => $infosAnnee[$annee]->duree.' Mois',
|
|
'entrep' => $data,
|
|
'entrepEvol' => $dataEvol,
|
|
);
|
|
}
|
|
$this->view->assign('tabResult', $tabResult);
|
|
}
|
|
|
|
$this->view->assign('nbBilanN', $nbBilanN);
|
|
$this->view->assign('nbBilanC', $nbBilanC);
|
|
$this->view->assign('typeBilan', $typeBilan);
|
|
$this->view->assign('raisonSociale', $session->getRaisonSociale());
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('siren', substr($this->siret, 0, 9));
|
|
$this->view->assign('AutrePage', $autrePage);
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Affichage des graphiques d'évolution (synthese)
|
|
*/
|
|
public function synthesegraphevolAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
$ratio = $request->getParam('ratio');
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->pages . '/imgcache/';
|
|
$file = 'syntheseEvol-'.$this->siret.'-'.$this->id.'-'.$ratio.'.png';
|
|
if (file_exists($path.$file)) {
|
|
echo '<img src="/fichier/imgcache/'.$file.'" />';
|
|
} else {
|
|
echo "Erreur de génération du graphique";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affichage du graphique de comparaison (synthese)
|
|
*/
|
|
public function synthesegraphcompareAction()
|
|
{
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
$typeBilan = $request->getParam('typeBilan');
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->pages . '/imgcache/';
|
|
$file = 'synthese-linecompare-'.$this->siret.'-'.$this->id.'-'.$typeBilan.'.png';
|
|
if (file_exists($path.$file)) {
|
|
echo '<img src="/fichier/imgcache/'.$file.'" />';
|
|
} else {
|
|
echo "Erreur de génération du graphique";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Fonction qui affiche les bilan (actif, passif, SIG).
|
|
* Le principe est d'utiliser le mapping de données.
|
|
* @todo : RatiosData, RatiosGraph
|
|
*/
|
|
public function bilanAction()
|
|
{
|
|
$user = new Scores_Utilisateur();
|
|
$request = $this->getRequest();
|
|
$autrePage = $request->getParam('apage');
|
|
$typeBilan = $request->getParam('typeBilan', 'N');
|
|
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
|
|
//Récupération des informations
|
|
if (empty($autrePage)) {
|
|
$this->view->headTitle()->prepend("Bilan, Compte de résultat");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
$ws = new WsScores();
|
|
$infos = $ws->getRatios(substr($this->siret, 0, 9), 'ratios');
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $this->getRequest()->getParam('infos');
|
|
}
|
|
|
|
$ratiosData = new Scores_Finance_Ratios_Data($infos);
|
|
|
|
$nbBilanN = $ratiosData->getNbBilan('N');
|
|
$nbBilanC = $ratiosData->getNbBilan('C');
|
|
|
|
if ($typeBilan == 'N' && $nbBilanN==0){
|
|
$typeBilan = 'C';
|
|
}
|
|
|
|
if ($nbBilanN!=0 || $nbBilanC!=0)
|
|
{
|
|
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
|
|
$annees = array_keys($infosAnnee);
|
|
|
|
$ratiosGraph = new Scores_Finance_Ratios_Graph($this->siret, $this->id);
|
|
|
|
$tabRatioActif = array(
|
|
'r59' => array( 'titre' => 'Actif Immobilisé Net', 'class' => 'subhead'),
|
|
'r51' => array( 'titre' => 'Incorporelles', 'class' => ''),
|
|
'r52' => array( 'titre' => 'Corporelles', 'class' => '' ),
|
|
'r53' => array( 'titre' => 'Financières', 'class' => '' ),
|
|
'r69' => array( 'titre' => 'Actif Circulant Net', 'class' => 'subhead' ),
|
|
'r60' => array( 'titre' => 'Stock et encours', 'class' => '' ),
|
|
'r61' => array( 'titre' => 'Créances Clients', 'class' => '' ),
|
|
'r62' => array( 'titre' => 'Autres Créances', 'class' => '' ),
|
|
'00' => array( 'titre' => '', 'class' => '' ),
|
|
'r63' => array( 'titre' => 'Trésorerie Active', 'class' => '' ),
|
|
'r22' => array( 'titre' => 'TOTAL ACTIF', 'class' => 'subhead' ),
|
|
);
|
|
$totalRatioActif = 'r22';
|
|
|
|
$tabRatioPassif = array(
|
|
'r79' => array( 'titre' => 'Ressources Propres', 'class' => 'subhead'),
|
|
'r70' => array( 'titre' => 'Fonds Propres', 'class' => ''),
|
|
'r71' => array( 'titre' => 'Provisions Risques', 'class' => ''),
|
|
'r72' => array( 'titre' => 'Comptes Courants', 'class' => ''),
|
|
'r90' => array( 'titre' => 'Ressources Externes', 'class' => 'subhead'),
|
|
'r83' => array( 'titre' => 'Dettes Financières', 'class' => ''),
|
|
'r84' => array( 'titre' => 'Dettes Fournisseurs', 'class' => ''),
|
|
'r85' => array( 'titre' => 'Dettes Fiscales', 'class' => ''),
|
|
'r86' => array( 'titre' => 'Autres Dettes', 'class' => ''),
|
|
'r87' => array( 'titre' => 'Trésorerie Passive', 'class' => ''),
|
|
'r22' => array( 'titre' => 'TOTAL PASSIF', 'class' => 'subhead'),
|
|
);
|
|
$totalRatioPassif = 'r22';
|
|
|
|
$tabRatioSig = array(
|
|
'r101' => array( 'titre' => 'CHIFFRE D\'AFFAIRES HORS TAXE', 'op' => '', 'class' => 'subhead'),
|
|
'r102' => array( 'titre' => 'Achat de marchandises, de matières premières', 'op' => '-', 'class' => ''),
|
|
'r110' => array( 'titre' => 'MARGE COMMERCIALE', 'op' => '', 'class' => 'subhead'),
|
|
'r111' => array( 'titre' => 'Production vendue', 'op' => '+', 'class' => ''),
|
|
'r112' => array( 'titre' => 'Production immobilisée et stockée', 'op' => '+', 'class' => ''),
|
|
'r120' => array( 'titre' => 'PRODUCTION DE L\'EXERCICE', 'op' => '', 'class' => 'subhead'),
|
|
'r121' => array( 'titre' => 'Variation de stock de marchandises et matières premières', 'op' => '±', 'class' => ''),
|
|
'r122' => array( 'titre' => 'MARGE BRUTE', 'op' => '', 'class' => 'subhead'),
|
|
'r123' => array( 'titre' => 'Autres charges externes', 'op' => '-', 'class' => ''),
|
|
'r130' => array( 'titre' => 'VALEUR AJOUTÉE', 'op' => '', 'class' => 'subhead'),
|
|
'r132' => array( 'titre' => 'Charges de personnel', 'op' => '-', 'class' => ''),
|
|
'r133' => array( 'titre' => 'Impôts, taxes & versements assimilés', 'op' => '-', 'class' => ''),
|
|
'r131' => array( 'titre' => 'Subventions d\'exploitation', 'op' => '+', 'class' => ''),
|
|
'r140' => array( 'titre' => 'EXCÉDENT BRUT D\'EXPLOITATION (EBE)', 'op' => '', 'class' => 'subhead'),
|
|
'r141' => array( 'titre' => 'Autres produits d\'exploitation', 'op' => '+', 'class' => ''),
|
|
'r142' => array( 'titre' => 'Autres charges d\'exploitation', 'op' => '-', 'class' => ''),
|
|
'r143' => array( 'titre' => 'Reprise sur dotations & transferts de charges', 'op' => '+', 'class' => ''),
|
|
'r144' => array( 'titre' => '70% Loyer de crédit bail', 'op' => '+', 'class' => ''),
|
|
'r145' => array( 'titre' => 'Dotations d\'exploitation & provisions d\'exploitation', 'op' => '-', 'class' => ''),
|
|
'r150' => array( 'titre' => 'RÉSULTAT D\'EXPLOITATION', 'op' => '', 'class' => 'subhead'),
|
|
'r151' => array( 'titre' => 'Produits financiers', 'op' => '+', 'class' => ''),
|
|
'r152' => array( 'titre' => '30% Loyer de crédit bail', 'op' => '+', 'class' => ''),
|
|
'r153' => array( 'titre' => 'Charges financières', 'op' => '+', 'class' => ''),
|
|
'r170' => array( 'titre' => 'RÉSULTAT COURANT AVANT IMPOTS', 'op' => '', 'class' => 'subhead'),
|
|
'r171' => array( 'titre' => 'Produits exceptionnels', 'op' => '+', 'class' => ''),
|
|
'r172' => array( 'titre' => 'Charges exceptionnelles', 'op' => '-', 'class' => ''),
|
|
'r181' => array( 'titre' => 'Impôts sur les bénéfices', 'op' => '-', 'class' => ''),
|
|
'r182' => array( 'titre' => 'Participation salariale', 'op' => '-', 'class' => ''),
|
|
'r199' => array( 'titre' => 'RÉSULTAT NET', 'op' => '', 'class' => 'subhead'),
|
|
);
|
|
$totalRatioSig = 'r101';
|
|
|
|
//On prend les 5 derniers bilans pour l'affichage
|
|
$nbMaxBilan = 5;
|
|
rsort($annees);
|
|
$annees = array_slice($annees, 0, $nbMaxBilan);
|
|
sort($annees);
|
|
|
|
$tabResultActif = array();
|
|
$tabResultPassif = array();
|
|
$tabResultSig = array();
|
|
foreach($annees as $annee){
|
|
//Formatter les données Actif
|
|
$data = array();
|
|
foreach($tabRatioActif as $idRatio => $valRatio){
|
|
if ($idRatio == '00'){
|
|
$data[$idRatio] = '';
|
|
$dataTotal[$idRatio] = '';
|
|
} else {
|
|
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
|
|
$dataTotal[$idRatio] = $ratiosData->dPercent($typeBilan, $annee, $idRatio, $totalRatioActif);
|
|
}
|
|
}
|
|
//Génération du graphique Actif
|
|
$dataGraphActif = array(
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r51', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r52', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r53', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r60', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r61', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r62', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r63', 'r22'),
|
|
);
|
|
$ratiosGraph->bilansgraphactif($dataGraphActif, $typeBilan, $annee);
|
|
|
|
$date = new Zend_Date($annee, 'yyyyMMdd');
|
|
$tabResultActif[] = array(
|
|
'dateCloture' => $date->toString('dd/MM/yyyy'),
|
|
'duree' => $infosAnnee[$annee]->duree.' Mois',
|
|
'entrep' => $data,
|
|
'total' => $dataTotal,
|
|
);
|
|
|
|
//Formatter les données Passif
|
|
$data = array();
|
|
foreach($tabRatioPassif as $idRatio => $valRatio){
|
|
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
|
|
$dataTotal[$idRatio] = $ratiosData->dPercent($typeBilan, $annee, $idRatio, $totalRatioPassif);
|
|
}
|
|
//Génération données graphique passif
|
|
$dataGraphPassif = array(
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r70', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r71', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r72', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r83', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r84', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r85', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r86', 'r22'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r87', 'r22'),
|
|
);
|
|
$ratiosGraph->bilansgraphpassif($dataGraphPassif, $typeBilan, $annee);
|
|
|
|
$date = new Zend_Date($annee, 'yyyyMMdd');
|
|
$tabResultPassif[] = array(
|
|
'dateCloture' => $date->toString('dd/MM/yyyy'),
|
|
'duree' => $infosAnnee[$annee]->duree.' Mois',
|
|
'entrep' => $data,
|
|
'total' => $dataTotal,
|
|
);
|
|
|
|
//Formatter les données Sig
|
|
$data = array();
|
|
foreach($tabRatioSig as $idRatio => $valRatio){
|
|
$data[$idRatio] = $ratiosData->dRatio($typeBilan, $annee, $idRatio);
|
|
$dataTotal[$idRatio] = $ratiosData->dPercent($typeBilan, $annee, $idRatio, $totalRatioSig);
|
|
}
|
|
//Génération données graphique SIG
|
|
$dataGraphSIG = array(
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r101','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r122','r101'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r122','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r130','r101'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r130','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r140','r101'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r140','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r150','r101'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r150','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r170','r101'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r170','r101')-$ratiosData->graphPercent($typeBilan, $annee, 'r199','r101'),
|
|
$ratiosData->graphPercent($typeBilan, $annee, 'r199','r101'),
|
|
);
|
|
$ratiosGraph->bilansgraphsig($dataGraphSIG, $typeBilan, $annee);
|
|
|
|
$date = new Zend_Date($annee, 'yyyyMMdd');
|
|
$tabResultSig[] = array(
|
|
'dateCloture' => $date->toString('dd/MM/yyyy'),
|
|
'duree' => $infosAnnee[$annee]->duree.' Mois',
|
|
'entrep' => $data,
|
|
'total' => $dataTotal,
|
|
);
|
|
}
|
|
|
|
$this->view->assign('lastDateCloture', $annee);
|
|
|
|
$this->view->assign('tabRatioActif', $tabRatioActif);
|
|
$this->view->assign('tabRatioPassif', $tabRatioPassif);
|
|
$this->view->assign('tabRatioSig', $tabRatioSig);
|
|
|
|
$this->view->assign('tabResultActif', $tabResultActif);
|
|
$this->view->assign('tabResultPassif', $tabResultPassif);
|
|
$this->view->assign('tabResultSig', $tabResultSig);
|
|
|
|
}
|
|
|
|
$this->view->assign('nbBilanN', $nbBilanN);
|
|
$this->view->assign('nbBilanC', $nbBilanC);
|
|
$this->view->assign('typeBilan', $typeBilan);
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('siren', substr($this->siret, 0, 9));
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
$this->view->assign('AutrePage', $request->getParam('apage'));
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Affichage des graphiques bilan Actif/Passif/SIG
|
|
*/
|
|
public function bilangraphAction()
|
|
{
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
$type = $request->getParam('type', '');
|
|
$typeBilan = $request->getParam('typeBilan');
|
|
$dateCloture = $request->getParam('dateCloture');
|
|
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->pages . '/imgcache/';
|
|
switch($type){
|
|
case 'actif':
|
|
$file = 'bilansgraphactif-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png';
|
|
break;
|
|
case 'passif':
|
|
$file = 'bilansgraphpassif-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png';
|
|
break;
|
|
case 'sig':
|
|
$file = 'bilansgraphsig-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png';
|
|
break;
|
|
}
|
|
if (file_exists($path.$file)) {
|
|
echo '<img src="/fichier/imgcache/'.$file.'" />';
|
|
} else {
|
|
echo "Erreur de génération du graphique";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gestion de l'affichage des ratios.
|
|
*/
|
|
public function ratiosAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$autrePage = $request->getParam('apage');
|
|
|
|
//Récupération des informations
|
|
if (empty($autrePage)) {
|
|
$this->view->headTitle()->prepend("Ratios");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
$ws = new WsScores();
|
|
$infos = $ws->getRatios(substr($this->siret, 0, 9), 'ratios');
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $this->getRequest()->getParam('infos');
|
|
}
|
|
|
|
$typeBilan = $request->getParam('typeBilan', 'N');
|
|
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
|
|
$tabRatio = array(
|
|
array('titre' => 'EQUILIBRE FINANCIER'),
|
|
array('titre' => 'MARGE BRUTE D\'AUTOFINANCEMENT',
|
|
'stitre'=> '(MBA ou CAF)',
|
|
'ratio' => 'r233', 'parent' => 0, 'position' => '>'),
|
|
array('titre' => 'COUVERTURE du BFR',
|
|
'stitre'=> '(FR/BFR)',
|
|
'ratio' => 'r234', 'parent' => 0, 'position' => '>'),
|
|
array('titre' => 'COUVERTURE des IMMOS NETTES',
|
|
'stitre'=> '(Capitaux permanents / Immobilisations nettes)',
|
|
'ratio' => 'r237', 'parent' => 0, 'position' => '>'),
|
|
array('titre' => 'COUVERTURE du CA',
|
|
'stitre'=> '(Fond de roulement net global sur 12m x 360'.
|
|
' / Chiffre d\'affaire)',
|
|
'ratio' => 'r238', 'parent' => 0, 'position' => '>'),
|
|
array('titre' => 'SOLVABILITE',
|
|
'stitre'=> '(Capitaux propres / Ensemble des dettes)',
|
|
'ratio' => 'r239', 'parent' => 0, 'position' => '>'),
|
|
array('titre' => 'INDEPENDANCE FINANCIERE',
|
|
'stitre'=> '(Cap.propres/Capitaux permanents)',
|
|
'ratio' => 'r240', 'parent' => 0, 'position' => '>'),
|
|
|
|
array('titre' => 'PROFITABILITE'),
|
|
array('titre' => 'RENTABILITE ECONOMIQUE',
|
|
'stitre'=> '(EBE/TOTAL bilan)',
|
|
'ratio' => 'r262', 'parent' => 7, 'position' => '>'),
|
|
array('titre' => 'RENTABILITE FINANCIERE',
|
|
'stitre'=> '(Résult.Net/Cap.propres)',
|
|
'ratio' => 'r263', 'parent' => 7, 'position' => '>'),
|
|
array('titre' => 'RENTABILITE COMMERCIALE',
|
|
'stitre'=> '(Résultat net/CA)',
|
|
'ratio' => 'r264', 'parent' => 7, 'position' => '>'),
|
|
array('titre' => 'CONTRIBUTION DU CAPITAL',
|
|
'stitre'=> '(Capacité d\'autofinancement sur 12 mois'.
|
|
' / Capitaux permanents)',
|
|
'ratio' => 'r265', 'parent' => 7, 'position' => '>'),
|
|
array('titre' => 'CONTRIBUTION DE LA VA',
|
|
'stitre'=>'(Capacité d\'autofinancement / Valeur ajoutée)',
|
|
'ratio' => 'r266', 'parent' => 7, 'position' => '>'),
|
|
|
|
array('titre' => 'LIQUIDITE'),
|
|
array('titre' => 'LIQUIDITE IMMEDIATE',
|
|
'stitre'=> '(Disponibilité / Dettes CT)',
|
|
'ratio' => 'r250', 'parent' => 13, 'position' => '>'),
|
|
array('titre' => 'LIQUIDITE REDUITE',
|
|
'stitre'=>'(Disponibilité et créances réelles / Dettes CT)',
|
|
'ratio' => 'r252', 'parent' => 13, 'position' => '>'),
|
|
array('titre' => 'LIQUIDITE GENERALE',
|
|
'stitre'=> '(Act.circulant net/Dettes CT)',
|
|
'ratio' => 'r251', 'parent' => 13, 'position' => '>'),
|
|
|
|
array('titre' => 'ENDETTEMENT'),
|
|
array('titre' => 'ENDETTEMENT',
|
|
'stitre'=> '(Dettes a + 1 an / Capitaux propres)',
|
|
'ratio' => 'r244', 'parent' => 17, 'position' => '<'),
|
|
array('titre' => 'CAPACITE DE REMBOURSEMENT',
|
|
'stitre'=> '(Dettes.bancaires.(+MT+LT+C.bail)/CAF)',
|
|
'ratio' => 'r247', 'parent' => 17, 'position' => '<'),
|
|
array('titre' => 'FINANCEMENT DES STOCKS',
|
|
'stitre'=> '(Dettes aux fournisseurs / Stock)',
|
|
'ratio' => 'r248', 'parent' => 17, 'position' => '<'),
|
|
|
|
array('titre' => 'PRODUCTIVITE'),
|
|
array('titre' => 'PRODUCTIVITE DE L\'ACTIF',
|
|
'stitre'=> '(Chiffre d\'affaire / Actif comptable)',
|
|
'ratio' => 'r271', 'parent' => 21, 'position' => '>'),
|
|
array('titre' => 'DUREE CLIENT',
|
|
'stitre'=> '(Rotation clients en VJ TTC)',
|
|
'ratio' => 'r278', 'parent' => 21, 'position' => '<'),
|
|
array('titre' => 'DUREE FOURNISSEUR',
|
|
'stitre'=> '(Rotation fournisseurs en JA TTC)',
|
|
'ratio' => 'r279', 'parent' => 21, 'position' => '<'),
|
|
array('titre' => 'POIDS MASSE SALARIALE',
|
|
'stitre'=> '(Ch personnel / VA)',
|
|
'ratio' => 'r281', 'parent' => 21, 'position' => '<'),
|
|
array('titre' => 'RENDEMENT',
|
|
'stitre'=> '(Production sur 12mois / Effectif)',
|
|
'ratio' => 'r261', 'parent' => 21, 'position' => '>'),
|
|
array('titre' => 'PRODUCTIVITE',
|
|
'stitre'=> '(CA / Effectif)',
|
|
'ratio' => 'r267', 'parent' => 21, 'position' => '>')
|
|
);
|
|
|
|
if($ratio!=''){
|
|
$tabRatio = array( $ratio => $tabRatio[$ratio] );
|
|
}
|
|
|
|
$ratiosData = new Scores_Finance_Ratios_Data($infos);
|
|
|
|
$nbBilanN = $ratiosData->getNbBilan('N');
|
|
$nbBilanC = $ratiosData->getNbBilan('C');
|
|
|
|
if ($typeBilan == 'N' && $nbBilanN==0){
|
|
$typeBilan = 'C';
|
|
}
|
|
|
|
if ($nbBilanN!=0 || $nbBilanC!=0)
|
|
{
|
|
//Génération Graphique evolution
|
|
$ratiosGraph = new Scores_Finance_Ratios_Graph($this->siret, $this->id);
|
|
|
|
$infosAnnee = $ratiosData->getBilansInfo($typeBilan);
|
|
$annees = array_keys($infosAnnee);
|
|
rsort($annees);
|
|
|
|
$mil = $request->getParam('mil', $annees[0]);
|
|
|
|
$tabAnnees = array();
|
|
foreach($annees as $annee){
|
|
$date = new Zend_Date($annee, 'yyyyMMdd');
|
|
$tabAnnees[$annee] = $date->toString('dd/MM/yyyy');
|
|
}
|
|
|
|
$tabResult = array();
|
|
foreach($tabRatio as $item ) {
|
|
if (isset($item['ratio'])){
|
|
$dataGraph = $ratiosData->dGraph($typeBilan, $item['ratio']);
|
|
$ratiosGraph->ratiosgraph($item['ratio'], $dataGraph);
|
|
$item['entrep'] = $ratiosData->dRatio($typeBilan, $mil, $item['ratio']);
|
|
$item['secteur'] = $ratiosData->dSecteur($mil, $item['ratio']);
|
|
$item['position'] = $ratiosData->dPosition($typeBilan, $mil, $item['ratio'], $item['position']);
|
|
$item['comment'] = $ratiosData->wrapComment($item['ratio']);
|
|
}
|
|
$tabResult[] = $item;
|
|
}
|
|
$this->view->assign('tabResult', $tabResult);
|
|
|
|
$this->view->assign('annees', $tabAnnees);
|
|
$this->view->assign('mil', $mil);
|
|
$this->view->assign('typeBilan', $typeBilan);
|
|
$this->view->assign('duree', $infosAnnee[$mil]->duree);
|
|
}
|
|
$this->view->assign('nbBilanN', $nbBilanN);
|
|
$this->view->assign('nbBilanC', $nbBilanC);
|
|
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('naf', $infos->NafEnt);
|
|
$this->view->assign('nafLib', $infos->NafEntLib);
|
|
$this->view->assign('AutrePage', $request->getParam('apage'));
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Affichage des graphiques d'évolutions (ratios)
|
|
*/
|
|
public function ratiosgraphAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$request = $this->getRequest();
|
|
$ratio = $request->getParam('ratio');
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->pages . '/imgcache/';
|
|
$file = 'ratiosgraph-'.$this->siret.'-'.$this->id.'-'.$ratio.'.png';
|
|
if (file_exists($path.$file)) {
|
|
echo '<img src="/fichier/imgcache/'.$file.'" />';
|
|
} else {
|
|
echo "Erreur de génération du graphique";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Export d'une liasse au format XLS
|
|
*/
|
|
public function liassexlsAction()
|
|
{
|
|
//@todo : Gestion des unités dans l'export XLS
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$unite = $request->getParam('unit', '€');
|
|
$type = $request->getParam('type', '');
|
|
$date = $request->getParam('date', '');
|
|
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
|
|
switch($type)
|
|
{
|
|
case 'C':
|
|
case 'N':
|
|
$model = 'liasse_2050';
|
|
break;
|
|
case 'S':
|
|
$model = 'liasse_2033';
|
|
break;
|
|
}
|
|
|
|
$ws = new WsScores();
|
|
$liasses = $ws->getBilan(substr($this->siret, 0, 9), $date, $type, '');
|
|
$data = array();
|
|
$data['DATE_CLOTURE'] = $liasses->DATE_CLOTURE;
|
|
$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;
|
|
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->files . '/';
|
|
$file = 'liasse-'.substr($this->siret, 0, 9).'-'.$this->id.'-'.$type.$date.'.xls';
|
|
|
|
$liasse = new Scores_Finance_Liasse_XLS($model);
|
|
$liasse->dataModel(substr($this->siret, 0, 9), $entreprise->getRaisonSociale(), $data);
|
|
$liasse->dataFile($file);
|
|
|
|
if( file_exists($path.$file) ){
|
|
$ws = new WsScores();
|
|
$ws->setLog('liassexls', $siren, 0, '');
|
|
$this->view->assign('file', $file);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Commande de la saisie de bilan
|
|
* Enregistrement des caractéristiques, obtention référence commande puis upload fichier
|
|
*/
|
|
public function saisiebilanAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$user = new Scores_Utilisateur();
|
|
$params = $request->getParams();
|
|
|
|
$this->view->assign('siren', $params['siren']);
|
|
|
|
if ($request->isPost())
|
|
{
|
|
//Validation du formulaire
|
|
$valideField = true;
|
|
if ( empty($params['siren']))
|
|
{
|
|
$valideField = false;
|
|
}
|
|
if ( empty($params['dateCloture'])
|
|
&& !preg_match('/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}/', $params['dateCloture'])
|
|
&& !checkdate(substr($params['dateCloture'],3,2),substr($params['dateCloture'],0,2),substr($params['dateCloture'],6,2)))
|
|
{
|
|
$valideField = false;
|
|
}
|
|
if ( empty($params['dureeExercice']))
|
|
{
|
|
$valideField = false;
|
|
}
|
|
if ($valideField === true)
|
|
{
|
|
$ws = new Scores_Ws_Client('order', '0.1');
|
|
$parameters = new stdClass();
|
|
$parameters->siren = $params['siren'];
|
|
$parameters->date = substr($params['dateCloture'],6,4).'-'.substr($params['dateCloture'],3,2).'-'.substr($params['dateCloture'],0,2);
|
|
$parameters->type = $params['format'];
|
|
$parameters->source = 'extranet';
|
|
$parameters->private = $params['confidentiel'];
|
|
$result = $ws->setBilanInput($parameters);
|
|
if ($result === false) {
|
|
$this->view->msg = "Erreur lors de l'enregistrement des informations";
|
|
} else {
|
|
Zend_Registry::get('firebug')->info($result);
|
|
$this->view->ref = strtoupper($result);
|
|
$this->view->fileref = $params['siren'] . '_' . $params['format'] . '_' .
|
|
substr($params['dateCloture'],6,4) . substr($params['dateCloture'],3,2) .
|
|
substr($params['dateCloture'],0,2) . '_' . strtoupper($result);
|
|
$session = new Scores_Session_Entreprise($params['siren']);
|
|
$this->view->raisonSociale = $session->getRaisonSociale();
|
|
$this->view->bilanCloture = $params['dateCloture'];
|
|
$this->view->bilanDuree = $params['dureeExercice'];
|
|
switch($params['format']){
|
|
case 'C':
|
|
$this->view->type = 'consolidé';
|
|
break;
|
|
case 'N':
|
|
$this->view->type = 'réel normal (liasse 2050)';
|
|
break;
|
|
case 'S':
|
|
$this->view->type = 'simplifié (liasse 2033)';
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
$this->view->msg = "Formulaire invalide.";
|
|
}
|
|
}
|
|
}
|
|
|
|
public function saisiebilanupAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$ref = $request->getParam('ref');
|
|
$fileref = $request->getParam('fileref');
|
|
|
|
if ($request->isPost()) {
|
|
if (count($_FILES)==1 ) {
|
|
$n = $_FILES['fichier']['name'];
|
|
$s = $_FILES['fichier']['size'];
|
|
$tmp_name = $_FILES['fichier']['tmp_name'];
|
|
//Vérifier que l'extension du fichier est bien correcte
|
|
$extValide = array('pdf', 'tiff');
|
|
$extension = strrchr($n,'.');
|
|
$extension = strtolower(substr($extension,1));
|
|
if ( in_array($extension, $extValide) ) {
|
|
$name = $fileref.'.'.$extension;
|
|
$c = Zend_Registry::get('config');
|
|
$file = realpath($c->profil->path->data).'/bilanclient/'.$name;
|
|
if ( move_uploaded_file($tmp_name, $file) ) {
|
|
$ws = new Scores_Ws_Client('order', '0.1');
|
|
$parameters = new stdClass();
|
|
$parameters->ref = $ref;
|
|
$parameters->filename = $name;
|
|
$result = $ws->setBilanInputFile($parameters);
|
|
$this->view->assign('upload', true);
|
|
$this->view->file = $name;
|
|
} else {
|
|
$this->view->assign('upload', false);
|
|
$this->view->assign('errMsg', "<br/>Erreur lors de l'envoi du fichier!");
|
|
}
|
|
} else {
|
|
$this->view->assign('upload', false);
|
|
$this->view->assign('errMsg', "Extension de fichier invalide.");
|
|
}
|
|
} else {
|
|
$this->view->assign('upload', false);
|
|
$this->view->assign('errMsg', "<br/>Erreur.");
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Liste des liasses
|
|
*/
|
|
public function liasselistAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
|
|
$this->view->headTitle()->prepend("Liasse fiscale");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
|
|
//Paramètres utilisateur
|
|
$user = new Scores_Utilisateur();
|
|
$this->view->assign('edition', $user->checkModeEdition());
|
|
if ( $user->checkPerm('UPLOADBILAN') ) {
|
|
$this->view->assign('saisiebilan', true);
|
|
}
|
|
$this->view->assign('surveillance', $user->checkPerm('survbilan'));
|
|
|
|
$ws = new WsScores();
|
|
$bilanList = $ws->getListeBilans(substr($this->siret, 0, 9));
|
|
if ($bilanList === false) $this->forward('soap', 'error');
|
|
|
|
/** La liste des types de bilan existant **/
|
|
$liste = array (
|
|
'N' => array(),
|
|
'S' => array(),
|
|
'C' => array(),
|
|
'B' => array(),
|
|
'A' => array(),
|
|
);
|
|
|
|
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
$this->view->assign('siren', substr($this->siret, 0, 9));
|
|
$this->view->assign('siret', $this->siret);
|
|
|
|
$this->view->haveLiasse = ($bilanList->nbReponses > 0) ? true : false;
|
|
|
|
if( $bilanList->nbReponses > 0 ) {
|
|
// Tri des bilans par type
|
|
foreach ( array_keys($liste) as $t) {
|
|
foreach ( $bilanList->result->item as $item ) {
|
|
if ( $t == $item->typeBilan ) {
|
|
$liste[$item->typeBilan][] = $item;
|
|
}
|
|
}
|
|
}
|
|
$this->view->BilanList = $liste;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affichage des liasses.
|
|
* @todo :
|
|
* Afficher les liasses Simplifiées
|
|
* 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
|
|
*/
|
|
public function liasseAction()
|
|
{
|
|
$this->view->headTitle()->prepend("Liasse fiscale");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
|
|
$user = new Scores_Utilisateur();
|
|
$this->view->assign('edition', $user->checkModeEdition());
|
|
//Gestion saisie bilan
|
|
if ( $user->checkPerm('UPLOADBILAN') ) {
|
|
$this->view->assign('saisiebilan', true);
|
|
}
|
|
$this->view->assign('surveillance', $user->checkPerm('survbilan'));
|
|
|
|
/** Les ancres pour les liens **/
|
|
$ancres = array(
|
|
'C' => array(
|
|
'actif' => 'Actif',
|
|
'passif' => 'Passif',
|
|
'compteDeResultat' => 'Compte de résultat',
|
|
),
|
|
'N' => array(
|
|
'actif' => 'Actif',
|
|
'passif' => 'Passif',
|
|
'compteDeResultat' => 'Compte de résultat',
|
|
'immobilisations' => 'Immobilisations',
|
|
'amortissements' => 'Amortissements',
|
|
'provisions' => 'Provisions',
|
|
'creancesDettes' => 'Créances, Dettes',
|
|
'resultatfiscal' => 'Résultat fiscal',
|
|
'deficit' => 'Déficit',
|
|
'affectation' => 'Affectation',
|
|
'annexe16' => 'Valeur ajoutée',
|
|
),
|
|
'S' => array(
|
|
'actif' => 'Actif',
|
|
'passif' => 'Passif',
|
|
'compteDeResultat' => 'Compte de résultat',
|
|
'immobilisations' => 'Immobilisations',
|
|
'amortissements' => 'Amortissements',
|
|
'provisions' => 'Provisions',
|
|
'creancesDettes' => 'Créances, Dettes',
|
|
'affectation' => 'Affectation'
|
|
),
|
|
'A' => array(
|
|
'actif' => 'Actif',
|
|
'passif' => 'Passif',
|
|
'compteDeResultat' => 'Compte de résultat',
|
|
),
|
|
'B' => array(
|
|
'actif' => 'Actif',
|
|
'passif' => 'Passif',
|
|
'compteDeResultat' => 'Compte de résultat',
|
|
),
|
|
);
|
|
|
|
/** Liste des unités que l'ont proposent **/
|
|
$unit = array (
|
|
'E' => '€',
|
|
'K' => 'K€',
|
|
'M' => 'M€',
|
|
);
|
|
$liasse = array ();
|
|
$request = $this->getRequest();
|
|
$unite = $request->getParam('unit','K');
|
|
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
$ws = new WsScores();
|
|
|
|
|
|
// Récupération de la date
|
|
$dateAndType = $request->getParam('date', $defaultTypeBilan.$defaultDateExercice);
|
|
|
|
if ( !empty($dateAndType) ) {
|
|
|
|
$type = substr($dateAndType, 0, 1);
|
|
$date = substr($dateAndType, 1);
|
|
|
|
// Récupération des postes du bilan
|
|
$infos = $ws->getBilan(substr($this->siret, 0, 9), $date, $type, true);
|
|
if ($infos === false) $this->forward('soap', 'error');
|
|
|
|
// Formatage de la liasse
|
|
$infoLiasse = new Scores_Finance_Liasse($infos, $unite);
|
|
$this->view->assign('dateCloture', $infoLiasse->getInfo('dateCloture'));
|
|
$this->view->assign('dateCloturePre', $infoLiasse->getInfo('dateCloturePre'));
|
|
|
|
$date = new Zend_Date($infoLiasse->getInfo('dateCloture'), 'yyyyMMdd');
|
|
$this->view->assign('dateClotureD', $date->toString('dd/MM/yyyy'));
|
|
|
|
$dateCloturePre = $infoLiasse->getInfo('dateCloturePre');
|
|
if ( $dateCloturePre == '' ) {
|
|
$this->view->assign('dateCloturePreD', '-');
|
|
} else {
|
|
$date = new Zend_Date($dateCloturePre, 'yyyyMMdd');
|
|
$this->view->assign('dateCloturePreD', $date->toString('dd/MM/yyyy'));
|
|
}
|
|
|
|
$this->view->assign('dureesMois', $infoLiasse->getInfo('dureeMois'));
|
|
$this->view->assign('dureesMoisPre', $infoLiasse->getInfo('dureeMoisPre'));
|
|
|
|
$this->view->assign('date', $date);
|
|
$this->view->assign('champType', $type);
|
|
$this->view->assign('liasse', $infoLiasse->getPostes());
|
|
$this->view->assign('ancres', $ancres[$type]);
|
|
|
|
//Gestion export de la liasse au format XLS
|
|
if ( $user->checkPerm('liassexls') & in_array($type,array('C', 'N', 'S')) ) {
|
|
$this->view->assign('exportxls', true);
|
|
}
|
|
|
|
}
|
|
|
|
$this->view->assign('id', $id);
|
|
$this->view->assign('unite', $unite);
|
|
$this->view->assign('unit', $unit);
|
|
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
$this->view->assign('siren', substr($this->siret, 0, 9));
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Fonction qui gére la cotation en bourse.
|
|
*/
|
|
public function bourseAction()
|
|
{
|
|
$this->view->headTitle()->prepend("Bourse & Cotations");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
|
|
require_once 'Scores/Logo.php';
|
|
|
|
$siren = substr($this->siret, 0, 9);
|
|
|
|
$urlImg = new Logo($siren);
|
|
|
|
$sessionEntreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
|
|
$ws = new WsScores();
|
|
$infos = $ws->getInfosBourse($siren);
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
|
|
$this->view->assign('InfosBourse', $infos);
|
|
|
|
$user = new Scores_Utilisateur();
|
|
if ($user->checkModeEdition()) {
|
|
$this->view->assign('edition', $this->view->url(array(
|
|
'controller'=>'saisie',
|
|
'action'=>'bourse',
|
|
'siren' => $siren
|
|
), 'default', true));
|
|
}
|
|
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('raisonSociale', $sessionEntreprise->getRaisonSociale());
|
|
$this->view->assign('siren', $siren);
|
|
$this->view->assign('exportObjet', $infos);
|
|
$this->view->assign('urlImg', $urlImg->affiche());
|
|
}
|
|
|
|
/**
|
|
* Fonction qui gére les etablissements bancaires.
|
|
*/
|
|
public function banqueAction()
|
|
{
|
|
$autrePage = $this->getRequest()->getParam('apage');
|
|
//Récupération des informations
|
|
if (empty($autrePage)) {
|
|
$this->view->headTitle()->prepend("Relations Banquaires");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
$ws = new WsScores();
|
|
$infos = $ws->getBanques(substr($this->siret, 0, 9));
|
|
if ($infos === false) $this->_forward('soap', 'error');
|
|
} else {
|
|
$infos = $this->getRequest()->getParam('infos');
|
|
}
|
|
|
|
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
$this->view->assign('banques', $infos->result->item);
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
$this->view->assign('siren', substr($this->siret, 0, 9));
|
|
$this->view->assign('exportObjet', $infos);
|
|
}
|
|
|
|
/**
|
|
* Flux de trésorerie
|
|
*/
|
|
public function fluxAction()
|
|
{
|
|
$this->view->headTitle()->prepend("Flux de trésorerie");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
|
|
$request = $this->getRequest();
|
|
$typeBilan = $request->getParam('type', 'N');
|
|
$this->view->assign('typeBilan', $typeBilan);
|
|
|
|
$this->view->assign('siret', $this->siret);
|
|
|
|
$siren = substr($this->siret, 0, 9);
|
|
|
|
$ws = new WsScores();
|
|
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
|
|
|
|
$infos = $ws->getRatios($siren, 'ratios');
|
|
|
|
//Formattage des données
|
|
$ratiosData = new Scores_Finance_Ratios_Data($infos);
|
|
$nbBilanN = $ratiosData->getNbBilan('N');
|
|
$nbBilanC = $ratiosData->getNbBilan('C');
|
|
|
|
$this->view->assign('nbBilanN', $nbBilanN);
|
|
$this->view->assign('nbBilanC', $nbBilanC);
|
|
|
|
$bilansInfos = $ratiosData->getBilansInfo($typeBilan);
|
|
foreach ($bilansInfos as $infos) {
|
|
$dateCloture[] = $infos->dateCloture;
|
|
}
|
|
$this->view->assign('bilansInfos', $bilansInfos);
|
|
|
|
$ratiosInfos = $ratiosData->getTableRatiosInfos();
|
|
$this->view->assign('ratiosInfos', $ratiosInfos);
|
|
|
|
$ratiosEntrep = $ratiosData->getTableRatiosEntrep($typeBilan);
|
|
$this->view->assign('ratiosEntrep', $ratiosEntrep);
|
|
|
|
$ratiosEntrepEvol = $ratiosData->getTableRatiosEntrepEvol($typeBilan);
|
|
$this->view->assign('ratiosEntrepEvol', $ratiosEntrepEvol);
|
|
|
|
$ratiosSecteur = $ratiosData->getTableRatiosSecteur();
|
|
$this->view->assign('ratiosSecteur', $ratiosSecteur);
|
|
|
|
//Tableau des différents type de bilans
|
|
$typBil = array('C'=>'Consolidé', 'N'=>'', 'S'=>'Réel Simplifié', 'B'=> 'Banque', 'A'=>'Assurance');
|
|
|
|
$dataTable = array(
|
|
0 => array(
|
|
'titre' => "ACTIVITE",
|
|
'r' => '', 'op' => '',
|
|
),
|
|
1 => array(
|
|
'titre' => "Chiffre d'affaires HT & autres produits d'exploitation",
|
|
'r' => 561, 'op' => '',
|
|
),
|
|
2 => array(
|
|
'titre' => "Variation des creances clients & autres creances d'exploitation",
|
|
'r' => 562, 'op' => '-',
|
|
),
|
|
3 => array(
|
|
'titre' => "Recettes d'exploitation (a)",
|
|
'r' => 563, 'op' => '=', 'class' => 'subhead'
|
|
),
|
|
4 => array(
|
|
'titre' => "Achats & autres charges d'exploitation",
|
|
'r' => 564, 'op' => '',
|
|
),
|
|
5 => array(
|
|
'titre' => "Variation des dettes fournisseurs & autres dettes d'exploitation",
|
|
'r' => 565, 'op' => '-',
|
|
),
|
|
6 => array(
|
|
'titre' => "Depenses d'exploitation (b)",
|
|
'r' => 566, 'op' => '=', 'class' => 'subhead'
|
|
),
|
|
7 => array(
|
|
'titre' => "Excedent de Tresorerie d'Exploitation (ETE) (a-b)",
|
|
'r' => 567, 'op' => '=', 'class' => 'subhead'
|
|
),
|
|
8 => array(
|
|
'titre' => "Flux lies aux operations hors exploitation",
|
|
'r' => 568,
|
|
'op' => '+',
|
|
),
|
|
9 => array(
|
|
'titre' => "Interets bancaires",
|
|
'r' => 569,
|
|
'op' => '-',
|
|
),
|
|
10 => array(
|
|
'titre' => "Impots sur les benefices",
|
|
'r' => 570,
|
|
'op' => '-',
|
|
),
|
|
11 => array(
|
|
'titre' => "Flux affectes a la participation des salaries",
|
|
'r' => 571,
|
|
'op' => '-',
|
|
),
|
|
12 => array(
|
|
'titre' => "Dividendes verses",
|
|
'r' => 572,
|
|
'op' => '-',
|
|
),
|
|
13 => array(
|
|
'titre' => "Flux de tresorerie interne (A)",
|
|
'r' => 573, 'op' => '=', 'class' => 'subhead'
|
|
),
|
|
14 => array(
|
|
'titre' => "INVESTISSEMENT",
|
|
'r' => '',
|
|
'op' => '',
|
|
),
|
|
15 => array(
|
|
'titre' => "Investissements d'exploitation hors production immobilisee",
|
|
'r' => 574,
|
|
'op' => '',
|
|
),
|
|
16 => array(
|
|
'titre' => "Acquisition de participations & autres titres immobilises",
|
|
'r' => 575,
|
|
'op' => '+',
|
|
),
|
|
17 => array(
|
|
'titre' => "Variation des autres actifs immobilises hors charges a repartir",
|
|
'r' => 576,
|
|
'op' => '+',
|
|
),
|
|
18 => array(
|
|
'titre' => "Subventions d'investissement recues",
|
|
'r' => 577,
|
|
'op' => '-',
|
|
),
|
|
19 => array(
|
|
'titre' => "Variation des dettes sur immobilisations",
|
|
'r' => 578,
|
|
'op' => '-',
|
|
),
|
|
20 => array(
|
|
'titre' => "Encaissements sur cessions d'immobilisations",
|
|
'r' => 579,
|
|
'op' => '-',
|
|
),
|
|
21 => array(
|
|
'titre' => "Flux d'investissement (I)",
|
|
'r' => 580, 'op' => '=', 'class' => 'subhead'
|
|
),
|
|
22 => array(
|
|
'titre' => "FINANCEMENT",
|
|
'r' => '',
|
|
'op' => '',
|
|
),
|
|
23 => array(
|
|
'titre' => "Augmentation-Reduction de capital",
|
|
'r' => 581,
|
|
'op' => '',
|
|
),
|
|
24 => array(
|
|
'titre' => "Variation des creances sur capital appele non verse",
|
|
'r' => 582,
|
|
'op' => '-',
|
|
),
|
|
25 => array(
|
|
'titre' => "Flux du capital (C)",
|
|
'r' => 583,
|
|
'op' => '=',
|
|
),
|
|
26 => array(
|
|
'titre' => "Variation des emprunts (D)",
|
|
'r' => 586,
|
|
'op' => '=',
|
|
),
|
|
27 => array(
|
|
'titre' => "Variation de la tresorerie du passif (E)",
|
|
'r' => 589,
|
|
'op' => '=',
|
|
),
|
|
28 => array(
|
|
'titre' => "Flux du financement (F)=(C)+(D)+(E)",
|
|
'r' => 590,
|
|
'op' => '=',
|
|
),
|
|
29 => array(
|
|
'titre' => "VARIATION DE TRESORERIE D'ACTIF",
|
|
'r' => '',
|
|
'op' => '=',
|
|
),
|
|
30 => array(
|
|
'titre' => "Variation du disponible",
|
|
'r' => 591,
|
|
'op' => '',
|
|
),
|
|
31 => array(
|
|
'titre' => "Variation des valeurs mobilieres de placement",
|
|
'r' => 592,
|
|
'op' => '',
|
|
),
|
|
32 => array(
|
|
'titre' => "Variation de la tresorerie d'actif = (A)-(I)+(F)",
|
|
'r' => 593, 'op' => '=', 'class' => 'subhead'
|
|
),
|
|
);
|
|
|
|
//Valeur pour le tableau
|
|
rsort($dateCloture);
|
|
$dateClotureTable = array();
|
|
foreach ($dateCloture as $k => $date) {
|
|
if ($k > 5) break;
|
|
$dateClotureTable[] = $date;
|
|
}
|
|
sort($dateClotureTable);
|
|
$this->view->assign('dateCloture', $dateClotureTable);
|
|
|
|
for ( $i=0 ; $i<count($dataTable) ; $i++ ) {
|
|
|
|
$values = array();
|
|
if ( !empty($dataTable[$i]['r']) ) {
|
|
foreach ($dateClotureTable as $k => $date) {
|
|
$values[$date] = $ratiosData->dRatio($typeBilan, $date, 'r'.$dataTable[$i]['r']);
|
|
}
|
|
}
|
|
|
|
$dataTable[$i]['values'] = $values;
|
|
}
|
|
$this->view->assign('dataTable',$dataTable);
|
|
|
|
//Valeur pour le graphique
|
|
$labels = array();
|
|
$data = array();
|
|
$graphRatio = array(28, 21, 13);
|
|
foreach ($graphRatio as $iRatio => $ratio) {
|
|
$data[$iRatio]['titre'] = $dataTable[$ratio]['titre'];
|
|
$data[$iRatio]['values'] = array();
|
|
foreach ($dateCloture as $k=>$date) {
|
|
$data[$iRatio]['values'][] = $ratiosEntrep[$date]['r'.$dataTable[$ratio]['r']];
|
|
}
|
|
}
|
|
sort($dateCloture);
|
|
foreach ($dateCloture as $k => $date) {
|
|
$labels[] = substr($date, 0, 4);
|
|
}
|
|
|
|
//Création du graphique
|
|
$graph = new Scores_Finance_Ratios_Graph($this->siret, $this->id);
|
|
$image = $graph->flux($labels, $data, $typeBilan);
|
|
if ( $image != false ){
|
|
$this->view->assign('graph', $image);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Subvention accordés, principalement les associations
|
|
*/
|
|
public function subventionsAction()
|
|
{
|
|
$this->view->headTitle()->prepend("Subventions");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
$sessionEntreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
$siren = substr($this->siret, 0, 9);
|
|
$this->view->assign('raisonSociale', $sessionEntreprise->getRaisonSociale());
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('siren', $siren);
|
|
|
|
$ws = new WsScores();
|
|
$infos = $ws->getSubventionList($siren);
|
|
if ($infos === false) {
|
|
$this->forward('soap', 'error');
|
|
} elseif (is_string($infos)) {
|
|
$this->view->assign('msg', $infos);
|
|
} else {
|
|
$this->view->assign('subventions', $infos->result->item);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Détail d'une subvention
|
|
*/
|
|
public function subventionAction()
|
|
{
|
|
$this->view->headTitle()->prepend("Subvention");
|
|
$this->view->headTitle()->prepend("Siret ".$this->siret);
|
|
|
|
$sessionEntreprise = new Scores_Session_Entreprise($this->siret, $this->id);
|
|
$siren = substr($this->siret, 0, 9);
|
|
$this->view->assign('raisonSociale', $sessionEntreprise->getRaisonSociale());
|
|
$this->view->assign('id', $this->id);
|
|
$this->view->assign('siret', $this->siret);
|
|
$this->view->assign('siren', $siren);
|
|
|
|
$request = $this->getRequest();
|
|
$id = $request->getParam('subventionId');
|
|
|
|
$ws = new WsScores();
|
|
$infos = $ws->getSubventionDetail($id);
|
|
if ($infos === false) {
|
|
$this->forward('soap', 'error');
|
|
} elseif (is_string($infos)) {
|
|
$this->view->assign('msg', $infos);
|
|
} else {
|
|
|
|
$p = $request->getParam('p', 1);
|
|
$this->view->assign('p', $p);
|
|
|
|
$nbMax = 100;
|
|
$nbReponses = $infos->nbReponses;
|
|
$nbPages = ceil($nbReponses/$nbMax);
|
|
|
|
if ( $p <= 1 ) {
|
|
$lienPagePrecedente = false;
|
|
} else {
|
|
$lienPagePrecedente = $this->view->url(array(
|
|
'controller' => 'finance',
|
|
'action' => 'subventions',
|
|
'p' => $p-1
|
|
));
|
|
}
|
|
|
|
if ( $p+1 > $nbPages ) {
|
|
$lienPageSuivante = false;
|
|
} else {
|
|
$lienPageSuivante = $this->view->url(array(
|
|
'controller' => 'finance',
|
|
'action' => 'subventions',
|
|
'p' => $p+1
|
|
));
|
|
}
|
|
|
|
$this->view->assign('nbPages',$nbPages);
|
|
$this->view->assign('lienPagePrecedente',$lienPagePrecedente);
|
|
$this->view->assign('lienPageSuivante',$lienPageSuivante);
|
|
|
|
$this->view->assign('Millesime',$infos->Millesime);
|
|
$this->view->assign('Budget',$infos->Budget);
|
|
$this->view->assign('AssoSiren',$infos->AssoSiren);
|
|
$this->view->assign('AssoNom',$infos->AssoNom);
|
|
$this->view->assign('OrigineSiren',$infos->OrigineSiren);
|
|
$this->view->assign('OrigineLib',$infos->OrigineLib);
|
|
$this->view->assign('Programme',$infos->Programme);
|
|
$this->view->assign('Montant',$infos->Montant);
|
|
$this->view->assign('SubventionObjet',$infos->SubventionObjet);
|
|
$this->view->assign('Mission',$infos->Mission);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affichage en ajax des informations dernière date de cloture du bilan et etat de saisie
|
|
*/
|
|
public function liasseinfosAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
$request = $this->getRequest();
|
|
$siren = $request->getParam('siren');
|
|
|
|
$ws = new WsScores();
|
|
$response = $ws->getEntrepriseLiasseInfos($siren);
|
|
|
|
if ( $response === null ) {
|
|
$this->view->assign('msg','Aucun bilan déposé.');
|
|
} else {
|
|
$date = new Zend_Date($response->BilanDateCloture, 'yyyy-MM-dd');
|
|
$this->view->assign('BilanDateCloture', $date->toString('dd/MM/yyyy'));
|
|
$this->view->assign('BilanDateClotureIso', $response->BilanDateCloture);
|
|
$this->view->assign('BilanType', $response->BilanType);
|
|
$this->view->assign('SaisieCode', $response->SaisieCode);
|
|
$this->view->assign('SaisieLabel', $response->SaisieLabel);
|
|
if ( $response->SaisieDate!='' || $response->SaisieDate!='0000-00-00' ) {
|
|
$this->view->assign('SaisieDateIso', $response->SaisieDate);
|
|
$date = new Zend_Date($response->SaisieDate, 'yyyy-MM-dd');
|
|
$this->view->assign('SaisieDate', $date->toString('dd/MM/yyyy'));
|
|
}
|
|
}
|
|
}
|
|
|
|
} |