Date interval selection
This commit is contained in:
parent
5f412b2315
commit
5c74b398f5
@ -87,6 +87,12 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
$html.= $this->structureHTML(
|
||||
$label,
|
||||
$this->checkboxHTML($name, $options)
|
||||
);
|
||||
break;
|
||||
case 'intervalDate':
|
||||
$html.= $this->structureHTML(
|
||||
$label,
|
||||
$this->intervalDateHTML($name, $options)
|
||||
);
|
||||
break;
|
||||
case 'interval':
|
||||
@ -204,6 +210,11 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
return ($return);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown_type $name
|
||||
* @param unknown_type $options
|
||||
*/
|
||||
protected function checkboxHTML($name, $options)
|
||||
{
|
||||
$session = new Scores_Fields();
|
||||
@ -271,6 +282,65 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function intervalDateHTML($name, $options)
|
||||
{
|
||||
$session = new Scores_Fields();
|
||||
$sessionValeur = $session->getCritere($name);
|
||||
|
||||
$return = '';
|
||||
|
||||
$return.= '<select name="'.$name.'1_j" style="width:40px;">';
|
||||
for ($i=1;$i<=31;$i++) {
|
||||
$return.= '<option>'.str_pad($i,2,'0',STR_PAD_LEFT).'</option>';
|
||||
}
|
||||
$return.= '</select>';
|
||||
$return.= '<select name="'.$name.'1_m" style="width:40px;">';
|
||||
for ($i=1;$i<=12;$i++) {
|
||||
$return.= '<option>'.str_pad($i,2,'0',STR_PAD_LEFT).'</option>';
|
||||
}
|
||||
$return.= '</select>';
|
||||
$return.= '<select name="'.$name.'1_a" style="width:55px;">';
|
||||
for ($i=1900;$i<=date('Y');$i++) {
|
||||
$return.= '<option>'.$i.'</option>';
|
||||
}
|
||||
$return.= '</select>';
|
||||
|
||||
$return.= ' à ';
|
||||
|
||||
$return.= '<select name="'.$name.'2_j" style="width:40px;">';
|
||||
for ($i=1;$i<=31;$i++) {
|
||||
$select = '';
|
||||
if ($i==date('d')) {
|
||||
$select = ' selected';
|
||||
}
|
||||
$return.= '<option'.$select.'>'.str_pad($i,2,'0',STR_PAD_LEFT).'</option>';
|
||||
}
|
||||
$return.= '</select>';
|
||||
$return.= '<select name="'.$name.'2_m" style="width:40px;">';
|
||||
for ($i=1;$i<=12;$i++) {
|
||||
$select = '';
|
||||
if ($i==date('m')) {
|
||||
$select = ' selected';
|
||||
}
|
||||
$return.= '<option'.$select.'>'.str_pad($i,2,'0',STR_PAD_LEFT).'</option>';
|
||||
}
|
||||
$return.= '</select>';
|
||||
$return.= '<select name="'.$name.'2_a" style="width:55px;">';
|
||||
$lastYear = date('Y');
|
||||
for ($i=1900;$i<=$lastYear;$i++) {
|
||||
$select = '';
|
||||
if ($i==$lastYear) {
|
||||
$select = ' selected';
|
||||
}
|
||||
$return.= '<option'.$select.'>'.$i.'</option>';
|
||||
}
|
||||
$return.= '</select>';
|
||||
$return .= '<br/><a href="#" id="'.$name.'" class="intervalDate">Valider</a>';
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/* Interval */
|
||||
private function intervalHTML($name, $field)
|
||||
{
|
||||
|
@ -279,13 +279,28 @@ class Ciblage
|
||||
//Don't work
|
||||
protected function dateCrea_etab($value)
|
||||
{
|
||||
if ( array_key_exists('in', $value) ) {
|
||||
|
||||
$min = $value['in'][0];
|
||||
$max = $value['in'][1];
|
||||
|
||||
if ($min===null || $max===null)
|
||||
return;
|
||||
|
||||
$this->setFilterRange('dateCrea_etab', $min, $max);
|
||||
}
|
||||
}
|
||||
|
||||
//Don't work
|
||||
protected function dateCrea_ent($value)
|
||||
{
|
||||
$min = $value['in'][0];
|
||||
$max = $value['in'][1];
|
||||
|
||||
if ($min===null || $max===null)
|
||||
return;
|
||||
|
||||
$this->setFilterRange('dateCrea_ent', $min, $max);
|
||||
}
|
||||
|
||||
protected function nbActio($value)
|
||||
|
@ -114,6 +114,7 @@ class Scores_Fields
|
||||
'famille' => 'entreprise',
|
||||
'activated' => true,
|
||||
),
|
||||
|
||||
'nbMPubli' => array(
|
||||
'label' => 'Marchés publiques remportés',
|
||||
'fields' => array(
|
||||
@ -125,7 +126,7 @@ class Scores_Fields
|
||||
'dateCrea_ent' => array(
|
||||
'label' => "Date de création de l'entreprise",
|
||||
'fields' => array(
|
||||
'interval' => array('value' => array('0', '1000'))
|
||||
'intervalDate' => array('value' => null)
|
||||
),
|
||||
'famille' => 'entreprise',
|
||||
'activated' => true,
|
||||
@ -133,7 +134,7 @@ class Scores_Fields
|
||||
'dateCrea_etab' => array(
|
||||
'label' => "Date de création de l'établissement",
|
||||
'fields' => array(
|
||||
'interval' => array('value' => array('0', '1000'))
|
||||
'intervalDate' => array('value' => null )
|
||||
),
|
||||
'famille' => 'entreprise',
|
||||
'activated' => true,
|
||||
@ -460,7 +461,7 @@ class Scores_Fields
|
||||
'dateImmat' => array(
|
||||
'label' => 'Date d\'immatriculation',
|
||||
'fields' => array(
|
||||
'interval' => array('value' => array('0', '1000'))
|
||||
'intervalDate' => array('value' => null)
|
||||
),
|
||||
'famille' => 'juridique',
|
||||
'activated' => true,
|
||||
|
@ -140,10 +140,21 @@ $(document).ready(function()
|
||||
set(obj.attr('name'), obj.val(), 1);
|
||||
});
|
||||
|
||||
$('#tabs').delegate('a.intervalDate', 'click', function(e){
|
||||
e.preventDefault();
|
||||
var key = $(this).attr('id');
|
||||
var val1 = $('select[name='+key+'1_a]').val() + $('select[name='+key+'1_m]').val() + $('select[name='+key+'1_j]').val();
|
||||
var val2 = $('select[name='+key+'2_a]').val() + $('select[name='+key+'2_m]').val() + $('select[name='+key+'2_j]').val();
|
||||
if(!val1) val1 = '';
|
||||
if(!val2) val2 = '';
|
||||
var values = val1 + ',' + val2;
|
||||
set(key, values);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#tabs').delegate('a.interval', 'click', function(e){
|
||||
e.preventDefault();
|
||||
var key = $(this).attr('id'); //Remove id to find all input value
|
||||
var key = $(this).attr('id');
|
||||
var val1 = $('input[name='+key+'1]').val();
|
||||
var val2 = $('input[name='+key+'2]').val();
|
||||
if(!val1) val1 = '';
|
||||
@ -156,7 +167,7 @@ $(document).ready(function()
|
||||
|
||||
//@todo : We have two event bind on each element why ?
|
||||
$('.intervalSelect').change(function(){
|
||||
var key = $(this).attr('id'); //Remove id to find all input value
|
||||
var key = $(this).attr('id');
|
||||
var number = $(this).attr('number');
|
||||
if(number == 1) {
|
||||
$('span#'+key).html(' <span id="'+key+'"><a href="" class="intervalSelect" id="'+key+'">Valider</a></span>');
|
||||
|
@ -319,6 +319,8 @@ ul#fieldsblock li div.fieldgrp div.field input[type="checkbox"] {
|
||||
}
|
||||
|
||||
ul#fieldsblock li div.fieldgrp div.field select {
|
||||
font-size: 0.9em;
|
||||
margin: 2px 0;
|
||||
width:265px;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user