Merge from 1.2

This commit is contained in:
Michael RICOIS 2012-07-31 16:02:06 +00:00
commit 9affb31118
8 changed files with 142 additions and 77 deletions

View File

@ -1,11 +1,6 @@
<?php <?php
class ComptageController extends Zend_Controller_Action class ComptageController extends Zend_Controller_Action
{ {
public function init()
{
/* Initialize action controller here */
}
public function indexAction() public function indexAction()
{ {
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();

View File

@ -24,7 +24,7 @@ class FieldsController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$family = $request->getParam('family'); $family = $request->getParam('family');
if (!empty($family) ) if ( !empty($family) )
{ {
$fields = new Scores_Fields(); $fields = new Scores_Fields();
$fields->resetFamille($family); $fields->resetFamille($family);
@ -67,7 +67,7 @@ class FieldsController extends Zend_Controller_Action
$q = preg_replace("/['-]/", ' ', $q); $q = preg_replace("/['-]/", ' ', $q);
//Remove characters //Remove characters
$q = preg_replace("/^[a-z0-9]\s/i", '', $q); $q = preg_replace("/^[a-z]\s/i", '', $q);
//Detect if we have string //Detect if we have string
if ( preg_match("/[a-zA-Z]+/", $q) ) if ( preg_match("/[a-zA-Z]+/", $q) )
@ -92,13 +92,11 @@ class FieldsController extends Zend_Controller_Action
$sql->where("LOWER(NC) ".$where); $sql->where("LOWER(NC) ".$where);
} }
$result = $table->fetchAll($sql); $result = $table->fetchAll($sql);
if (count($result)>0) { foreach ($result as $item) {
foreach ($result as $item) { $output[] = array(
$output[] = array( 'label' => $item->NCCENR . ' (Région)',
'label' => $item->NCCENR . ' (Région)', 'value' => 'R'.$item->REGION
'value' => 'R'.$item->REGION );
);
}
} }
//Département //Département
@ -119,13 +117,11 @@ class FieldsController extends Zend_Controller_Action
$sql->where("LOWER(libdep) ".$where); $sql->where("LOWER(libdep) ".$where);
} }
$result = $table->fetchAll($sql); $result = $table->fetchAll($sql);
if (count($result)>0) { foreach ($result as $item) {
foreach ($result as $item) { $output[] = array(
$output[] = array( 'label' => $item->libdep . ' (Dépatement)',
'label' => $item->libdep . ' (Département)', 'value' => 'D'.$item->numdep
'value' => 'D'.$item->numdep );
);
}
} }
//Ville //Ville
@ -146,31 +142,28 @@ class FieldsController extends Zend_Controller_Action
$sql->where("LOWER(Commune) ".$where); $sql->where("LOWER(Commune) ".$where);
} }
$result = $table->fetchAll($sql); $result = $table->fetchAll($sql);
if (count($result)>0) { foreach ($result as $item) {
foreach ($result as $item) { $output[] = array(
$output[] = array( 'label' => $item->Commune . ', '. $item->Codepos .' (Ville)',
'label' => $item->Commune . ', '. $item->Codepos .' (Ville)', 'value' => 'C'.$item->INSEE
'value' => 'C'.$item->INSEE );
);
}
} }
} elseif ( preg_match('/[0-9]{1,5}/', $q) ) { } elseif ( preg_match('/[0-9]{1,5}/', $q) ) {
//Code Postal //Code Postal
$table = new Application_Model_CodePostaux(); $table = new Application_Model_CodePostaux();
$sql = $table->select()->where('Codepos LIKE "'.$q.'%"')->limit(1); $sql = $table->select()->where('Codepos LIKE "'.$q.'%"');
$result = $table->fetchAll($sql); $result = $table->fetchAll($sql);
if (count($result)>0) { foreach ($result as $item) {
foreach ($result as $item) { $output[] = array(
$output[] = array( 'label' => $item->Commune . ', '. $item->Codepos .' (Ville)',
'label' => $item->Codepos . ' ( Code postal )', 'value' => 'C'.$item->INSEE
'value' => $item->Codepos );
);
}
} }
} }
break; break;
case 'cj': case 'cj':
$table = new Application_Model_FormeJuridique(); $table = new Application_Model_FormeJuridique();

View File

@ -91,10 +91,59 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
$this->checkboxHTML($name, $options), $this->checkboxHTML($name, $options),
$title $title
); );
break;
case 'intervalDate':
$html.= $this->structureHTML(
$label,
$this->intervalDateHTML($name, $options),
$title
);
break; break;
case 'interval':
$html.= $this->structureHTML(
$label,
$this->intervalHTML($name, $field),
$title
);
break;
case 'date':
$html.= $this->structureHTML(
$field['label'],
$this->dateHTML($name, $field));
break;
case 'text':
$html.= $this->structureHTML(
$label,
$this->textHTML($name, $options),
$title
);
break;
case 'textarea':
$html.= $this->structureHTML(
$field['label'],
$this->textareaHTML($name, $field)
);
break;
case 'radio':
$html.= $this->structureHTML(
$field['label'],
$this->radioHTML($name, $field));
break;
case 'file':
$html.= $this->structureHTML(
$field['label'],
$this->fileuploadHtml($name, $field));
break;
case 'tree': case 'tree':
//Do nothing //Do nothing
break; break;
case 'list':
$html.= $this->structureHTML(
$label,
$this->textareaHTML($name, $options),
$title
);
break;
default: default:
$html.= $this->structureHTML($name, ''); $html.= $this->structureHTML($name, '');
break; break;
@ -334,32 +383,8 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
} }
/* Textes */ /* Textes */
private function textHTML($name, $options) protected function textHTML($name, $options)
{ {
$session = new Scores_Fields();
switch($name) {
case 'ape_entrep':
case 'ape_etab':
$type = 'Naf';
break;
case 'vil':
$type= 'Vil';
break;
case 'adr_com':
case 'adr_com_ex':
$type= $name;
break;
case 'cj':
$type = 'Cj';
break;
case 'cj_ex':
$type = 'Cj_ex';
break;
case 'adr_dept':
case 'adr_dept_ex':
$type= $name;
break;
}
$return = '<input type="text" class="criteres autocomplete" name="'.$name.'" />'; $return = '<input type="text" class="criteres autocomplete" name="'.$name.'" />';
$return.= '<ul id="selectqueries"></ul>'; $return.= '<ul id="selectqueries"></ul>';
$return.= '<a href="#" class="autocomplete">Sélectionner</a>'; $return.= '<a href="#" class="autocomplete">Sélectionner</a>';
@ -368,14 +393,12 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
} }
/* Textarea */ /* Textarea */
private function textareaHTML($name, $field) protected function textareaHTML($name, $field)
{ {
$return = '<a class="arborescence" title="'.$field['title'].'" href="'.$this->view->url(array('controller' => 'arborescence', 'action' => $field['action'], 'key' => $name)).'"> $return = '<textarea class="criteres" name="'.$name.'" ></textarea>';
<img src="/themes/default/images/arborescence.gif" /> $return.= '<a href="#" class="list">Sélectionner</a>';
</a> <img style="cursor:pointer" class="manuel" ref="'.$name.'" src="/themes/default/images/Textarea.gif" title="Champs texte"/>'; $return.= '&nbsp;<a href="#" class="listEx">Exclure</a>';
if($name == 'adr_com') return $return;
$return .= ' <img src="/themes/default/images/img_carte_fr.gif" title="Carte de france"/>';
return ($return);
} }
private function fileuploadHtml($name, $field) private function fileuploadHtml($name, $field)

View File

@ -60,12 +60,15 @@
<?=$this->Field('geo_etranger')?> <?=$this->Field('geo_etranger')?>
<?=$this->Field('geo_corse')?> <?=$this->Field('geo_corse')?>
</li> </li>
<li class="advanced"><?=$this->Field('codespostaux')?></li>
<li class="advanced"><?=$this->Field('codesinsee')?></li>
<li><?=$this->Field('zus')?></li> <li><?=$this->Field('zus')?></li>
<li><?=$this->Field('zru')?></li> <li><?=$this->Field('zru')?></li>
<li><?=$this->Field('zfu')?></li> <li><?=$this->Field('zfu')?></li>
<li><?=$this->Field('cucs')?></li> <li><?=$this->Field('cucs')?></li>
<li><?=$this->Field('zrr')?></li> <li><?=$this->Field('zrr')?></li>
<li><?=$this->Field('zafr')?></li> <li><?=$this->Field('zafr')?></li>
<li class="mode"><img src="/themes/default/images/fleche-bas.gif" /></li>
</ul> </ul>
</div> </div>
<div style="text-align:right;margin-top:20px;"> <div style="text-align:right;margin-top:20px;">

View File

@ -107,4 +107,4 @@ foreach($keys as $key) {
$db->insert('fields_minmax', $data); $db->insert('fields_minmax', $data);
if ($opts->manuel) echo $key.' -> min:'.$result->min.' max:'.$result->max."\n"; if ($opts->manuel) echo $key.' -> min:'.$result->min.' max:'.$result->max."\n";
} }
if ($opts->manuel) print('Terminé'); if ($opts->manuel) print("Terminé\n");

View File

@ -451,7 +451,7 @@ class Ciblage
if ($min===null || $max===null) if ($min===null || $max===null)
return; return;
$this->setFilterRange('age_entrep', $min, $max); $this->setFilterRange('age_entrep', $min, $max);
} }
} }
@ -1058,6 +1058,28 @@ class Ciblage
} }
} }
} }
protected function codesinsee($value)
{
if ( array_key_exists('in', $value) && is_array($value['in']) && count($value['in'])>0 ) {
$this->setFilter('codeCommune', $value['in']);
}
if ( array_key_exists('ex', $value) && is_array($value['ex']) && count($value['ex'])>0 ) {
$this->setFilter('codeCommune', $value['ex'], true);
}
}
protected function codespostaux($value)
{
if ( array_key_exists('in', $value) && is_array($value['in']) && count($value['in'])>0 ) {
$this->setFilter('adr_cp', $value['in']);
}
if ( array_key_exists('ex', $value) && is_array($value['ex']) && count($value['ex'])>0 ) {
$this->setFilter('adr_cp', $value['ex']);
}
}
protected function getChildCJ($list) protected function getChildCJ($list)
{ {

View File

@ -333,7 +333,6 @@ class Scores_Fields
'famille' => 'geographique', 'famille' => 'geographique',
'activated' => true, 'activated' => true,
), ),
'geo_domtom' => array( 'geo_domtom' => array(
'label' => 'Exlcure les DOM-TOM', 'label' => 'Exlcure les DOM-TOM',
'fields' => array( 'fields' => array(
@ -361,6 +360,24 @@ class Scores_Fields
'activated' => true, 'activated' => true,
'title' => 'Exclure les établissements situés en région Corse', 'title' => 'Exclure les établissements situés en région Corse',
), ),
'codesinsee' => array(
'label' => 'Liste de codes Insee',
'fields' => array(
'list' => array(),
),
'famille' => 'geographique',
'activated' => true,
'title' => 'Liste de code Insee séparés par des virgules ou des points-virgules',
),
'codespostaux' => array(
'label' => 'Liste de codes postaux',
'fields' => array(
'list' => array(),
),
'famille' => 'geographique',
'activated' => true,
'title' => 'Liste de code postaux séparés des virgules ou des points-virgules',
),
'adr_reg' => array( 'adr_reg' => array(
'label' => 'Liste code région', 'label' => 'Liste code région',
'fields' => array( 'fields' => array(
@ -770,6 +787,7 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
/** /**
* single * single
* interval
* multiple * multiple
* *
* *
@ -825,7 +843,10 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
break; break;
case 'tree': case 'tree':
//@todo : Check if values exist //@todo : Check if values exist
break; break;
case 'list':
break;
} }
//Save the value //Save the value
@ -841,10 +862,6 @@ Les zones urbaines sensibles constituent un sous-ensemble de l'ensemble plus lar
return true; return true;
} }
/** /**
* Définir les critères en une fois * Définir les critères en une fois

View File

@ -87,7 +87,7 @@ $(document).ready(function()
var oldhtml = $('ul#selectqueries').html(); var oldhtml = $('ul#selectqueries').html();
var newhtml = '<li name="' + ui.item.value + '">' + ui.item.label + '</li>'; var newhtml = '<li name="' + ui.item.value + '">' + ui.item.label + '</li>';
$('ul#selectqueries').html(oldhtml + newhtml); $('ul#selectqueries').html(oldhtml + newhtml);
} }
this.value = ''; this.value = '';
return false; return false;
}, },
@ -105,6 +105,7 @@ $(document).ready(function()
}); });
set(name, values.join(',')); set(name, values.join(','));
} }
ul.empty();
}); });
$('#tabs').delegate('a.autocompleteEx', 'click', function(e){ $('#tabs').delegate('a.autocompleteEx', 'click', function(e){
@ -118,6 +119,7 @@ $(document).ready(function()
}); });
set(name, values.join(','), 1); set(name, values.join(','), 1);
} }
ul.empty();
}); });
$('#tabs').delegate('a.selectMultiple', 'click', function(e){ $('#tabs').delegate('a.selectMultiple', 'click', function(e){
@ -217,6 +219,16 @@ $(document).ready(function()
} }
}); });
$('#tabs').delegate('a.list', 'click', function(e) {
e.stopPropagation();
var obj = $(this).parent().find('textarea.criteres');
var name = obj.attr('name');
var value = obj.val();
if (value!='') {
set(name, value);
}
});
}); });
function set(key, value, ex) function set(key, value, ex)