173 lines
4.9 KiB
PHP
173 lines
4.9 KiB
PHP
<?php
|
|
require_once ('Giant/WSgiant.php');
|
|
require_once ('Giant/Search.lib.php');
|
|
|
|
/**
|
|
* Cette classe gere les méthodes de Giant le nom des méthode de cette classe
|
|
* doivent êtres en correlation avec les méthodes de giant.
|
|
*
|
|
*
|
|
* @author Lasserre Damien
|
|
*
|
|
*/
|
|
class GiantController extends Zend_Controller_Action
|
|
{
|
|
protected $soapClient;
|
|
protected $Provider;
|
|
protected $TestIndication;
|
|
protected $user;
|
|
|
|
protected $language;
|
|
protected $labelResults;
|
|
|
|
/**
|
|
* Permet de gerer la liste des pays.
|
|
*
|
|
* @var unknown_type
|
|
*/
|
|
protected $ListAuthorized = array(
|
|
'FR' => '006', 'BE' => '001', 'ES' => '001',
|
|
'UK' => '003', 'NL' => '002');
|
|
|
|
/**
|
|
* Paramêtres d'initialisation de la class
|
|
*
|
|
* @see Zend_Controller_Action::init()
|
|
*/
|
|
public function init()
|
|
{
|
|
/** @todo provisoir **/
|
|
$auth = Zend_Auth::getInstance();
|
|
$this->user = $auth->getIdentity();
|
|
$this->view->headLink()->appendStylesheet('/themes/default/styles/giant.css', 'all');
|
|
|
|
if (!isset($_SESSION['recherche']['giant']['page']))
|
|
$_SESSION['recherche']['giant']['page'] = 0;
|
|
if (!isset($_SESSION['recherche']['giant']['nbResults']))
|
|
$_SESSION['recherche']['giant']['nbResults'] = 0;
|
|
|
|
self::setTestIndication(true); // ! Important en DEV !
|
|
self::setCountryCode($_SESSION['recherche']['giant']['pays']);
|
|
$this->soapClient = new WSgiant($this->Provider);
|
|
|
|
}
|
|
|
|
public function indexAction()
|
|
{
|
|
|
|
$rechercheParams = new RechercheHistorique();
|
|
if (count($rechercheParams->liste())>0){
|
|
$recherche = $rechercheParams->item(0);
|
|
$type = $recherche['type'];
|
|
$params = $recherche['params'];
|
|
}
|
|
$siret = $params['siret'];
|
|
|
|
if(empty($siret))
|
|
$this->_forward('search');
|
|
else
|
|
$this->_forward('advanced');
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Action Search
|
|
*/
|
|
public function searchAction()
|
|
{
|
|
$search = new Search($this->soapClient,
|
|
$this->getRequest()->getParam('page'));
|
|
|
|
$this->view->assign('label', $search->getLabelDesc());
|
|
$this->view->assign('labelResults', $search->getLabelResults);
|
|
|
|
$this->view->assign('pays', self::getCountryCode());
|
|
$this->view->assign('currentPage', $_SESSION['recherche']['giant']['page']);
|
|
$this->view->assign('userMaxResult', $this->user->nbReponses);
|
|
|
|
$rechercheParams = new RechercheHistorique();
|
|
if (count($rechercheParams->liste())>0){
|
|
$recherche = $rechercheParams->item(0);
|
|
$type = $recherche['type'];
|
|
$params = $recherche['params'];
|
|
}
|
|
|
|
$this->view->assign('resultats', $search->getMethode('search', $params) );
|
|
$this->view->assign('referer', $search->getQuery());
|
|
}
|
|
|
|
/**
|
|
* Advanced search et la methode de chez giant pour des recherches affinées
|
|
*
|
|
*/
|
|
public function advancedAction()
|
|
{
|
|
$advanced = new Search($this->soapClient,
|
|
$this->getRequest()->getParam('page'));
|
|
$this->view->assign('pays', self::getCountryCode());
|
|
$this->view->assign('currentPage', $_SESSION['recherche']['giant']['page']);
|
|
$this->view->assign('userMaxResult', $this->user->nbReponses);
|
|
|
|
$rechercheParams = new RechercheHistorique();
|
|
if (count($rechercheParams->liste())>0){
|
|
$recherche = $rechercheParams->item(0);
|
|
$type = $recherche['type'];
|
|
$params = $recherche['params'];
|
|
}
|
|
|
|
$this->view->assign('resultats', $advanced->getMethode('advancedSearch', $params));
|
|
|
|
$this->view->assign('referer', $advanced->getQuery());
|
|
$this->render('search');
|
|
}
|
|
|
|
/**
|
|
* Fonction permettant de receuillir de par la recherche quelque infos
|
|
* pour une sommaire fiche d'identité.
|
|
*
|
|
* En utilisant l'advanced seaarch.
|
|
*/
|
|
public function companyidentitieAction()
|
|
{
|
|
$companyIdentitie = new Search($this->soapClient, EOF);
|
|
|
|
$this->view->assign('pays', self::getCountryCode());
|
|
$siret = new stdClass();
|
|
$siret->siret = $this->getRequest()->getParam('companyId');
|
|
|
|
$this->view->assign('resultats', $companyIdentitie
|
|
->getMethode('advancedSearch', $siret)
|
|
);
|
|
}
|
|
|
|
public function setCountryCode($CountryCode)
|
|
{
|
|
if(array_key_exists($CountryCode, $this->ListAuthorized))
|
|
{
|
|
$this->Provider->CountryCode = $CountryCode;
|
|
self::setProviderId($this->ListAuthorized[$CountryCode]);
|
|
}
|
|
}
|
|
|
|
private function setProviderId($ProviderId) {
|
|
$this->Provider->ProviderId = $ProviderId;
|
|
}
|
|
|
|
public function setTestIndication($bool) {
|
|
if (is_bool($bool))
|
|
$this->TestIndication = $bool;
|
|
}
|
|
|
|
public function getCountryCode() {
|
|
return ($this->Provider->CountryCode);
|
|
}
|
|
|
|
public function getProviderId() {
|
|
return ($this->Provider->ProviderId);
|
|
}
|
|
|
|
public function __destruct()
|
|
{
|
|
unset($_SESSION['recherche']['giant']);
|
|
}
|
|
} |