Issue #0001787:
This commit is contained in:
parent
e0372ca5f0
commit
b780a59f8b
@ -2211,4 +2211,29 @@ class SaisieController extends Zend_Controller_Action
|
||||
$this->view->assign('message', $message);
|
||||
$this->view->assign('refresh', $refresh);
|
||||
}
|
||||
|
||||
public function citysearchAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$cp = $this->getRequest()->getParam('cp', null);
|
||||
$output = array();
|
||||
|
||||
if ( null !== $cp && strlen($cp)<6) {
|
||||
$city = new Application_Model_City();
|
||||
$sql = $city->select('cp, commune');
|
||||
$sql->where("cp LIKE '".$cp."%'");
|
||||
$rows = $city->fetchAll($sql);
|
||||
if ( count($rows)>0 ) {
|
||||
foreach ($rows as $item) {
|
||||
$output[] = array(
|
||||
'label' => $item->cp.": ".$item->commune,
|
||||
'value' => $item->cp,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('output', $output);
|
||||
}
|
||||
}
|
5
application/models/City.php
Normal file
5
application/models/City.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class Application_Model_City extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'tabVilles';
|
||||
}
|
@ -0,0 +1 @@
|
||||
<?=json_encode($this->output)?>
|
@ -92,6 +92,25 @@ $('input[name=naissance_date]').datepicker({ changeMonth: true, changeYear: true
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('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 },
|
||||
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);
|
||||
$('select[name=adresse_pays]').val('FRA');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="fieldgrp">
|
||||
<label>Pays</label>
|
||||
<div class="field">
|
||||
|
@ -280,6 +280,26 @@ class WsScores
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCatalogCity($id, $columns)
|
||||
{
|
||||
$params = new stdClass();
|
||||
$params->id = $id;
|
||||
$params->columns = $columns;
|
||||
$client = $this->loadClient('catalog');
|
||||
try {
|
||||
$reponse = $client->getCity($params);
|
||||
return $reponse->getCityResult;
|
||||
} catch (SoapFault $fault) {
|
||||
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
|
||||
return $fault->faultstring;
|
||||
} else {
|
||||
echo $client->__getLastResponse();
|
||||
//$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCatalogLegalForm($id, $columns)
|
||||
{
|
||||
|
6
scripts/build/config/_sql/structure/tabVilles.sql
Normal file
6
scripts/build/config/_sql/structure/tabVilles.sql
Normal file
@ -0,0 +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,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM COMMENT='Codes Postales';
|
@ -43,6 +43,11 @@ $catalogs = array(
|
||||
'table' => 'tabFJur',
|
||||
'method' => array('name'=>'getCatalogLegalForm', 'params'=> array( null , array('code', 'libelle', 'libelleEn') ))
|
||||
),
|
||||
'city' => array(
|
||||
'sql' => 'tabVilles.sql',
|
||||
'table' => 'tabVilles',
|
||||
'method' => array('name'=>'getCatalogCity', 'params'=> array( null , array('cp', 'commune') ))
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user