public function indexAction()
 {
     // Prepare form
     $this->view->form = $form = new User_Form_Search(array('type' => 'user'));
     $p = Zend_Controller_Front::getInstance()->getRequest()->getParams();
     $form->populate($p);
     $this->view->topLevelId = $form->getTopLevelId();
     $this->view->topLevelValue = $form->getTopLevelValue();
 }
예제 #2
0
 protected function _executeSearch()
 {
     // Check form
     $form = new User_Form_Search(array('type' => 'user'));
     if (!$form->isValid($this->_getAllParams())) {
         $this->view->error = true;
         return false;
     }
     $this->view->form = $form;
     // Get search params
     $page = (int) $this->_getParam('page', 1);
     $ajax = (bool) $this->_getParam('ajax', false);
     $options = $form->getValues();
     // Get table info
     $table = Engine_Api::_()->getItemTable('user');
     $userTableName = $table->info('name');
     $searchTable = Engine_Api::_()->fields()->getTable('user', 'search');
     $searchTableName = $searchTable->info('name');
     //extract($options); // displayname
     $profile_type = @$options['profile_type'];
     $displayname = @$options['displayname'];
     extract($options['extra']);
     // is_online, has_photo, submit
     // Contruct query
     $select = $table->select()->from($userTableName)->joinLeft($searchTableName, "`{$searchTableName}`.`item_id` = `{$userTableName}`.`user_id`", null)->where("{$userTableName}.search = ?", 1)->where("{$userTableName}.enabled = ?", 1)->order("{$userTableName}.displayname ASC");
     // Build the photo and is online part of query
     if (!empty($has_photo)) {
         $select->where($userTableName . '.photo_id != ?', "0");
     }
     if (!empty($is_online)) {
         $select->joinRight("engine4_user_online", "engine4_user_online.user_id = `{$userTableName}`.user_id", null)->group("engine4_user_online.user_id")->where($userTableName . '.user_id != ?', "0");
     }
     // Add displayname
     if (!empty($displayname)) {
         $select->where("`{$userTableName}`.`displayname` LIKE ?", "%{$displayname}%")->orWhere("`{$userTableName}`.`username` LIKE ?", "%{$displayname}%");
     }
     // Build search part of query
     $searchParts = Engine_Api::_()->fields()->getSearchQuery('user', $options);
     foreach ($searchParts as $k => $v) {
         $select->where("`{$searchTableName}`.{$k}", $v);
     }
     // Build paginator
     $paginator = Zend_Paginator::factory($select);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($page);
     $this->view->page = $page;
     $this->view->ajax = $ajax;
     $this->view->users = $paginator;
     $this->view->totalUsers = $paginator->getTotalItemCount();
     $this->view->userCount = $paginator->getCurrentItemCount();
     $this->view->topLevelId = $form->getTopLevelId();
     $this->view->topLevelValue = $form->getTopLevelValue();
     return true;
 }
예제 #3
0
 public function indexAction()
 {
     $this->view->title = "User";
     // calling form
     $searchForm = new User_Form_Search();
     $this->view->form = $searchForm;
     //calling  model
     $userdetail = new User_Model_User();
     $result = $userdetail->getUserDetails();
     //listing designation
     $designation = $this->view->adm->viewRecord("ourbank_master_designation", "id", "DESC");
     foreach ($designation as $designation) {
         $searchForm->designation->addMultiOption($designation['id'], $designation['name']);
     }
     //listing grants
     $grant = $this->view->adm->viewRecord("ourbank_grant", "id", "DESC");
     foreach ($grant as $grant) {
         $searchForm->grant_id->addMultiOption($grant['id'], $grant['name']);
     }
     //listing office
     $user = new User_Model_User();
     $bankname = $this->view->adm->viewRecord("ourbank_office", "id", "DESC");
     foreach ($bankname as $bankname) {
         $searchForm->bank->addMultiOption($bankname['id'], $bankname['name']);
     }
     //pagination
     $page = $this->_getParam('page', 1);
     $paginator = Zend_Paginator::factory($result);
     $paginator->setItemCountPerPage(5);
     $paginator->setCurrentPageNumber($page);
     $this->view->paginator = $paginator;
     //search action
     if ($this->_request->isPost() && $this->_request->getPost('Search')) {
         if ($this->_request->isPost()) {
             if ($searchForm->isValid($this->_request->getPost())) {
                 $result = $userdetail->userSearch($searchForm->getValues());
                 $page = $this->_getParam('page', 1);
                 $paginator = Zend_Paginator::factory($result);
                 $paginator->setItemCountPerPage(5);
                 $paginator->setCurrentPageNumber($page);
                 $this->view->paginator = $paginator;
             }
             //error message
             if (!$result) {
                 echo "<font color='RED'>Records Not Found Try Again...</font>";
             }
         }
     }
 }
예제 #4
0
 protected function _executeSearch()
 {
     // Check form
     $form = new User_Form_Search(array('type' => 'user'));
     if (!$form->isValid($this->_getAllParams())) {
         $this->view->error = true;
         $this->view->totalUsers = 0;
         $this->view->userCount = 0;
         $this->view->page = 1;
         return false;
     }
     $this->view->form = $form;
     // Get search params
     $page = (int) $this->_getParam('page', 1);
     $ajax = (bool) $this->_getParam('ajax', false);
     $options = $form->getValues();
     // Process options
     $tmp = array();
     $originalOptions = $options;
     foreach ($options as $k => $v) {
         if (null == $v || '' == $v || is_array($v) && count(array_filter($v)) == 0) {
             continue;
         } else {
             if (false !== strpos($k, '_field_')) {
                 list($null, $field) = explode('_field_', $k);
                 $tmp['field_' . $field] = $v;
             } else {
                 if (false !== strpos($k, '_alias_')) {
                     list($null, $alias) = explode('_alias_', $k);
                     $tmp[$alias] = $v;
                 } else {
                     $tmp[$k] = $v;
                 }
             }
         }
     }
     $options = $tmp;
     // Get table info
     $table = Engine_Api::_()->getItemTable('user');
     $userTableName = $table->info('name');
     $searchTable = Engine_Api::_()->fields()->getTable('user', 'search');
     $searchTableName = $searchTable->info('name');
     //extract($options); // displayname
     $profile_type = @$options['profile_type'];
     $displayname = @$options['displayname'];
     if (!empty($options['extra'])) {
         extract($options['extra']);
         // is_online, has_photo, submit
     }
     // Contruct query
     $select = $table->select()->from($userTableName)->joinLeft($searchTableName, "`{$searchTableName}`.`item_id` = `{$userTableName}`.`user_id`", null)->where("{$userTableName}.search = ?", 1)->where("{$userTableName}.enabled = ?", 1);
     $searchDefault = true;
     // Build the photo and is online part of query
     if (isset($has_photo) && !empty($has_photo)) {
         $select->where($userTableName . '.photo_id != ?', "0");
         $searchDefault = false;
     }
     if (isset($is_online) && !empty($is_online)) {
         $select->joinRight("engine4_user_online", "engine4_user_online.user_id = `{$userTableName}`.user_id", null)->group("engine4_user_online.user_id")->where($userTableName . '.user_id != ?', "0");
         $searchDefault = false;
     }
     // Add displayname
     if (!empty($displayname)) {
         $select->where("(`{$userTableName}`.`username` LIKE ? || `{$userTableName}`.`displayname` LIKE ?)", "%{$displayname}%");
         $searchDefault = false;
     }
     // Build search part of query
     $searchParts = Engine_Api::_()->fields()->getSearchQuery('user', $options);
     foreach ($searchParts as $k => $v) {
         $select->where("`{$searchTableName}`.{$k}", $v);
         if (isset($v) && $v != "") {
             $searchDefault = false;
         }
     }
     if ($searchDefault) {
         $select->order("{$userTableName}.lastlogin_date DESC");
     } else {
         $select->order("{$userTableName}.displayname ASC");
     }
     // Build paginator
     $paginator = Zend_Paginator::factory($select);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($page);
     $this->view->page = $page;
     $this->view->ajax = $ajax;
     $this->view->users = $paginator;
     $this->view->totalUsers = $paginator->getTotalItemCount();
     $this->view->userCount = $paginator->getCurrentItemCount();
     $this->view->topLevelId = $form->getTopLevelId();
     $this->view->topLevelValue = $form->getTopLevelValue();
     $this->view->formValues = array_filter($originalOptions);
     return true;
 }