diff --git a/includes/scoresws/WsScores.php b/includes/scoresws/WsScores.php index 4ef99232d..db4ec053a 100644 --- a/includes/scoresws/WsScores.php +++ b/includes/scoresws/WsScores.php @@ -1,274 +1,288 @@ webservices = $config[ENVIRONNEMENT]; - if ( !empty($login) && !empty($password) ){ - $this->login = $login; - $this->password = $password; - } else { - $this->login = $_SESSION['tabInfo']['login']; - $this->password = $_SESSION['tabInfo']['password']; - } - } - - public function rechercheEntreprise($type, $criteres, $position=0){ - $params = new stdClass(); - $params->type = $type; - $params->criteres = $criteres; - $params->position = $position; - if (isset($_SESSION['tabInfo']['nbReponses'])){ - $params->nbRep = $_SESSION['tabInfo']['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 = ''; - - } elseif ($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']; - } - try { - $client = $this->loadClient('entreprise'); - $reponse = $client->rechercheEntreprise($params); - FB::log($reponse, 'rechercheEntreprise'); - return $reponse->rechercheEntrepriseResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client, $fault, $_SESSION['tabInfo']); - return false; - } - } - - public function getPortefeuille($filtre, $position = 0, $nbAffichage = 100){ - $params = new stdClass(); - $params->filtre = $filtre; - $params->deb = $position; - $params->nbRep = $nbAffichage; - try { - $client = $this->loadClient('interne'); - $reponse = $client->getPortefeuille($params); - return $reponse->getPortefeuilleResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client, $fault, $_SESSION['tabInfo']); - return false; - } - } - - public function getListeDroits(){ - try { - $client = $this->loadClient('interne'); - $reponse = $client->getListeDroits(); - return $reponse->getListeDroitsResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client, $fault, $_SESSION['tabInfo']); - return false; - } - } - - public function getListePrefs(){ - try { - $client = $this->loadClient('interne'); - $reponse = $client->getListePrefs(); - return $reponse->getListePrefsResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client, $fault, $_SESSION['tabInfo']); - return false; - } - } - - public function setClient($tabInfos, $idModele = null){ - $params = new stdClass(); - if (!empty($idModele)){ - $params->idModele = $idModele; - } - //Element du tableau - $client = new stdClass(); - $client->idClient = $tabInfos['idClient']; - $client->nom = $tabInfos['nom']; - $client->actif = $tabInfos['actif']; - $client->test = $tabInfos['test']; - $client->racineLogin = $tabInfos['racineLogin']; - $client->siren = $tabInfos['siren']; - $client->nic = $tabInfos['nic']; - $client->tva = $tabInfos['tva']; - $client->editerFacture = $tabInfos['editerFacture']; - $client->fact_detail = $tabInfos['fact_detail']; - $client->fac_dest = $tabInfos['fac_dest']; - $client->fac_adr1 = $tabInfos['fac_adr1']; - $client->fac_adr2 = $tabInfos['fac_adr2']; - $client->fac_adr3 = $tabInfos['fac_adr3']; - $client->fac_email = $tabInfos['fac_email']; - $client->fac_tel = $tabInfos['fac_tel']; - $client->fact_rib = $tabInfos['fact_rib']; - $client->liv_dest = $tabInfos['liv_dest']; - $client->liv_adr1 = $tabInfos['liv_adr1']; - $client->liv_adr2 = $tabInfos['liv_adr2']; - $client->liv_adr3 = $tabInfos['liv_adr3']; - $client->liv_email = $tabInfos['liv_email']; - $client->liv_tel = $tabInfos['liv_tel']; - $client->droits = $tabInfos['droits']; - $client->filtres_ip = $tabInfos['filtres_ip']; - $client->typeContrat = $tabInfos['typeContrat']; - $client->dateSignature = $tabInfos['dateSignature']; - $client->typeAccess = $tabInfos['typeAccess']; - $client->typeScore = $tabInfos['typeScore']; - $client->timeout = $tabInfos['timeout']; - $client->accesPieces = $tabInfos['accesPieces']; - $client->accesKbis = $tabInfos['accessKbis']; - $client->accesInvestigations = $tabInfos['accesInvestigations']; - $client->accesInternationnal = $tabInfos['accesInternationnal']; - $client->accesEnquetes = $tabInfos['accesEnquetes']; - $client->miseSousSurveillance = $tabInfos['miseSousSurveillance']; - $client->forfaitExtranetPeriode = $tabInfos['forfaitExtranetPeriode']; - $client->forfaitExtranetMontant = $tabInfos['forfaitExtranetMontant']; - $client->reconductionAuto = $tabInfos['reconductionAuto']; - $client->remarque = $tabInfos['remarque']; - $client->forfaitPiecesNb = $tabInfos['forfaitPiecesNb']; - $client->forfaitPiecesMt = $tabInfos['forfaitPiecesMt']; - $client->forfaitPiecesDep = $tabInfos['forfaitPiecesDep']; - $client->forfaitInvestigNb = $tabInfos['forfaitInvestigNb']; - $client->forfaitInvestigMt = $tabInfos['forfaitInvestigMt']; - $client->forfaitInvestigDep = $tabInfos['forfaitInvestigDep']; - $client->tarifIndiscore = $tabInfos['tarifIndiscore']; - $client->InterSudLogin = $tabInfos['InterSudLogin']; - $client->InterSudPass = $tabInfos['InterSudPass']; - $params->infos = $client; - try { - $client = $this->loadClient('interne'); - $reponse = $client->setClient($params); - return $reponse->setClientResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client, $fault, $_SESSION['tabInfo']); - return false; - } - } - - public function getListeClients($idClient = 0){ - $params = new stdClass(); - $params->idClient = $idClient; - try { - $client = $this->loadClient('interne'); - $reponse = $client->getListeClients($params); - return $reponse->getListeClientsResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client,$fault,$_SESSION['tabInfo']); - return false; - } - } - - public function getListeUtilisateurs($login, $idClient=-1){ - $params = new stdClass(); - $params->login = $login; - $params->idClient = $idClient; - try { - $client = $this->loadClient('interne'); - $reponse = $client->getListeUtilisateurs($params); - return $reponse->getListeUtilisateursResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client,$fault,$_SESSION['tabInfo']); - return false; - } - } - - public function setInfosLogin($login, $tabInfos){ - $params = new stdClass(); - $params->login = $login; - $params->tabInfoUserWS = $tabInfos; - try { - $client = $this->loadClient('interne'); - $reponse = $client->setInfosLogin($params); - return $reponse->seInfosLoginResult->result; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client,$fault,$_SESSION['tabInfo']); - return false; - } - } - - public function getNextLogin($login = ''){ - $params = new stdClass(); - $params->login = $login; - try { - $client = $this->loadClient('interne'); - $reponse = $client->getNextLogin($params); - return $reponse->getNextLoginResult; - } catch (SoapFault $fault) { - require_once 'soaperror.php'; - processSoapFault($client, $fault, $_SESSION['tabInfo']); - return false; - } - } - - public function getInfosLogin($login, $ipUtilisateur = ''){ - $params = new stdClass(); - $params->login = $login; - $params->ipUtilisateur = $ipUtilisateur; - try { - $client = $this->loadClient('interne'); - $reponse = $client->getInfosLogin($params); - return $reponse->getInfosLoginResult; - } catch (SoapFault $fault) { - if($fault->faultcode != '900') { - require_once 'soaperror.php'; - processSoapFault($client, $fault, $_SESSION['tabInfo']); - } - return false; - } - } - - protected function loadClient($webservice){ - $wsdl = $this->webservices['webservices.'.$webservice.'.wsdl']; - $options['trace'] = isset($this->webservices['webservices.'.$webservice.'options.trace']) ? - $this->webservices['webservices.'.$webservice.'options.trace'] : false; - $options['soap_version'] = isset($this->webservices['webservices.'.$webservice.'options.soap_version']) ? - $this->webservices['webservices.'.$webservice.'options.soap_version'] : SOAP_1_2; - $options['features'] = isset($this->webservices['webservices.'.$webservice.'options.features']) ? - $this->webservices['webservices.'.$webservice.'options.features'] : ''; - $options['login'] = $this->login; - $options['password'] = $this->password; - $client = new SoapClient($wsdl, $options); - return $client; - } -} + protected $webservices = array(); + protected $login = ''; + protected $password = ''; + public function __construct($login = '', $password = '') { + $config = parse_ini_file(PATH_SITE.'/config/scoresws.ini', true); + $this->webservices = $config[ENVIRONNEMENT]; + if (empty($login) == false && empty($password) == false) { + $this->login = $login; + $this->password = $password; + } else { + $this->login = $_SESSION['tabInfo']['login']; + $this->password = $_SESSION['tabInfo']['password']; + } + } + + public function rechercheEntreprise($type, $criteres, $position = 0) { + $params = new stdClass(); + $params->type = $type; + $params->criteres = $criteres; + $params->position = $position; + if (isset($_SESSION['tabInfo']['nbReponses'])) { + $params->nbRep = $_SESSION['tabInfo']['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']; + } + $client = $this->loadClient('entreprise'); + try { + $reponse = $client->rechercheEntreprise($params); + FB::log($reponse, 'rechercheEntreprise'); + return $reponse->rechercheEntrepriseResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function getPortefeuille($filtre, + $position = 0, $nbAffichage = 100) { + $params = new stdClass(); + $params->filtre = $filtre; + $params->deb = $position; + $params->nbRep = $nbAffichage; + $client = $this->loadClient('interne'); + try { + $reponse = $client->getPortefeuille($params); + return $reponse->getPortefeuilleResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function getListeDroits() { + $client = $this->loadClient('interne'); + try { + $reponse = $client->getListeDroits(); + return $reponse->getListeDroitsResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function getListePrefs() { + $client = $this->loadClient('interne'); + try { + $reponse = $client->getListePrefs(); + return $reponse->getListePrefsResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function setClient($tabInfos, $idModele = null) { + $params = new stdClass(); + if (empty($idModele) == false) { + $params->idModele = $idModele; + } + // Element du tableau + $client = new stdClass(); + $client->idClient = $tabInfos['idClient']; + $client->nom = $tabInfos['nom']; + $client->actif = $tabInfos['actif']; + $client->test = $tabInfos['test']; + $client->racineLogin = $tabInfos['racineLogin']; + $client->siren = $tabInfos['siren']; + $client->nic = $tabInfos['nic']; + $client->tva = $tabInfos['tva']; + $client->editerFacture = $tabInfos['editerFacture']; + $client->fact_detail = $tabInfos['fact_detail']; + $client->fac_dest = $tabInfos['fac_dest']; + $client->fac_adr1 = $tabInfos['fac_adr1']; + $client->fac_adr2 = $tabInfos['fac_adr2']; + $client->fac_adr3 = $tabInfos['fac_adr3']; + $client->fac_email = $tabInfos['fac_email']; + $client->fac_tel = $tabInfos['fac_tel']; + $client->fact_rib = $tabInfos['fact_rib']; + $client->liv_dest = $tabInfos['liv_dest']; + $client->liv_adr1 = $tabInfos['liv_adr1']; + $client->liv_adr2 = $tabInfos['liv_adr2']; + $client->liv_adr3 = $tabInfos['liv_adr3']; + $client->liv_email = $tabInfos['liv_email']; + $client->liv_tel = $tabInfos['liv_tel']; + $client->droits = $tabInfos['droits']; + $client->filtres_ip = $tabInfos['filtres_ip']; + $client->typeContrat = $tabInfos['typeContrat']; + $client->dateSignature = $tabInfos['dateSignature']; + $client->typeAccess = $tabInfos['typeAccess']; + $client->typeScore = $tabInfos['typeScore']; + $client->timeout = $tabInfos['timeout']; + $client->accesPieces = $tabInfos['accesPieces']; + $client->accesKbis = $tabInfos['accessKbis']; + $client->accesInvestigations = $tabInfos['accesInvestigations']; + $client->accesInternationnal = $tabInfos['accesInternationnal']; + $client->accesEnquetes = $tabInfos['accesEnquetes']; + $client->miseSousSurveillance = $tabInfos['miseSousSurveillance']; + $client->forfaitExtranetPeriode = $tabInfos['forfaitExtranetPeriode']; + $client->forfaitExtranetMontant = $tabInfos['forfaitExtranetMontant']; + $client->reconductionAuto = $tabInfos['reconductionAuto']; + $client->remarque = $tabInfos['remarque']; + $client->forfaitPiecesNb = $tabInfos['forfaitPiecesNb']; + $client->forfaitPiecesMt = $tabInfos['forfaitPiecesMt']; + $client->forfaitPiecesDep = $tabInfos['forfaitPiecesDep']; + $client->forfaitInvestigNb = $tabInfos['forfaitInvestigNb']; + $client->forfaitInvestigMt = $tabInfos['forfaitInvestigMt']; + $client->forfaitInvestigDep = $tabInfos['forfaitInvestigDep']; + $client->tarifIndiscore = $tabInfos['tarifIndiscore']; + $client->InterSudLogin = $tabInfos['InterSudLogin']; + $client->InterSudPass = $tabInfos['InterSudPass']; + $params->infos = $client; + $client = $this->loadClient('interne'); + try { + $reponse = $client->setClient($params); + return $reponse->setClientResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function getListeClients($idClient = 0) { + $params = new stdClass(); + $params->idClient = $idClient; + $client = $this->loadClient('interne'); + try { + $reponse = $client->getListeClients($params); + return $reponse->getListeClientsResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function getListeUtilisateurs($login, $idClient = -1) { + $params = new stdClass(); + $params->login = $login; + $params->idClient = $idClient; + $client = $this->loadClient('interne'); + try { + $reponse = $client->getListeUtilisateurs($params); + return $reponse->getListeUtilisateursResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function setInfosLogin($login, $tabInfos) { + $params = new stdClass(); + $params->login = $login; + $params->tabInfoUserWS = $tabInfos; + $client = $this->loadClient('interne'); + try { + $reponse = $client->setInfosLogin($params); + return $reponse->seInfosLoginResult->result; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function getNextLogin($login = '') { + $params = new stdClass(); + $params->login = $login; + $client = $this->loadClient('interne'); + try { + $reponse = $client->getNextLogin($params); + return $reponse->getNextLoginResult; + } catch (SoapFault $fault) { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + return false; + } + } + + public function getInfosLogin($login, $ipUtilisateur = '') { + $params = new stdClass(); + $params->login = $login; + $params->ipUtilisateur = $ipUtilisateur; + $client = $this->loadClient('interne'); + try { + $reponse = $client->getInfosLogin($params); + return $reponse->getInfosLoginResult; + } catch (SoapFault $fault) { + if($fault->faultcode != '900') { + require_once 'soaperror.php'; + processSoapFault($client, $fault, $_SESSION['tabInfo']); + } + return false; + } + } + + protected function loadClient($webservice) { + $wsdl = $this->webservices['webservices.'.$webservice.'.wsdl']; + $options['trace'] = + isset($this->webservices['webservices.'.$webservice. + 'options.trace']) ? + $this->webservices['webservices.'.$webservice. + 'options.trace'] : false; + $options['soap_version'] = + isset($this->webservices['webservices.'.$webservice. + 'options.soap_version']) ? + $this->webservices['webservices.'.$webservice. + 'options.soap_version'] : SOAP_1_2; + $options['features'] = + isset($this->webservices['webservices.'.$webservice. + 'options.features']) ? + $this->webservices['webservices.'.$webservice. + 'options.features'] : ''; + $options['login'] = $this->login; + $options['password'] = $this->password; + try { + $client = new SoapClient($wsdl, $options); + } catch (SoapFault $f) { + require_once 'soaperror.php'; + print messageSoapFault(); + } + return $client; + } +} diff --git a/includes/scoresws/scoresws.php b/includes/scoresws/scoresws.php index 8e4b60548..7ca0898ce 100644 --- a/includes/scoresws/scoresws.php +++ b/includes/scoresws/scoresws.php @@ -140,7 +140,7 @@ function scoresws_annonces($siret, $siren, $idEntreprise, } else { $fileName = 'annonces-'.$siren; } - if ($vue != '') { + if ($vue != '' && $idan != false) { $fileName .= '-'.$idan; } cache_filename($fileName); @@ -161,7 +161,7 @@ function scoresws_annonces($siret, $siren, $idEntreprise, $o = new StdClass; $o->siren = $siren; $o->filtre = $filtre; - if ($idan !== false) { + if ($idan != false) { $o->idAnn = $idan; } //$o->position = ; @@ -321,7 +321,7 @@ function scoresws_listeBilans($siret, $siren, $idEntreprise, $mil) } else { $fileName = 'liasse-'.$siret; } - if ($mil !== false) { + if ($mil != false) { $indice = str_replace('/', '', substr($mil[0], 0, 11)); $fileName .= '-'.$indice; } @@ -349,7 +349,7 @@ function scoresws_listeBilans($siret, $siren, $idEntreprise, $mil) cache_delete(); cache_add('tabBilans', $tabBilans); - if ($mil !== false) { + if ($mil != false) { $o = new StdClass; $o->siren = $siren; $o->millesime = substr($mil[0], -10); @@ -390,25 +390,27 @@ function scoresws_indiscore($siret, $siren, $idEntreprise, $niveau = 2) $return = cache_get('etab'); } else { try { - $plus = false; - if (hasPerm('INDISCOREP') || hasPerm('INDISCORE2P') || hasPerm('INDISCORE3P')){ - $plus = true; - } + $plus = false; + if (hasPerm('INDISCOREP') || + hasPerm('INDISCORE2P') || + hasPerm('INDISCORE3P')) { + $plus = true; + } $params = new StdClass; $params->siren = $siren; if (strlen($siret) == 14) { $params->nic = substr($siret, 9); } - $params->accesDist = true; + $params->accesDist = true; if ($niveau != 2) { $params->niveau = $niveau; } - //$params->plus = $plus; - $O = $ws_soap_client_ent->getIndiscore($params); + $params->plus = $plus; + $O = $ws_soap_client_ent->getIndiScore($params); print '
';
 print_r($O);
 print '
'; - $return = $O->getIndiscoreResult->result; + $return = $O->getIndiScoreResult->result; cache_delete(); cache_add('etab', $return); } catch (SoapFault $f) { @@ -843,12 +845,20 @@ function scorews_setSurveillance($siret, $email, $ref = '', try { $o = new StdClass; - $o->siret = $siret; - $o->email = $email; - $o->ref = $ref; - $o->source = $source; - $o->delete = $delete; - $o->encoursClient = $encoursClient; + $o->siret = $siret; + $o->email = $email; + if ($ref != '') { + $o->ref = $ref; + } + if ($source != 'annonces') { + $o->source = $source; + } + if ($delete != false) { + $o->delete = $delete; + } + if ($encoursClient != 0) { + $o->encoursClient = $encoursClient; + } $O = $ws_soap_client_ent->__call('setSurveillance', array($o)); @@ -911,9 +921,13 @@ function scorews_searchMandataire($nom, $type = array(), $cpDep = 0) try { $o = new StdClass; - $o->nom = $nom; - $o->type = $type; - $o->cpDep = $cpDep; + $o->nom = $nom; + if (empty($type) == false) { + $o->type = $type; + } + if ($cpDep != 0) { + $o->cpDep = $cpDep; + } $O = $ws_soap_client_ent->__call('searchMandataire', array($o));