158 lines
5.2 KiB
PHP
158 lines
5.2 KiB
PHP
<?php
|
|
class WorldcheckController extends Zend_Controller_Action
|
|
{
|
|
protected $wcConfig;
|
|
|
|
public function init()
|
|
{
|
|
require_once 'WorldCheck/WsWorldCheck.php';
|
|
require_once 'WorldCheck/SessionWorldcheck.php';
|
|
require_once 'Scores/Cache.php';
|
|
|
|
$configWC = new Zend_Config_Ini(APPLICATION_PATH . '/../library/WorldCheck/applicationWC.ini');
|
|
$this->wcConfig = $configWC->worldcheck->toArray();
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function indexAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$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');
|
|
|
|
$user = new Scores_Utilisateur();
|
|
$session = new SessionWorldcheck();
|
|
$wc = new WsWorldCheck();
|
|
$wcLocal = new Application_Model_Worldcheck();
|
|
|
|
//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();
|
|
$localDBParams = $wcLocal->getScreenerId($param);
|
|
$param->matchCount = $localDBParams->matchCount;
|
|
$param->nameIdentifier = $localDBParams->nameIdentifier;
|
|
$session->setSession($param);
|
|
}
|
|
|
|
$nameIdentifier = $session->getNameIdentifier();
|
|
$matchCount = $session->getMatchCount();
|
|
|
|
if ($matchCount!==0)
|
|
{
|
|
$summary = new stdClass();
|
|
$summary->nameIdentifier = $nameIdentifier;
|
|
$summary->matchType = 'WATCHLIST';
|
|
|
|
$cache = new Cache();
|
|
$unfilteredWC = $cache->wcCache($this->wcConfig['cachedir'], $wc, "getSummariesArr", $summary, $nameIdentifier);
|
|
|
|
//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;
|
|
}
|
|
|
|
$filtres = array(
|
|
'tout' => array(
|
|
'txt'=>'Résultats par Nom',
|
|
'select'=>'',
|
|
'value' => 2,
|
|
),
|
|
'filtered' => array(
|
|
'txt'=>'Résultats précis',
|
|
'select'=>'',
|
|
'value' => 1,
|
|
)
|
|
);
|
|
|
|
$filtres[$filtre]['select'] = ' selected';
|
|
|
|
$this->view->assign('filtres', $filtres);
|
|
//end
|
|
|
|
//paginate results list
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('worldcheck/controls.phtml');
|
|
$paginator = Zend_Paginator::factory($resultWC);
|
|
$this->view->paginator = $paginator;
|
|
$itemCount = $this->wcConfig['page']['items'];
|
|
$page = $this->_getParam('page', 1);
|
|
$ol_number = ($page-1)*$itemCount+1;
|
|
|
|
$paginator->setCurrentPageNumber($page);
|
|
$paginator->setItemCountPerPage($itemCount);
|
|
|
|
$this->view->assign('ol_number', $ol_number);
|
|
$this->view->assign('itemCount', $itemCount);
|
|
//end
|
|
|
|
$this->view->assign('resultWC', $resultWC);
|
|
$this->view->assign('allMatches', $wc->getMatchesArrName($summary));
|
|
$this->view->assign('param', $param);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affichage le quantite des occurences de la bdd en popup.
|
|
*/
|
|
public function occurenceAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
|
|
if ( $request->isXmlHttpRequest() ) {
|
|
$this->_helper->layout()->disableLayout();
|
|
$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');
|
|
|
|
$wcLocal = new Application_Model_Worldcheck();
|
|
$this->view->assign('occurrence', $wcLocal->getCount($data));
|
|
$this->view->assign('data', $data);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Affichage le resultat de recherche en WorldCheck
|
|
*/
|
|
public function matchcontentAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
$session = new SessionWorldcheck();
|
|
|
|
$param = new stdClass();
|
|
$param->matchIdentifier = $request->getParam('matchIdentifier');
|
|
$param->nameType = $session->getNameType();
|
|
|
|
$wc = new WsWorldCheck();
|
|
|
|
$cache = new Cache();
|
|
$content = $cache->wcCache($this->wcConfig['cachedir'], $wc, "getDetailsContent", $param, $param->matchIdentifier);
|
|
|
|
$this->view->assign('matchIdentifier', $param->matchIdentifier);
|
|
$this->view->assign('content', $content);
|
|
$this->view->assign('nameType', $param->nameType);
|
|
$this->view->assign('exportObjet', $content);
|
|
}
|
|
} |