public function viewUserAccessAction() { /* Initialize action controller here */ if ($this->getRequest()->getParam('id')) { $id = $this->getRequest()->getParam('id'); $db = new RsvAcl_Model_DbTable_DbUserType(); $userAccessQuery = "SELECT user_type_id, user_type, status from rms_acl_user_type where user_type_id=" . $id; $rows = $db->getUserTypeInfo($userAccessQuery); $this->view->rs = $rows; //Add filter search $gc = new Application_Model_GlobalClass(); // For list all module $sql = "SELECT DISTINCT acl.`module` FROM `rms_acl_acl` AS acl"; $this->view->optoin_mod = $gc->getOptonsHtml($sql, "module", "module"); // For list all controller $sql = "SELECT DISTINCT acl.`controller` FROM `rms_acl_acl` AS acl WHERE acl.`status` = 1"; $this->view->optoin_con = $gc->getOptonsHtml($sql, "controller", "controller"); // For List all action $sql = "SELECT DISTINCT acl.`action` FROM `rms_acl_acl` AS acl WHERE acl.`status` = 1"; $this->view->optoin_act = $gc->getOptonsHtml($sql, "action", "action"); //For Status enable or disable $this->view->optoin_status = $gc->getYesNoOption(); $where = " "; $status = null; if ($this->getRequest()->isPost()) { $post = $this->getRequest()->getPost(); if (!empty($post['fmod'])) { $where .= " AND acl.`module` = '" . $post['fmod'] . "' "; } if (!empty($post['fcon'])) { $where .= " AND acl.`controller` = '" . $post['fcon'] . "' "; } if (!empty($post['fact'])) { $where .= " AND acl.`action` = '" . $post['fact'] . "' "; } if (!empty($post['fstatus'])) { $status = $post['fstatus'] === "Yes" ? 1 : 0; //$where .= " AND acl.`status` = " . $st ; } $this->view->datafiter = $post; //echo $where; exit; } //Sophen add here //to assign project list in view $db_acl = new Application_Model_DbTable_DbGlobal(); $sqlNotParentId = "SELECT user_type_id FROM `rms_acl_user_type` WHERE `parent_id` =" . $id; $notParentId = $db_acl->getGlobalDb($sqlNotParentId); $usernotparentid = $notParentId[0]['user_type_id']; if ($id == 1) { //Display all for admin id = 1 //Do not change admin id = 1 in database //Otherwise, it error $sql = "select acl.acl_id,CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access\n\t\t\t\t\t\tfrom rms_acl_acl as acl \n\t\t\t\t\t\tWHERE 1 " . $where; } else { //Display all of his/her parent access $sql = "SELECT acl.acl_id, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status \n\t\t\t\t\t\tFROM rms_acl_user_access AS ua \n\t\t\t\t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.parent_id)\n\t\t\t\t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ut.user_type_id =" . $id . $where; } //echo $sql; exit; $acl = $db_acl->getGlobalDb($sql); $acl = is_null($acl) ? array() : $acl; //print_r($acl); $this->view->acl = $acl; if (!$usernotparentid) { ///Display only of his/her parent access and not have user_type_id of user access in user type parent id //ua.user_type_id != ut.parent_id $sql_acl = "SELECT acl.acl_id, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status \n\t\t\t\t\t\t\tFROM rms_acl_user_access AS ua \n\t\t\t\t\t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.user_type_id)\n\t\t\t\t\t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id . $where; } else { //Display only he / she access in rms_acl_user_access $sql_acl = "SELECT acl.acl_id, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status \n\t\t\t\t\t\t\tFROM rms_acl_user_access AS ua \n\t\t\t\t\t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.parent_id)\n\t\t\t\t\t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id . $where; } $acl_name = $db_acl->getGlobalDb($sql_acl); $acl_name = is_null($acl_name) ? array() : $acl_name; // $imgnone='<img src="'.BASE_URL.'/images/icon/none.png"/>'; // $imgtick='<img src="'.BASE_URL.'/images/icon/tick.png"/>'; $rows = array(); $num = 1; foreach ($acl as $com) { $img = '<img src="' . BASE_URL . '/images/icon/none.png" id="img_' . $com['acl_id'] . '" onclick="changeStatus(' . $com['acl_id'] . ',' . $id . ');" class="pointer"/>'; $tmp_status = 0; foreach ($acl_name as $read) { if ($read['acl_id'] == $com['acl_id']) { $img = '<img src="' . BASE_URL . '/images/icon/tick.png" id="img_' . $com['acl_id'] . '" onclick="changeStatus(' . $com['acl_id'] . ', ' . $id . ');" class="pointer"/>'; $tmp_status = 1; break; } } if (!empty($status) || $status === 0) { if ($tmp_status !== $status) { continue; } } $rows[] = array('num' => $num++, 'acl_id' => $com['acl_id'], "user_access" => $com['user_access'], 'status' => $tmp_status); } // $list=new Application_Form_Frmlist(); // $tr = Application_Form_FrmLanguages::getCurrentlanguage(); // $columns=array($tr->translate('URL'), $tr->translate('STATUS')); // $this->view->acl_name = $list->getCheckList('radio', $columns, $rows); $db_tran = new Application_Model_DbTable_DbGlobal(); //create sesesion $session_transfer = new Zend_Session_Namespace('search_user-access-acl'); if (empty($session_transfer->limit)) { $session_transfer->limit = Application_Form_FrmNavigation::getLimit(); $session_transfer->lock(); } if ($this->getRequest()->isPost() && $this->getRequest()->getParam("btsave") !== "Search") { $formdata = $this->getRequest()->getPost(); $session_transfer->unlock(); $session_transfer->limit = $formdata['rows_per_page']; $session_transfer->lock(); } //start page nevigation $limit = $session_transfer->limit; $start = $this->getRequest()->getParam('limit_satrt', 0); $result = array(); if ($limit == "All") { $result = $rows; } else { for ($i = $start; $i < $start + $limit; $i++) { if (count($rows) == $i) { break; } $result[] = $rows[$i]; } } $record_count = count($rows); if (empty($result)) { $result = array('err' => 1, 'msg' => 'មិន​ទាន់​មាន​ទន្និន�យ​នូវ​ឡើយ​ទ�!'); } $this->view->list = Zend_Json::encode($result); $page = new Application_Form_FrmNavigation(); $page->init(self::REDIRECT_URL . "/view-user-access?id=" . $id, $start, $limit, $record_count, "&"); $this->view->nevigation = $page->navigationPage(); $this->view->rows_per_page = $page->getRowsPerPage($limit, 'frmlist'); $this->view->result_row = $page->getResultRows(); } }
public function addAction() { /* Initialize action controller here */ if ($this->getRequest()->getParam('id')) { $id = $this->getRequest()->getParam('id'); $db = new RsvAcl_Model_DbTable_DbUserType(); $userAccessQuery = "SELECT user_type_id, user_type, status from rms_acl_user_type where user_type_id=" . $id; $rows = $db->getUserTypeInfo($userAccessQuery); $this->view->rs = $rows; //Add filter search $gc = new Application_Model_GlobalClass(); // For list all module $sql = "SELECT DISTINCT acl.`module` FROM `rms_acl_acl` AS acl"; $this->view->optoin_mod = $gc->getOptonsHtml($sql, "module", "module"); // For list all controller $sql = "SELECT DISTINCT acl.`controller` FROM `rms_acl_acl` AS acl WHERE acl.`status` = 1"; $this->view->optoin_con = $gc->getOptonsHtml($sql, "controller", "controller"); // For List all action $sql = "SELECT DISTINCT acl.`action` FROM `rms_acl_acl` AS acl WHERE acl.`status` = 1"; $this->view->optoin_act = $gc->getOptonsHtml($sql, "action", "action"); //For Status enable or disable $this->view->optoin_status = $gc->getYesNoOption(); $where = " "; $status = null; if ($this->getRequest()->isPost()) { $post = $this->getRequest()->getPost(); if (!empty($post['fmod'])) { $where .= " AND acl.`module` = '" . $post['fmod'] . "' "; } if (!empty($post['fcon'])) { $where .= " AND acl.`controller` = '" . $post['fcon'] . "' "; } if (!empty($post['fact'])) { $where .= " AND acl.`action` = '" . $post['fact'] . "' "; } if (!empty($post['fstatus'])) { $status = $post['fstatus'] === "Yes" ? 1 : 0; //$where .= " AND acl.`status` = " . $st ; } //echo $where; exit; } else { $post = array('fmod' => '', 'fcon' => '', 'fact' => '', 'fstatus' => ''); } $this->view->data = $post; //Sophen add here //to assign project list in view $db_acl = new Application_Model_DbTable_DbGlobal(); $sqlNotParentId = "SELECT user_type_id FROM `rms_acl_user_type` WHERE `parent_id` =" . $id; $notParentId = $db_acl->getGlobalDb($sqlNotParentId); $usernotparentid = $notParentId[0]['user_type_id']; if ($id == 1) { //Display all for admin id = 1 //Do not change admin id = 1 in database //Otherwise, it error $sql = "select acl.acl_id,acl.label,CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access\r\n \t\t\tfrom rms_acl_acl as acl\r\n \t\t\tWHERE 1 " . $where; } else { //Display all of his/her parent access $sql = "SELECT acl.acl_id,acl.label, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status\r\n \t\t\tFROM rms_acl_user_access AS ua\r\n \t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.parent_id)\r\n \t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ut.user_type_id =" . $id . $where; } //echo $sql; exit; $acl = $db_acl->getGlobalDb($sql); $acl = is_null($acl) ? array() : $acl; //print_r($acl); $this->view->acl = $acl; if (!$usernotparentid) { ///Display only of his/her parent access and not have user_type_id of user access in user type parent id //ua.user_type_id != ut.parent_id $sql_acl = "SELECT acl.acl_id,acl.label, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status\r\n \t\t\tFROM rms_acl_user_access AS ua\r\n \t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.user_type_id)\r\n \t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id . $where; } else { //Display only he / she access in rsv_acl_user_access $sql_acl = "SELECT acl.acl_id,acl.label, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status\r\n \t\t\tFROM rms_acl_user_access AS ua\r\n \t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.parent_id)\r\n \t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id . $where; } $acl_name = $db_acl->getGlobalDb($sql_acl); $acl_name = is_null($acl_name) ? array() : $acl_name; $imgnone = '<img src="' . BASE_URL . '/images/icon/none.png"/>'; $imgtick = '<img src="' . BASE_URL . '/images/icon/tick.png"/>'; $rows = array(); foreach ($acl as $com) { $img = '<img src="' . BASE_URL . '/images/icon/none.png" id="img_' . $com['acl_id'] . '" onclick="changeStatus(' . $com['acl_id'] . ',' . $id . ');" class="pointer"/>'; $tmp_status = 0; foreach ($acl_name as $read) { if ($read['acl_id'] == $com['acl_id']) { $img = '<img src="' . BASE_URL . '/images/icon/tick.png" id="img_' . $com['acl_id'] . '" onclick="changeStatus(' . $com['acl_id'] . ', ' . $id . ');" class="pointer"/>'; $tmp_status = 1; break; } } if (!empty($status) || $status === 0) { if ($tmp_status !== $status) { continue; } } $rows[] = array($com['acl_id'], $com['label'], $com['user_access'], $img); } // $list=new Application_Form_Frmlist(); $list = new Application_Form_Frmtable(); $tr = Application_Form_FrmLanguages::getCurrentlanguage(); $columns = array("Label", $tr->translate('URL'), $tr->translate('STATUS')); $this->view->list = $list->getCheckList('radio', $columns, $rows); //$this->view->acl_name=$acl_name; } }