Issue #0001787: modification concernant les colonnes de la table tabVilles
This commit is contained in:
parent
b51a1210e8
commit
2107c62341
@ -2215,19 +2215,23 @@ class SaisieController extends Zend_Controller_Action
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$cp = $this->getRequest()->getParam('cp', null);
|
||||
$cpVille = $this->getRequest()->getParam('cpville', null);
|
||||
$output = array();
|
||||
|
||||
if ( null !== $cp && strlen($cp)<6) {
|
||||
$city = new Application_Model_City();
|
||||
$sql = $city->select('cp, commune');
|
||||
$sql->where("cp LIKE '".$cp."%'");
|
||||
if ( null !== $cpVille) {
|
||||
$city = new Application_Model_City();
|
||||
$sql = $city->select('code, libelle');
|
||||
if (is_numeric($cpVille) && strlen($cpVille)<6) {
|
||||
$sql->where("code LIKE '".$cpVille."%'");
|
||||
} else {
|
||||
$sql->where("libelle LIKE '%".$cpVille."%'");
|
||||
}
|
||||
$rows = $city->fetchAll($sql);
|
||||
if ( count($rows)>0 ) {
|
||||
foreach ($rows as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->cp.": ".$item->commune,
|
||||
'value' => $item->cp,
|
||||
'label' => str_pad($item->code, 5, 0, STR_PAD_LEFT).": ".$item->libelle,
|
||||
'value' => str_pad($item->code, 5, 0, STR_PAD_LEFT),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -97,18 +97,19 @@ $('input[name=adresse_cp]').autocomplete({
|
||||
minLength: 4,
|
||||
delay: 250,
|
||||
source: function(request, response) {
|
||||
var cp = $('input[name=adresse_cp]').val();
|
||||
$.getJSON('<?=$this->url(array('controller'=>'saisie','action'=>'citysearch'),null,true)?>', { cp: cp },
|
||||
var cpVille = $('input[name=adresse_cp]').val();
|
||||
$.getJSON('<?=$this->url(array('controller'=>'saisie','action'=>'citysearch'),null,true)?>', { cpville: cpVille },
|
||||
function(data) { response(data); }
|
||||
);
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
var value = ui.item.label;
|
||||
value = value.replace(ui.item.value+': ','');
|
||||
$('input[name=adresse_ville]').val(value);
|
||||
var text = ui.item.label;
|
||||
text = text.replace(ui.item.value+': ','');
|
||||
$(this).val(ui.item.value);
|
||||
$('input[name=adresse_ville]').val(text);
|
||||
$('select[name=adresse_pays]').val('FRA');
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="fieldgrp">
|
||||
|
@ -1,6 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `tabVilles` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`cp` char(5) NOT NULL,
|
||||
`commune` varchar(80) NOT NULL,
|
||||
`code` mediumint(5) UNSIGNED ZEROFILL DEFAULT NULL,
|
||||
`libelle` char(45) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM COMMENT='Codes Postales';
|
@ -46,7 +46,7 @@ $catalogs = array(
|
||||
'city' => array(
|
||||
'sql' => 'tabVilles.sql',
|
||||
'table' => 'tabVilles',
|
||||
'method' => array('name'=>'getCatalogCity', 'params'=> array( null , array('cp', 'commune') ))
|
||||
'method' => array('name'=>'getCatalogCity', 'params'=> array( null , array('codePostal', 'LIBGEO') ))
|
||||
),
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user