예제 #1
0
 /**
  * This action is used for adding/updating data.
  * @parameters
  * @param id  =  id of role (optional)
  * 
  * @return Zend_Form.
  */
 public function editAction()
 {
     $groups_model = new Default_Model_Groups();
     $role_model = new Default_Model_Roles();
     $group_arr = $groups_model->getGroupsListForRoles();
     $id = $this->getRequest()->getParam('id', null);
     $display_grp = "1";
     $total_role_cnt = 0;
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $form = new Default_Form_Roles();
     $data = array();
     if ($id && is_numeric($id) && $id > 1) {
         try {
             $id = (int) $id;
             $id = abs($id);
             $form->submit->setLabel('Update');
             $data = $role_model->getRoleDataById($id);
             if (count($data) > 0) {
                 foreach ($data as $key => $val) {
                     $data[$key] = htmlentities(addslashes($val), ENT_QUOTES, "UTF-8");
                 }
                 $form->populate($data);
             }
         } catch (Exception $e) {
             $this->view->nodata = "nodata";
         }
     } else {
         if ($id == '') {
             $total_role_cnt = $role_model->getTotalRolecnt();
             foreach ($group_arr as $gid => $gdata) {
                 if ($gdata['cnt'] < 5) {
                     $display_grp = $gid;
                     break;
                 }
             }
         } else {
             $this->view->nodata = "nodata";
         }
     }
     $this->view->form = $form;
     $this->view->group_arr = $group_arr;
     $this->view->data = $data;
     $this->view->display_grp = $display_grp;
     $this->view->total_role_cnt = $total_role_cnt;
 }
예제 #2
0
 /**
  * This function gives all content for grid view.
  * @parameters
  * @param $sort          = ascending or descending
  * @param $by            = name of field which to be sort
  * @param $pageNo        = page number
  * @param $perPage       = no.of records per page
  * @param $searchData    = search string
  * @param $call          = type of call like ajax.
  * @return  Array;
  */
 public function getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $p2, $p3, $p4, $p5)
 {
     $group_model = new Default_Model_Groups();
     $searchQuery = '';
     $searchArray = array();
     $data = array();
     if ($searchData != '' && $searchData != 'undefined') {
         $searchValues = json_decode($searchData);
         if (count($searchValues) > 0) {
             foreach ($searchValues as $key => $val) {
                 $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                 $searchArray[$key] = $val;
             }
             $searchQuery = rtrim($searchQuery, " AND");
         }
     }
     $objName = 'roles';
     $tableFields = array('action' => 'Action', 'rolename' => 'Role Name', 'roletype' => 'Role Type', 'roledescription' => 'Role Description', 'group_name' => 'Group');
     $tablecontent = $this->getRolesData($sort, $by, $pageNo, $perPage, $searchQuery);
     $group_data = $group_model->getGroupsListForRoles();
     $group_arr = array();
     foreach ($group_data as $gkey => $gdata) {
         $group_arr[$gdata['group_name']] = $gdata['group_name'];
     }
     $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'call' => $call, 'dashboardcall' => $dashboardcall, 'search_filters' => array('group_name' => array('type' => 'select', 'filter_data' => array('' => 'All') + $group_arr)));
     return $dataTmp;
 }