Issue #0001653: Remove access to worldcheck db from dirigeantController and IdentityController

This commit is contained in:
Aram HARUTYUNYAN 2013-09-12 12:13:17 +00:00
parent 397c481137
commit 4440bc8e6e
8 changed files with 115 additions and 84 deletions

View File

@ -34,28 +34,22 @@ class DirigeantController extends Zend_Controller_Action
$dirigeants = $infos->result->item;
$wcLocal = new Application_Model_Worldcheck();
$allOccurrences = $wcLocal->getCounts($dirigeants);
$user = new Scores_Utilisateur();
$session = new SessionEntreprise($this->siret, $this->id);
$user = new Scores_Utilisateur();
$permission = $user->getIdClient(); // change to $permission = $user->checkPerm('WORLDCHECK');
if ($user->checkPerm('dirigeantsop')){
$href = $this->view->url(array('controller'=>'dirigeant', 'action'=>'op', 'siret'=>$this->siret));
$this->view->assign('dirigeantsop', $href);
}
$this->view->assign('edition', $user->checkModeEdition());
$this->view->assign('allOccurrences', $allOccurrences);
$this->view->assign('permission', $user->checkPerm('WORLDCHECK'));
$this->view->assign('siren', $siren);
$this->view->assign('siret', $this->siret);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('dirigeants', $dirigeants);
$this->view->assign('exportObjet', $dirigeants);
$this->view->assign('permission', $permission);
$this->view->assign('AutrePage', $this->getRequest()->getParam('apage'));
$this->view->assign('surveillance', $user->checkPerm('survdirigeants'));

View File

@ -161,17 +161,6 @@ class IdentiteController extends Zend_Controller_Action
'texte' => $logo->affiche(),
);
$permission = $user->getIdClient(); // change to $permission = $user->checkPerm('WORLDCHECK');
$data = new stdClass();
$data->org->Nom = $infos->Nom;
$data->org->Societe = $infos->Nom;
$wcLocal = new Application_Model_Worldcheck();
$occurrence = $wcLocal->getCounts($data);
$this->view->assign('occurrence', $occurrence);
$this->view->assign('permission', $permission);
$this->view->assign('exportObjet', $infos);
$this->view->assign('dBlock', $dBlock);
$this->view->assign('logo', $logoImg);
@ -180,6 +169,7 @@ class IdentiteController extends Zend_Controller_Action
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('infos', $infos);
$this->view->assign('siret', $infos->Siret);
$this->view->assign('permission', $user->checkPerm('WORLDCHECK'));
$survDroits = array('survannonce', 'survinsee', 'survbilan', 'survscore', 'survactes', 'survdirigeants', 'survpriv');
$countSurvDroits = 0;

View File

@ -37,7 +37,7 @@ class WorldcheckController extends Zend_Controller_Action
$localDBParams = $wcLocal->getScreenerId($idClient, $login, $data);
$this->nameIdentifier = $localDBParams->nameIdentifier;
//Save nameIdentifier, name, matchCount into session
//Save nameIdentifier, name, nameType into session
$wcheck = new stdClass();
$wcheck->screenerNameIdentifier = $this->nameIdentifier;
$wcheck->screenerName = $param->dirNom;
@ -93,7 +93,7 @@ class WorldcheckController extends Zend_Controller_Action
'value' => 2,
),
'filtered' => array(
'txt'=>'Résultats par Nom et Prénom',
'txt'=>'Résultats précis',
'select'=>'',
'value' => 1,
)
@ -124,6 +124,34 @@ class WorldcheckController extends Zend_Controller_Action
}
}
/**
* Affichage le quantite des occurences de la bdd en popup.
* Changer le couleur de l'icone WorldCheck en gris, s'il n'y a pas d'occurence
*/
public function occurenceAction()
{
$request = $this->getRequest();
if ( $request->isXmlHttpRequest() ) {
//use in future if Ajax call needed
} else {
$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();
$occurrence = $wcLocal->getCount($data);
$this->view->assign('occurrence', $occurrence);
$this->view->assign('data', $data);
}
}
/**
* Affichage le resultat de recherche en WorldCheck
*/
public function matchcontentAction()
{
$request = $this->getRequest();

View File

@ -40,29 +40,31 @@ class Application_Model_Worldcheck extends Zend_Db_Table_Abstract
}
/**
* Return array of names with matchCount
* @param object $data (Nom, Societe)
* @return array
* Return matchCount of name
* @param object $data (Nom, Prenom, Societe, Type)
* @return int
*/
public function getCounts($data)
public function getCount($data)
{
$allOccurences = array();
foreach ($data as $dir)
if (isset($data->Societe) && $data->Societe!='')
{
$nameType = (isset($dir->Societe) && $dir->Societe!='')?'ORGANISATION':'INDIVIDUAL';
$sql = $this->select()
->where("name='".$dir->Nom."' AND nameType='".$nameType."' AND LEFT(nameIdentifier, 3)='so_'")
->group('name');
$matchCount = NULL;
if ($this->fetchRow($sql))
{
$result=$this->fetchRow($sql);
$matchCount = $result->matchCount;
}
$allOccurences[$dir->Nom] = $matchCount;
$nameType = 'ORGANISATION';
$name = $data->Societe;
}
return $allOccurences;
else {
$nameType = 'INDIVIDUAL';
$name = $data->Nom;
}
$sql = $this->select()
->where("name='".$name."' AND nameType='".$nameType."' AND LEFT(nameIdentifier, 3)='so_'")
->group('name');
if ($this->fetchRow($sql))
{
$result=$this->fetchRow($sql);
return $result->matchCount;
}
return false;
}
}

View File

@ -88,6 +88,18 @@ div.img {background:url(/themes/default/images/worldcheck/wc.png) no-repeat; hei
<?php } ?>
<?php } ?>
</td>
<?php if($this->permission) { ?>
<td>
<?php
if ($dir->Societe != '') {
echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$dir->Societe, 'dirType' =>'ORGANISATION'));
}
if ($dir->Nom != '') {
echo $this->action('occurence','worldcheck', null, array('dirNom'=>$dir->Nom, 'dirPrenom'=>$dir->Prenom, 'dirType' =>'INDIVIDUAL'));
}
?>
</td>
<?php } ?>
<td class="StyleInfoData" width="100" valign="top">
<?php if ($dir->Siren!='') {?>
<a title="Consulter la fiche identité" href="<?=$this->url(array('controller'=>'identite', 'action'=>'fiche', 'siret'=>$dir->Siren))?>">

View File

@ -32,45 +32,7 @@
<?php }?>
<?php }?>
<div style='margin-right:10px; float:right'>
<?php if($this->permission==1) { ?>
<?php
foreach ($this->occurrence as $organisation => $count){
if ($count===NULL) {
$qtipContent = "WorldCheck<br/>Cliquez sur l&rsquo;icone WorldCheck";
} else {
$qtipContent = "WorldCheck<br/>Occurrences: ".$count;
}
?>
<a class='wcheck' tooltip='<?=$qtipContent ?>' href="<?=$this->url(array(
'controller' => 'worldcheck',
'action' => 'index',
'dirNom' => $organisation,
'dirType' => 'ORGANISATION'), null, true)?>" style="cursor: pointer;" >
<div class='txt'>WorldCheck&nbsp;</div> <div id='<?=$count;?>' class='img'></div></a><br/>
<?php }?>
</div>
<style>
div.img {background:url(/themes/default/images/worldcheck/wc.png) no-repeat; height:25px; width:25px; float:left;}
div.txt {line-height:25px; float:left;}
</style>
<script>
$(document).ready(function(){
$('a.wcheck div').each(function(){
if ($(this).attr('id')=='0') {
$(this).css("backgroundImage", 'url(/themes/default/images/worldcheck/wc0.png)');
}
});
});
$('a.wcheck').each(function(){
$(this).qtip({
content: $(this).attr('tooltip'),
position: { at: "right center", my: "bottom left" }
});
});
</script>
<?php }?>
<?php if ( empty($this->AutrePage) ) {?>
<h1 class="titre">FICHE D'IDENTIT&Eacute;</h1>
<?php }?>
@ -96,6 +58,9 @@ echo $this->partial('identite/fiche-item.phtml', $this->dBlock['AutreSiren']);
<h2>Raison sociale &amp; Coordonnées</h2>
<div class="paragraph">
<div style="float:right;">
<?php if($this->permission) echo $this->action('occurence','worldcheck', null, array('dirSociete'=>$this->infos->Nom, 'dirType' =>'ORGANISATION'));?>
</div>
<table>
<?php
echo $this->partial('identite/fiche-item.phtml', $this->dBlock['RaisonSociale']);

View File

@ -2,6 +2,7 @@
<h1>World-Check</h1>
<div id="center-recherche" style='margin-left: 10px; margin-right:10px'>
<?php if ($this->filtres) { ?>
<?php if ($this->param->dirType =='INDIVIDUAL') {?>
<div style='float:right;'>
<select name="filtre">
<?php foreach ($this->filtres as $k => $filtre) {?>
@ -9,13 +10,14 @@
<?php }?>
</select>
</div>
<?php }?>
<?php }?>
<script type="text/javascript">
$('select[name=filtre]').change(function(e){
window.location = $(this).val();
});
</script>
</div>
<?php }?>
<?php
if (!$this->resultWC)
{

View File

@ -0,0 +1,38 @@
<?php if ($this->data->Type) {?>
<?php
if ($this->occurrence===false) {
$qtipContent = "WorldCheck<br/>Cliquez sur l&rsquo;icone WorldCheck";
} else {
$qtipContent = "WorldCheck<br/>Occurrences: ".$this->occurrence;
}
$params = array(
'controller' => 'worldcheck',
'action' => 'index',
'dirNom' => $this->data->Nom,
'dirPrenom' => $this->data->Prenom,
'dirSociete' => $this->data->Societe,
'dirType' => $this->data->Type);
?>
<a class='wcheck' tooltip='<?=$qtipContent ?>' href="<?=$this->url($params, null, true)?>" style="cursor: pointer;" >
<div id='_<?=$this->occurrence;?>' class='img'></div></a><br/>
<style>
div.img {background:url(/themes/default/images/worldcheck/wc.png) no-repeat; height:25px; width:25px; float:left;}
</style>
<script>
$(document).ready(function(){
$('a.wcheck div').each(function(){
if ($(this).attr('id')=='_0') {
$(this).css("backgroundImage", 'url(/themes/default/images/worldcheck/wc0.png)');
}
});
});
$('a.wcheck').qtip({
content: $('a.wcheck').attr('tooltip'),
position: { at: "right center", my: "bottom left" }
});
</script>
<?php } else {}?>