2011-04-20 09:18:04 +00:00
|
|
|
<?php
|
|
|
|
class SessionEntreprise
|
|
|
|
{
|
|
|
|
protected $index = 'entrep';
|
|
|
|
|
2012-04-13 15:43:42 +00:00
|
|
|
/**
|
|
|
|
* @param string $siret
|
|
|
|
* @param int $id
|
|
|
|
* @param boolean $set
|
|
|
|
*/
|
2011-04-20 09:18:04 +00:00
|
|
|
public function __construct($siret, $id = 0, $set = false)
|
|
|
|
{
|
2012-08-16 11:47:02 +00:00
|
|
|
if ( !empty($siret) && !$set ) {
|
|
|
|
if (!$this->checkSession($siret, $id) ){
|
|
|
|
$this->getInfoEntrep($siret, $id);
|
|
|
|
}
|
2011-04-20 09:18:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getId()
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
return $this->get('id');
|
2011-04-20 09:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSiren()
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
return $this->get('siren');
|
2011-04-20 09:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSiret()
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
return $this->get('siret');
|
2011-04-20 09:18:04 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 11:29:03 +00:00
|
|
|
public function getAutreId()
|
|
|
|
{
|
|
|
|
return $this->get('AutreId');
|
|
|
|
}
|
|
|
|
|
2011-08-29 14:22:39 +00:00
|
|
|
public function getSiretSiege()
|
|
|
|
{
|
|
|
|
return $this->get('siretSiege');
|
|
|
|
}
|
|
|
|
|
2011-04-20 09:18:04 +00:00
|
|
|
public function getRaisonSociale()
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
return $this->get('raisonSociale');
|
2011-04-20 09:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setInfoEntrep($identite)
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
$this->setSession($identite);
|
2011-04-20 09:18:04 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 14:29:58 +00:00
|
|
|
public function getFormeJuridique()
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
return $this->get('fj');
|
2011-04-22 14:29:58 +00:00
|
|
|
}
|
|
|
|
|
2011-04-29 10:28:32 +00:00
|
|
|
public function getNaf()
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
return $this->get('nafEn');
|
2011-04-29 10:28:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-02 06:52:12 +00:00
|
|
|
public function getCodeCommune()
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
return $this->get('codeCommune');
|
|
|
|
}
|
|
|
|
|
2011-06-03 08:53:22 +00:00
|
|
|
public function getTva()
|
|
|
|
{
|
2011-06-15 13:26:11 +00:00
|
|
|
return $this->get('tva');
|
|
|
|
}
|
|
|
|
|
2012-11-03 09:22:32 +00:00
|
|
|
public function getIsin()
|
|
|
|
{
|
|
|
|
return $this->get('isin');
|
|
|
|
}
|
|
|
|
|
2011-06-15 13:26:11 +00:00
|
|
|
public function getSource()
|
|
|
|
{
|
|
|
|
return $this->get('Source');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSourceId()
|
|
|
|
{
|
|
|
|
return $this->get('SourceId');
|
2011-06-03 08:53:22 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 14:24:24 +00:00
|
|
|
protected function get($key)
|
|
|
|
{
|
2011-05-17 15:05:31 +00:00
|
|
|
$session = new Zend_Session_Namespace($this->index);
|
|
|
|
return $session->$key;
|
2011-05-02 06:52:12 +00:00
|
|
|
}
|
|
|
|
|
2011-04-20 09:18:04 +00:00
|
|
|
protected function getInfoEntrep($siret, $id = 0)
|
|
|
|
{
|
2011-05-17 15:05:31 +00:00
|
|
|
Zend_Registry::get('firebug')->info('getInfoEntrep');
|
2011-04-20 09:18:04 +00:00
|
|
|
require_once 'Scores/WsScores.php';
|
|
|
|
$ws = new WsScores();
|
2012-02-08 19:50:45 +00:00
|
|
|
$etab = $ws->getIdentiteLight($siret, $id);
|
2011-05-17 14:24:24 +00:00
|
|
|
$this->setSession($etab);
|
2011-04-20 09:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function setSession($etab)
|
|
|
|
{
|
2011-05-17 14:24:24 +00:00
|
|
|
$session = new Zend_Session_Namespace($this->index);
|
2011-04-20 09:18:04 +00:00
|
|
|
$session->raisonSociale = $etab->Nom;
|
|
|
|
$session->id = $etab->id;
|
|
|
|
$session->siren = $etab->Siren;
|
|
|
|
$session->siret = $etab->Siret;
|
|
|
|
$session->siretSiege = $etab->SiretSiege;
|
|
|
|
$session->tva = $etab->TvaNumero;
|
|
|
|
$session->isin = $etab->Isin;
|
|
|
|
$session->AutreId = $etab->AutreId;
|
|
|
|
$session->active = $etab->Statut;
|
|
|
|
$session->Source = $etab->Source;
|
|
|
|
$session->SourceId = $etab->SourceId;
|
|
|
|
$session->codeCommune = $etab->Dept.$etab->codeCommune;
|
|
|
|
$session->nafEn = $etab->NafEnt;
|
|
|
|
$session->nafEnt = $etab->NafEtab;
|
|
|
|
$session->fj = $etab->FJ;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function checkSession($siret, $id = 0)
|
|
|
|
{
|
|
|
|
$compare = false;
|
2011-05-17 14:24:24 +00:00
|
|
|
|
|
|
|
if (!Zend_Session::namespaceIsset($this->index)) {
|
2011-04-20 09:18:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-17 15:05:31 +00:00
|
|
|
$session = new Zend_Session_Namespace($this->index);
|
2011-04-20 09:18:04 +00:00
|
|
|
|
|
|
|
$compare = false;
|
|
|
|
// Comparaison Siren / Siret
|
|
|
|
if ( !empty($siret) && intval($siret) != 0) {
|
|
|
|
if (strlen($siret) == 9) {
|
|
|
|
// Comparaison entre siren
|
2011-05-17 15:05:31 +00:00
|
|
|
if ($siret == $session->siren) {
|
2011-04-20 09:18:04 +00:00
|
|
|
$compare = true;
|
|
|
|
}
|
|
|
|
} else if (strlen($siret) == 14) {
|
|
|
|
// Comparaison entre siret
|
2011-05-17 15:05:31 +00:00
|
|
|
if ($siret == $session->siret) {
|
2011-04-20 09:18:04 +00:00
|
|
|
$compare = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Comparaison id
|
2011-08-24 12:33:36 +00:00
|
|
|
if ( empty($siret) || intval($siret) == 0) {
|
2011-05-17 15:05:31 +00:00
|
|
|
if ($id != 0 && $id == $session->id) {
|
2011-04-20 09:18:04 +00:00
|
|
|
$compare = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $compare;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|