From b46afdc48c4449e43804b1e9b8a5bc5de359c31d Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 26 Apr 2018 16:11:56 +0530 Subject: [PATCH] multiple role branch access --- api/application/controllers/Employee_Controller.php | 3 ++- api/application/models/Employee_model.php | 8 +++++--- assets/js/controllers/employeeCtrl.js | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/api/application/controllers/Employee_Controller.php b/api/application/controllers/Employee_Controller.php index 8c2c53e..b281cbe 100755 --- a/api/application/controllers/Employee_Controller.php +++ b/api/application/controllers/Employee_Controller.php @@ -133,7 +133,8 @@ class Employee_Controller extends REST_Controller { public function getMasterBranchDetails_post () { $reqRoleID = $this->post('reqRoleID'); $reqUserID = $this->post('reqUserID'); - $resMasterBranchDetails = $this->employee_model->get_req_master_branch_detail( $reqRoleID, $reqUserID );// Check if the employee exist + $branchId= $this->post('branchId'); + $resMasterBranchDetails = $this->employee_model->get_req_master_branch_detail( $reqRoleID, $reqUserID,$branchId);// Check if the employee exist if ($resMasterBranchDetails) { $resMasterBranchDetails['status'] = REST_Controller::HTTP_OK; diff --git a/api/application/models/Employee_model.php b/api/application/models/Employee_model.php index e1e4601..2fa02ed 100755 --- a/api/application/models/Employee_model.php +++ b/api/application/models/Employee_model.php @@ -272,8 +272,9 @@ class Employee_model extends CI_Model } // get branch details based on login user - public function get_req_master_branch_detail($reqRoleId, $reqUserID) + public function get_req_master_branch_detail($reqRoleId, $reqUserID,$branchId) { + $listcode="R003"; if ($reqRoleId == SUPER_ADMIN) { // res for SuperAdmin $this->db->select('BranchCode, BranchName'); @@ -288,9 +289,10 @@ class Employee_model extends CI_Model $subQuery = "SELECT t1.BranchCode, t1.BranchName FROM T_BranchMaster as t1 LEFT JOIN T_Staff_BranchAccess as t2 ON t2.StaffID = '$staffId' - WHERE t2.BranchCode = t1.BranchCode + WHERE t1.BranchCode='$branchId' and t2.ListCode='$listcode' AND t1.IsActive = 1 - AND t2.IsActive = 1"; + AND t2.IsActive = 1 + group by t1.BranchCode"; $mBranchDetails = $this->db->query($subQuery); $results['MeasterBranchDetailStatus'] = true; $results['branch_details'] = $mBranchDetails->result(); diff --git a/assets/js/controllers/employeeCtrl.js b/assets/js/controllers/employeeCtrl.js index c3eeafb..ec694c4 100755 --- a/assets/js/controllers/employeeCtrl.js +++ b/assets/js/controllers/employeeCtrl.js @@ -69,6 +69,8 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ if (localDetail != null) { $scope.currentDate = new Date(); $scope.localUserListCode = localDetail.localType; + $scope.localBranchID = localDetails.localBranchID; + // $scope.currentPage = 1; $scope.getEmployeeList(); @@ -459,6 +461,7 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ data: { reqRoleID: localDetails.localType, reqUserID: localDetails.localUserID, + branchId : localDetails.localBranchID, } }; $http(req).then(function (response) {