getInfoEntrep($siret, $id); return; } if (!$this->checkSession($siret, $id) ){ $this->getInfoEntrep($siret, $id); return; } } } public function getId() { return $this->get('id'); } public function getSiren() { return $this->get('siren'); } public function getSiret() { return $this->get('siret'); } public function getRaisonSociale() { return $this->get('raisonSociale'); } public function setInfoEntrep($identite) { $this->setSession($identite); } public function getFormeJuridique() { return $this->get('fj'); } public function getNaf() { return $this->get('nafEn'); } public function getCodeCommune() { return $this->get('codeCommune'); } public function getTva() { return $this->get('tva'); } public function getSource() { return $this->get('Source'); } public function getSourceId() { return $this->get('SourceId'); } protected function get($key) { $session = new Zend_Session_Namespace($this->index); return $session->$key; } protected function getInfoEntrep($siret, $id = 0) { Zend_Registry::get('firebug')->info('getInfoEntrep'); require_once 'Scores/WsScores.php'; $ws = new WsScores(); $etab = $ws->getIdentite($siret, $id); $this->setSession($etab); } protected function setSession($etab) { $session = new Zend_Session_Namespace($this->index); $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; if (!Zend_Session::namespaceIsset($this->index)) { return false; } $session = new Zend_Session_Namespace($this->index); $compare = false; // Comparaison Siren / Siret if ( !empty($siret) && intval($siret) != 0) { if (strlen($siret) == 9) { // Comparaison entre siren if ($siret == $session->siren) { $compare = true; } } else if (strlen($siret) == 14) { // Comparaison entre siret if ($siret == $session->siret) { $compare = true; } } } // Comparaison id if ( empty($siret) && intval($siret) == 0) { if ($id != 0 && $id == $session->id) { $compare = true; } } return $compare; } }