2011-01-06 08:37:20 +00:00
|
|
|
<?php
|
|
|
|
class WsScores
|
|
|
|
{
|
|
|
|
protected $webservices = array();
|
2011-01-07 17:16:07 +00:00
|
|
|
protected $login = '';
|
|
|
|
protected $password = '';
|
2011-04-11 14:20:26 +00:00
|
|
|
protected $nbReponses = 20;
|
2011-01-07 17:16:07 +00:00
|
|
|
|
2011-04-11 14:20:26 +00:00
|
|
|
public function __construct($login = '', $password = '')
|
|
|
|
{
|
2011-01-06 08:37:20 +00:00
|
|
|
$config = new Zend_Config_Ini(APPLICATION_PATH .
|
|
|
|
'/configs/webservices.ini', APPLICATION_ENV);
|
|
|
|
$this->webservices = $config->webservices->toArray();
|
2011-01-07 17:16:07 +00:00
|
|
|
|
|
|
|
if ( !empty($login) && !empty($password) ){
|
|
|
|
$this->login = $login;
|
|
|
|
$this->password = $password;
|
|
|
|
} else {
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$this->login = $auth->getIdentity()->username;
|
|
|
|
$this->password = md5($this->login.'|'.$auth->getIdentity()->password);
|
2011-04-11 14:20:26 +00:00
|
|
|
$this->nbReponses = $auth->getIdentity()->nbReponses;
|
2011-01-07 17:16:07 +00:00
|
|
|
}
|
2011-01-06 08:37:20 +00:00
|
|
|
}
|
2011-04-11 14:20:26 +00:00
|
|
|
|
2011-04-19 07:14:04 +00:00
|
|
|
/**
|
|
|
|
* getRatios
|
|
|
|
* @param string $siren
|
|
|
|
* @param string $page
|
|
|
|
*/
|
|
|
|
public function getRatios($siren, $page = 'ratios')
|
|
|
|
{
|
|
|
|
$params = new StdClass();
|
|
|
|
$params->siren = $siren;
|
|
|
|
$params->page = $page;
|
|
|
|
$client = $this->loadClient('entreprise');
|
|
|
|
try {
|
|
|
|
$reponse = $client->getRatios($params);
|
|
|
|
return $reponse->getRatiosResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-19 06:23:20 +00:00
|
|
|
/**
|
|
|
|
* getDirigeants
|
|
|
|
* @param string $siren
|
|
|
|
* @param boolean $histo
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getDirigeants($siren, $histo=false)
|
|
|
|
{
|
|
|
|
$params = new StdClass();
|
|
|
|
$params->siren = $siren;
|
|
|
|
$params->histo = $histo;
|
|
|
|
$client = $this->loadClient('entreprise');
|
|
|
|
try {
|
|
|
|
$reponse = $client->getDirigeants($params);
|
|
|
|
return $reponse->getDirigeantsResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-14 13:12:50 +00:00
|
|
|
/**
|
|
|
|
* getIdentite
|
|
|
|
* @param string $siret
|
|
|
|
* @param int $id
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getIdentite($siret, $id = 0)
|
|
|
|
{
|
|
|
|
$params = new StdClass();
|
|
|
|
$params->siret = $siret;
|
|
|
|
$params->id = $id;
|
|
|
|
$client = $this->loadClient('entreprise');
|
|
|
|
try {
|
|
|
|
$reponse = $client->getIdentite($params);
|
|
|
|
return $reponse->getIdentiteResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-18 15:25:26 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* getLiens
|
|
|
|
* @param string $siren
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getLiens($siren)
|
|
|
|
{
|
|
|
|
$params = new StdClass();
|
|
|
|
$params->siren = $siren;
|
|
|
|
$params->actifsUniquement = true;
|
|
|
|
$client = $this->loadClient('entreprise');
|
|
|
|
try {
|
|
|
|
$reponse = $client->getLiens($params);
|
|
|
|
return $reponse->getLiensResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getListeEvenements
|
|
|
|
* @param string $siren
|
|
|
|
* @param string $nic
|
|
|
|
* @param integer $position
|
|
|
|
* @param integer $nbRep
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getListeEvenements($siren, $nic=0, $position=0, $nbRep=200)
|
|
|
|
{
|
|
|
|
$params = new stdClass();
|
|
|
|
$params->siren = $siren;
|
|
|
|
$params->nic = $nic;
|
|
|
|
$params->position = $position;
|
|
|
|
$params->nbRep = $nbRep;
|
|
|
|
$client = $this->loadClient('entreprise');
|
|
|
|
try {
|
|
|
|
$reponse = $client->getListeEvenements($params);
|
|
|
|
return $reponse->getListeEvenementsResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getListeEtablissements
|
|
|
|
* @param string $siren
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getListeEtablissements($siren)
|
|
|
|
{
|
|
|
|
$params = new StdClass();
|
|
|
|
$params->siren = $siren;
|
|
|
|
$params->dep = 0;
|
|
|
|
$params->actif = -1;
|
|
|
|
$params->position = 0;
|
|
|
|
$params->nbRep = 100;
|
|
|
|
$client = $this->loadClient('entreprise');
|
|
|
|
try {
|
|
|
|
$reponse = $client->getListeEtablissements($params);
|
|
|
|
return $reponse->getListeEtablissementsResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-14 13:12:50 +00:00
|
|
|
|
2011-04-11 14:20:26 +00:00
|
|
|
/**
|
|
|
|
* rechercheEntreprise
|
|
|
|
* @param unknown_type $type
|
|
|
|
* @param unknown_type $criteres
|
|
|
|
* @param unknown_type $position
|
|
|
|
*/
|
|
|
|
public function rechercheEntreprise($type, $criteres, $position = 0)
|
|
|
|
{
|
|
|
|
$params = new StdClass;
|
|
|
|
$params->type = $type;
|
|
|
|
$params->position = $position;
|
|
|
|
$params->nbRep = $this->nbReponses;
|
|
|
|
|
|
|
|
if ($type == 'ent') {
|
|
|
|
$criteresEntreprise = new StdClass;
|
|
|
|
$criteresEntreprise->identifiant = $criteres['identifiant'];
|
|
|
|
$criteresEntreprise->raisonSociale = $criteres['raisonSociale'];
|
|
|
|
$criteresEntreprise->adresse = $criteres['adresse'];
|
|
|
|
$criteresEntreprise->codePostal = $criteres['codePostal'];
|
|
|
|
$criteresEntreprise->ville = $criteres['ville'];
|
|
|
|
$criteresEntreprise->telFax = $criteres['telFax'];
|
|
|
|
$criteresEntreprise->naf = $criteres['naf'];
|
|
|
|
$criteresEntreprise->siege = false;
|
|
|
|
$criteresEntreprise->actif = false;
|
|
|
|
|
|
|
|
$criteresDirigeant = new StdClass;
|
|
|
|
$criteresDirigeant->nom = '';
|
|
|
|
$criteresDirigeant->prenom = '';
|
|
|
|
$criteresDirigeant->dateNaiss = '';
|
|
|
|
$criteresDirigeant->lieuNaiss = '';
|
|
|
|
|
|
|
|
} else if ($type == 'dir') {
|
|
|
|
$criteresEntreprise = new StdClass;
|
|
|
|
$criteresEntreprise->identifiant = '';
|
|
|
|
$criteresEntreprise->raisonSociale = '';
|
|
|
|
$criteresEntreprise->adresse = '';
|
|
|
|
$criteresEntreprise->codePostal = '';
|
|
|
|
$criteresEntreprise->ville = '';
|
|
|
|
$criteresEntreprise->telFax = '';
|
|
|
|
$criteresEntreprise->naf = '';
|
|
|
|
$criteresEntreprise->siege = false;
|
|
|
|
$criteresEntreprise->actif = false;
|
|
|
|
|
|
|
|
$criteresDirigeant = new StdClass;
|
|
|
|
$criteresDirigeant->nom = $criteres['nom'];
|
|
|
|
$criteresDirigeant->prenom = $criteres['prenom'];
|
|
|
|
$criteresDirigeant->dateNaiss = $criteres['dateNaiss'];
|
|
|
|
$criteresDirigeant->lieuNaiss = $criteres['lieuNaiss'];
|
|
|
|
}
|
|
|
|
$params->criteres = new StdClass;
|
|
|
|
$params->criteres->elementEntreprise = $criteresEntreprise;
|
|
|
|
$params->criteres->elementDirigeant = $criteresDirigeant;
|
|
|
|
$client = $this->loadClient('entreprise');
|
|
|
|
try {
|
|
|
|
$reponse = $client->rechercheEntreprise($params);
|
|
|
|
return $reponse->rechercheEntrepriseResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getInfosLogin
|
|
|
|
* @param unknown_type $login
|
|
|
|
* @param unknown_type $ipUtilisateur
|
|
|
|
*/
|
|
|
|
public function getInfosLogin($login, $ipUtilisateur = '')
|
|
|
|
{
|
2011-01-06 08:37:20 +00:00
|
|
|
$params = new stdClass();
|
|
|
|
$params->login = $login;
|
|
|
|
$params->ipUtilisateur = $ipUtilisateur;
|
2011-01-07 17:16:07 +00:00
|
|
|
try {
|
|
|
|
$client = $this->loadClient('interne');
|
|
|
|
$reponse = $client->getInfosLogin($params);
|
|
|
|
return $reponse->getInfosLoginResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
//Placer exception pour affichage message
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-06 08:37:20 +00:00
|
|
|
}
|
|
|
|
|
2011-04-11 14:20:26 +00:00
|
|
|
/**
|
|
|
|
* getNextLogin
|
|
|
|
* @param unknown_type $login
|
|
|
|
*/
|
|
|
|
public function getNextLogin($login)
|
|
|
|
{
|
2011-04-01 12:14:40 +00:00
|
|
|
$params = new stdClass();
|
|
|
|
$params->login = $login;
|
|
|
|
try {
|
|
|
|
$client = $this->loadClient('interne');
|
|
|
|
$reponse = $client->getNextLogin($params);
|
|
|
|
return $reponse->getNextLoginResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
//Placer exception pour affichage message
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-11 14:20:26 +00:00
|
|
|
/**
|
|
|
|
* getListePrefs
|
|
|
|
*/
|
|
|
|
public function getListePrefs()
|
|
|
|
{
|
2011-04-01 12:14:40 +00:00
|
|
|
try {
|
|
|
|
$client = $this->loadClient('interne');
|
|
|
|
$reponse = $client->getListePrefs();
|
|
|
|
return $reponse->getListePrefsResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
//Placer exception pour affichage message
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-11 14:20:26 +00:00
|
|
|
/**
|
|
|
|
* getListeDroits
|
|
|
|
*/
|
|
|
|
public function getListeDroits()
|
|
|
|
{
|
2011-04-01 12:14:40 +00:00
|
|
|
try {
|
|
|
|
$client = $this->loadClient('interne');
|
|
|
|
$reponse = $client->getListeDroits();
|
|
|
|
return $reponse->getListeDroitsResult;
|
|
|
|
} catch (SoapFault $fault) {
|
|
|
|
//Placer exception pour affichage message
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-04-11 14:20:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* soaperror
|
|
|
|
* @param unknown_type $requete
|
|
|
|
* @param unknown_type $reponse
|
|
|
|
* @param unknown_type $fault
|
|
|
|
*/
|
|
|
|
protected function soaperror($requete, $reponse, $fault)
|
|
|
|
{
|
2011-04-19 07:14:04 +00:00
|
|
|
$message = '';
|
|
|
|
// Quel machine ....
|
2011-04-11 14:20:26 +00:00
|
|
|
$mail = new Zend_Mail();
|
|
|
|
$mail->setBodyText('Ceci est le texte du message.');
|
|
|
|
$mail->setSubject('TestSubject');
|
|
|
|
$mail->setFrom('supportdev@scores-decisions.com', 'SERVEUR');
|
|
|
|
$mail->addTo('supportdev@scores-decisions.com', 'Support DEV');
|
|
|
|
$mail->send();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* loadClient
|
|
|
|
* @param unknown_type $webservice
|
|
|
|
*/
|
|
|
|
protected function loadClient($webservice)
|
|
|
|
{
|
2011-01-06 08:37:20 +00:00
|
|
|
$wsdl = $this->webservices[$webservice]['wsdl'];
|
|
|
|
$options = $this->webservices[$webservice]['options'];
|
2011-01-07 17:16:07 +00:00
|
|
|
$options['login'] = $this->login;
|
|
|
|
$options['password'] = $this->password;
|
2011-02-16 14:41:54 +00:00
|
|
|
if (APPLICATION_ENV != 'production'){
|
|
|
|
$options['cache_wsdl'] = WSDL_CACHE_NONE;
|
|
|
|
}
|
|
|
|
$options['encoding'] = 'utf-8';
|
2011-01-06 08:37:20 +00:00
|
|
|
$client = new SoapClient($wsdl, $options);
|
|
|
|
return $client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|