odea/application/controllers/JuridiqueController.php
Michael RICOIS cf528a531a autocomplete
2012-05-14 13:16:14 +00:00

49 lines
1.1 KiB
PHP

<?php
class JuridiqueController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$field = new Scores_Fields();
$this->view->fields = $field;
}
public function resetAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$fields = new Scores_Fields();
$fields->resetFamille('juridique');
}
public function completedAction()
{
$table = new Application_Model_FormeJuridique();
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
$q = strtolower($request->getParam('q'));
$separator = ' , ';
$sql = $table->select()
->where('LOWER(fjLibelle) LIKE "%'.$q.'%"')
->where('LENGTH(fjCode) = 4');
$result = $table->fetchAll($sql);
foreach ($result as $item) {
$output[] = array(
'label' => $item->fjLibelle . $separator . $item->fjCode,
'value' => $item->fjCode
);
}
echo json_encode($output);
}
}