Label and values

This commit is contained in:
Michael RICOIS 2014-07-04 14:09:49 +00:00
parent fd50f7ce6c
commit 5a14343455
40 changed files with 46469 additions and 85 deletions

View File

@ -10,6 +10,20 @@ class ComptageController extends Zend_Controller_Action
$cle = $request->getParam('cle');
$valeur = $request->getParam('valeur');
//Values sent must always be an array
if ( is_array($valeur) ) {
$values = $valeur;
} elseif ( is_string($valeur) ) {
//Remove all spaces
$valeur = preg_replace('/\s+/', '', $valeur);
$valeur = str_replace(';', ',', $valeur);
//Split valeur
$values = explode(',', $valeur);
}
Zend_Registry::get('firebug')->info('Comptage');
Zend_Registry::get('firebug')->info($values);
/**
* Error code
* 0 : OK
@ -29,7 +43,7 @@ class ComptageController extends Zend_Controller_Action
$fields = new Scores_Ciblage_FieldList();
$sessionValue = new Scores_Ciblage_Session($fields);
$insert = $sessionValue->setSelected($cle, $valeur, $ex);
$insert = $sessionValue->setSelected($cle, $values, $ex);
if ($insert) {
//Informations utilisateur

View File

@ -53,56 +53,14 @@ class IndexController extends Zend_Controller_Action
$allFields = $fields->getItems(true);
foreach ( $allFields as $key => $params ) {
$valueSelected = $sessionValue->getSelectedValue($key);
if ( $valueSelected !== false ) {
$inValue = $valueSelected['in'];
$exValue = $valueSelected['ex'];
if ( $valueSelected !== null ) {
if ( $params['type'] == 'one' ) {
$inLabel = '';
if ( count($inValue)>0 ) {
foreach ( $inValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$inLabel = $params['values'][$value];
}
}
}
$exLabel = '';
if ( count($exValue)>0 ) {
foreach ( $exValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$exLabel = $params['values'][$value];
}
}
}
} else {
$inLabel = array();
if ( count($inValue)>0 ) {
foreach ( $inValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$inLabel[] = $params['values'][$value];
}
}
}
$exLabel = array();
if ( count($exValue)>0 ) {
foreach ( $exValue as $value ) {
if ( array_key_exists($value, $params['values']) ) {
$exLabel[] = $params['values'][$value];
}
}
}
}
$resultLabel = $sessionValue->resumeLabel($key);
$infosCriteres[$key] = array(
'label' => $params['label'],
'in' => $inLabel,
'ex' => $exLabel,
'in' => $resultLabel['in'],
'ex' => $resultLabel['ex'],
);
}
}

View File

@ -6,8 +6,8 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$fields = new Scores_Ciblage_FieldList();
$sessionValue = new Scores_Ciblage_Session($fields);
$valueSelected = $sessionValue->getSelectedValues();
$valueSelected = $sessionValue->getSelectedValue($name);
$html = $fields->getItemHtml($name, $valueSelected);
if ($html) {

View File

@ -12,13 +12,20 @@
<div class="alert alert-info">
<a class="close" data-dismiss="alert" href="<?=$this->url(array(
'controller'=>'index', 'action'=>'remove', 'critere'=>$critere), null, true)?>" aria-hidden="true">&times;</a>
<div style='font-weight: 700;'><?=$item['label']?>:</div>
<?php if ( is_string($item['in']) && !empty($item['in']) ) {?>
<p>&nbsp;&nbsp;<?=$item['in']?></p>
<?php } elseif ( is_array($item['in']) || is_array($item['ex']) ) {?>
<p>&nbsp;&nbsp;<a class="criterelist" title="<?=$item['label']?>" href="<?=$this->url(array(
'controller'=>'index', 'action'=>'criterelist', 'key'=>$critere), null, true)?>">Liste</a></p>
<?php }?>
<strong><?=$item['label']?>:</strong>
<?php if ( $item['in'] == 'Liste' ) { ?>
<a href="<?=$this->url(array('controller'=>'index', 'action'=>'criterelist',
'key'=>$critere), null, true)?>">&Eacute;léments inclus.</a>
<?php } elseif ( !empty($item['in']) ) {?>
<span><?=$item['in']?>.</span>
<?php }?>
<?php if ( $item['ex'] == 'Liste' ) { ?>
<a href="<?=$this->url(array('controller'=>'index', 'action'=>'criterelist',
'key'=>$critere), null, true)?>">&Eacute;léments exclus.</a>
<?php } elseif ( !empty($item['ex']) ) {?>
<span><s><?=$item['ex']?></s>.</span>
<?php }?>
</div>
<?php }?>
<?php } else {?><div class="alert alert-warning">Aucune sélection.</div><?}?>

View File

@ -31,7 +31,7 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst
// Chargement des critères de ciblage à partir de l'enregistrement en bdd
$id = $request->getParam('id', 0);
if (!empty($id)) {
if ( !empty($id) ) {
$criteresM = new Application_Model_CiblageCriteres();
$sql = $criteresM->select()
->from($criteresM, array('criteres'))
@ -57,6 +57,12 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst
$sessionValue->setCritereSession();
}
} else {
if ( $sessionValue->getCountTotal() === false ) {
$ciblage = new Scores_Ciblage_Engine($sessionValue->getSelectedValues(), $user->globalRNCS);
}
}
$view->total = $sessionValue->getCountTotal();

View File

@ -21,19 +21,20 @@ class Scores_Ciblage_Field_Range
'<div class="col-md-10">';
if ( count($this->data)>0 ) {
if ( $valueSelected === null || count($valueSelected)==0 ) {
$valueSelected = $this->data;
if ( $valueSelected === null || count($valueSelected['in'])==0 ) {
$selectedMin = $this->data['min'];
$selectedMax = $this->data['max'];
} else {
$selectedMin = $valueSelected['in'][0];
$selectedMax = $valueSelected['in'][1];
}
Zend_Registry::get('firebug')->info('Range');
Zend_Registry::get('firebug')->info($valueSelected);
$html.= '<b style="margin:0 15px">'.number_format($this->data['min'], 0, ',', ' ').'</b>'.
'<input id="slider-'.$this->name.'" type="text" class="span2" value=""
data-slider-min="'.$this->data['min'].'"
data-slider-max="'.$this->data['max'].'"
data-slider-step="1"
data-slider-value="['.$valueSelected['min'].','.$valueSelected['max'].']"/>'.
data-slider-value="['.$selectedMin.','.$selectedMax.']"/>'.
'<b style="margin:0 15px">'.number_format($this->data['max'], 0, ',', ' ').'</b>';
}
$html.= '</div>'.

View File

@ -840,4 +840,52 @@ class Scores_Ciblage_FieldList
return array();
}
public function checkValue($key, $value)
{
$info = $this->items[$key];
$staticValuesLabel = $this->getItemValues($key);
switch($info['type']) {
case 'range':
if ( floatval($value)>=floatval($staticValuesLabel['min']) && floatval($value)<=floatval($staticValuesLabel['max']) ) {
return true;
}
break;
default:
$staticValues = array_keys($staticValuesLabel);
if ( in_array($value, $staticValues) ) {
return true;
}
break;
}
return false;
}
public function labelValue($key, $values)
{
$info = $this->items[$key];
$staticValuesLabel = $this->getItemValues($key);
switch($info['type']) {
case 'one':
return $staticValuesLabel[$values[0]];
break;
case 'range':
//@todo : unit
return $values[0]." à ".$values[1];
break;
case 'rangedate':
return "du ".$values[0]." à ".$values[1];
break;
default:
return "Liste";
break;
}
return false;
}
public function labelValueDetail($key, $value)
{
}
}

View File

@ -79,18 +79,16 @@ class Scores_Ciblage_Session
$valueToSave = null;
//Prepare data
//check data
if ( is_array($value) ) {
foreach ( $value as $item ) {
if ( in_array($item, $staticValues) ) {
if ( $this->fields->checkValue($key, $item) ){
$valueToSave[] = $item;
}
}
} else {
if ( in_array($value, $staticValues) ) {
$valueToSave = array($value);
} else {
return false;
if ( $this->fields->checkValue($key, $value) ){
$valueToSave[] = $value;
}
}
@ -173,13 +171,13 @@ class Scores_Ciblage_Session
public function getSelectedValue($key)
{
if ( $this->ciblage === null )
return false;
return null;
if ( array_key_exists($key, $this->ciblage->select) ) {
return $this->ciblage->select[$key];
}
return false;
return null;
}
/**
@ -188,7 +186,7 @@ class Scores_Ciblage_Session
public function getSelectedValues()
{
if ( $this->ciblage === null )
return false;
return null;
return $this->ciblage->select;
}
@ -241,4 +239,25 @@ class Scores_Ciblage_Session
Zend_Session::namespaceUnset('ciblage');
}
/**
* Renvoi les libellés
* @param string $key
*/
public function resumeLabel($key)
{
$values = $this->getSelectedValue($key);
if (count($values['in'])>0) {
$in = $this->fields->labelValue($key, $values['in']);
}
if (count($values['ex'])>0) {
$ex = $this->fields->labelValue($key, $values['ex']);
}
return array(
'in' => $in,
'ex' => $ex,
);
}
}

View File

@ -0,0 +1,31 @@
<?php
return array(
'1' => "Guadeloupe",
'2' => "Martinique",
'3' => "Guyane",
'4' => "La Réunion",
'11' => "Île-de-France",
'21' => "Champagne-Ardenne",
'22' => "Picardie",
'23' => "Haute-Normandie",
'24' => "Centre",
'25' => "Basse-Normandie",
'26' => "Bourgogne",
'31' => "Nord-Pas-de-Calais",
'41' => "Lorraine",
'42' => "Alsace",
'43' => "Franche-Comté",
'52' => "Pays de la Loire",
'53' => "Bretagne",
'54' => "Poitou-Charentes",
'72' => "Aquitaine",
'73' => "Midi-Pyrénées",
'74' => "Limousin",
'82' => "Rhône-Alpes",
'83' => "Auvergne",
'91' => "Languedoc-Roussillon",
'93' => "Provence-Alpes-Côte d'Azur",
'94' => "Corse",
'98' => "Territoires d'outre-mer",
'99' => "Etranger",
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 255,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 255,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 2014,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 2014,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -934414,
'max'=> 164625000000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -8069898,
'max'=> 7058000000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -3755227,
'max'=> 69225933400,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -5728610,
'max'=> 54205000000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -220460628,
'max'=> 55971660000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -8508000,
'max'=> 10599281000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -2147483648,
'max'=> 12401380000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -7483854,
'max'=> 7878000000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -8122288,
'max'=> 6909000000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -79462149,
'max'=> 60126000000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -377700211,
'max'=> 59027792000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -2147483648,
'max'=> 9766284000,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> -2278223,
'max'=> 50274502,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 7821000000000,
);

View File

@ -0,0 +1,109 @@
<?php
return array(
'03' => "Allier",
'04' => "Alpes-de-Haute-Provence",
'02' => "Aisne",
'01' => "Ain",
'05' => "Hautes-Alpes",
'06' => "Alpes-Maritimes",
'07' => "Ardèche",
'08' => "Ardennes",
'09' => "Ariège",
'10' => "Aube",
'11' => "Aude",
'12' => "Aveyron",
'13' => "Bouches-du-Rhône",
'14' => "Calvados",
'15' => "Cantal",
'16' => "Charente",
'17' => "Charente-Maritime",
'18' => "Cher",
'19' => "Corrèze",
'2A' => "Corse-du-Sud",
'20' => "Corse",
'21' => "Côte-d'Or",
'22' => "Côtes-d'Armor",
'23' => "Creuse",
'24' => "Dordogne",
'25' => "Doubs",
'26' => "Drôme",
'27' => "Eure",
'28' => "Eure-et-Loir",
'29' => "Finistère",
'30' => "Gard",
'33' => "Gironde",
'32' => "Gers",
'34' => "Hérault",
'31' => "Haute-Garonne",
'36' => "Indre",
'37' => "Indre-et-Loire",
'35' => "Ille-et-Vilaine",
'39' => "Jura",
'38' => "Isère",
'40' => "Landes",
'41' => "Loir-et-Cher",
'42' => "Loire",
'43' => "Haute-Loire",
'44' => "Loire-Atlantique",
'45' => "Loiret",
'46' => "Lot",
'47' => "Lot-et-Garonne",
'48' => "Lozère",
'49' => "Maine-et-Loire",
'53' => "Mayenne",
'51' => "Marne",
'50' => "Manche",
'52' => "Haute-Marne",
'54' => "Meurthe-et-Moselle",
'56' => "Morbihan",
'55' => "Meuse",
'57' => "Moselle",
'58' => "Nièvre",
'59' => "Nord",
'60' => "Oise",
'62' => "Pas-de-Calais",
'61' => "Orne",
'63' => "Puy-de-Dôme",
'67' => "Bas-Rhin",
'68' => "Haut-Rhin",
'69' => "Rhône",
'64' => "Pyrénées-Atlantiques",
'65' => "Hautes-Pyrénées",
'66' => "Pyrénées-Orientales",
'70' => "Haute-Saône",
'71' => "Saône-et-Loire",
'72' => "Sarthe",
'73' => "Savoie",
'74' => "Haute-Savoie",
'75' => "Paris",
'76' => "Seine-Maritime",
'77' => "Seine-et-Marne",
'78' => "Yvelines",
'79' => "Deux-Sèvres",
'80' => "Somme",
'81' => "Tarn",
'82' => "Tarn-et-Garonne",
'83' => "Var",
'84' => "Vaucluse",
'85' => "Vendée",
'86' => "Vienne",
'87' => "Haute-Vienne",
'88' => "Vosges",
'89' => "Yonne",
'90' => "Territoire de Belfort",
'91' => "Essonne",
'92' => "Hauts-de-Seine",
'93' => "Seine-Saint-Denis",
'94' => "Val-de-Marne",
'95' => "Val-d'Oise",
'971' => "Guadeloupe",
'972' => "Martinique",
'973' => "Guyane",
'974' => "Réunion",
'976' => "Mayotte",
'988' => "Nouvelle-Calédonie",
'987' => "Polynésie-Française",
'975' => "Saint-Pierre-et-Miquelon",
'986' => "Wallis-et-Futuna",
'2B' => "Haute-Corse",
);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 19000101,
'max'=> 20150501,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 19000101,
'max'=> 20150501,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 18000101,
'max'=> 20181003,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 248500,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 59700,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 132,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 1,
'max'=> 11700,
);

View File

@ -0,0 +1,5 @@
<?php
return array(
'min'=> 0,
'max'=> 1024,
);

View File

@ -27,34 +27,36 @@ $(document).ready(function()
e.preventDefault();
var btn = $(this);
var result = set(btn.attr('name'), btn.val());
if (!result) {
if (result===false) {
alert('error');
$('div.critere-one[name='+btn.attr('name')+']').button('reset');
btn.button('reset');
}
});
$('div.ciblage-many button').change(function(e){
$('div.ciblage-many button').click(function(e){
e.preventDefault();
var key = $(this).data('ciblagename');
var values = $('select[name='+key+']:selected').val();
var result = set(key, values);
if (!result) {
alert('error');
$('div.critere-one[name='+btn.attr('name')+']').button('reset');
if (result===false) {
alert('error');
}
});
$('div.ciblage-range button').change(function(e){
$('div.ciblage-range button').click(function(e){
e.preventDefault();
var key = $(this).data('ciblagename');
var values = $('#slider-'+key).slider('getValue');
alert(values);
var result = set(key, values);
if (result===false) {
alert('error');
}
});
$('div.ciblage-rangedate button').change(function(e){
$('div.ciblage-rangedate button').click(function(e){
e.preventDefault();
var key = $(this).data('ciblagename');
var values = $('#slider-'+key).slider('getValue');
alert(values);
});
@ -121,9 +123,7 @@ function set(key, value, ex) {
ex = typeof ex !== 'undefined' ? ex : 0;
$('#panel').html('<span class="glyphicon glyphicon-refresh img-rounded"></span>');
var result = false;
$.post('/comptage/index', { cle:key, valeur:value, exclude:ex }, function(data, status) {
//Resume criteres content
$.post('/index/criteres', { total:data.count, insee:data.insee }, function(data) { $('#panel').html(data); });
$.post('/comptage/index', { cle:key, valeur:value, exclude:ex }, function(data, status) {
if (data.error==1) {
$('div#actionMessage').html('<div class="alert alert-danger"><strong>Erreur !</strong> Un problème technique est survenu.</div>');
result = false;
@ -132,7 +132,9 @@ function set(key, value, ex) {
$('div#actionMessage').html('<div class="alert alert-warning"><strong>Information !</strong> Valeur saisi incorrecte.</div>');
result = false;
}
return true;
result = true;
//Resume criteres content
$.post('/index/criteres', { total:data.count, insee:data.insee }, function(data) { $('#panel').html(data); });
}, 'json').error(function(){
$('div#actionMessage').html('<div class="alert alert-danger"><strong>Erreur !</strong> Un problème inconnu est survenu.</div>');
result = false;

View File

@ -40,4 +40,8 @@ body {
code {
font-size: 80%;
}
#panel div.alert {
margin-bottom:0 !important;
}