extranet/application/controllers/WorldcheckController.php

158 lines
5.2 KiB
PHP
Raw Normal View History

2013-07-30 08:26:23 +00:00
<?php
class WorldcheckController extends Zend_Controller_Action
{
2013-10-04 12:41:24 +00:00
protected $wcConfig;
2013-07-30 08:26:23 +00:00
public function init()
{
2013-09-23 08:47:30 +00:00
require_once 'WorldCheck/WsWorldCheck.php';
2013-09-16 15:41:31 +00:00
require_once 'WorldCheck/SessionWorldcheck.php';
2013-10-04 12:41:24 +00:00
require_once 'Scores/Cache.php';
$configWC = new Zend_Config_Ini(APPLICATION_PATH . '/../library/WorldCheck/applicationWC.ini');
$this->wcConfig = $configWC->worldcheck->toArray();
2013-07-30 08:26:23 +00:00
}
/**
2013-09-23 08:47:30 +00:00
*
2013-07-30 08:26:23 +00:00
*/
public function indexAction()
{
$request = $this->getRequest();
2013-09-16 15:41:31 +00:00
$param = new stdClass();
$dirNom = $request->getParam('dirNom');
$param->dirNom = ($dirNom)?$dirNom:$request->getParam('dirSociete');
$param->dirPrenom = $request->getParam('dirPrenom');
$param->dirType = $request->getParam('dirType');
$param->Siren = $request->getParam('siren');
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$user = new Scores_Utilisateur();
$session = new SessionWorldcheck();
$wc = new WsWorldCheck();
$wcLocal = new Application_Model_Worldcheck();
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
//check worldcheck data correctness in the session
if (!$session->getName() || $session->getName()!=$param->dirNom || substr($session->getNameIdentifier(),0,3)!='so_' || $session->getNameType()!=$param->dirType)
{
$param->idClient = $user->getIdClient();
$param->login = $user->getLogin();
2013-09-23 08:47:30 +00:00
$localDBParams = $wcLocal->getScreenerId($param);
2013-09-16 15:41:31 +00:00
$param->matchCount = $localDBParams->matchCount;
$param->nameIdentifier = $localDBParams->nameIdentifier;
$session->setSession($param);
}
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$nameIdentifier = $session->getNameIdentifier();
$matchCount = $session->getMatchCount();
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
if ($matchCount!==0)
{
$summary = new stdClass();
$summary->nameIdentifier = $nameIdentifier;
$summary->matchType = 'WATCHLIST';
2013-10-04 12:41:24 +00:00
$cache = new Cache();
$unfilteredWC = $cache->wcCache($this->wcConfig['cachedir'], $wc, "getSummariesArr", $summary, $nameIdentifier);
2013-09-16 15:41:31 +00:00
//check if display all results (search by lastName), or filtered results (search by fullName)
$filtre = $request->getParam('filtre', 'tout');
$resultWC = $unfilteredWC;
if ($filtre=='filtered')
{
//get results by fullName (lastName and givenName)
$filteredWC = array();
foreach ($unfilteredWC as $entityId=>$shortData)
{
if (stripos($shortData->lastName, $param->dirNom)!==false || stripos($param->dirNom, $shortData->lastName)!==false) {
if (stripos($shortData->givenName, $param->dirPrenom)!==false || stripos($param->dirPrenom, $shortData->givenName)!==false) {
$filteredWC[$entityId] = $shortData;
}
}
}
//end
$resultWC = $filteredWC;
}
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$filtres = array(
'tout' => array(
'txt'=>'Résultats par Nom',
'select'=>'',
'value' => 2,
),
'filtered' => array(
'txt'=>'Résultats précis',
'select'=>'',
'value' => 1,
)
);
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$filtres[$filtre]['select'] = ' selected';
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$this->view->assign('filtres', $filtres);
//end
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
//paginate results list
Zend_View_Helper_PaginationControl::setDefaultViewPartial('worldcheck/controls.phtml');
$paginator = Zend_Paginator::factory($resultWC);
$this->view->paginator = $paginator;
2013-10-04 12:41:24 +00:00
$itemCount = $this->wcConfig['page']['items'];
2013-09-16 15:41:31 +00:00
$page = $this->_getParam('page', 1);
$ol_number = ($page-1)*$itemCount+1;
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage($itemCount);
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$this->view->assign('ol_number', $ol_number);
$this->view->assign('itemCount', $itemCount);
//end
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$this->view->assign('resultWC', $resultWC);
$this->view->assign('allMatches', $wc->getMatchesArrName($summary));
$this->view->assign('param', $param);
}
2013-09-23 08:47:30 +00:00
}
2013-09-16 15:41:31 +00:00
/**
* Affichage le quantite des occurences de la bdd en popup.
*/
public function occurenceAction()
2013-09-23 08:47:30 +00:00
{
2013-09-16 15:41:31 +00:00
$request = $this->getRequest();
2013-09-23 08:47:30 +00:00
if ( $request->isXmlHttpRequest() ) {
$this->_helper->layout()->disableLayout();
2013-09-16 15:41:31 +00:00
$data = new stdClass();
if ($request->getParam('dirType')) $data->Type = $request->getParam('dirType');
if ($request->getParam('dirNom')) $data->Nom = $request->getParam('dirNom');
if ($request->getParam('dirPrenom')) $data->Prenom = $request->getParam('dirPrenom');
if ($request->getParam('dirSociete')) $data->Societe = $request->getParam('dirSociete');
2013-07-30 08:26:23 +00:00
2013-09-23 08:47:30 +00:00
$wcLocal = new Application_Model_Worldcheck();
$this->view->assign('occurrence', $wcLocal->getCount($data));
2013-09-23 15:26:02 +00:00
$this->view->assign('data', $data);
2013-09-16 15:41:31 +00:00
}
2013-07-30 08:26:23 +00:00
}
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
/**
* Affichage le resultat de recherche en WorldCheck
*/
public function matchcontentAction()
2013-09-23 08:47:30 +00:00
{
2013-09-16 15:41:31 +00:00
$request = $this->getRequest();
$session = new SessionWorldcheck();
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$param = new stdClass();
$param->matchIdentifier = $request->getParam('matchIdentifier');
$param->nameType = $session->getNameType();
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$wc = new WsWorldCheck();
2013-10-04 12:41:24 +00:00
$cache = new Cache();
$content = $cache->wcCache($this->wcConfig['cachedir'], $wc, "getDetailsContent", $param, $param->matchIdentifier);
2013-09-23 08:47:30 +00:00
2013-09-16 15:41:31 +00:00
$this->view->assign('matchIdentifier', $param->matchIdentifier);
$this->view->assign('content', $content);
2013-09-23 15:26:02 +00:00
$this->view->assign('nameType', $param->nameType);
2013-10-04 12:41:24 +00:00
$this->view->assign('exportObjet', $content);
2013-07-30 08:26:23 +00:00
}
}