Nombreuses améliorations

This commit is contained in:
Michael RICOIS 2012-05-15 11:38:51 +00:00
parent 92d20339f7
commit b939e9604e
17 changed files with 286 additions and 313 deletions

View File

@ -5,7 +5,11 @@ class ArborescenceController extends Zend_Controller_Action
public function nafAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$request = $this->getRequest();
$key = $request->getParam('key');
$object = new Object_Naf();
@ -62,8 +66,8 @@ class ArborescenceController extends Zend_Controller_Action
{
$this->_helper->layout()->disableLayout();
$object = new Object_Formejuridique();
$key = $this->getRequest()->getParam('key');
$object = new Object_Formejuridique();
$key = $this->getRequest()->getParam('key');
$this->view->key = $key;
$this->view->formejuridiques = $object->_getParents();
@ -77,7 +81,7 @@ class ArborescenceController extends Zend_Controller_Action
$request = $this->getRequest();
$id = $request->getParam('id');
echo ($object->_getFils($id));
echo $object->_getFils($id);
}
}

View File

@ -14,7 +14,6 @@ class DashboardController extends Zend_Controller_Action
$this->view->comptages = $object->index();
$this->view->enrichissements = $object->enrichissements();
}
public function ciblagesAction()
@ -29,18 +28,55 @@ class DashboardController extends Zend_Controller_Action
public function ciblageAction()
{
require_once('Scores/Field.php');
$object = new Object_Dashboard();
$request = $this->getRequest();
$comptage = $object->ciblagedetail($request->getParam('id'));
$enrichissement = $object->enrichissement($request->getParam('id'));
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$this->view->comptageId = $request->getParam('id');
$this->view->label = new Fields();
$this->view->criteres = $comptage['criteres'];
$this->view->comptages = $comptage['comptages'];
$this->view->enrichissements = $enrichissement;
$this->view->pathfile = $config->path->data;
$comptageId = $request->getParam('id');
$fields = new Scores_Fields();
//Lecture des paramètres du ciblage
$criteresM = new Application_Model_Criteres();
$sql = $criteresM->select()
->where('idClient = ?', $user->idClient)
->where('login = ?', $user->username)
->where('id = ?', $comptageId);
$criteres = $criteresM->fetchRow($sql)->toArray();
$infosCriteres = array();
if ($criteres != null) {
$decodeCriteres = json_decode($criteres['criteres'], true);
//Construction affichage des critères
foreach ( $decodeCriteres as $key => $item ) {
//Add label to struct for display
$infosCriteres[] = array(
'label' => $fields->getLabel($key),
'in' => $item['in'],
'ex' => $item['ex'],
);
}
//Lecture des comptages
$comptageM = new Application_Model_Comptages();
$sql = $comptageM->select()
->where('idDefinition = ?', $comptageId)
->order('dateAjout DESC');
$comptages = $comptageM->fetchAll($sql)->toArray();
Zend_Registry::get('firebug')->info($comptages[0]);
//Lecture enrichissement existe
//Affichage
$this->view->comptageId = $comptageId;
$this->view->criteres = $infosCriteres;
$this->view->comptages = $comptages;
$this->view->enrichissements = $enrichissement;
}
}
public function rcomptageAction()

View File

@ -104,15 +104,20 @@ class EnrichissementController extends Zend_Controller_Action
$criteres = $criteresRow->current();
$structure = json_decode($criteres->criteres, true);
require_once 'Scores/Field.php';
$field = new Fields();
$values = $field->getValues($structure);
//Récupération des SIRET
require_once 'Scores/Ciblage.php';
$ciblage = new Ciblage($values, true);
$ciblage = new Ciblage($structure, true);
$infosExtraction = $ciblage->execute(true);
/*
* @todo :
* Vérifier le nombre d'éléments avec le nombre de ligne
*
*
*/
//Attention calcul uniteInsee réelle
//car si donnée insee alors toutes les lignes doivent être comptés en unité insee
$data = array(
@ -125,13 +130,13 @@ class EnrichissementController extends Zend_Controller_Action
'fichier' => '',
'nbLigneTotales' => count($infosExtraction),
'nbLigneTraites' => 0,
'uniteInsee' => $ciblage->calculRedevanceInsee(),
'uniteInsee' => $result['uniteInsee'],
'error' => '',
'dateAdded' => date('YmdHms'),
);
$identifiantsM = new Application_Model_EnrichissementIdentifiants();
$idIdentifiant = $identifiantsM->insert($data);
exec('php '.APPLICATION_PATH.'/../batch/enrichissement.php --id '.$idIdentifiant);
//exec('php '.APPLICATION_PATH.'/../batch/enrichissement.php --id '.$idIdentifiant);
}
/**
@ -177,10 +182,9 @@ class EnrichissementController extends Zend_Controller_Action
$sql = $criteres->select()->where('id = ?', $idCritere);
$result = $criteres->fetchRow($sql)->toArray();
$criteres = json_decode($result['criteres'], true);
require_once('Scores/Field.php');
require_once('Scores/Ciblage.php');
$field = new Fields();
$count = new Ciblage($field->getValues($criteres));
require_once 'Scores/Ciblage.php';
$count = new Ciblage($criteres);
$item['resultat'] = $count->execute();
$item['uniteInsee'] = $count->calculRedevanceInsee();
}

View File

@ -29,18 +29,20 @@ class GeographiqueController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
if($request->getParam('dep')) {
$output = $this->completedDep($request->getParam('q'));
} else if ($request->getParam('reg')) {
$output = $this->completedReg($request->getParam('q'));
} else if($request->getParam('vil')) {
$output = $this->completedVil($request->getParam('q'));
}else if($request->getParam('adr_com')) {
$output = $this->completedVil($request->getParam('q'));
}else if($request->getParam('adr_com_ex')) {
$output = $this->completedVil($request->getParam('q'));
$q = $request->getParam('q');
//Région
$output = $this->completedReg($q);
//Département
if ( count($output)==0 ) {
$output = $this->completedDep($q);
}
//Ville
if ( count($output)==0 ) {
$output = $this->completedVil($q);
}
echo json_encode($output);
}
@ -49,8 +51,7 @@ class GeographiqueController extends Zend_Controller_Action
$separator = ' , ';
$table = new Application_Model_Departements();
$sql = $table->select()
->where('libdep LIKE "'.$q.'%"');
$sql = $table->select()->where('libdep LIKE "'.$q.'%"');
$result = $table->fetchAll($sql);
foreach ($result as $item) {
$output[] = array(

View File

@ -14,7 +14,7 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$html = '';
$label = $labelG = $fields->getLibelle($name);
$label = $labelG = $fields->getLabel($name);
//How many type of fields is defined
$nbFields = count($params['fields']);

View File

@ -1,25 +1,20 @@
<ul class="chemin clearfix rounded_t">
<li class="e0"><a class="lir" href="/">Accueil</a></li>
<li><a href="/dashboard/index"><span>Tableau de bord</span></a></li>
<li class="last"><span>Detail du ciblage</span></li>
</ul>
<div id="dashboard" style="padding:10px">
<a href="/dashboard/index">Tableau de bord</a> > Detail du ciblage<br /><br />
<a class="update" href="<?=$this->url(array('controller'=> 'comptage','action'=>'update', 'id'=>$this->comptageId))?>">Actualiser</a> |
<a href="<?=$this->url(array('controller'=> 'index','action'=>'index', 'id'=>$this->comptageId))?>">Recharger les critères de ciblage</a> |
<a class="update" href="<?=$this->url(array('controller'=> 'comptage','action'=>'update', 'id'=>$this->comptageId))?>">Actualiser</a> |
<a href="<?=$this->url(array('controller'=> 'index','action'=>'index', 'id'=>$this->comptageId))?>">Recharger les critères de ciblage</a> |
<a class="enrichissementref" href="<?=$this->url(array('controller'=> 'enrichissement','action'=>'reference', 'id'=>$this->comptageId))?>">Enrichissement</a>
<fieldset>
<legend>Critères</legend>
<?php foreach(json_decode($this->criteres['criteres'], true) as $critere => $valeur): ?>
<?php if(!empty($valeur) and $valeur != ',' and !empty($critere)): ?>
<?php $label = $this->label->get($critere); ?>
<?php if(!is_array($valeur)): ?>
<?php if($label['type'] != 'textarea' and $label['type'] != 'interval') :?>
<?php echo '<b>'.$label['label'] . '</b> : '.$label['fields'][$label['type']]['value'][$valeur];?><br />
<?php else: ?>
<?php echo '<b>'.$label['label'] . '</b>:'.$valeur; ?><br />
<?php endif; ?>
<?php else:?>
<?php echo '<b>'.$label['label'] .'</b> : '. implode(',', $valeur).'<br />'; ?>
<?php endif; ?>
<?php endif; ?>
<?php endforeach;?>
<pre>
<?php print_r($this->criteres)?>
</pre>
</fieldset>
<fieldset>
@ -47,7 +42,7 @@
<fieldset>
<legend>Enrichissements</legend>
<?php if ( count($this->enrichissements)>0 ) {?>
<?php if ( count($this->enrichissements)>0 ) {?>
<table style="width:100%">
<thead>
<tr>

View File

@ -1,9 +1,16 @@
<div id="dashboard">
<ul class="chemin clearfix rounded_t">
<li class="e0"><a class="lir" href="/">Accueil</a></li>
<li>
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'index'))?>">
<span>Tableau de bord</span>
</a>
</li>
<li class="last">
<span>Liste de vos ciblages</span>
</li>
</ul>
<div class="chemin">
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>''))?>">Tableau de bord</a> >
Liste de vos ciblages
</div>
<div id="dashboard">
<div style="margin:5px 0;">
<h2>Liste de vos ciblages</h2>
@ -26,7 +33,7 @@ Liste de vos ciblages
<td class="reference"><?=$item['reference']?></td>
<td class="update resultat"><?=number_format($item['resultat'], 0, ',', ' ')?></td>
<td class="update insee"><?=number_format($item['uniteInsee'], 0, ',', ' ')?></td>
<td class="update date"><?=$item['dateComptage']?></td>
<td class="update date"><?=$item['dateComptage']?></td>
<td><a class="update" href="<?=$this->url(array('controller'=> 'comptage','action'=>'update', 'id'=>$item['id']))?>">Actualiser</a></td>
<td><a href="<?=$this->url(array('controller'=> 'index','action'=>'index', 'id'=>$item['id']))?>">Recharger les critères de ciblage</a></td>
<td><a href="<?=$this->url(array('controller'=> 'dashboard','action'=>'ciblage', 'id'=>$item['id']))?>">Detail</a></td>

View File

@ -1,9 +1,16 @@
<div id="dashboard">
<ul class="chemin clearfix rounded_t">
<li class="e0"><a class="lir" href="/">Accueil</a></li>
<li>
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'index'))?>">
<span>Tableau de bord</span>
</a>
</li>
<li class="last">
<span>Enrichissements</span>
</li>
</ul>
<div class="chemin">
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>''))?>">Tableau de bord</a> >
Enrichissement à partir d'un ciblage
</div>
<div id="dashboard">
<h2>Fichiers en cours d'enrichissement</h2>
@ -15,7 +22,7 @@ Enrichissement à partir d'un ciblage
<th>Nombre de lignes totales</th>
<th>Nombre de lignes traitées</th>
<th>Date</th>
<th>Etat</th>
<th>Etat</th>
</tr>
</thead>
<tbody>
@ -49,7 +56,7 @@ Enrichissement à partir d'un ciblage
<th>Référence</th>
<th>Nombre de lignes totales</th>
<th>Date</th>
<th>Fichier</th>
<th>Fichier</th>
</tr>
</thead>
<tbody>
@ -77,7 +84,7 @@ $(document).ready(function()
$(document).focusout(function(){
clearInterval(timer);
});
timer = setInterval(updateInfo, 10000);
timer = setInterval(updateInfo, 10000);
});
var timer;

View File

@ -1,13 +1,21 @@
<ul class="chemin clearfix rounded_t">
<li class="e0"><a class="lir" href="/">Accueil</a></li>
<li>
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'index'))?>">
<span>Tableau de bord</span>
</a>
</li>
<li class="last">
<span></span>
</li>
</ul>
<div id="dashboard">
<div class="chemin">
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>''))?>">Tableau de bord</a>
</div>
<div id="menu">
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'ciblages'))?>">Liste de vos ciblages</a> -
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'enrichissements'))?>">Liste de vos enrichissements</a> -
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'configuration'))?>">Préférences de l'application</a> -
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'ciblages'))?>">Liste de vos ciblages</a> -
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'enrichissements'))?>">Liste de vos enrichissements</a> -
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>'configuration'))?>">Préférences de l'application</a> -
<a href="<?=$this->url(array('controller'=>'dashboard', 'action'=>''))?>">Enrichissement de fichier</a>
</div>
@ -27,7 +35,7 @@
<th>Nombre d'entité</th>
<th>Unité Insee</th>
<th>Date</th>
<th colspan="4"></th>
<th colspan="4"></th>
</tr>
</thead>
<tbody>
@ -40,14 +48,14 @@
<td><a class="update" href="<?=$this->url(array('controller'=> 'comptage','action'=>'update', 'id'=>$item['id']))?>">Actualiser</a></td>
<td><a href="<?=$this->url(array('controller'=> 'index','action'=>'index', 'id'=>$item['id']))?>">Recharger les critères de ciblage</a></td>
<td><a href="<?=$this->url(array('controller'=> 'dashboard','action'=>'ciblage', 'id'=>$item['id']))?>">Detail</a></td>
<td><a class="enrichissementref" href="<?=$this->url(array('controller'=> 'enrichissement','action'=>'reference', 'id'=>$item['id']))?>">Enrichissement</a></td>
<td><a class="enrichissementref" href="<?=$this->url(array('controller'=> 'enrichissement','action'=>'reference', 'id'=>$item['id']))?>">Enrichissement</a></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php else:?>
<p>Aucun ciblage.<p>
<?php endif;?>
<?php endif;?>
</div>
@ -60,7 +68,7 @@
<th>Référence</th>
<th>Nombre de lignes totales</th>
<th>Date</th>
<th>Etat</th>
<th>Etat</th>
</tr>
</thead>
<tbody>
@ -86,4 +94,6 @@
<?php else:?>
<p>Aucun enrichissement.<p>
<?php endif;?>
</div>
</div>

View File

@ -1,7 +1,7 @@
<div id="geographique">
<ul id="fieldsblock">
<li>
<?=$this->Field('adr_com')?>
<?=$this->Field('geo')?>
<?=$this->Field('geo_domtom')?>
<?=$this->Field('geo_etranger')?>
<?=$this->Field('geo_corse')?>

View File

@ -111,8 +111,9 @@ class Object_Codepostaux
foreach($departements as $nom) {
$structure[] = array(
'data' => $nom[0]['numdep'].' '.$nom[0]['libdep'],
'attr' => array('id' => $nom[0]['numdep'],
'data' => $nom[0]['libdep'].' ('.$nom[0]['numdep'].')',
'attr' => array(
'id' => $nom[0]['numdep'],
'niveau' => 1,
'class' => $this->_getClass($nom[0]['numdep'], 1)
),
@ -134,8 +135,9 @@ class Object_Codepostaux
foreach($codepostaux as $nom) {
$structure[] = array(
'data' => $nom['Codepos'].' '.$nom['Commune'],
'attr' => array('id'=> $nom['INSEE'],
'data' => $nom['Commune'].' ('.$nom['Codepos'].')',
'attr' => array(
'id'=> $nom['INSEE'],
'niveau' => 2,
'class' => $this->_getClass($nom['INSEE'], 2)
),

View File

@ -3,47 +3,41 @@ class Object_Formejuridique
{
protected function _jstree_checked()
{
$fields = new Scores_Fields();
$valeurs = explode(',', $fields->getCritere('cj'));
foreach($valeurs as $valeur) {
if($valeur != '')
$return[] = $valeur;
}
if(is_array($return))
return ($return);
return (array($valeurs));
//@todo : A faire
return array();
}
protected function _jstree_undetermined()
{
return (array());
//@todo : A faire
return array();
}
public function _getClass($valeur)
{
if(in_array($valeur, $this->_jstree_checked()))
return ('jstree-checked');
return 'jstree-checked';
else if (in_array($valeur, $this->_jstree_undetermined()))
return ('jstree-undetermined');
return 'jstree-undetermined';
}
public function _getParents()
{
$formes = new Application_Model_FormeJuridique();
$formes = $formes->fetchAll($formes->select()->where('LENGTH(fjCode) = 1'))->toArray();
$structure = array();
$sql = $formes->select()->where('LENGTH(fjCode) = 1');
$formes = $formes->fetchAll($sql)->toArray();
$structure = array();
foreach($formes as $forme) {
$structure[] = array(
'data' => $forme['fjCode'].' : '.$forme['fjLibelle'],
'attr' => array('id' => $forme['fjCode'],
'class' => $this->_getClass($forme['fjCode'])),
'attr' => array( 'id' => $forme['fjCode'], 'class' => $this->_getClass($forme['fjCode']) ),
'state' => 'closed',
//@todo : Requete Ajax
'children' => array($this->_getFils($forme['fjCode'])),
);
}
return (json_encode($structure));
return json_encode($structure);
}
public function _getFils($fjcode)
@ -60,15 +54,14 @@ class Object_Formejuridique
$structure = array();
foreach($formes as $forme) {
$structure = array(
'data' => $forme['fjCode'].' : '.$forme['fjLibelle'],
'attr' => array('id' => $forme['fjCode'],
'class' => $this->_getClass($forme['fjCode'])),
'state' => 'close',
'children' => (($lenth < 6)?$this->_getFils($forme['fjCode']):array())
'data' => $forme['fjCode'].' : '.$forme['fjLibelle'],
'attr' => array( 'id' => $forme['fjCode'], 'class' => $this->_getClass($forme['fjCode']) ),
'state' => 'close',
'children' => (($lenth < 6)?$this->_getFils($forme['fjCode']):array())
);
$tabfj[] = $structure;
}
return ($tabfj);
return $tabfj;
}
}

View File

@ -25,8 +25,14 @@ class Object_Naf
$tabNaf = array();
foreach($result as $item)
{
if ( $item['niveau']==1 ) {
$data = $item['lib'];
} else {
$data = $item['lib'].' ('.$item['code'].')';
}
$structure = array(
'data' => $item['code'].' - '.$item['lib'],
'data' => $data,
'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']),
'state' => 'closed',
'children' => array(),
@ -68,16 +74,20 @@ class Object_Naf
$valuesChecked = array();
$valuesUndetermined = array();
if ($val != null){
$valuesChecked = explode(',',$val);
foreach($valuesChecked as $value){
$valuesUndetermined = array_merge($valuesUndetermined, $this->getNafParent($value));
}
if ($val != null){
$valuesChecked = $val['in'];
if (count($valuesChecked)>0) {
foreach($valuesChecked as $value){
$valuesUndetermined = array_merge($valuesUndetermined, $this->getNafParent($value, true));
}
}
}
$niveau++;
$nafM = new Application_Model_Naf();
$sql = $nafM->select();
$nafM = new Application_Model_Naf();
$sql = $nafM->select();
if (!empty($parent) && $niveau==2) {
$sql->where('parent = ?', $parent);
} elseif (!empty($parent) && $niveau>2) {
@ -89,8 +99,8 @@ class Object_Naf
$tabNaf = array();
foreach($result as $item){
$structure = array(
'data' => $item['code'].' - '.$item['lib'],
'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']),
'data' => $item['code'].' - '.$item['lib'],
'attr' => array('id' => $item['code'], 'niveau' => $item['niveau']),
);
if (in_array($item['code'], $valuesChecked)){
$structure['attr']['class'] = 'jstree-checked';

View File

@ -27,7 +27,7 @@ class Ciblage
* @param array $structure
* @param boolean $need
*/
public function __construct($structure, $need = false)
public function __construct($structure)
{
Zend_Registry::get('firebug')->info($structure);
@ -37,8 +37,6 @@ class Ciblage
*/
require_once 'sphinxapi/sphinxapi-2.0.4.php';
$this->need = true;
//Load configuration from registry
$configuration = Zend_Registry::get('configuration');
@ -139,36 +137,52 @@ class Ciblage
foreach($structure['matches'] as $element){
$siret[] = $element['attrs']['siren'].$element['attrs']['nic'];
}
return ($siret);
return $siret;
} else
return (array());
return array();
}
/**
*
* @param unknown_type $need
* @param unknown_type $limitD
*/
public function execute($need = false, $limitD = false)
public function execute($need = false)
{
if($need) {
$return = array();
$limit = 0;
do {
$this->sphinx->SetLimits($limit, (($limitD!=false)?10:1000), 50000);
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
if(is_array($resSphinx))
$return = array_merge($return, $this->getSiret($resSphinx));
$limit = $limit + 1000;
}while($limit < (($limitD!=false)?10:$resSphinx['total_found']));
return ($return);
$limit = 1000;
$this->sphinx->SetLimits(0, $limit, 50000);
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
$total = $resSphinx['total_found'];
//
$return = $this->getSiret($resSphinx);
if ( $limit<$total ) {
$max = ceil($total/$limit);
//Get siret by $limit units for each request
for($i=1; $i<$max; $i++){
$offset = $i*$limit;
$this->sphinx->SetLimits($offset, $limit, 50000);
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
$tmpSiret = $this->getSiret($resSphinx);
$return = array_merge($return, $tmpSiret);
}
}
return $return;
} else {
$this->sphinx->SetLimits(0, 1);
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
Zend_Registry::get('firebug')->info("Sphinx : ".$this->alpha);
Zend_Registry::get('firebug')->info($resSphinx);
return $resSphinx['total_found'];
}
Zend_Registry::get('firebug')->info("Sphinx : ".$this->alpha);
Zend_Registry::get('firebug')->info($resSphinx);
return $resSphinx['total_found'];
}

View File

@ -1,7 +1,4 @@
<?php
/**
*
*/
class Scores_Fields
{
/**
@ -320,7 +317,7 @@ class Scores_Fields
'activated' => true,
),
//geographique
'adr_com' => array(
'geo' => array(
'label' => 'Localisation géographique',
'fields' => array(
'tree' => array('value' => null, 'action' => 'geographique', 'title' => "Arborescence géographique"),
@ -708,18 +705,25 @@ class Scores_Fields
return;
}
if ( !is_array($value) ) {
$types = array_keys($this->fields[$key]['fields']);
if ( !is_array($value) && !in_array($types[0], array('select', 'checkbox')) ) {
//Remove all space in string value
$value = str_replace(' ', '', $value);
//Try to detect separator et transform as array
//Try to detect separator and transform as array
if ( preg_match_all('/([0-9A-Z]{1,5})(,|;){0,1}/', $value, $matches) ){
Zend_Registry::get('firebug')->info($matches);
$value = $matches[1];
}
//Add value to the existing
if ($ex) {
$value = array_merge($this->ciblage[$key]['ex'], $value);
} else {
$value = array_merge($this->ciblage[$key]['in'], $value);
}
}
//Before to save the value
$types = array_keys($this->fields[$key]['fields']);
switch ( $types[0] ) {
case 'interval':
//@todo : Check Min Max
@ -745,11 +749,14 @@ class Scores_Fields
/**
* Définir les critères en une fois
* @param array $criteres Criteres as array with key => val
* @param boolean $inSession pour désactiver l'enregistrement en session
*/
public function setCriteres($criteres)
public function setCriteres($criteres, $inSession = true)
{
$this->ciblage = $criteres;
$this->setSession();
if ( $inSession ) {
$this->setSession();
}
}
/**
@ -864,127 +871,10 @@ class Scores_Fields
return $val;
}
public function selectArbo($name, $valeur)
{
$values = array();
switch($name)
{
case 'ape_etab' :
case 'ape_entrep' :
case 'ape_etab_ex':
case 'ape_entrep_ex':
$nafs = explode(',', $valeur);
foreach($nafs as $naf) {
if($naf != ' ') {
$values = array_merge($values, $this->nafArbo($name, $naf));
}
}
break;
case 'adr_dept':
case 'adr_reg':
case 'adr_com':
case 'adr_com_ex':
case 'adr_dept_ex':
$valeurs = explode(',', $valeur);
foreach($valeurs as $element) {
if(!empty($element)) {
$val = explode(':', $element);
if(count($val)>1) {
$diff = $this->localisationArbo($val[0], $val[1]);
if(!empty($diff))
$array = array_diff($diff, $values);
} else if(!empty($element)) {
$diff = $this->localisationArbo($name, $element);
if(!empty($diff))
$array = array_diff($diff, $values);
}
if(!empty($array)) {
$values = array_merge($values, $array);
}
}
}
break;
case 'cj':
case 'cj_ex':
$valeurs = explode(',', $valeur);
foreach($valeurs as $valeur) {
if($valeur != ' ' and !empty($valeur))
$values = array_merge($values, $this->fj($name, trim($valeur)));
}
}
return ($values);
}
protected function fj($name, $valeur)
{
$table = new Application_Model_FormeJuridique();
if(strlen($valeur) < 5) {
$sql = $table->select('formejuridique', array('fjCode'))
->where('fjCode LIKE "'.$valeur.'%"');
} else {
$sql = $table->select('formejuridique', array('fjCode'))
->where('fjCode = "'.$valeur.'"');
}
$result = $table->fetchAll($sql)->toArray();
foreach ($result as $code) {
if(strlen($code['fjCode']) > 2) {
$return[] = $code['fjCode'];
}
}
return ($return);
}
protected function localisationArbo($name, $valeur)
{
if(strlen($valeur) == 2) {
switch($name) {
case 'adr_reg':
$table = new Application_Model_Departements();
$sql = $table->select()
->from('departements')
->where('codeRegionInsee ='.$valeur)
->setIntegrityCheck(false);
$result = $table->fetchAll($sql)->toArray();
foreach ($result as $res) {
$return[] = trim($res['numdep']);
}
break;
case 'adr_dept':
case 'adr_dept_ex':
return (array($valeur));
break;
}
} else
return (array($valeur));
return ($return);
}
protected function nafArbo($key, $valeur)
{
$value = array();
$table = new Application_Model_Naf();
$valeur = trim($valeur);
if(strlen($valeur) == 1)
{
$sql = $table->select()->where('parent = ?', $valeur);
$result =$table->fetchAll($sql)->toArray();
foreach($result as $code) $where .= " code LIKE '".trim($code['code'])."%' and niveau = 5 or ";
$where = substr($where, 0, (strlen($where)) - 3);
$sql = $table->select()->where($where);
$result = $table->fetchAll($sql)->toArray();
foreach($result as $code) $value[] = $code['code'];
} else if(strlen($valeur) < 5){
$sql = $table->select()->where('code LIKE "'.trim($valeur).'%" and niveau = 5');
$result = $table->fetchAll($sql)->toArray();
foreach($result as $code) $value[] = $code['code'];
} else if(strlen($valeur) == 5) {
$value[] = $valeur;
}
return ($value);
}
/**
*
* @param unknown_type $name
*/
protected function getMinMax($name)
{
$MinMaxM = new Application_Model_MinMax();
@ -992,6 +882,9 @@ class Scores_Fields
return $minmax;
}
/**
*
*/
public function getFields() {
return $this->fields;
}
@ -1015,21 +908,14 @@ class Scores_Fields
return ($section);
}
public function getNotActivated($fields)
{
foreach($fields as $name => $field)
{
if(!$field['activated']) {
$desactivated[$name] = "";
} else if ($field['activated']){
}
}
return (json_encode($desactivated));
}
public function getLibelle($name)
public function getLabel($name)
{
return $this->fields[$name]['label'];
}
public function getInfoCritere()
{
}
}

View File

@ -126,7 +126,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
function sphPackI64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
@ -138,7 +138,7 @@ function sphPackI64 ( $v )
if ( is_int($v) )
return pack ( "NN", $v < 0 ? -1 : 0, $v );
// x32, bcmath
// x32, bcmath
if ( function_exists("bcmul") )
{
if ( bccomp ( $v, 0 ) == -1 )
@ -175,16 +175,16 @@ function sphPackI64 ( $v )
function sphPackU64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
assert ( $v>=0 );
// x64, int
if ( is_int($v) )
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
// x64, bcmath
if ( function_exists("bcmul") )
{
@ -192,12 +192,12 @@ function sphPackU64 ( $v )
$l = bcmod ( $v, 4294967296 );
return pack ( "NN", $h, $l );
}
// x64, no-bcmath
$p = max ( 0, strlen($v) - 13 );
$lo = (int)substr ( $v, $p );
$hi = (int)substr ( $v, 0, $p );
$m = $lo + $hi*1316134912;
$l = $m % 4294967296;
$h = $hi*2328 + (int)($m/4294967296);
@ -208,7 +208,7 @@ function sphPackU64 ( $v )
// x32, int
if ( is_int($v) )
return pack ( "NN", 0, $v );
// x32, bcmath
if ( function_exists("bcmul") )
{
@ -221,7 +221,7 @@ function sphPackU64 ( $v )
$p = max(0, strlen($v) - 13);
$lo = (float)substr($v, $p);
$hi = (float)substr($v, 0, $p);
$m = $lo + $hi*1316134912.0;
$q = floor($m / 4294967296.0);
$l = $m - ($q * 4294967296.0);
@ -277,11 +277,11 @@ function sphUnpackU64 ( $v )
// x32, bcmath
if ( function_exists("bcmul") )
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -324,7 +324,7 @@ function sphUnpackI64 ( $v )
return $lo;
return sprintf ( "%.0f", $lo - 4294967296.0 );
}
$neg = "";
$c = 0;
if ( $hi<0 )
@ -333,7 +333,7 @@ function sphUnpackI64 ( $v )
$lo = ~$lo;
$c = 1;
$neg = "-";
}
}
$hi = sprintf ( "%u", $hi );
$lo = sprintf ( "%u", $lo );
@ -345,7 +345,7 @@ function sphUnpackI64 ( $v )
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -510,7 +510,7 @@ class SphinxClient
$this->_path = $host;
return;
}
assert ( is_int($port) );
$this->_host = $host;
$this->_port = $port;
@ -590,14 +590,14 @@ class SphinxClient
$fp = @fsockopen ( $host, $port, $errno, $errstr );
else
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
if ( !$fp )
{
if ( $this->_path )
$location = $this->_path;
else
$location = "{$this->_host}:{$this->_port}";
$errstr = trim ( $errstr );
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
$this->_connerror = true;
@ -1236,7 +1236,7 @@ class SphinxClient
if ( $type==SPH_ATTR_FLOAT )
{
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
$attrvals[$attr] = $fval;
continue;
}
@ -1264,7 +1264,7 @@ class SphinxClient
} else if ( $type==SPH_ATTR_STRING )
{
$attrvals[$attr] = substr ( $response, $p, $val );
$p += $val;
$p += $val;
} else
{
$attrvals[$attr] = sphFixUint($val);
@ -1345,7 +1345,7 @@ class SphinxClient
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
/////////////////
// build request
@ -1634,7 +1634,7 @@ class SphinxClient
fclose ( $this->_socket );
$this->_socket = false;
return true;
}

View File

@ -66,6 +66,9 @@ $(document).ready(function()
case 'cj':
var href = '/juridique/completed';
break;
case 'geo':
var href = '/geographique/completed';
break;
}
if (href) {
$.getJSON( href, { q: val }, function(data) {
@ -78,15 +81,16 @@ $(document).ready(function()
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
select: function( event, ui ) {
if ( this.name == 'geo') {
this.value = ui.item.value;
} else {
var terms = split( this.value );
terms.pop();
terms.push( ui.item.value );
terms.push( "" );
this.value = terms.join( ", " );
}
return false;
},
});