public function indexAction()
 {
     $form = new SearchForm();
     $searchEntity = new Search();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($searchEntity->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $searchEntity->exchangeArray($form->getData());
             try {
                 $searchEntity = $this->getServiceLocator()->get('application.service.elasticsearch')->search($searchEntity);
             } catch (\Exception $e) {
                 $this->getServiceLocator()->get('log.app')->emerg($e->getMessage());
                 $searchEntity->setResult(array('Error' => $e->getMessage()));
             }
         }
     }
     return new ViewModel(array('form' => $form, 'searchEntity' => $searchEntity));
 }
 public function listAction()
 {
     $loggedInUserAddress = array();
     $common = new Common();
     $model = new Practitioners();
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $session = new Container('frontend');
     $loggedInUser = $session->userid;
     $userType = $session->user_type_id;
     $auth = new FrontEndAuth();
     $loggedInUserAddress = $model->getLoggedInUserAddress($loggedInUser, $userType, $api_url);
     if ($this->getRequest()->isXmlHttpRequest()) {
         if ($this->getRequest()) {
             $post = $this->getRequest()->getPost();
             $remoteAddr = $this->getRequest()->getServer('REMOTE_ADDR');
             $model->userlistByFilterData($post, $api_url, $remoteAddr);
             exit;
         } else {
             echo '';
             // return null
             exit;
         }
     } else {
         $sp_list = '';
         $treatment_list = $common->getAllservices($api_url);
         $country_list = $common->getCountries($api_url);
         $search_form = new SearchForm($treatment_list, $common->getstatesByCountry($api_url, $loggedInUserAddress->country_id));
         $data = $this->request->getPost();
         if ($this->request->isPost()) {
             $search_form->bind($data);
         }
         // getting banner for this page
         $banners = $common->getBanner($api_url, 2);
         // getting advertisments
         $ad = $common->getAdvertisement($api_url, 2);
         return new ViewModel(array('treatment_list' => $treatment_list, 'country_list' => $country_list, 'address' => $loggedInUserAddress, 'state' => $common->getstatesByCountry($api_url, $loggedInUserAddress->country_id), 'search_form' => $search_form, 'auth' => $auth, 'location_types' => $model->getLocationTypes($api_url), 'banners' => $banners, 'advertisement' => $ad));
     }
 }