extranet/application/controllers/IdentiteController.php

446 lines
13 KiB
PHP
Raw Normal View History

2011-02-21 08:45:13 +00:00
<?php
class IdentiteController extends Zend_Controller_Action
{
2011-04-19 06:57:16 +00:00
protected $siret = null;
protected $id = 0;
2011-04-11 14:19:14 +00:00
public function init()
{
2011-04-19 06:57:16 +00:00
$request = $this->getRequest();
$this->siret = $request->getParam('siret');
$this->id = $request->getParam('id', 0);
2011-04-20 09:33:02 +00:00
require_once 'Scores/WsScores.php';
2011-04-21 13:31:59 +00:00
require_once 'Scores/Utilisateur.php';
2011-04-20 09:33:02 +00:00
require_once 'Scores/SessionEntreprise.php';
2011-04-21 13:31:59 +00:00
require_once 'Scores/IdentiteEntreprise.php';
require_once 'common/dates.php';
require_once 'Graphique/Graphique.lib.php';
2011-04-21 13:31:59 +00:00
$this->view->headLink()->appendStylesheet('/themes/default/styles/identite.css', 'all');
2011-04-11 14:19:14 +00:00
}
2011-02-21 08:45:13 +00:00
2011-04-11 14:19:14 +00:00
public function indexAction()
{
$this->_forward('fiche', 'identite');
2011-04-11 14:19:14 +00:00
}
public function ficheAction()
{
$this->view->headScript()->appendFile('/themes/default/scripts/identite.js', 'text/javascript');
$session = new Zend_Session_Namespace('Historique');
2011-04-14 13:12:29 +00:00
//Modification du titre
2011-04-19 06:57:16 +00:00
if(empty($this->siret)){
$titre = 'Identifiant '.$this->id;
2011-04-14 13:12:29 +00:00
} else {
2011-04-19 06:57:16 +00:00
$titre = 'Siret '.$this->siret;
2011-04-14 13:12:29 +00:00
}
$this->view->headTitle()->append('Identité - '.$titre);
2011-04-20 09:33:02 +00:00
2011-04-21 13:31:59 +00:00
$user = new Utilisateur();
2011-04-14 13:12:29 +00:00
//Récupération des informations
$ws = new WsScores();
2011-04-19 06:57:16 +00:00
$infos = $ws->getIdentite($this->siret, $this->id);
2011-04-20 09:33:02 +00:00
//Mise en session
$session = new SessionEntreprise($this->siret, $this->id, true);
$session->setInfoEntrep($infos);
2011-04-21 13:31:59 +00:00
//Date de dernière mise à jour
$tabDate = array(
'DateMajINSEE' => "Insee&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ",
'DateMajRCS' => "RCS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ",
'DateMajBILAN' => "Bilans&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ",
'DateMajANN' => "Annonces : ",
);
$datemajTexte = '';
foreach ( $tabDate as $dateId => $dateLib ) {
if (isset($infos->{$dateId}) && !empty($infos->{$dateId}) && $infos->{$dateId}!='0000-00-00') {
Zend_Registry::get('firebug')->info($dateId);
$datemajTexte.= $dateLib;
$datemajTexte.= WDate::dateT('Y-m-d', 'd/m/Y', $infos->{$dateId});
$datemajTexte.= '<br/>';
}
}
$dateDerMaj = '';
if (isset($infos->DateMajID) && !empty($infos->DateMajID) && $infos->DateMajID!='0000-00-00' ){
if ( $user->checkModeEdition() ){
$datemajTexte.= "Scores & Décisions : ";
$datemajTexte.= WDate::dateT('Y-m-d', 'd/m/Y', $infos->DateMajID);
$datemajTexte.= '<br/>';
}
$dateDerMaj = ' le '.WDate::dateT('Y-m-d', 'd/m/Y', $infos->DateMajID);
}
$identite = new IdentiteEntreprise($infos, $this->view);
2011-04-21 13:31:59 +00:00
//Définition des blocks
$blocks = array(
'Siret',
'SiretSiege',
'TvaNumero',
'Isin',
'Capitalisation',
'NumRC',
'AutreId',
'Actif',
'SituationJuridique',
'AutreSiren',
'RaisonSociale',
'EnseigneSigle',
'FormeJuridique',
'DateImmat',
'DateCreaEn',
'DateCreaEt',
'Adresse',
'Zones',
'Tel',
'Fax',
'Web',
'Mail',
'ActiviteEt',
'ActiviteEn',
'Naf4',
'Nace',
'NatureActivite',
'OrigineFond',
'TypeExploitation',
'Saisonnalite',
'NbEtabActif',
'Capital',
'ChiffreAffaire',
'Dirigeants',
'Effectif',
'EffectifEtab'
);
2011-04-22 15:10:03 +00:00
2011-04-21 13:31:59 +00:00
$dBlock = array();
foreach ($blocks as $item) {
$display = array(
'label' => method_exists($identite, 'get'.$item.'Label') ? $identite->{'get'.$item.'Label'}() : '',
'texte' => method_exists($identite, 'get'.$item.'Texte') ? $identite->{'get'.$item.'Texte'}() : '',
'titre' => method_exists($identite, 'get'.$item.'Titre') ? $identite->{'get'.$item.'Titre'}() : '',
);
$dBlock[$item] = $display;
}
require_once 'Scores/Logo.php';
$logo = new Logo($infos->Siren, $infos->Isin);
$logoImg = array(
'label' => 'Logo',
'texte' => $logo->affiche(),
);
2011-04-21 13:31:59 +00:00
Zend_Registry::get('firebug')->info($infos);
2011-05-24 06:25:58 +00:00
$this->view->assign('exportObjet', $infos);
2011-04-21 13:31:59 +00:00
$this->view->assign('dBlock', $dBlock);
$this->view->assign('logo', $logoImg);
2011-04-21 13:31:59 +00:00
$this->view->assign('dateDerMaj', $dateDerMaj);
$this->view->assign('datemajTexte', $datemajTexte);
2011-04-20 09:33:02 +00:00
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('infos', $infos);
$this->view->assign('siret', $infos->Siret);
$this->view->assign('AutrePage', $this->getRequest()->getParam('page'));
2011-04-11 14:19:14 +00:00
}
2011-04-19 07:37:39 +00:00
public function fichepcAction()
{
2011-06-14 07:36:07 +00:00
$siren = substr($this->siret,0,9);
//Modification du titre
if(empty($this->siret)){
$titre = 'Identifiant '.$this->id;
} else {
$titre = 'Siret '.$this->siret;
}
$this->view->headTitle()->append('Fiche procédure collective - '.$titre);
//Récupération des informations
$ws = new WsScores();
$infos = $ws->getIdentiteProcol($this->siret, $this->id);
//Mise en session
$session = new SessionEntreprise($this->siret, $this->id, true);
$session->setInfoEntrep($infos);
//Element Fiche identite
$identite = new IdentiteEntreprise($infos->Identite, $this->view);
//Définition des blocks
$blocks = array(
'Siret',
'SiretSiege',
'TvaNumero',
'Isin',
'Capitalisation',
'NumRC',
'AutreId',
'Actif',
'SituationJuridique',
'AutreSiren',
'RaisonSociale',
'EnseigneSigle',
'FormeJuridique',
'DateImmat',
'DateCreaEn',
'DateCreaEt',
'Adresse',
'Zones',
'Tel',
'Fax',
'Web',
'Mail',
'ActiviteEt',
'ActiviteEn',
'Naf4',
'Nace',
'NatureActivite',
'OrigineFond',
'TypeExploitation',
'Saisonnalite',
'NbEtabActif',
'Capital',
'ChiffreAffaire',
'Dirigeants',
'Effectif',
'EffectifEtab'
);
$dBlock = array();
foreach ($blocks as $item) {
$display = array(
'label' => method_exists($identite, 'get'.$item.'Label') ? $identite->{'get'.$item.'Label'}() : '',
'texte' => method_exists($identite, 'get'.$item.'Texte') ? $identite->{'get'.$item.'Texte'}() : '',
'titre' => method_exists($identite, 'get'.$item.'Titre') ? $identite->{'get'.$item.'Titre'}() : '',
);
$dBlock[$item] = $display;
}
require_once 'Scores/Logo.php';
$logo = new Logo($infos->Siren, $infos->Isin);
$logoImg = array(
'label' => 'Logo',
'texte' => $logo->affiche(),
);
$Identite = new stdClass();
$Identite->siret = $this->siret;
$Identite->dBlock = $dBlock;
$Identite->logo = $logo;
$Identite->AutrePage = 'fichepc';
$this->view->assign('Identite', $Identite);
//Element Fiche procédure collective
require_once 'Scores/IdentiteProcol.php';
$procol = new IdentiteProcol($infos);
$blocks = array(
'CessionOffreDate',
'CessionInvenDate',
'CessionDesc',
2011-06-14 07:46:58 +00:00
);
2011-06-14 07:36:07 +00:00
$dBlock = array();
foreach ($blocks as $item) {
$display = array(
'label' => method_exists($procol, 'get'.$item.'Label') ? $procol->{'get'.$item.'Label'}() : '',
'texte' => method_exists($procol, 'get'.$item.'Texte') ? $procol->{'get'.$item.'Texte'}() : '',
'titre' => method_exists($procol, 'get'.$item.'Titre') ? $procol->{'get'.$item.'Titre'}() : '',
);
$dBlock[$item] = $display;
}
$this->view->assign('dBlock', $dBlock);
$this->view->assign('infosProcol', $procol);
$this->view->assign('exportObjet', $infos);
$this->view->assign('infos', $infos);
$this->view->assign('siret', $infos->Siret);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('fj', $session->getFormeJuridique());
2011-04-19 07:37:39 +00:00
}
2011-04-11 14:19:14 +00:00
public function etablissementsAction()
{
2011-04-19 06:57:16 +00:00
$siren = substr($this->siret,0,9);
2011-04-22 13:30:35 +00:00
$actif = $this->getRequest()->getParam('actif', -1);
$this->view->headTitle()->append('Liste des établissements - Siren '.$siren);
2011-04-20 09:33:02 +00:00
$session = new SessionEntreprise($this->siret, $this->id);
$user = new Utilisateur();
2011-04-20 09:33:02 +00:00
$ws = new WsScores();
2011-04-22 13:30:35 +00:00
$infos = $ws->getListeEtablissements($siren, $actif);
2011-04-20 09:33:02 +00:00
2011-04-22 13:30:35 +00:00
$etabs = $infos->result->item;
2011-05-04 15:51:47 +00:00
2011-04-22 13:30:35 +00:00
$this->view->assign('siren', $siren);
$this->view->assign('siret', $this->siret);
2011-04-20 09:33:02 +00:00
$this->view->assign('raisonSociale', $session->getRaisonSociale());
2011-04-22 13:30:35 +00:00
$this->view->assign('etabs', $etabs);
2011-05-25 09:17:30 +00:00
$this->view->assign('exportObjet', $etabs);
// Permet de verifier si la personne a la preference d'affichage des cartes.
2011-05-25 09:17:30 +00:00
$this->view->assign('hasPrefCarte', true);
$this->view->assign('listeEtablissement', $infos);
}
2011-04-11 14:19:14 +00:00
public function liensAction()
{
2011-04-19 06:57:16 +00:00
$siren = substr($this->siret,0,9);
$this->view->headTitle()->append('Liens inter-entreprises - Siren '.$siren);
2011-04-22 14:29:58 +00:00
$session = new SessionEntreprise($this->siret, $this->id);
$this->view->assign('siren', $siren);
$this->view->assign('siret', $this->siret);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
if ( ($session->getFormeJuridique()>=1000 && $session->getFormeJuridique()<=1999)
|| ($session->getFormeJuridique()>=10 && $session->getFormeJuridique()<=19) ) {
$this->renderScript('identite/liens-personne-physique.phtml');
}
require_once 'Scores/WsScores.php';
2011-04-22 14:29:58 +00:00
$ws = new WsScores();
$infos = $ws->getLiens($siren);
2011-04-22 14:29:58 +00:00
$actionnaires = $infos->actionnaires->item;
$participations = $infos->participations->item;
//Informations de MAJ
if(count($actionnaires)>0){
$nb = count($actionnaires)-1;
$source = $actionnaires[$nb]->Source;
$dateMaj = $actionnaires[$nb]->DateMaj;
} else if (count($participations)>0){
$nb = count($participations)-1;
$source = $participations[$nb]->Source;
$dateMaj = $participations[$nb]->DateMaj;
} else {
$source = '';
$dateLien = '';
$dateMaj = '';
}
self::GraphiqueParticipation($participations, $siren);
2011-04-22 14:29:58 +00:00
2011-05-25 09:17:30 +00:00
$this->view->assign('exportObjet', $infos);
2011-04-22 14:29:58 +00:00
$this->view->assign('source', $source);
$this->view->assign('dateLien', $dateLien);
$this->view->assign('dateMaj', $dateMaj);
$this->view->assign('actionnaires', $actionnaires);
2011-05-25 08:51:16 +00:00
$this->view->assign('participations', $participations);
$this->view->assign('AutrePage', $this->getRequest()->getParam('page'));
}
public function graphiqueAction()
{
$request = $this->getRequest();
$this->view->assign('name', $request->getParam('name'));
}
private function GraphiqueParticipation($participation, $siret)
{
if(empty($participation))
return;
$parametres = new stdClass();
$graphique = new Graphique(APPLICATION_PATH . '/../cache/pages/imgcache/');
$i = 0;
foreach ($participation as $item) {
if($i <= 10) {
$parametres->datas[] = $item->Pmin;
$parametres->labels[] = $item->RaisonSociale;
$i++;
}else
break;
}
$parametres->title = array('Radar sur 10 Participations', "", 12, TextColor);
$parametres->nom = 'rsynthese-'.$siret.'-radar.png';
$parametres->width = 640;
$parametres->height = 450;
$parametres->setPlotArea = array(320, 210, 150);
$parametres->labelStyle = array("normal", 9, TextColor, 0);
$parametres->dataColor = 0x9999ff;
$graphique->GraphiqueRadar($parametres);
}
2011-04-11 14:19:14 +00:00
2011-04-22 15:10:03 +00:00
public function evenementsAction()
{
2011-04-19 06:57:16 +00:00
$siren = substr($this->siret,0,9);
$this->view->headTitle()->append('Evènements - Siren '.$siren);
2011-04-22 15:10:03 +00:00
$session = new SessionEntreprise($this->siret, $this->id);
require_once 'Scores/WsScores.php';
2011-04-22 15:10:03 +00:00
$ws = new WsScores();
$infos = $ws->getListeEvenements($siren);
2011-04-22 15:10:03 +00:00
$evens = $infos->result->item;
$this->view->assign('siren', $siren);
$this->view->assign('siret', $this->siret);
$this->view->assign('id', $this->id);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('evens', $evens);
2011-05-25 09:17:30 +00:00
$this->view->assign('exportObjet', $evens);
}
2011-02-21 08:45:13 +00:00
2011-05-17 09:39:51 +00:00
public function newsAction()
{
$nbNews = 15;
$session = new SessionEntreprise($this->siret, $this->id);
2011-05-17 09:39:51 +00:00
$url = 'http://news.google.fr/news?hl=fr&ned=fr&q='.
urlencode('"'.$session->getRaisonSociale().'"').'&output=rss';
2011-05-19 15:19:14 +00:00
define('MAGPIE_CACHE_ON', false);
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
define('MAGPIE_INPUT_ENCODING', 'UTF-8');
define('MAGPIE_DETECT_ENCODING', false);
require_once ('Vendors/magpierss/rss_fetch.inc');
2011-05-17 09:39:51 +00:00
$rss = fetch_rss($url);
$items = array_slice($rss->items, 0, 15);
2011-05-17 09:39:51 +00:00
$this->view->assign('items', $items);
}
2011-05-19 07:11:56 +00:00
public function avisAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
// ==> Start
require_once 'Scores/AvisSituation.php';
$avis = new AvisSituation($this->siret);
if (!$avis->erreur()){
$avis->erreurcpt('raz');
$body = $avis->get('pdf', 1);
if($body !== false) {
header("Pragma: public");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate");
header("Content-type: application/pdf");
header("Content-Length: ".strlen($body));
header('Content-disposition: inline; filename="avis-'.$this->siret.'.pdf"');
header("Accept-Ranges: ".strlen($body));
echo $body;
$ws = new WsScores();
$ws->setLog('avis_situation', $this->siret, 0, '');
} else {
$avis->erreurcpt('plus');
echo $avis->erreurmsg();
}
} else {
if ($avis->nberreur()==5){
$avis->mailerreur();
}
$avis->erreurcpt('plus');
echo $avis->erreurmsg();
}
}
2011-02-21 08:45:13 +00:00
}