Interval works on some fields

This commit is contained in:
Michael RICOIS 2012-05-23 19:40:49 +00:00
parent a6f17922bd
commit 42cf983eb5
3 changed files with 119 additions and 14 deletions

View File

@ -54,6 +54,8 @@ class Ciblage
foreach($structure as $key => $valeur) { foreach($structure as $key => $valeur) {
if ($key!= 'NB' && method_exists($this, $key)) { if ($key!= 'NB' && method_exists($this, $key)) {
$this->{$key}($valeur); $this->{$key}($valeur);
} else {
Zend_Registry::get('firebug')->info('KEY:'.$key);
} }
} }
} }
@ -182,7 +184,7 @@ class Ciblage
} else { } else {
$this->sphinx->SetLimits(0, 1); $this->sphinx->SetLimits(0, 1);
Zend_Registry::get('firebug')->info("Sphinx : ".$this->alpha); //Zend_Registry::get('firebug')->info("Sphinx : ".$this->alpha);
$resSphinx = $this->sphinx->Query($this->alpha, $this->index); $resSphinx = $this->sphinx->Query($this->alpha, $this->index);
Zend_Registry::get('firebug')->info($resSphinx); Zend_Registry::get('firebug')->info($resSphinx);
@ -288,9 +290,24 @@ class Ciblage
protected function nbActio($value) protected function nbActio($value)
{ {
//Read min max
$minmaxM = new Application_Model_MinMax();
$minmax = $minmaxM->find('nbActio')->current();
$valMin = '';
$valMax = '';
if ($minmax!==false) {
$valMin = $minmax->min;
$valMax = $minmax->max;
}
if ( array_key_exists('in', $value) ) { if ( array_key_exists('in', $value) ) {
$min = $value['in'][0]; $min = ($value['in'][0]=='') ? $valMin : $value['in'][0];
$max = $value['in'][1]; $max = ($value['in'][1]=='') ? $valMax : $value['in'][1];
if ($min=='' || $max=='')
return;
$this->setFilterRange('nbActio', $min, $max); $this->setFilterRange('nbActio', $min, $max);
} }
} }
@ -358,6 +375,87 @@ class Ciblage
} }
} }
protected function eff_etab($value)
{
//Read min max
$minmaxM = new Application_Model_MinMax();
$minmax = $minmaxM->find('eff_etab')->current();
$valMin = 0;
$valMax = null;
if ($minmax!==false) {
$valMin = $minmax->min;
$valMax = $minmax->max;
}
if ( array_key_exists('in', $value) ) {
$min = ($value['in'][0]=='') ? $valMin : $value['in'][0];
$max = ($value['in'][1]=='') ? $valMax : $value['in'][1];
Zend_Registry::get('firebug')->info('eff_etab Min : '.$min.', Max : '.$max);
if ($min===null || $max===null)
return;
Zend_Registry::get('firebug')->info('Min : '.$min.', Max : '.$max);
$this->setFilterRange('eff_etab', $min, $max);
}
}
protected function eff_entrep($value)
{
//Read min max
$minmaxM = new Application_Model_MinMax();
$minmax = $minmaxM->find('eff_entrep')->current();
$valMin = 0;
$valMax = null;
if ($minmax!==false) {
$valMin = $minmax->min;
$valMax = $minmax->max;
}
if ( array_key_exists('in', $value) ) {
$min = ($value['in'][0]=='') ? $valMin : $value['in'][0];
$max = ($value['in'][1]=='') ? $valMax : $value['in'][1];
Zend_Registry::get('firebug')->info('Min : '.$min.', Max : '.$max);
if ($min===null || $max===null)
return;
$this->setFilterRange('eff_entrep', $min, $max);
}
}
protected function nbEtab($value)
{
//Read min max
$minmaxM = new Application_Model_MinMax();
$minmax = $minmaxM->find('nbEtab')->current();
$valMin = 0;
$valMax = null;
if ($minmax!==false) {
$valMin = $minmax->min;
$valMax = $minmax->max;
}
if ( array_key_exists('in', $value) ) {
$min = ($value['in'][0]=='') ? $valMin : $value['in'][0];
$max = ($value['in'][1]=='') ? $valMax : $value['in'][1];
if ($min===null || $max===null)
return;
Zend_Registry::get('firebug')->info('Min : '.$min.', Max : '.$max);
$this->setFilterRange('nbEtab', $min, $max);
}
}
protected function geo_domtom($value) protected function geo_domtom($value)
{ {
if( $value['in']==1 ) { if( $value['in']==1 ) {
@ -442,6 +540,12 @@ class Ciblage
} }
} }
protected function dateImmat($value)
{
}
protected function bilType($value) protected function bilType($value)
{ {
if ( array_key_exists('in', $value) ) { if ( array_key_exists('in', $value) ) {
@ -609,7 +713,7 @@ class Ciblage
//First code level is letter, length 1 //First code level is letter, length 1
if ( !is_numeric($item) && strlen($item)==1 ) { if ( !is_numeric($item) && strlen($item)==1 ) {
$sql = $nafM->select()->from($nafM, array('code'))->where('parent = ?', strtoupper($item)); $sql = $nafM->select()->from($nafM, array('code'))->where('parent = ?', strtoupper($item));
Zend_Registry::get('firebug')->info($sql->__toString()); //Zend_Registry::get('firebug')->info($sql->__toString());
$result = $nafM->fetchAll($sql)->toArray(); $result = $nafM->fetchAll($sql)->toArray();
} }
@ -628,7 +732,7 @@ class Ciblage
$sql->where('code LIKE "'.$item.'%"'); $sql->where('code LIKE "'.$item.'%"');
} }
Zend_Registry::get('firebug')->info($sql->__toString()); //Zend_Registry::get('firebug')->info($sql->__toString());
$result = $nafM->fetchAll($sql)->toArray(); $result = $nafM->fetchAll($sql)->toArray();
if ( count($result)>0 ) { if ( count($result)>0 ) {

View File

@ -147,9 +147,8 @@ class Scores_Fields
'activated' => true, 'activated' => true,
), ),
'nbActio' => array( 'nbActio' => array(
'label' => 'Nombre d\'actionnaires connus', 'label' => "Nombre d'actionnaires connus",
'fields' => array( 'fields' => array(
//@todo : getMinMax
'interval' => array('value' => null) 'interval' => array('value' => null)
), ),
'famille' => 'entreprise', 'famille' => 'entreprise',
@ -286,7 +285,7 @@ class Scores_Fields
'activated' => true, 'activated' => true,
), ),
'eff_entrep' => array( 'eff_entrep' => array(
'label' => 'Effectif réel de l\'entreprise', 'label' => "Effectif réel de l'entreprise",
'fields' => array( 'fields' => array(
'interval' => array('value' => array('0', '10000000')) 'interval' => array('value' => array('0', '10000000'))
), ),
@ -294,7 +293,7 @@ class Scores_Fields
'activated' => true, 'activated' => true,
), ),
'eff_etab' => array( 'eff_etab' => array(
'label' => 'Effectif réel de l\'établissement', 'label' => "Effectif réel de l'établissement",
'fields' => array( 'fields' => array(
'interval' => array('value' => array('0', '10000000')) 'interval' => array('value' => array('0', '10000000'))
), ),
@ -709,7 +708,7 @@ class Scores_Fields
$types = array_keys($this->fields[$key]['fields']); $types = array_keys($this->fields[$key]['fields']);
if ( !is_array($value) && !in_array($types[0], array('select', 'checkbox')) ) { if ( !is_array($value) && !in_array($types[0], array('select', 'checkbox', 'interval')) ) {
//Remove all space in string value //Remove all space in string value
$value = str_replace(' ', '', $value); $value = str_replace(' ', '', $value);
//Try to detect separator and transform as array //Try to detect separator and transform as array
@ -728,6 +727,10 @@ class Scores_Fields
} }
} }
if ($types[0]=='interval') {
$value = explode(',', $value);
}
//Remove duplicate values //Remove duplicate values
if (is_array($value) ) { if (is_array($value) ) {
$value = array_unique($value); $value = array_unique($value);

View File

@ -146,10 +146,8 @@ $(document).ready(function()
var key = $(this).attr('id'); //Remove id to find all input value var key = $(this).attr('id'); //Remove id to find all input value
var val1 = $('input[name='+key+'1]').val(); var val1 = $('input[name='+key+'1]').val();
var val2 = $('input[name='+key+'2]').val(); var val2 = $('input[name='+key+'2]').val();
if(!val1) if(!val1) val1 = '';
val1 = 0; if(!val2) val2 = '';
if(!val2)
val2 = 0;
var values = val1 + ',' + val2; var values = val1 + ',' + val2;
set(key, values); set(key, values);
return false; return false;