extranet/application/controllers/GiantController.php

153 lines
4.4 KiB
PHP
Raw Normal View History

2011-04-15 12:40:29 +00:00
<?php
2011-04-19 15:59:50 +00:00
require_once ('Giant/WSgiant.php');
require_once ('Giant/Search.lib.php');
2011-04-26 13:39:19 +00:00
/**
* 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
*
*/
2011-04-15 12:40:29 +00:00
class GiantController extends Zend_Controller_Action
{
2011-04-19 15:59:50 +00:00
protected $soapClient;
protected $Provider;
protected $TestIndication;
protected $user;
2011-04-15 12:40:29 +00:00
2011-04-19 15:59:50 +00:00
protected $language;
protected $labelResults;
2011-04-26 13:39:19 +00:00
/**
* Permet de gerer la liste des pays.
*
* @var unknown_type
*/
2011-04-19 15:59:50 +00:00
protected $ListAuthorized = array(
'FR' => '006', 'BE' => '001', 'ES' => '001',
'UK' => '003', 'NL' => '002');
2011-04-15 12:40:29 +00:00
2011-04-26 13:39:19 +00:00
/**
* Paramêtres d'initialisation de la class
*
* @see Zend_Controller_Action::init()
*/
2011-04-19 15:59:50 +00:00
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']))
$_SESSION['recherche']['giant'] = $this->getRequest()->getParams();
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);
self::setCountryCode($_SESSION['recherche']['giant']['pays']);
$this->soapClient = new WSgiant($this->Provider);
2011-04-15 12:40:29 +00:00
}
2011-04-19 15:59:50 +00:00
public function indexAction()
{
$siret = $this->getRequest()->getParam('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);
$this->view->assign('resultats', $search
->getMethode('search', $_SESSION['recherche']['giant'])
);
$this->view->assign('referer', $search->getQuery());
}
2011-04-26 13:39:19 +00:00
/**
* Advanced search et la methode de chez giant pour des recherches affinées
*
*/
2011-04-19 15:59:50 +00:00
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);
$this->view->assign('resultats', $advanced
->getMethode('advancedSearch', $_SESSION['recherche']['giant'])
);
$this->view->assign('referer', $advanced->getQuery());
$this->render('search');
}
2011-04-26 13:39:19 +00:00
/**
* Fonction permettant de receuillir de par la recherche quelque infos
* pour une sommaire fiche d'identité.
*
* En utilisant l'advanced seaarch.
*/
2011-04-21 15:04:27 +00:00
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)
);
}
2011-04-19 15:59:50 +00:00
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 __destrcut()
{
unset($_SESSION['recherche']['giant']);
}
2011-04-15 12:40:29 +00:00
}