extranet/library/Giant/Search.lib.php
Damien LASSERRE c269262d5a Giant !
2011-06-27 16:34:26 +00:00

132 lines
4.3 KiB
PHP

<?php
require_once 'Functions.php';
/**
* Module de recherche pour Giant V2
*
* @author Lasserre Damien
* @copyright Scores et decisions
*
*/
Class Search extends GiantFunction
{
/** Merci de respecter les fonctions WSDL **/
private $soapG;
protected $label;
protected $labelResults;
protected $query;
protected $methodes = array(
'search',
'advancedSearch'
);
/** Parametres de paginations **/
private $headerSearch;
private $nbOfResults;
/**
* Permet de construire l'objet avec des paramêtres (init)
*
* @param unknown_type $soap
* @param unknown_type $paginatorAction
*/
public function __construct($soap, $paginatorAction = null)
{
$this->soapG = $soap;
$this->label = new Zend_Config_Ini('Giant/Traductions/label.ini', 'search');
$this->labelResults = new Zend_Config_Ini('Giant/Traductions/results.ini', 'search');
$this->soapG->getAllMethodesFromWsdl('search');
$this->headerSearch = new stdClass();
$this->headerSearch->IncludePhoneticMatches = FALSE;
$this->headerSearch->IncludeSuggestions = FALSE;
parent::searchPaginator($paginatorAction);
}
/**
* Methode de recherche traite les informations retounrés par giant.
*
* @param unknown_type $paramatres
*/
protected function search($paramatres)
{
$searchParametre = new stdClass();
$searchParametre->Query = '';
$champQuery = array(
'raisonSociale', 'numero',
'voie', 'cpVille',
'telFax', 'naf'
);
$searchParametre->StartRow = $_SESSION['recherches']['giant']['page'];
$this->soapG->getAllMethodesFromWsdl('search');
foreach($paramatres as $champ => $parametre) {
if(!empty($parametre)) {
foreach($champQuery as $valeur) {
if($champ == $valeur)
$searchParametre->Query .= $parametre.' ';
}
}
}
$this->query = $searchParametre->Query;
$search = array_merge((array)$searchParametre, (array)$this->headerSearch);
try {
$result = $this->soapG->search($search);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();}
return ($result);
}
public function advancedSearch($parametres)
{
$advancedParametres = new stdClass();
$TypeAdvanced = new stdClass();
$labelForm = array(
'siret' => 'CompanyId',
'raisonSociale' => 'RegisteredName',
'numero' => 'HouseNumber',
'voie' => 'Street',
'cpVille' => 'City'
);
foreach ($parametres as $champ => $parametre) {
if (!empty($parametre)) {
foreach ($labelForm as $nameForm => $valeur) {
if ($champ == $nameForm)
$TypeAdvanced->$valeur = $parametre;
}}}
$advancedParametres->Query = $TypeAdvanced;
$advanced = array_merge((array)$advancedParametres, (array)$this->headerSearch);
$this->query = $advancedParametres->Query->CompanyId;
try {
$result = $this->soapG->advancedSearch($advanced);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();}
return($result);
}
protected function Tier2Search($Query, $StartRow, $NumRows)
{
$parametres = new stdClass();
$parametres->Query = $Query;
$parametres->StartRow = $StartRow;
$parametres->NumRows = $NumRows;
try {
$this->soapG->Tier2Search($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();}
}
public function Tier2SearchMethods()
{
try {
$result = $this->soapG->Tier2SearchMethods();
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
public function __destruct()
{
unset($this->soapG);
}
}