Gestion des champs
This commit is contained in:
parent
5a14343455
commit
c7f6359b87
@ -39,32 +39,24 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst
|
||||
->where('id = ?', $id);
|
||||
$row = $criteresM->fetchRow($sql);
|
||||
if ($row != null) {
|
||||
|
||||
//On charge les critères
|
||||
$sessionValue->setSelectedValues(json_decode($row->criteres, true));
|
||||
|
||||
//Réalise le comptage
|
||||
$ciblage = new Scores_Ciblage_Engine($sessionValue->getSelectedValues(), $user->globalRNCS);
|
||||
|
||||
$total = $ciblage->execute();
|
||||
$sessionValue->setCountTotal($total);
|
||||
if ($user->preferences['interface']['insee']==1) {
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
} else {
|
||||
$insee = null;
|
||||
}
|
||||
$sessionValue->setCountInsee($insee);
|
||||
$sessionValue->setCritereSession();
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
if ( $sessionValue->getCountTotal() === false ) {
|
||||
$ciblage = new Scores_Ciblage_Engine($sessionValue->getSelectedValues(), $user->globalRNCS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Réalise le comptage
|
||||
$ciblage = new Scores_Ciblage_Engine($sessionValue->getSelectedValues(), $user->globalRNCS);
|
||||
|
||||
$total = $ciblage->execute();
|
||||
$sessionValue->setCountTotal($total);
|
||||
if ($user->preferences['interface']['insee']==1) {
|
||||
$insee = $ciblage->calculRedevanceInsee();
|
||||
} else {
|
||||
$insee = null;
|
||||
}
|
||||
$sessionValue->setCountInsee($insee);
|
||||
$sessionValue->setCritereSession();
|
||||
|
||||
$view->total = $sessionValue->getCountTotal();
|
||||
$view->insee = $sessionValue->getCountInsee();
|
||||
$view->msgComptage = true;
|
||||
|
@ -30,12 +30,12 @@ class Scores_Ciblage_Field_List
|
||||
}
|
||||
}
|
||||
}
|
||||
$html.= '<textarea class="form-control" rows="3" name="'.$this->name.'">';
|
||||
$html.= '<textarea class="form-control" rows="2" name="'.$this->name.'">';
|
||||
$html.= $valueTxt;
|
||||
$html.= '</textarea>'.
|
||||
'</div>';
|
||||
$html.= '<div class="col-md-2">' .
|
||||
'<button class="btn btn-primary btn-sm pull-right" type="button">Sélectionner</button>' .
|
||||
'<button class="btn btn-primary btn-xs pull-right" type="button">Sélectionner</button>' .
|
||||
'</div>'.
|
||||
'</div>';
|
||||
return $html;
|
||||
|
@ -32,7 +32,7 @@ class Scores_Ciblage_Field_Many
|
||||
}
|
||||
$html.= '</div>'.
|
||||
'<div class="col-md-2">' .
|
||||
'<button class="btn btn-primary btn-sm" type="button" data-ciblagename="'.$this->name.'">Sélectionner</button>' .
|
||||
'<button class="btn btn-primary btn-xs pull-right" type="button" data-ciblagename="'.$this->name.'">Sélectionner</button>' .
|
||||
'</div>'.
|
||||
'</div>';
|
||||
return $html;
|
||||
|
@ -17,7 +17,9 @@ class Scores_Ciblage_Field_One
|
||||
|
||||
public function getHTML($valueSelected = '')
|
||||
{
|
||||
$html = '<div class="btn-group ciblage-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
|
||||
$html = '<div class="row">' .
|
||||
'<div class="col-md-12">';
|
||||
$html.= '<div class="btn-group ciblage-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
|
||||
if ( count($this->data)>0 ) {
|
||||
foreach ( $this->data as $value => $label ) {
|
||||
$active = '';
|
||||
@ -25,12 +27,14 @@ class Scores_Ciblage_Field_One
|
||||
$active = ' active';
|
||||
}
|
||||
|
||||
$html.= '<label class="btn btn-primary btn-sm'.$active.'">'.
|
||||
$html.= '<label class="btn btn-primary btn-xs'.$active.'">'.
|
||||
'<input type="radio" name="'.$this->name.'" value="'.$value.'">'.$label.
|
||||
'</label>';
|
||||
}
|
||||
}
|
||||
$html .= '</div>';
|
||||
$html.= '</div>';
|
||||
$html.= '</div>'.
|
||||
'</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class Scores_Ciblage_Field_Range
|
||||
}
|
||||
$html.= '</div>'.
|
||||
'<div class="col-md-2">' .
|
||||
'<button class="btn btn-primary btn-sm pull-right" type="button" data-ciblagename="'.$this->name.'">Sélectionner</button>' .
|
||||
'<button class="btn btn-primary btn-xs pull-right" type="button" data-ciblagename="'.$this->name.'">Sélectionner</button>' .
|
||||
'</div>'.
|
||||
'</div>';
|
||||
return $html;
|
||||
|
@ -27,21 +27,23 @@ class Scores_Ciblage_Field_RangeDate
|
||||
|
||||
public function getHTML($valueSelected = array())
|
||||
{
|
||||
$html = '<div class="row ciblage-rangedate">';
|
||||
if ( count($this->data)>0 ) {
|
||||
$html.= '<div class="col-md-10">' .
|
||||
'<div class="clearfix">' .
|
||||
'<div id="rangedate_'.$this->name.'" class="pull-right" style="background:#fff;cursor:pointer; padding:5px 10px; border:1px solid #ccc;">' .
|
||||
'<div id="rangedate-'.$this->name.'" class="pull-right" style="background:#fff;cursor:pointer; padding:5px 10px; border:1px solid #ccc;">' .
|
||||
'<i class="glyphicon glyphicon-calendar icon-calendar icon-large"></i>' .
|
||||
'<span></span> <b class="caret"></b>' .
|
||||
'</div>' .
|
||||
'</div>' .
|
||||
'</div>' .
|
||||
'<div class="col-md-2">' .
|
||||
'<button class="btn btn-primary btn-sm pull-right" type="button">Sélectionner</button>' .
|
||||
'<button class="btn btn-primary btn-xs pull-right" type="button" data-ciblagename="'.$this->name.'">Sélectionner</button>' .
|
||||
'</div>';
|
||||
} else {
|
||||
$html.= '<p>Affichage impossible de l\'interface.</p>';
|
||||
}
|
||||
$html.= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
@ -49,7 +51,7 @@ class Scores_Ciblage_Field_RangeDate
|
||||
public function getJS()
|
||||
{
|
||||
return "
|
||||
$('#rangedate_".$this->name."').daterangepicker(
|
||||
$('#rangedate-".$this->name."').daterangepicker(
|
||||
{
|
||||
startDate: '".$this->minDate."',
|
||||
endDate: '".$this->maxDate."',
|
||||
@ -84,12 +86,12 @@ class Scores_Ciblage_Field_RangeDate
|
||||
}
|
||||
},
|
||||
function(start, end) {
|
||||
$('#rangedate_".$this->name." span').html(start.format('DD/MM/YYYY') + ' - ' + end.format('DD/MM/YYYY'));
|
||||
$('#rangedate-".$this->name." span').html(start.format('DD/MM/YYYY') + ' - ' + end.format('DD/MM/YYYY'));
|
||||
}
|
||||
);
|
||||
|
||||
//Set the initial state of the picker label
|
||||
$('#rangedate_".$this->name." span').html('".$this->minDate."' + ' - ' + '".$this->maxDate."');
|
||||
$('#rangedate-".$this->name." span').html('".$this->minDate."' + ' - ' + '".$this->maxDate."');
|
||||
";
|
||||
}
|
||||
|
||||
|
@ -17,20 +17,13 @@ class Scores_Ciblage_Field_Search
|
||||
|
||||
public function getHTML($valueSelected = '')
|
||||
{
|
||||
$html = '<div class="btn-group critere-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
|
||||
if ( count($this->data)>0 ) {
|
||||
foreach ( $this->data as $value => $label ) {
|
||||
$active = '';
|
||||
if( $valueSelected === $value ) {
|
||||
$active = ' active';
|
||||
}
|
||||
|
||||
$html.= '<label class="btn btn-primary btn-sm'.$active.'">'.
|
||||
'<input type="radio" name="'.$this->name.'" value="'.$value.'">'.$label.
|
||||
'</label>';
|
||||
}
|
||||
}
|
||||
$html .= '</div>';
|
||||
$html = '<form class="form-inline" role="form">';
|
||||
$html.= '<div class="form-group">';
|
||||
$html.= '<label class="sr-only">Recherche</label>';
|
||||
$html.= '<input type="text" class="form-control" placeholder="Recherche">';
|
||||
$html.= '</div>';
|
||||
$html.= '</form>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
@ -18,14 +18,17 @@ class Scores_Ciblage_Field_Tag
|
||||
public function getHTML($valueSelected = '')
|
||||
{
|
||||
$html = '<div class="row ciblage-tag">' .
|
||||
'<div class="col-md-2">';
|
||||
'<div class="col-md-4">';
|
||||
|
||||
$html.= '<input class="tags" type="text" data-url="/fields/tag/name/'.$this->name.'" value=""/>';
|
||||
$html.= '<div class="form-group">';
|
||||
$html.= '<label class="sr-only">Recherche</label>';
|
||||
$html.= '<input type="text" class="form-control" placeholder="Recherche" data-url="/fields/tag/name/'.$this->name.'">';
|
||||
$html.= '</div>';
|
||||
|
||||
$html.= '</div>'.
|
||||
'<div class="col-md-8">' . '</div>' .
|
||||
'<div class="col-md-2">' .
|
||||
'<button class="btn btn-primary btn-sm" type="button" data-ciblagename="'.$this->name.'">Ajouter</button>' .
|
||||
'<div class="col-md-5">' . '</div>' .
|
||||
'<div class="col-md-3">' .
|
||||
'<button class="btn btn-primary btn-xs pull-right" type="button" data-ciblagename="'.$this->name.'">Ajouter à la selection</button>' .
|
||||
'</div>'.
|
||||
'</div>';
|
||||
|
||||
|
@ -17,20 +17,16 @@ class Scores_Ciblage_Field_Tree
|
||||
|
||||
public function getHTML($valueSelected = '')
|
||||
{
|
||||
$html = '<div class="btn-group critere-one pull-right" data-toggle="buttons" name="'.$this->name.'">';
|
||||
if ( count($this->data)>0 ) {
|
||||
foreach ( $this->data as $value => $label ) {
|
||||
$active = '';
|
||||
if( $valueSelected === $value ) {
|
||||
$active = ' active';
|
||||
}
|
||||
$html = '<div class="row ciblage-tree">' .
|
||||
'<div class="col-md-9">';
|
||||
|
||||
$html.= '<label class="btn btn-primary btn-sm'.$active.'">'.
|
||||
'<input type="radio" name="'.$this->name.'" value="'.$value.'">'.$label.
|
||||
'</label>';
|
||||
}
|
||||
}
|
||||
$html .= '</div>';
|
||||
$html.= '<p><a href="#">Choisir dans une arboresence Région, Département, Ville</a></p>';
|
||||
|
||||
$html.= '</div>'.
|
||||
'<div class="col-md-3">' .
|
||||
'<button class="btn btn-primary btn-xs pull-right" type="button" data-ciblagename="'.$this->name.'">Valider</button>' .
|
||||
'</div>'.
|
||||
'</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class Scores_Ciblage_FieldList
|
||||
protected $items = array (
|
||||
'siege' => array (
|
||||
'label' => "Type d'établissement",
|
||||
'desc' => "",
|
||||
'desc' => "Restreindre la séléction uniquement aux établissements siéges (les entreprises) ou les établissements secondaires.",
|
||||
'family' => 'entreprise',
|
||||
'type' => 'one',
|
||||
'values' => array('1' => 'Sièges', '0' => 'Secondaires'),
|
||||
@ -22,7 +22,7 @@ class Scores_Ciblage_FieldList
|
||||
),
|
||||
'groupe' => array(
|
||||
'label' => "Appartient à un groupe",
|
||||
'desc' => "Possibilité de restreindre la sélection aux entreprises appartenant à un groupe",
|
||||
'desc' => "Restreindre la sélection aux entreprises appartenant à un groupe",
|
||||
'family' => 'entreprise',
|
||||
'type' => 'one',
|
||||
'values' => array('1' => 'Oui', '0' => 'Non'),
|
||||
@ -531,7 +531,7 @@ class Scores_Ciblage_FieldList
|
||||
'activated' => true,
|
||||
),
|
||||
'bilFK' => array(
|
||||
'label' => "'Chiffre d'affaires Export (FK)",
|
||||
'label' => "Chiffre d'affaires Export (FK)",
|
||||
'desc' => "Limitation aux entreprises dont le poste FK (Montant du Chiffre d'Affaires Export en Euros) est connu (Chiffres Réels uniquement)",
|
||||
'family' => 'financier',
|
||||
'type' => 'range',
|
||||
@ -633,10 +633,60 @@ class Scores_Ciblage_FieldList
|
||||
|
||||
//Bloc header
|
||||
$html = '<div class="panel panel-info">';
|
||||
$html.= '<div class="panel-heading">'.$this->items[$name]['label'].'</div>';
|
||||
$html.= '<div class="panel-heading">'.$this->items[$name]['label'];
|
||||
|
||||
if ( $valueSelected !== null ) {
|
||||
if ( count($valueSelected['in']) > 0 ) {
|
||||
$html.= '<span class="label label-success pull-right" title="Des valeurs sont incluses dans votre sélection">+</span>';
|
||||
}
|
||||
if (count($valueSelected['ex']) > 0 ) {
|
||||
$html.= '<span class="label label-warning pull-right" title="Des valeurs sont exclus dans votre sélection">-</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$html.= '</div>';
|
||||
|
||||
if ( is_array($type) ) {
|
||||
|
||||
$html.= '<div class="panel-body">';
|
||||
|
||||
foreach ( $type as $key => $label ) {
|
||||
//Bloc content
|
||||
$htmlfield = '';
|
||||
switch ($key) {
|
||||
case 'list':
|
||||
$field = new Scores_Ciblage_Field_List($name, $values);
|
||||
break;
|
||||
case 'many':
|
||||
$field = new Scores_Ciblage_Field_Many($name, $values);
|
||||
break;
|
||||
case 'one':
|
||||
$field = new Scores_Ciblage_Field_One($name, $values);
|
||||
break;
|
||||
case 'range':
|
||||
$field = new Scores_Ciblage_Field_Range($name, $values);
|
||||
break;
|
||||
case 'rangedate':
|
||||
$field = new Scores_Ciblage_Field_RangeDate($name, $values);
|
||||
break;
|
||||
case 'search':
|
||||
$field = new Scores_Ciblage_Field_Search($name, $values);
|
||||
break;
|
||||
case 'tree':
|
||||
$field = new Scores_Ciblage_Field_Tree($name, $values);
|
||||
break;
|
||||
case 'tag':
|
||||
$field = new Scores_Ciblage_Field_Tag($name, $values);
|
||||
break;
|
||||
}
|
||||
$htmlfield = $field->getHTML($valueSelected);
|
||||
$html.= $htmlfield;
|
||||
|
||||
if ( method_exists($field, 'getJS') ) {
|
||||
$html.= '<script>'.$field->getJS().'</script>';
|
||||
}
|
||||
}
|
||||
$html.= '</div>';
|
||||
|
||||
|
||||
} else {
|
||||
@ -719,7 +769,6 @@ class Scores_Ciblage_FieldList
|
||||
|
||||
$item['label'] = $info['label'];
|
||||
$item['desc'] = $info['desc'];
|
||||
$item['type'] = $info['type'];
|
||||
|
||||
if ( $withValues ) {
|
||||
$item['values'] = $this->getItemValues($key);
|
||||
@ -846,6 +895,7 @@ class Scores_Ciblage_FieldList
|
||||
$staticValuesLabel = $this->getItemValues($key);
|
||||
switch($info['type']) {
|
||||
case 'range':
|
||||
case 'rangedate':
|
||||
if ( floatval($value)>=floatval($staticValuesLabel['min']) && floatval($value)<=floatval($staticValuesLabel['max']) ) {
|
||||
return true;
|
||||
}
|
||||
@ -874,7 +924,9 @@ class Scores_Ciblage_FieldList
|
||||
return $values[0]." à ".$values[1];
|
||||
break;
|
||||
case 'rangedate':
|
||||
return "du ".$values[0]." à ".$values[1];
|
||||
$date1 = new Zend_Date($values[0], 'YYYYMMdd');
|
||||
$date2 = new Zend_Date($values[1], 'YYYYMMdd');
|
||||
return "du ".$date1->toString('dd/MM/YYYY')." au ".$date2->toString('dd/MM/YYYY');
|
||||
break;
|
||||
default:
|
||||
return "Liste";
|
||||
|
@ -1,5 +1,4 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
$(document).ready(function(){
|
||||
/*$('div#criteres a.criterelist').click(function(e){
|
||||
e.preventDefault();
|
||||
var title = $(this).attr('title');
|
||||
@ -26,38 +25,33 @@ $(document).ready(function()
|
||||
$('div.ciblage-one input[type=radio]').change(function(e){
|
||||
e.preventDefault();
|
||||
var btn = $(this);
|
||||
var result = set(btn.attr('name'), btn.val());
|
||||
if (result===false) {
|
||||
alert('error');
|
||||
btn.button('reset');
|
||||
}
|
||||
set(btn.attr('name'), btn.val());
|
||||
});
|
||||
|
||||
$('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===false) {
|
||||
alert('error');
|
||||
}
|
||||
var values = $('select[name='+key+']:selected').val();
|
||||
set(key, values);
|
||||
});
|
||||
|
||||
$('div.ciblage-range button').click(function(e){
|
||||
e.preventDefault();
|
||||
var key = $(this).data('ciblagename');
|
||||
var values = $('#slider-'+key).slider('getValue');
|
||||
var result = set(key, values);
|
||||
if (result===false) {
|
||||
alert('error');
|
||||
}
|
||||
set(key, values);
|
||||
});
|
||||
|
||||
$('div.ciblage-rangedate button').click(function(e){
|
||||
e.preventDefault();
|
||||
var key = $(this).data('ciblagename');
|
||||
|
||||
alert(values);
|
||||
var date = $('div#rangedate-'+key+' span').text();
|
||||
var reg = new RegExp(" - ", "g");
|
||||
var get = date.replace(reg,',').split( /,\s*/ );
|
||||
var values = [];
|
||||
values[0] = moment(get[0], "DD/MM/YYYY").format("YYYYMMDD");
|
||||
values[1] = moment(get[1], "DD/MM/YYYY").format("YYYYMMDD");
|
||||
set(key, values);
|
||||
});
|
||||
|
||||
$('input[type=text].autocomplete').bind('keydown', function( event ) {
|
||||
@ -122,24 +116,25 @@ $(document).ready(function()
|
||||
function set(key, value, ex) {
|
||||
ex = typeof ex !== 'undefined' ? ex : 0;
|
||||
$('#panel').html('<span class="glyphicon glyphicon-refresh img-rounded"></span>');
|
||||
var result = false;
|
||||
var isCount = false;
|
||||
$.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;
|
||||
isCount = false;
|
||||
}
|
||||
if (data.error==2) {
|
||||
$('div#actionMessage').html('<div class="alert alert-warning"><strong>Information !</strong> Valeur saisi incorrecte.</div>');
|
||||
result = false;
|
||||
isCount = false;
|
||||
}
|
||||
result = true;
|
||||
isCount = true;
|
||||
//Resume criteres content
|
||||
$.post('/index/criteres', { total:data.count, insee:data.insee }, function(data) { $('#panel').html(data); });
|
||||
if (isCount) {
|
||||
$.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;
|
||||
isCount = false;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function split( val ) {
|
||||
|
Loading…
Reference in New Issue
Block a user