Modification des champs + création de nouveau champs et des recherches autocompleted
This commit is contained in:
parent
26869a2fd8
commit
bb5b0b707a
@ -23,5 +23,24 @@ class EconomiqueController extends Libs_Controller
|
||||
$session = new SessionCiblage();
|
||||
$session->resetFamille('economique');
|
||||
}
|
||||
|
||||
public function completedAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
$request = $this->getRequest();
|
||||
$table = new Table_Nafs();
|
||||
|
||||
$sql = $table->select()
|
||||
->where('lib LIKE "%'.$this->getRequest()->getParam('q').'%"');
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->lib . $separator . $item->code,
|
||||
'value' => $item->code
|
||||
);
|
||||
}
|
||||
echo json_encode($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,5 +26,69 @@ class GeographiqueController extends Libs_Controller
|
||||
$session = new SessionCiblage();
|
||||
$session->resetFamille('geographique');
|
||||
}
|
||||
|
||||
public function completedAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$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'));
|
||||
}
|
||||
|
||||
echo json_encode($output);
|
||||
}
|
||||
|
||||
protected function completedDep($q)
|
||||
{
|
||||
$table = new Table_Departements();
|
||||
|
||||
$sql = $table->select()
|
||||
->where('libdep LIKE "'.$q.'%"');
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->libdep . $separator . $item->numdep,
|
||||
'value' => 'D'.$item->numdep
|
||||
);
|
||||
}
|
||||
return ($output);
|
||||
}
|
||||
|
||||
protected function completedVil($q)
|
||||
{
|
||||
$table = new Table_Codepostauxs();
|
||||
|
||||
$sql = $table->select()->where('Commune LIKE "'.$q.'%"');
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->Commune . $separator . $item->Codepos,
|
||||
'value' => $item->INSEE
|
||||
);
|
||||
}
|
||||
return ($output);
|
||||
}
|
||||
|
||||
protected function completedReg($q)
|
||||
{
|
||||
$table = new Table_Regions();
|
||||
|
||||
$sql = $table->select()
|
||||
->where('NCCENR LIKE "%'.$q.'%"');
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->NCCENR . $separator . $item->REGION,
|
||||
'value' => 'R'.$item->REGION
|
||||
);
|
||||
}
|
||||
return ($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,5 +24,24 @@ class JuridiqueController extends Libs_Controller
|
||||
$session = new SessionCiblage();
|
||||
$session->resetFamille('juridique');
|
||||
}
|
||||
|
||||
public function completedAction()
|
||||
{
|
||||
$table = new Table_Formejuridiques();
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
$request = $this->getRequest();
|
||||
|
||||
$sql = $table->select()
|
||||
->where('fjLibelle LIKE "'.$request->getParam('q').'%"');
|
||||
$result = $table->fetchAll($sql);
|
||||
foreach ($result as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->fjLibelle . $separator . $item->fjCode,
|
||||
'value' => $item->fjCode
|
||||
);
|
||||
}
|
||||
echo json_encode($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,25 @@ class Object_Comptage extends Libs_Row
|
||||
{
|
||||
require_once 'Scores/SessionCiblage.php';
|
||||
$session = new SessionCiblage();
|
||||
|
||||
|
||||
$sessionValeur = $session->getCritere($key);
|
||||
$session->setCritere($key, $valeur);
|
||||
if($valeur[strlen($valeur)] == ',')
|
||||
$valeur = substr($valeur, 0, strlen($valeur) -1);
|
||||
if($key == 'reg' or $key == 'vil' or $key == 'dep') {
|
||||
$key = 'adr_com';
|
||||
if($session->getCritere('reg')){
|
||||
$reg = trim($session->getCritere('reg'));
|
||||
}
|
||||
if($session->getCritere('vil')){
|
||||
$vil = trim($session->getCritere('vil'));
|
||||
}
|
||||
if($session->getCritere('dep')){
|
||||
$dep = trim($session->getCritere('dep'));
|
||||
}
|
||||
$valeur = implode('', array($reg, $vil, $dep));
|
||||
$session->setCritere($key, $valeur);
|
||||
}
|
||||
|
||||
require_once 'Scores/Field.php';
|
||||
$field = new Fields();
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function Field($name, $field)
|
||||
public function Field($name, $field, $type = null)
|
||||
{
|
||||
$html = '';
|
||||
if($field != null) {
|
||||
$html.= '<div class="fieldgrp">';
|
||||
$type = $field['type'];
|
||||
if($type == null)
|
||||
$type = $field['type'];
|
||||
switch($type)
|
||||
{
|
||||
case 'select':
|
||||
@ -35,9 +36,22 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
$this->dateHTML($name, $field));
|
||||
break;
|
||||
case 'text':
|
||||
switch($name) {
|
||||
case 'reg':
|
||||
$label = 'Localisation Régions';
|
||||
break;
|
||||
case 'vil':
|
||||
$label = 'Localisation Villes';
|
||||
break;
|
||||
case 'dep':
|
||||
$label = 'Localisation Départements';
|
||||
break;
|
||||
default:
|
||||
$label = $field['label'];
|
||||
}
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->textHTML($name, $field));
|
||||
$label,
|
||||
$this->textHTML($name, $field, $name));
|
||||
break;
|
||||
case 'textarea':
|
||||
$html.= $this->structureHTML(
|
||||
@ -177,12 +191,29 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
}
|
||||
|
||||
/* Textes */
|
||||
private function textHTML($name, $field)
|
||||
private function textHTML($name, $field, $name)
|
||||
{
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<input style="border:1px inset silver;width:60%" class="criteres" type="text" name="'.$name.'" value="'.$session->getCritere($name).'" />';
|
||||
|
||||
switch($name) {
|
||||
case 'ape_entrep':
|
||||
case 'ape_etab':
|
||||
$type = 'Naf';
|
||||
break;
|
||||
case 'dep':
|
||||
$type = 'Dep';
|
||||
break;
|
||||
case 'reg':
|
||||
$type = 'Reg';
|
||||
break;
|
||||
case 'vil':
|
||||
$type= 'Vil';
|
||||
break;
|
||||
case 'cj':
|
||||
$type = 'Cj';
|
||||
break;
|
||||
}
|
||||
$return = '<textarea rows="5" style="border:1px inset silver;width:60%" class="criteres complited'.$type.'" id="textarea_'.$name.'" name="'.$name.'">'.$session->getCritere($name).'</textarea>';
|
||||
$return .= '<a href="" class="autocomplet" textarea="'.$name.'">Valider</a>';
|
||||
return ($return);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,9 @@
|
||||
<ul id="fieldsblock">
|
||||
<li><?php echo $this->Field('capital', $this->fields->get('capital'));?></li>
|
||||
<li><?php echo $this->Field('ape_etab', $this->fields->get('ape_etab'));?></li>
|
||||
<li style="background-image:none;height:80px;"><?php echo $this->Field('ape_etab', $this->fields->get('ape_etab'), 'text');?></li>
|
||||
<li><?php echo $this->Field('ape_entrep', $this->fields->get('ape_entrep'));?></li>
|
||||
<li style="background-image:none;height:80px;"><?php echo $this->Field('ape_entrep', $this->fields->get('ape_entrep'), 'text');?></li>
|
||||
<li><?php echo $this->Field('age_entrep', $this->fields->get('age_entrep'));?></li>
|
||||
<li><?php echo $this->Field('age_etab', $this->fields->get('age_etab'));?></li>
|
||||
<li><?php echo $this->Field('teff_entrep', $this->fields->get('teff_entrep'));?></li>
|
||||
|
@ -15,7 +15,9 @@
|
||||
<li id="nbMPublic" ><?php echo $this->Field('nbMPubli', $this->fields->get('nbMPubli'));?></li>
|
||||
<li id="li_dateCrea_etab" ><?php echo $this->Field('dateCrea_ent',$this->fields->get('dateCrea_ent'));?></li>
|
||||
<li id="li_dateCrea_etab" ><?php echo $this->Field('dateCrea_etab', $this->fields->get('dateCrea_etab'));?></li>
|
||||
<li id="action" ><?php echo $this->Field('action', $this->fields->get('action'));?></li>
|
||||
<li id="nbActio" ><?php echo $this->Field('nbActio', $this->fields->get('nbActio'));?></li>
|
||||
<li id="part" ><?php echo $this->Field('part', $this->fields->get('part'));?></li>
|
||||
<li id="nbPart" ><?php echo $this->Field('nbPart', $this->fields->get('nbPart'));?></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -1,6 +1,9 @@
|
||||
<div id="geographique">
|
||||
<ul id="fieldsblock">
|
||||
<li><?php echo $this->Field('adr_com', $this->fields->get('adr_com'));?></li>
|
||||
<li style="background-image:none;height:80px;"><?php echo $this->Field('vil', $this->fields->get('adr_com'), 'text');?></li>
|
||||
<li style="background-image:none;height:80px;"><?php echo $this->Field('dep', $this->fields->get('adr_com'), 'text');?></li>
|
||||
<li style="background-image:none;height:80px;"><?php echo $this->Field('reg', $this->fields->get('adr_com'), 'text');?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="text-align:right;margin-top:20px;">
|
||||
|
@ -1,6 +1,7 @@
|
||||
<div id="juridique">
|
||||
<ul id="fieldsblock">
|
||||
<li><?php echo $this->Field('cj', $this->fields->get('cj'));?></li>
|
||||
<li style="background-image:none;height:80px;"><?php echo $this->Field('cj', $this->fields->get('cj'), 'text');?></li>
|
||||
<li><?php echo $this->Field('actifEco', $this->fields->get('actifEco'));?></li>
|
||||
<li><?php echo $this->Field('procolHisto', $this->fields->get('procolHisto'));?></li>
|
||||
<li><?php echo $this->Field('tvaIntraValide', $this->fields->get('tvaIntraValide'));?></li>
|
||||
|
@ -12,6 +12,13 @@ Class Ciblage
|
||||
public $nb_results = 5000;
|
||||
public $max_results = 500000;
|
||||
|
||||
public $mysql_host = '192.168.78.230';
|
||||
public $mysql_user = 'sphinx';
|
||||
public $mysql_password = 'indexer';
|
||||
public $mysql_database = 'jo';
|
||||
|
||||
public $sphinx_host = '192.168.78.252';
|
||||
public $sphinx_port = 3312;
|
||||
public $sphinx_match = SPH_MATCH_EXTENDED2;
|
||||
public $sphinx_sort = SPH_SORT_EXTENDED;
|
||||
|
||||
@ -29,11 +36,8 @@ Class Ciblage
|
||||
|
||||
public function __construct($structure, $need = false)
|
||||
{
|
||||
$configuration = Zend_Registry::get('configuration');
|
||||
|
||||
//Instantiation Sphinx
|
||||
$this->sphinx = new SphinxClient();
|
||||
$this->sphinx->SetServer($configuration->sphinx->host, intval($configuration->sphinx->port));
|
||||
$this->sphinx->SetServer($this->sphinx_host, $this->sphinx_port);
|
||||
$this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
|
||||
$this->sphinx->ResetFilters();
|
||||
foreach($structure as $key => $valeur) {
|
||||
@ -148,11 +152,19 @@ Class Ciblage
|
||||
protected function adr_dep($valeur) {
|
||||
$this->setAlpha('adr_dep', $valeur);
|
||||
}
|
||||
|
||||
|
||||
protected function adr_com($valeur) {
|
||||
$this->setFilter('adr_com', $valeur);
|
||||
}
|
||||
|
||||
protected function action($valeur) {
|
||||
$this->setFilter('action', $valeur);
|
||||
}
|
||||
|
||||
protected function part($valeur) {
|
||||
$this->setFilter('part', $valeur);
|
||||
}
|
||||
|
||||
protected function tel($valeur) {
|
||||
$this->setFilter('tel', $valeur);
|
||||
}
|
||||
|
@ -131,6 +131,16 @@ Class Fields
|
||||
'type' => 'interval',
|
||||
'class' => 'datepicker'
|
||||
),
|
||||
'action' => array(
|
||||
'label' => 'Présence d\'actionnaires',
|
||||
'fields' => array(
|
||||
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
||||
),
|
||||
'famille' => 'entreprise',
|
||||
'activated' => true,
|
||||
'type' => 'select',
|
||||
'class' => null
|
||||
),
|
||||
'nbActio' => array(
|
||||
'label' => 'Nombre d\'actionnaires connus',
|
||||
'fields' => array(
|
||||
@ -141,6 +151,16 @@ Class Fields
|
||||
'type' => 'interval',
|
||||
'class' => null
|
||||
),
|
||||
'part' => array(
|
||||
'label' => 'Nombre de participations connues',
|
||||
'fields' => array(
|
||||
'select' => array('value' => array('1' => 'Oui', '0' => 'Non'))
|
||||
),
|
||||
'famille' => 'entreprise',
|
||||
'activated' => true,
|
||||
'type' => 'select',
|
||||
'class' => null
|
||||
),
|
||||
'nbPart' => array(
|
||||
'label' => 'Nombre de participations connues',
|
||||
'fields' => array(
|
||||
@ -336,7 +356,7 @@ Class Fields
|
||||
'class' => null,
|
||||
'action' => 'geographique',
|
||||
'title' => 'Localisation'
|
||||
),
|
||||
),
|
||||
//juridique
|
||||
'cj' => array(
|
||||
'label' => 'Forme Juridique',
|
||||
@ -648,8 +668,10 @@ Class Fields
|
||||
case 'ape_etab' :
|
||||
case 'ape_entrep' :
|
||||
$nafs = explode(',', $valeur);
|
||||
foreach($nafs as $naf)
|
||||
$values = array_merge($values, $this->nafArbo($name, $naf));
|
||||
foreach($nafs as $naf) {
|
||||
if($naf != ' ')
|
||||
$values = array_merge($values, $this->nafArbo($name, $naf));
|
||||
}
|
||||
break;
|
||||
case 'adr_com':
|
||||
$valeurs = explode(',', $valeur);
|
||||
@ -664,6 +686,7 @@ Class Fields
|
||||
foreach($valeurs as $valeur)
|
||||
$values = array_merge($values, $this->fj($name, $valeur));
|
||||
}
|
||||
|
||||
return ($values);
|
||||
}
|
||||
|
||||
@ -755,18 +778,18 @@ Class Fields
|
||||
{
|
||||
$value = array();
|
||||
$table = new Table_Nafs();
|
||||
|
||||
|
||||
if(strlen($valeur) == 1)
|
||||
{
|
||||
$sql = $table->select()->where('parent = ?', $valeur);
|
||||
$result =$table->fetchAll($sql)->toArray();
|
||||
foreach($result as $code) $where .= " code LIKE '".$code['code']."%' and niveau = 5 or ";
|
||||
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 '".$valeur."%' and niveau = 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) {
|
||||
|
93
public/themes/default/scripts/autocompleted.js
Normal file
93
public/themes/default/scripts/autocompleted.js
Normal file
@ -0,0 +1,93 @@
|
||||
function split( val ) {
|
||||
return val.split( /,\s*/ );
|
||||
}
|
||||
function extractLast( term ) {
|
||||
return split( term ).pop();
|
||||
}
|
||||
$(document).ready(function(){
|
||||
|
||||
$('textarea.complitedCj').autocomplete({
|
||||
delay:600,
|
||||
source: function(request, response) {
|
||||
$.getJSON('/juridique/completed', { q: extractLast( request.term ) },
|
||||
function(data) { response(data); }
|
||||
);
|
||||
},
|
||||
select: function(event, ui){
|
||||
var terms = split( this.value );
|
||||
terms.pop();
|
||||
terms.push( ui.item.value );
|
||||
terms.push( "" );
|
||||
this.value = terms.join( ", " );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('textarea.complitedNaf').autocomplete({
|
||||
delay:600,
|
||||
source: function(request, response) {
|
||||
$.getJSON('/economique/completed', { q: extractLast( request.term ) },
|
||||
function(data) { response(data); }
|
||||
);
|
||||
},
|
||||
select: function(event, ui){
|
||||
var terms = split( this.value );
|
||||
terms.pop();
|
||||
terms.push( ui.item.value );
|
||||
terms.push( "" );
|
||||
this.value = terms.join( ", " );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('textarea.complitedDep').autocomplete({
|
||||
delay:600,
|
||||
source: function(request, response) {
|
||||
$.getJSON('/geographique/completed/dep/1', { q: extractLast( request.term ) },
|
||||
function(data) { response(data); }
|
||||
);
|
||||
},
|
||||
select: function(event, ui){
|
||||
var terms = split( this.value );
|
||||
terms.pop();
|
||||
terms.push( ui.item.value );
|
||||
terms.push( "" );
|
||||
this.value = terms.join( ", " );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('textarea.complitedReg').autocomplete({
|
||||
delay:600,
|
||||
source: function(request, response) {
|
||||
$.getJSON('/geographique/completed/reg/1', { q: extractLast( request.term ) },
|
||||
function(data) { response(data); }
|
||||
);
|
||||
},
|
||||
select: function(event, ui){
|
||||
var terms = split( this.value );
|
||||
terms.pop();
|
||||
terms.push( ui.item.value );
|
||||
terms.push( "" );
|
||||
this.value = terms.join( ", " );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('textarea.complitedVil').autocomplete({
|
||||
delay:600,
|
||||
source: function(request, response) {
|
||||
$.getJSON('/geographique/completed/vil/1', { q: extractLast( request.term ) },
|
||||
function(data) { response(data); }
|
||||
);
|
||||
},
|
||||
select: function(event, ui){
|
||||
var terms = split( this.value );
|
||||
terms.pop();
|
||||
terms.push( ui.item.value );
|
||||
terms.push( "" );
|
||||
this.value = terms.join( ", " );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
@ -99,11 +99,20 @@ $(document).ready(function()
|
||||
set($(this).attr('name'), $(this).val());
|
||||
});
|
||||
|
||||
$('#tabs').delegate('textarea', 'blur', function(e){
|
||||
/*$('#tabs').delegate('textarea', 'change', function(e){
|
||||
e.stopPropagation();
|
||||
set($(this).attr('name'), $(this).val());
|
||||
});
|
||||
});*/
|
||||
|
||||
$('#tabs').delegate('a.autocomplet', 'click', function(e){
|
||||
e.preventDefault();
|
||||
var key = $(this).attr('textarea');
|
||||
var values = $('#textarea_'+$(this).attr('textarea')).val();
|
||||
|
||||
set(key, values);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#tabs').delegate('a.interval', 'click', function(e){
|
||||
e.preventDefault();
|
||||
var key = $(this).attr('id');
|
||||
|
Loading…
Reference in New Issue
Block a user