Exemplo n.º 1
0
 /**
  * List action
  */
 public function contactListAction()
 {
     $page = $this->_request->getParam('page');
     $perPage = $this->_request->getParam('perPage');
     $langFilter = $this->_request->getParam('langFilter');
     $searchFilter = $this->_request->getParam('searchFilter');
     $fromFilter = $this->_request->getParam('fromFilter');
     $toFilter = $this->_request->getParam('toFilter');
     $orderFilter = $this->_request->getParam('order');
     if (isset($fromFilter) && !empty($fromFilter)) {
         $fromFilter = HCMS_Utils_Date::dateLocalToCustom($fromFilter);
     }
     if (isset($toFilter) && !empty($toFilter)) {
         $toFilter = HCMS_Utils_Date::dateLocalToCustom($toFilter);
     }
     if (isset($orderFilter) && !empty($orderFilter)) {
         $orderBy = array($orderFilter);
     } else {
         $orderBy = array('c.posted DESC');
     }
     if (!isset($page) || $page < 1) {
         $page = 1;
     }
     if (!isset($perPage) || $perPage < 1 || $perPage > 100) {
         $perPage = 100;
     }
     $paging = array('page' => $page, 'perPage' => $perPage);
     $criteria = array('application_id' => $this->_applicationId);
     if (isset($searchFilter) && $searchFilter != "") {
         $criteria['search_filter'] = $searchFilter;
     }
     if (isset($langFilter) && $langFilter != "") {
         $criteria['lang_filter'] = $langFilter;
     }
     if (isset($fromFilter) && $fromFilter != "") {
         $criteria['from_filter'] = $fromFilter;
     }
     if (isset($toFilter) && $toFilter != "") {
         $criteria['to_filter'] = $toFilter;
     }
     $records = Contact_Model_ContactMapper::getInstance()->fetchAll($criteria, $orderBy, $paging);
     $data = array('total' => $paging['total'], 'page' => $paging['page'], 'records' => $paging['records'], 'perPage' => $paging['perPage'], 'rows' => array());
     $languages = Application_Model_TranslateMapper::getInstance()->getLanguages();
     /* @var $record Application_Model_Candidate */
     foreach ($records as $record) {
         $data['rows'][] = array('id' => $record->get_id(), 'posted' => HCMS_Utils_Time::timeMysql2Local($record->get_posted()), 'first_name' => $record->get_first_name(), 'last_name' => $record->get_last_name(), 'email' => $record->get_email(), 'street' => $record->get_street(), 'country' => $record->get_country(), 'phone' => $record->get_phone(), 'mobile' => $record->get_mobile(), 'fax' => $record->get_fax(), 'zip' => $record->get_zip(), 'city' => $record->get_city(), 'gender' => $this->translate($record->get_gender()), 'description' => $record->get_description(), 'description_short' => $this->view->abbreviate($record->get_description(), 150), 'message' => $record->get_message(), 'message_short' => $this->view->abbreviate($record->get_message(), 150), 'language' => $languages[$record->get_language()]['name']);
     }
     $this->_helper->json->sendJson($data);
 }
 protected function populateCriteria(&$criteria, &$orderBy, &$paging)
 {
     $page = $this->_request->getParam('page');
     $form_id = $this->_request->getParam('form_id');
     $perPage = $this->_request->getParam('perPage');
     $langFilter = $this->_request->getParam('langFilter');
     $searchFilter = $this->_request->getParam('searchFilter');
     $fromFilter = $this->_request->getParam('fromFilter');
     $toFilter = $this->_request->getParam('toFilter');
     $orderFilter = $this->_request->getParam('order');
     if (isset($fromFilter) && !empty($fromFilter)) {
         $fromFilter = HCMS_Utils_Date::dateLocalToCustom($fromFilter);
     }
     if (isset($toFilter) && !empty($toFilter)) {
         $toFilter = HCMS_Utils_Date::dateLocalToCustom($toFilter);
     }
     if (isset($orderFilter) && !empty($orderFilter)) {
         $orderBy = array($orderFilter);
     } else {
         $orderBy = array('c.posted DESC');
     }
     if (!isset($page) || $page < 1) {
         $page = 1;
     }
     if (!isset($perPage) || $perPage < 1 || $perPage > 100) {
         $perPage = 100;
     }
     $paging = array('page' => $page, 'perPage' => $perPage);
     $criteria = array('application_id' => $this->_applicationId);
     if (isset($searchFilter) && $searchFilter != "") {
         $criteria['search_filter'] = $searchFilter;
     }
     if (isset($form_id) && $form_id != "") {
         $criteria['form_id'] = $form_id;
     }
     if (isset($langFilter) && $langFilter != "") {
         $criteria['lang_filter'] = $langFilter;
     }
     if (isset($fromFilter) && $fromFilter != "") {
         $criteria['from_filter'] = $fromFilter;
     }
     if (isset($toFilter) && $toFilter != "") {
         $criteria['to_filter'] = $toFilter;
     }
     return;
 }