dbConfig = $dbConfig->db; $this->iDbCrm = new WDB('sdv1'); } /** * checkAuth * @param string $login * @param string $password * @param string $ipConnexion */ protected function checkAuth($login, $password, $ipConnexion) { $rep = $this->iDbCrm->select(//'utilisateurs', 'login, id, email, password, idClient, typeCompte, filtre_ip, civilite, nom, prenom, tel, fax, mobile, profil, raisonSociale, siret, adrNum, adrIndRep, adrTypeVoie, adrLibVoie, adrCp, adrVille, adrComp, tel, fax, mobile, pref, profil, dateInscription, dateValidation, nombreConnexions, dateDerniereConnexion, droits, referenceParDefaut, nbReponses, formatMail, dateDebutCompte, dateFinCompte, maxFicheId', "login='$login' AND actif=1", true, MYSQL_ASSOC); 'utilisateurs u, clients c', 'u.login, u.id, u.email, u.password, u.idClient, u.typeCompte, u.actif, u.filtre_ip, u.civilite, u.nom, u.prenom, u.tel, u.fax, u.mobile, u.profil, u.raisonSociale, u.siret, u.adrNum, u.adrIndRep, u.adrTypeVoie, u.adrLibVoie, u.adrCp, u.adrVille, u.adrComp, u.tel, u.fax, u.mobile, u.pref, u.profil, u.dateInscription, u.dateValidation, u.nombreConnexions, u.dateDerniereConnexion, u.droits, u.referenceParDefaut, u.nbReponses, u.formatMail, u.dateDebutCompte, u.dateFinCompte, u.maxFicheId, c.droits AS droitsClients, c.timeout', "u.login='$login' AND u.idClient=c.id AND u.actif=1 AND u.deleted=0 AND c.actif='Oui'", true, MYSQL_ASSOC); $tabRep = $rep[0]; if (count($rep)>0) { if ($tabRep['password']==$password || $tabRep['password']==md5($password) || $password==md5($login.'|'.$tabRep['password']) || (substr($password,0,7)=='iponly:' && checkPlagesIp($tabRep['filtre_ip'], substr($password,7)))) // Controle par IP { $timeOutSec=$tabRep['timeout']*60; if ($timeOutSec==0) $timeOutSec=1800; $this->tabInfoUser=array( 'login'=> $login, 'id'=> $tabRep['id'], 'email'=> $tabRep['email'], 'typeCompte'=> $tabRep['typeCompte'], 'idClient'=> $tabRep['idClient'], 'filtre_ip'=> $tabRep['filtre_ip'], 'ipPasserelle'=> '', 'ipConnexion'=> $ipConnexion, 'civilite'=> $tabRep['civilite'], 'nom'=> $tabRep['nom'], 'prenom'=> $tabRep['prenom'], 'raisonSociale'=> $tabRep['raisonSociale'], 'siret'=> $tabRep['siret'], 'adrNum'=> $tabRep['adrNum'], 'adrIndRep'=> $tabRep['adrIndRep'], 'adrTypeVoie'=> $tabRep['adrTypeVoie'], 'adrLibVoie'=> $tabRep['adrLibVoie'], 'adrCp'=> $tabRep['adrCp'], 'adrVille'=> $tabRep['adrVille'], 'adrComp'=> $tabRep['adrComp'], 'tel'=> $tabRep['tel'], 'fax'=> $tabRep['fax'], 'mobile'=> $tabRep['mobile'], 'pref'=> $tabRep['pref'], 'profil'=> $tabRep['profil'], 'dateInscription'=> $tabRep['dateInscription'], 'dateValidation'=> $tabRep['dateValidation'], 'nombreConnexions'=> $tabRep['nombreConnexions'], 'dateDerniereConnexion'=> $tabRep['dateDerniereConnexion'], 'droits'=> $tabRep['droits'], 'droitsClients'=> $tabRep['droitsClients'], 'timeout'=> $timeOutSec, 'nbReponses'=> $tabRep['nbReponses'], 'formatMail'=> $tabRep['formatMail'], 'referenceParDefaut'=> $tabRep['referenceParDefaut'], 'dateDebutCompte'=> $tabRep['dateDebutCompte'], 'dateFinCompte'=> $tabRep['dateFinCompte'], 'maxFicheId'=> $tabRep['maxFicheId'], ); $tabTmp = $this->iDbCrm->select('clients', 'typeScore', 'id='.$tabRep['idClient'], true, MYSQL_ASSOC); $tabRep = $tabTmp[0]; $this->tabInfoUser['typeScore'] = $tabRep['typeScore']; debugLog('W',"CheckAuth $login/$password OK", __LINE__,__FILE__, __FUNCTION__, __CLASS__); return true; } debugLog('W',"CheckAuth $login/$password incorrect (IP=$ipConnexion)", __LINE__,__FILE__, __FUNCTION__, __CLASS__); return false; } debugLog('W',"CheckAuth $login/$password inexistant ou inactif (IP=$ipConnexion)", __LINE__,__FILE__, __FUNCTION__, __CLASS__); return false; } /** * Enregistrement des informations saisie manuellement * @param string $siret * @param int $idEntreprise * @param array $tabInfos */ public function setInfosEntrep( $siret, $idEntreprise, $tabInfos ) { } /** * Commande de bilan * @param InfoCommandeBilan $infoCommande * @param InfoDemandeur $infoDemandeur * @return CmdBilanReturn */ public function setCmdBilan( InfoCommandeBilan $infoCommande, InfoDemandeur $infoDemandeur ) { } /** * Renvoi des informations sur une commande de bilan * @param string $reference * @return CmdBilanReturn */ public function getCmdBilan( $reference ) { } /** * Commande d'acte * @param InfoCommandeActe $infoCommande * @param InfoDemandeur $infoDemandeur * @return CmdActeReturn */ public function setCmdActe( $infoCommande, $infoDemandeur ) { } /** * Renvoi des informations sur une commande d'acte * @param string $reference * @return CmdActeReturn */ public function getCmdActe( $reference ){} /** * Commande de kbis * @param InfoCommandeKbis $infoCommande * @param InfoDemandeur $infoDemandeur * @return CmdKbisReturn */ public function setCmdKbis(InfoCommandeKbis $infoCommande, InfoDemandeur $infoDemandeur ) { $error = new ErrorType(); $ref = new RefCommande(); //Vérifier les informations switch($infoCommande->mode) { case 'courrier': break; case 'mail': break; default: exit; break; } if (empty($infoCommande->siren)) { $error->errnum = 0; $error->errmsg = 'Erreur SIREN invalide'; } else { $login = $_SERVER['PHP_AUTH_USER']; // Insertion des données commande $dataCommandes = array( 'user_login' => $login, 'user_email' => '', 'type' => 'kbis', 'demandeurReference' => $infoDemandeur->reference, 'demandeurEmail' => $infoDemandeur->email, 'demandeurTel' => $infoDemandeur->tel, 'demandeurNom' => $infoDemandeur->nom, 'demandeurService' => $infoDemandeur->service, 'demandeurSociete' => $infoDemandeur->societe, 'demandeurAdresse' => $infoDemandeur->adresse, 'demandeurCp' => $infoDemandeur->cp, 'demandeurVille' => $infoDemandeur->ville, 'infoCommande' => serialize($infoCommande) ); try { $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); $commande = new Application_Model_Commandes(); $commande_id = $commande->insert($dataCommandes); } catch (Zend_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); } if ($commande_id) { //Enregistrement des détails de commande $dataCommandesKbis = array( 'commande_id' => $commande_id, 'siren' => $infoCommande->siren, 'raisonSociale' => '', 'fichier' => '', 'partenaireRequete' => '', 'partenaireReponse' => '', ); try { $commandeKbisTable = new Application_Model_CommandesPieces(); $commandeKbisTable->insert($dataCommandesKbis); } catch (Zend_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); } try { $row = $commande->find($commande_id); $data = $row->current(); $ref->reference = $data->id; $ref->dateCommande = $data->date_added; $ref->dateMaj = $data->date_updated; $ref->dateReception = $data->date_closed; } catch (Zend_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); $error->errnum = 0; $error->errmsg = "Commande Introuvable"; } } else { $error->errnum = 0; $error->errmsg = "Erreur enregistrement commande"; } } $output = new CmdKbisReturn(); $cmd = new CmdKbisDetail(); $cmd->infoCommande = $infoCommande; $cmd->infoDemandeur = $infoDemandeur; $cmd->refCommande = $ref; $output->commande = $cmd; $output->error = $error; return $output; } /** * Renvoi des informations sur une commande de Kbis * @param string $reference * @return CmdKbisReturn */ public function getCmdKbis( $reference ){} /** * Commande de statut association * @param InfoCommandeAsso $infoCommande * @param InfoDemandeur $infoDemandeur * @return CmdAssoReturn */ public function setCmdAsso( $infoCommande, $infoDemandeur ){} /** * Renvoi des informations sur une commande association * @param string $reference * @return CmdAssoReturn */ public function getCmdAsso( $reference ){} /** * Commande de privilèges et nantissements par email * @param InfoCommandePieces $infoCommande * @param InfoDemandeur $infoDemandeur * @return CmdPiecesReturn */ public function setCmdPieces( $infoCommande, $infoDemandeur ) { $error = new ErrorType(); $ref = new RefCommande(); if (!empty($infoCommande->siren)) { $login = $_SERVER['PHP_AUTH_USER']; //Vérification SIREN //Vérification email - Si infoDemandeur->email vide alors on prend //user_email // Insertion des données commande $dataCommandes = array( 'user_login' => $login, 'user_email' => '', 'type' => 'pieces', 'demandeurReference' => $infoDemandeur->reference, 'demandeurEmail' => $infoDemandeur->email, 'demandeurTel' => $infoDemandeur->tel, 'demandeurNom' => $infoDemandeur->nom, 'demandeurService' => $infoDemandeur->service, 'demandeurSociete' => $infoDemandeur->societe, 'demandeurAdresse' => $infoDemandeur->adresse, 'demandeurCp' => $infoDemandeur->cp, 'demandeurVille' => $infoDemandeur->ville, 'infoCommande' => serialize($infoCommande) ); try { $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); $commande = new Application_Model_Commandes(); $commande_id = $commande->insert($dataCommandes); } catch (Zend_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); } if ($commande_id) { //Enregistrement des détails de commande $dataCommandesPieces = array( 'commande_id' => $commande_id, 'siren' => $infoCommande->siren, 'raisonSociale' => '', 'fichier' => '', ); try { $commandePieces = new Application_Model_CommandesPieces(); $commandePieces->insert($dataCommandesPieces); } catch (Zend_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); } try { $row = $commande->find($commande_id); $data = $row->current(); $ref->reference = $data->id; $ref->dateCommande = $data->date_added; $ref->dateMaj = $data->date_updated; $ref->dateReception = $data->date_closed; } catch (Zend_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); $error->errnum = 0; $error->errmsg = "Commande Introuvable"; } } else { $error->errnum = 0; $error->errmsg = "Erreur enregistrement commande"; } } else { $error->errnum = 0; $error->errmsg = 'Erreur SIREN invalide'; } $output = new CmdPiecesReturn(); $cmd = new CmdPiecesDetail(); $cmd->infoCommande = $infoCommande; $cmd->infoDemandeur = $infoDemandeur; $cmd->refCommande = $ref; $output->error = $error; return $output; } /** * Renvoi des informations sur une commande pièces * @param string $reference * @return CmdPiecesReturn */ public function getCmdPieces( $reference ) { list($typeCommande, $idCommande) = explode('-', $reference); try { $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); $commandeTable = new Application_Model_Commandes(); $select = $commandeTable->select() ->where('type = ?', 'pieces') ->where('id = ?', $idCommande); $commandeRowset = $commandeTable->fetchAll($select); } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); } $error = new ErrorType(); $ref = new RefCommande(); $infoCommande = new InfoCommandePieces(); $infoDemandeur = new InfoDemandeur(); if ( $commandeRowset->count()>0 ) { $commande = $commandeRowset->current(); $selectEven = $commandeTable->select() ->order('date_added DESC')->limit(1); $evenRowset = $commande->findDependentRowset( 'Application_Model_CommandesEven', null, $selectEven); $info = ''; if($evenRowset->count()>0){ $even = $evenRowset->current(); $info = $even->commentaire; } $ref->reference = strtoupper($commande->type).'-'.$commande->id; $ref->dateCommande = $commande->date_added; $ref->dateMaj = $commande->date_updated; $ref->dateReception = $commande->date_closed; $ref->info = $info; $ref->fichier = ''; // @todo : Détecter le fichier $ref->login = $commande->user_login; $infoCommande = unserialize($commande->infoCommande); $infoDemandeur->reference = $commande->demandeurReference; $infoDemandeur->email = $commande->demandeurEmail; $infoDemandeur->tel = $commande->demandeurTel; $infoDemandeur->nom = $commande->demandeurNom; $infoDemandeur->service = $commande->demandeurService; $infoDemandeur->societe = $commande->demandeurSociete; $infoDemandeur->adresse = $commande->demandeurAdresse; $infoDemandeur->cp = $commande->demandeurCp; $infoDemandeur->ville = $commande->demandeurVille; } else { $error->errnum = 0; $error->errmsg = 'Référence inconnue'; } $output = new CmdPiecesReturn(); $cmd = new CmdPiecesDetail(); $cmd->refCommande = $ref; $cmd->infoCommande = $infoCommande; $cmd->infoDemandeur = $infoDemandeur; $output->commande = $cmd; $output->error = $error; return $output; } /** * Retourne la liste des commandes de pièces ainsi que leur détails * @param CmdFiltrePieces $filtre * @param int $position * @param int $nbRep * @return ListeCmdPiecesReturn */ public function getListeCmdPieces( $filtre, $position = 0, $nbRep = 20 ) { $error = new ErrorType(); //Traitements des filtres pour générer la requête SQL //Selection $nbCommandes = 0; try { $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); $commandeTable = new Application_Model_Commandes(); $select = $commandeTable->select()->where('type = ?', 'pieces'); $countRowset = $commandeTable->fetchAll($select); $nbCommandes = $countRowset->count(); $select->order('date_added DESC')->limit($nbRep, $position); $commandeRowset = $commandeTable->fetchAll($select); } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); $error->errnum = 1; $error->errmsg = 'Erreur'; } if ( $commandeRowset->count()>0 ) { $liste = array(); foreach ($commandeRowset as $commande) { $selectEven = $commandeTable->select() ->order('date_added DESC')->limit(1); $evenRowset = $commande->findDependentRowset( 'Application_Model_CommandesEven', null, $selectEven); $info = ''; if($evenRowset->count()>0){ $even = $evenRowset->current(); $info = $even->commentaire; } $ref = new RefCommande(); $ref->reference = strtoupper($commande->type).'-'.$commande->id; $ref->dateCommande = $commande->date_added; $ref->dateMaj = $commande->date_updated; $ref->dateReception = $commande->date_closed; $ref->info = $info; $ref->fichier = ''; // @todo : Détecter le fichier $ref->login = $commande->user_login; $infoCommande = new InfoCommandePieces(); $infoCommande = unserialize($commande->infoCommande); $infoDemandeur = new InfoDemandeur(); $infoDemandeur->reference = $commande->demandeurReference; $infoDemandeur->email = $commande->demandeurEmail; $infoDemandeur->tel = $commande->demandeurTel; $infoDemandeur->nom = $commande->demandeurNom; $infoDemandeur->service = $commande->demandeurService; $infoDemandeur->societe = $commande->demandeurSociete; $infoDemandeur->adresse = $commande->demandeurAdresse; $infoDemandeur->cp = $commande->demandeurCp; $infoDemandeur->ville = $commande->demandeurVille; $cmd = new CmdPiecesDetail(); $cmd->refCommande = $ref; $cmd->infoCommande = $infoCommande; $cmd->infoDemandeur = $infoDemandeur; $liste[] = $cmd; } } $output = new ListeCmdPiecesReturn(); $output->error = $error; $output->nbCommandes = $nbCommandes; $output->liste = $liste; return $output; } /** * Liste des bilans * @param string $siren * @param string $waldec * @param int $idEntreprise * @return ListeBilan */ public function getListeBilan( $siren, $waldec = null, $idEntreprise = null ){} /** * Liste des actes * @param string $siren * @return ListeActe */ public function getListeActe( $siren ){} /** * Retourne la liste des statuts de commande * @param string $type * @return CmdStatut[] */ public function getListeCmdStatut( $type ) { Zend_Registry::get('WsLogger')->info("getListeStatut - ".$type); try { $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); $dbStatut = new Application_Model_CommandesStatut(); $result = $dbStatut->fetchAll(array("commande_type = '$type'")); } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); } $listeStatut = array(); if (count($result)>0) { foreach($result as $r) { $statut = new CmdStatut(); $statut->code = $r['code']; $statut->lib = $r['libelle']; $listeStatut[] = $statut; } } return $listeStatut; } /** * Spécifier un état défini pour une commande * (avec déclenchement d'une action) * @param int $reference * @param int $statutCode * @return bool */ public function setCmdStatut( $reference, $statutCode) { $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); $dbStatut = new Application_Model_CommandesStatut(); $row = $dbStatut->fetchRow(array("code = '$statutCode'")); if ( count($row)>0 && $this->setCommandeEven($reference, $row['lib']) ) { if (!empty($row['action'])){ switch($row['action']){ case 'CLOSE': //date_closed break; } } return true; } else { return false; } } /** * Spécifier un état pour une commande * @param int $reference * @param string $comment * @return bool */ public function setCmdEven ( $reference, $comment ) { $login = $_SERVER['PHP_AUTH_USER']; $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); try { //Vérifier que la commande existe avec la référence fournie $commandeTable = new Application_Model_Commandes(); $commandeRowset = $commandeTable->find($reference); if ($commandeRowset->count()>0) { $commande = $commandeRowset->current(); //Enregistrer l'événement $commandeEvenTable = new Application_Model_CommandesEven(); $insert = $commandeEvenTable->createRow(); $insert->commande_id = $commande->id; $insert->commentaire = $comment; $insert->user_login = $login; $insert->save(); //Mettre à jour la commande $commande->date_updated = date('Y-m-d H:i:s'); $commande->save(); return true; } else { return false; } } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); return false; } } /** * Ajout du nom de fichier liée à la commande * @param int $reference * @param string $filename * @return bool */ public function setCmdDocument( $reference, $filename ) { $login = $_SERVER['PHP_AUTH_USER']; $db = Zend_Db::factory($this->dbConfig->Commandes); Zend_Db_Table_Abstract::setDefaultAdapter($db); try { //Vérifier que la commande existe avec la référence fournie $commandeTable = new Application_Model_Commandes(); $commandeRowset = $commandeTable->find($reference); if ($commandeRowset->count()>0) { $commande = $commandeRowset->current(); switch($commande->type) { case 'pieces': $infoCommandePieces = $commande->findDependentRowset('Application_Model_CommandesPieces'); if ($infoCommandePieces->count()>0) { //Update informations pieces $commandePieces = $infoCommandePieces->current(); $commandePieces->fichier = $filename; $commandePieces->save(); //Mettre à jour la commande $commande->date_updated = date('Y-m-d H:i:s'); $commande->save(); return true; } break; case 'default': return false; break; } } else { return false; } } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('WsLogger') ->err(__FUNCTION__.' - '.$e->getMessage()); return false; } } /** * Récupère les informations du profil connecté * @param string $login * @param string $ipUtilisateur * @return InfosLoginReturn */ public function getInfosLogin($login, $ipUtilisateur = '') { //Authentification if (!$this->checkAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $_SERVER['REMOTE_ADDR'])) { throw new SoapFault('900','Identifiant ou mot de passe incorrect !'); exit; } //Initialisation if (empty($ipUtilisateur)) $ipUtilisateur = $_SERVER['REMOTE_ADDR']; $error = new ErrorType(); debugLog('I',"getInfosLogin pour $login (IP=$ipUtilisateur)",__LINE__,__FILE__, __FUNCTION__, __CLASS__); //L'utilisateur qui demande les informations est différent if ($this->tabInfoUser['login']<>$login && ( $this->tabInfoUser['profil']=='Administrateur' || $this->tabInfoUser['profil']=='SuperAdministrateur') ) { //debugLog('I',"getInfosLogin - Un administrateur veut il des infos sur un login",__LINE__,__FILE__, __FUNCTION__, __CLASS__); /** Un administrateur veut il des infos sur un login ? **/ $rep = $this->iDbCrm->select( 'utilisateurs u, clients c', 'u.login, u.id, u.email, u.password, u.idClient, u.typeCompte, u.actif, u.filtre_ip, u.civilite, u.nom, u.prenom, u.tel, u.fax, u.mobile, u.profil, u.raisonSociale, u.siret, u.adrNum, u.adrIndRep, u.adrTypeVoie, u.adrLibVoie, u.adrCp, u.adrVille, u.adrComp, u.tel, u.fax, u.mobile, u.pref, u.profil, u.dateInscription, u.dateValidation, u.nombreConnexions, u.dateDerniereConnexion, u.droits, u.referenceParDefaut, u.nbReponses, u.formatMail, u.dateDebutCompte, u.dateFinCompte, u.maxFicheId, c.droits AS droitsClients, c.timeout', "u.login='$login' AND u.idClient=c.id AND u.deleted=0", true, MYSQL_ASSOC ); $tabRep = $rep[0]; if (count($rep)>0) { $timeOutSec=$tabRep['timeout']*60; if ($timeOutSec==0) $timeOutSec=1800; $rep = array( 'login'=> $login, 'id'=> $tabRep['id'], 'email'=> $tabRep['email'], 'typeCompte'=> $tabRep['typeCompte'], 'idClient'=> $tabRep['idClient'], 'filtre_ip'=> $tabRep['filtre_ip'], 'civilite'=> $tabRep['civilite'], 'nom'=> $tabRep['nom'], 'prenom'=> $tabRep['prenom'], 'raisonSociale'=> $tabRep['raisonSociale'], 'siret'=> $tabRep['siret'], 'adrNum'=> $tabRep['adrNum'], 'adrIndRep'=> $tabRep['adrIndRep'], 'adrTypeVoie'=> $tabRep['adrTypeVoie'], 'adrLibVoie'=> $tabRep['adrLibVoie'], 'adrCp'=> $tabRep['adrCp'], 'adrVille'=> $tabRep['adrVille'], 'adrComp'=> $tabRep['adrComp'], 'tel'=> $tabRep['tel'], 'fax'=> $tabRep['fax'], 'mobile'=> $tabRep['mobile'], 'pref'=> $tabRep['pref'], 'profil'=> $tabRep['profil'], 'dateInscription'=> $tabRep['dateInscription'], 'dateValidation'=> $tabRep['dateValidation'], 'nombreConnexions'=> $tabRep['nombreConnexions'], 'dateDerniereConnexion'=> $tabRep['dateDerniereConnexion'], 'droits'=> $tabRep['droits'], 'droitsClients'=> $tabRep['droitsClients'], 'timeout'=> $timeOutSec, 'nbReponses'=> $tabRep['nbReponses'], 'formatMail'=> $tabRep['formatMail'], 'reference'=> $tabRep['referenceParDefaut'], 'dateDebutCompte'=> $tabRep['dateDebutCompte'], 'dateFinCompte'=> $tabRep['dateFinCompte'], 'maxFicheId'=> $tabRep['maxFicheId'], ); $tabTmp = $this->iDbCrm->select('clients', 'typeScore', 'id='.$tabRep['idClient'], true, MYSQL_ASSOC); $tabRep = $tabTmp[0]; $rep['typeScore'] = $tabRep['typeScore']; } } else { //Identification utilisateur $connected = true; if (trim($this->tabInfoUser['filtre_ip'])<>'') { //debugLog('I',"getInfosLogin test filtre IP",__LINE__,__FILE__, __FUNCTION__, __CLASS__); $connected = checkPlagesIp($this->tabInfoUser['filtre_ip'], $ipUtilisateur); if (!$connected) { debugLog('I',"getInfosLogin Adresse IP $ipUtilisateur non declaree pour le compte $login",__LINE__,__FILE__, __FUNCTION__, __CLASS__); $error->errnum = 10818; $error->errmsg = "Adresse IP $ipUtilisateur non declaree pour ce compte. Contactez votre administrateur !"; } } $rep = array( 'connected'=> $connected, 'login'=> $this->tabInfoUser['login'], 'id'=> $this->tabInfoUser['id'], 'idClient'=> $this->tabInfoUser['idClient'], 'email'=> $this->tabInfoUser['email'], 'typeCompte'=> $this->tabInfoUser['typeCompte'], 'filtre_ip'=> $this->tabInfoUser['filtre_ip'], 'ipPasserelle'=> $this->tabInfoUser['ipConnexion'], 'ipConnexion'=> $ipUtilisateur, 'civilite'=> $this->tabInfoUser['civilite'], 'nom'=> $this->tabInfoUser['nom'], 'prenom'=> $this->tabInfoUser['prenom'], 'raisonSociale'=> $this->tabInfoUser['raisonSociale'], 'siret'=> $this->tabInfoUser['siret'], 'adrNum'=> $this->tabInfoUser['adrNum'], 'adrIndRep'=> $this->tabInfoUser['adrIndRep'], 'adrTypeVoie'=> $this->tabInfoUser['adrTypeVoie'], 'adrLibVoie'=> $this->tabInfoUser['adrLibVoie'], 'adrCp'=> $this->tabInfoUser['adrCp'], 'adrVille'=> $this->tabInfoUser['adrVille'], 'adrComp'=> $this->tabInfoUser['adrComp'], 'tel'=> $this->tabInfoUser['tel'], 'fax'=> $this->tabInfoUser['fax'], 'mobile'=> $this->tabInfoUser['mobile'], 'pref'=> $this->tabInfoUser['pref'], 'profil'=> $this->tabInfoUser['profil'], 'dateInscription'=> $this->tabInfoUser['dateInscription'], 'dateValidation'=> $this->tabInfoUser['dateValidation'], 'nombreConnexions'=> $this->tabInfoUser['nombreConnexions'], 'dateDerniereConnexion'=> $this->tabInfoUser['dateDerniereConnexion'], 'droits'=> $this->tabInfoUser['droits'], 'droitsClients'=> $this->tabInfoUser['droitsClients'], 'timeout'=> $this->tabInfoUser['timeout'], 'nbReponses'=> $this->tabInfoUser['nbReponses'], 'formatMail'=> $this->tabInfoUser['formatMail'], 'reference'=> $this->tabInfoUser['referenceParDefaut'], 'dateDebutCompte'=> $this->tabInfoUser['dateDebutCompte'], 'dateFinCompte'=> $this->tabInfoUser['dateFinCompte'], 'maxFicheId'=> $this->tabInfoUser['maxFicheId'], 'typeScore'=> $this->tabInfoUser['typeScore'], ); //debugLog('I',"getInfosLogin fin ".print_r($rep,true),__LINE__,__FILE__, __FUNCTION__, __CLASS__); } $result = new InfosLogin(); $result = arrayToClass($rep, 'InfosLogin'); $output = new InfosLoginReturn(); $output->error = $error; $output->result = $result; return $output; } /** * Enter description here ... * @param string $siret * @param string $type * @param string $codeInsee * @return ListeCompetencesReturn */ public function getListeCompetences($siret, $type, $codeInsee) { //Authentification if (!$this->checkAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $_SERVER['REMOTE_ADDR'])) { throw new SoapFault('900','Identifiant ou mot de passe incorrect !'); exit; } //Initialisation $error = new ErrorType(); $type = strtolower($type); debugLog('I',"Liste des compétences $type demandée pour la commune $codeInsee",__LINE__,__FILE__, __FUNCTION__, __CLASS__); $tabRet = array(); $iBodacc = new MBodacc(); $cp=$codeInsee*1; $dep=false; if (substr($codeInsee,0,2)=='2A' || substr($codeInsee,0,2)=='2B') { $dep=20; $cp=20000+(substr($codeInsee,2,3))*1; } elseif ($cp>0 && $cp<100) $dep=$cp; elseif ($cp>970 && $cp<977) $dep=$cp; elseif ($cp>999 && $cp<10000) $dep='0'.substr($cp,0,1); elseif ($cp>=10000 && $cp<96000) $dep=substr($cp,0,2); elseif ($cp>=99000) $dep=substr($cp,0,2); elseif ($cp>=98000) $dep=substr($cp,0,3); elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3); if ($type=='pre') { $iDb = new WDB('jo'); $tabTmp2 = $iDb->select('villes', 'DEP, COM, AR, CT', 'codeInsee='.$codeInsee, false, MYSQL_ASSOC); $arrond = $tabTmp2[0]['AR']; unset($iDb); $iDb = new WDB('insee'); $tabTmp2 = $iDb->select('insee_tabArrond', 'CHEFLIEU, ARTMAJ, NCC', "DEP='$dep' AND AR='$arrond'", false, MYSQL_ASSOC); $nomSousPref = trim(strtr($tabTmp2[0]['ARTMAJ'],array('('=>'',')'=>'',' '=>'', "'"=>'')).' '.$tabTmp2[0]['NCC']); unset($iDb); $tabTmp = $iBodacc->getTribunauxParDep($dep); foreach ($tabTmp as $i=>$tribunal) { if ($tribunal['triType']=='A' || $tribunal['triType']=='B') { $pref = levenshtein($tribunal['triNom'], 'PREFECTURE DE '.$nomSousPref); $spref = levenshtein($tribunal['triNom'], 'SOUS PREFECTURE DE '.$nomSousPref); if ($tribunal['triType']=='B' && ($pref>7 || $spref>5)) continue; $competence = new Competence(); $competence = arrayToClass(array( 'Id' => $tribunal['triId'], 'IdSup' => $tribunal['triIdSup'], 'Code' => $tribunal['triCode'], 'Type' => $tribunal['triType'].$typeP, 'Nom' => strtoupper($tribunal['triNom']), 'Siret' => $tribunal['triSiret'], 'Adr' => strtoupper(preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.$tribunal['triAdrIndRep'].' '. $tribunal['triAdrTypeVoie'].' '.$tribunal['triAdrVoie'])), 'AdrComp' => strtoupper($tribunal['triAdrComp']), 'CP' => $tribunal['triCP'], 'Ville' => strtoupper($tribunal['triVille']), 'CodeInsee' => $tribunal['CodeInsee'], 'Tel' => $tribunal['triTel'], 'Fax' => $tribunal['triFax'], 'Web' => $tribunal['triWeb'], 'Mail' => $tribunal['triMail'], 'Statut' => $tribunal['triStatut'], 'DateCessation' => $tribunal['triDateCessation'], 'Remarque' => $tribunal['triCommentaire'], ), 'Competence'); $tabRet[$i] = $competence; } } } elseif ($type=='jal') { $tabTmp = $iBodacc->getJALparDep($dep); foreach ($tabTmp as $i=>$comp) { $infos=''; if (trim($comp['parution'])<>'') $infos.='Parution '.$comp['parution'].'. '; if (trim($comp['aboAnnuel'])>0) $infos.='Abonnement Annuel : '.$comp['aboAnnuel'].' euros. '; if (trim($comp['infos'])<>'') $infos.=$comp['infos']; $competence = new Competence(); $competence = arrayToClass(array( 'Id' => 9000+$comp['id']*1, 'IdSup' => 0, 'Code' => '', 'Type' => '', 'Nom' => strtoupper($comp['nomJal']), 'Siret' => '', 'Adr' => strtoupper($comp['adresse']), 'AdrComp' => '', 'CP' => $comp['cp'], 'Ville' => strtoupper($comp['ville']), 'CodeInsee' => '', 'Tel' => $comp['tel'], 'Fax' => $comp['fax'], 'Web' => $comp['siteWeb'], 'Mail' => $comp['email'], 'Statut' => 'Actif', 'DateCessation' => '', 'Remarque' => trim($infos), ), 'Competence'); $tabRet[$i] = $competence; } } elseif ($type=='tri' || $type=='adm' || $type=='hui') { $tabTmp = $iBodacc->getTribunauxParCommune($codeInsee); foreach ($tabTmp as $i=>$tribunal) { if (//$tribunal['triType']=='C' || $tribunal['triType']=='G'// || /*$tribunal['triType']=='I'*/) { $idCA=$tribunal['triIdSup']; $codeTGI=$tribunal['triCode']; $code=strtoupper(substr($tribunal['triCode'],0,3)); } debugLog('D',"Liste des compétences $type demandée pour la commune $codeInsee ($dep) : ". "Type=".$tribunal['triType'].', '. "Code=".$tribunal['$codeTGI'],__LINE__,__FILE__, __FUNCTION__, __CLASS__); if ($tribunal['triType']<>'E' && $tribunal['triType']<>'O' && $tribunal['triType']<>'T' && $tribunal['triType']<>'R' && $tribunal['triType']<>'N' && $tribunal['triType']<>'U' && $tribunal['triType']<>'Z') { $competence = new Competence(); $competence = arrayToClass(array( 'Id' => $tribunal['triId'], 'IdSup' => $tribunal['triIdSup'], 'Code' => $tribunal['triCode'], 'Type' => $tribunal['triType'], 'Nom' => strtoupper($tribunal['triNom']), 'Siret' => $tribunal['triSiret'], 'Adr' => strtoupper(preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.$tribunal['triAdrIndRep'].' '. $tribunal['triAdrTypeVoie'].' '.$tribunal['triAdrVoie'])), 'AdrComp' => strtoupper($tribunal['triAdrComp']), 'CP' => $tribunal['triCP'], 'Ville' => strtoupper($tribunal['triVille']), 'CodeInsee' => $tribunal['CodeInsee'], 'Tel' => $tribunal['triTel'], 'Fax' => $tribunal['triFax'], 'Web' => $tribunal['triWeb'], 'Mail' => $tribunal['triMail'], 'Statut' => $tribunal['triStatut'], 'DateCessation' => $tribunal['triDateCessation'], 'Remarque' => $tribunal['triCommentaire'], ), 'Competence'); if ($tribunal['triNumGreffe']*1>0) { $competence->IdentifiantGreffe = $tribunal['triNumGreffe']; } $tabRet[$i] = $competence; } } } if ($type=='adm') { $tabTmp=$this->iInsee->getMandataires(array($idCA), false); $tabRet = array(); $nbAff=0; foreach ($tabTmp as $i=>$tribunal) { /** @todo A revoir Debut **/ if (stripos($tribunal['tribunal'], $code)!==false || stripos($tribunal['tribunal'], 'SAINT')!==false) { $competence = new Competence(); $competence = arrayToClass(array( 'Id' => $tribunal['id'], 'IdSup' => $tribunal['sirenGrp'], 'Code' => $tribunal['tribunal'].'/'.$code, 'Type' => $tribunal['type'], 'Nom' => $tribunal['Nom'].' '.$tribunal['Prenom'], 'Siret' => $tribunal['sirenMand'], 'Adr' => strtoupper($tribunal['adresse']), 'AdrComp' => strtoupper($tribunal['adresseComp']), 'CP' => $tribunal['cp'], 'Ville' => strtoupper($tribunal['ville']), //'CodeInsee'=>$tribunal['CodeInsee'], 'Tel' => $tribunal['tel'], 'Fax' => $tribunal['fax'], 'Web' => $tribunal['web'], 'Mail' => $tribunal['email'], 'Statut' => $tribunal['Statut'], //'DateCessation'=>$tribunal['triDateCessation'], 'Remarque' => $tribunal['contact'], ), 'Competence');//,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact $tabRet[$i] = $competence; $nbAff++; } } if ($nbAff==0) { foreach ($tabTmp as $i=>$tribunal) { $competence = new Competence(); $competence = arrayToClass(array( 'Id' => $tribunal['id'], 'IdSup' => $tribunal['sirenGrp'], 'Code' => $tribunal['tribunal'].'/'.$code, 'Type' => $tribunal['type'], 'Nom' => $tribunal['Nom'].' '.$tribunal['Prenom'], 'Siret' => $tribunal['sirenMand'], 'Adr' => strtoupper($tribunal['adresse']), 'AdrComp' => strtoupper($tribunal['adresseComp']), 'CP' => $tribunal['cp'], 'Ville' => strtoupper($tribunal['ville']), //'CodeInsee'=>$tribunal['CodeInsee'], 'Tel' => $tribunal['tel'], 'Fax' => $tribunal['fax'], 'Web' => $tribunal['web'], 'Mail' => $tribunal['email'], 'Statut' => $tribunal['Statut'], //'DateCessation'=>$tribunal['triDateCessation'], 'Remarque' => $tribunal['contact'], ), 'Competence');//,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact $tabRet[$i] = $competence; } }/** @todo A revoir Fin : Lier correctement les mandataires à un TI principal **/ } elseif ($type=='hui') { $tabTmp = $this->iInsee->getHuissiers(array($codeTGI), false); $tabRet = array(); $nbAff = 0; foreach ($tabTmp as $i=>$tribunal) { $adr=$this->iInsee->structureVoie($tribunal['adresse']); $competence = new Competence(); $competence = arrayToClass(array( 'Id' => $tribunal['id'], 'IdSup' => $tribunal['sirenGrp'], 'Code' => $tribunal['tribunal'].'/'.$code, 'Type' => $tribunal['type'], 'Nom' => $tribunal['Nom'].' '.$tribunal['Prenom'], 'Siret' => $tribunal['sirenMand'], 'Adr' => strtoupper($adr['num'].' '.$adr['adr_btq'].' '. $adr['typeVoie'].' '.$adr['libVoie']), 'AdrComp' => strtoupper($tribunal['adresseComp']), 'CP' => $adr['cp'], 'Ville' => strtoupper($tribunal['ville']), //'CodeInsee'=>$tribunal['CodeInsee'], 'Tel' => $tribunal['tel'], 'Fax' => $tribunal['fax'], 'Web' => $tribunal['web'], 'Mail' => $tribunal['email'], 'Statut' => $tribunal['Statut'], //'DateCessation'=>$tribunal['triDateCessation'], 'Remarque' => strtr($tribunal['contact'], array( '
'=>', ', '
'=>', ', '
'=>', ', )), ), 'Competence'); $tabRet[$i] = $competence; } $nbComp = count($tabTmp); debugLog('I',"$nbComp compétences $type trouvées pour le tribunal $codeTGI",__LINE__,__FILE__, __FUNCTION__, __CLASS__); } elseif ($type=='cfe') { $tabTmp = $iBodacc->getTribunauxParCommune($codeInsee); foreach ($tabTmp as $i=>$tribunal) { if ($tribunal['triType']=='C' || $tribunal['triType']=='O' || $tribunal['triType']=='T' || $tribunal['triType']=='R' || $tribunal['triType']=='N' || $tribunal['triType']=='U' || $tribunal['triType']=='Z') { if (strlen($tribunal['triCommentaire'])==32 && strpos($tribunal['triCommentaire'], ' ')===false) $remarque=''; else $remarque=prepareString($tribunal['triCommentaire']); $competence = new Competence(); $competence = arrayToClass(array( 'Id' => $tribunal['triId'], 'IdSup' => $tribunal['triIdSup'], 'Code' => $tribunal['triCode'], 'Type' => $tribunal['triType'], 'Nom' => strtoupper($tribunal['triNom']), 'Siret' => $tribunal['triSiret'], 'Adr' => strtoupper(preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.$tribunal['triAdrIndRep'].' '. $tribunal['triAdrTypeVoie'].' '.$tribunal['triAdrVoie'])), 'AdrComp' => strtoupper($tribunal['triAdrComp']), 'CP' => $tribunal['triCP'], 'Ville' => strtoupper($tribunal['triVille']), 'CodeInsee' => $tribunal['CodeInsee'], 'Tel' => $tribunal['triTel'], 'Fax' => $tribunal['triFax'], 'Web' => $tribunal['triWeb'], 'Mail' => $tribunal['triMail'], 'Statut' => $tribunal['triStatut'], 'DateCessation' => $tribunal['triDateCessation'], 'Remarque' => $remarque, ), 'Competence'); $tabRet[$i] = $competence; } } } wsLog('competences',$siret,$type.'/'.$codeInsee); $result = new ListeCompetencesResult(); $result->nbReponses = count($tabRet); $result->liste = $tabRet; $output = new ListeCompetencesReturn(); $output->error = $error; $output->result = $result; /*Zend_Registry::get('WsLogger') ->info(__FUNCTION__.' - '.print_r($output, 1));*/ return $output; } }