extranet/library/Giant/Search.lib.php

132 lines
4.3 KiB
PHP
Raw Normal View History

2011-04-19 15:59:50 +00:00
<?php
2011-06-27 16:34:26 +00:00
require_once 'Functions.php';
2011-04-19 15:59:50 +00:00
/**
* Module de recherche pour Giant V2
*
* @author Lasserre Damien
* @copyright Scores et decisions
*
*/
2011-06-27 16:34:26 +00:00
Class Search extends GiantFunction
2011-04-19 15:59:50 +00:00
{
/** Merci de respecter les fonctions WSDL **/
2011-06-27 16:34:26 +00:00
private $soapG;
protected $label;
protected $labelResults;
protected $query;
protected $methodes = array(
2011-04-19 15:59:50 +00:00
'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)
{
2011-06-27 16:34:26 +00:00
$this->soapG = $soap;
2011-04-19 15:59:50 +00:00
$this->label = new Zend_Config_Ini('Giant/Traductions/label.ini', 'search');
$this->labelResults = new Zend_Config_Ini('Giant/Traductions/results.ini', 'search');
2011-06-27 16:34:26 +00:00
$this->soapG->getAllMethodesFromWsdl('search');
2011-04-19 15:59:50 +00:00
$this->headerSearch = new stdClass();
$this->headerSearch->IncludePhoneticMatches = FALSE;
$this->headerSearch->IncludeSuggestions = FALSE;
2011-06-27 16:34:26 +00:00
parent::searchPaginator($paginatorAction);
2011-04-19 15:59:50 +00:00
}
/**
* Methode de recherche traite les informations retounrés par giant.
*
* @param unknown_type $paramatres
*/
protected function search($paramatres)
{
2011-06-27 16:34:26 +00:00
$searchParametre = new stdClass();
$searchParametre->Query = '';
$champQuery = array(
'raisonSociale', 'numero',
'voie', 'cpVille',
'telFax', 'naf'
2011-04-19 15:59:50 +00:00
);
2011-06-24 15:58:58 +00:00
$searchParametre->StartRow = $_SESSION['recherches']['giant']['page'];
2011-06-27 16:34:26 +00:00
$this->soapG->getAllMethodesFromWsdl('search');
2011-04-19 15:59:50 +00:00
foreach($paramatres as $champ => $parametre) {
if(!empty($parametre)) {
foreach($champQuery as $valeur) {
if($champ == $valeur)
$searchParametre->Query .= $parametre.' ';
}
}
}
$this->query = $searchParametre->Query;
2011-06-27 16:34:26 +00:00
$search = array_merge((array)$searchParametre, (array)$this->headerSearch);
try {
$result = $this->soapG->search($search);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();}
return ($result);
2011-04-19 15:59:50 +00:00
}
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;
2011-06-27 16:34:26 +00:00
}}}
2011-04-19 15:59:50 +00:00
$advancedParametres->Query = $TypeAdvanced;
$advanced = array_merge((array)$advancedParametres, (array)$this->headerSearch);
2011-06-27 16:34:26 +00:00
$this->query = $advancedParametres->Query->CompanyId;
try {
$result = $this->soapG->advancedSearch($advanced);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();}
return($result);
2011-04-19 15:59:50 +00:00
}
2011-06-27 16:34:26 +00:00
protected function Tier2Search($Query, $StartRow, $NumRows)
2011-04-19 15:59:50 +00:00
{
2011-06-27 16:34:26 +00:00
$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();}
2011-04-19 15:59:50 +00:00
}
2011-06-27 16:34:26 +00:00
public function Tier2SearchMethods()
2011-04-19 15:59:50 +00:00
{
2011-06-27 16:34:26 +00:00
try {
$result = $this->soapG->Tier2SearchMethods();
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
2011-04-19 15:59:50 +00:00
}
2011-06-27 16:34:26 +00:00
return ($result);
2011-04-19 15:59:50 +00:00
}
public function __destruct()
{
2011-06-27 16:34:26 +00:00
unset($this->soapG);
2011-04-19 15:59:50 +00:00
}
}