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

50 lines
1.0 KiB
PHP

<?php
class EconomiqueController 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('economique');
}
public function completedAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
$q = strtolower($request->getParam('q'));
$separator = ' , ';
$table = new Application_Model_Naf();
$sql = $table->select()
->where('LOWER(lib) LIKE "%'.$q.'%"')
->where('niveau = 5');
$result = $table->fetchAll($sql);
foreach ($result as $item) {
$output[] = array(
'label' => $item->lib . $separator . $item->code,
'value' => $item->code
);
}
echo json_encode($output);
}
}