public function searchAction()
 {
     $form = new PAP_Form_SearchForm();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $this->_helper->viewRenderer->setNoRender();
         $this->_helper->getHelper('layout')->disableLayout();
         $page = $_POST['page'];
         // get the requested page
         $limit = $_POST['rows'];
         // get how many rows we want to have into the grid
         $sidx = $_POST['sidx'];
         // get index row - i.e. user click to sort
         $sord = $_POST['sord'];
         $city_id = $this->getParam('city');
         $categories = '' . $this->getParam('categories');
     } else {
         $page = 0;
         // get the requested page
         $limit = 10;
         // get how many rows we want to have into the grid
         $sidx = 0;
         // get index row - i.e. user click to sort
         $sord = 'starts';
         $city_id = 150;
         return;
     }
     if (!$sidx) {
         $sidx = 1;
     }
     $promo = new PAP_Model_Promotion();
     $promotions = $promo->getPromotionsByCity($city_id, $categories);
     $count = count($promotions);
     if ($count > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $start = $limit * $page - $limit;
     if ($start < 0) {
         $start = 0;
     }
     //$row = $promoMapper->getByUserId($user->getId(), $sidx, $sord, $start, $limit);
     $response['page'] = $page;
     $response['total'] = $total_pages;
     $response['records'] = $count;
     $i = 0;
     foreach ($promotions as $r) {
         $response['rows'][$i]['id'] = $r['promotion_id'];
         //id
         $r['path'] = 'images' . $r['path'];
         $response['rows'][$i]['cell'] = array($r['path'], $r['name'], $r['displayed_text'], $r['street'] . ' ' . $r['number'] . ', ' . $r['city'], $r['promo_value'], isset($r['distance']) ? (string) $r['distance'] : 'N/D');
         $i++;
     }
     echo $this->_helper->json($response);
 }