From 9124786a749b050ba9213d1274db811efa4e22bc Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Thu, 19 Apr 2018 18:49:35 +0530 Subject: [PATCH] status update branch level for superadmin : kdk --- .../application/controllers/Status_Controller.php | 7 +++++-- Apollo/api/application/models/Status_model.php | 12 ++++++++---- Apollo/assets/js/controllers/statusCtrl.js | 12 ++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Apollo/api/application/controllers/Status_Controller.php b/Apollo/api/application/controllers/Status_Controller.php index 54880a48..94452e08 100755 --- a/Apollo/api/application/controllers/Status_Controller.php +++ b/Apollo/api/application/controllers/Status_Controller.php @@ -55,6 +55,7 @@ class Status_Controller extends REST_Controller { $details['ListGroup'] = "1"; $details['CreatedBy'] = $this->post('createdBy'); $details['IsActive'] = $this->post('status'); + $details['BranchCode'] = $this->post('branch'); $details['CreatedOn'] = $now->format('Y-m-d H:i:s'); $statusDetails = $this->status_model->addstatus($details);// Check if the users data store contains users (in case the database result returns NULL) if ($statusDetails) @@ -81,7 +82,8 @@ class Status_Controller extends REST_Controller { public function getStatusDetails_post() { $requestedBy = $this->post('requestedBy'); - $getStatus = $this->status_model->getStatus($requestedBy); + $requestedBranch = $this->post('requestBranch'); + $getStatus = $this->status_model->getStatus($requestedBy, $requestedBranch); if ($getStatus) { @@ -113,8 +115,9 @@ class Status_Controller extends REST_Controller { $details['ListName'] = $this->post('ListName'); $details['IsActive'] = $this->post('status'); $details['UpdatedBy'] = $this->post('updatedBy'); + $branch = $this->post('requestBranch'); $details['UpdatedOn'] = $now->format("Y-m-d H:i:s"); - $statusDetails = $this->status_model->update($details,$ListCode);// Check if the users data store contains users (in case the database result returns NULL) + $statusDetails = $this->status_model->update($details,$ListCode, $branch);// Check if the users data store contains users (in case the database result returns NULL) if ($statusDetails) diff --git a/Apollo/api/application/models/Status_model.php b/Apollo/api/application/models/Status_model.php index 66272ba7..17f333f8 100755 --- a/Apollo/api/application/models/Status_model.php +++ b/Apollo/api/application/models/Status_model.php @@ -17,9 +17,11 @@ class Status_model extends CI_Model { public function addstatus($arrayDetails=null) { - $this->db->select('ListCode'); + // print_r($arrayDetails);exit(); + $this->db->select('ListCode'); $this->db->where('ListGroup', '1'); $this->db->where('ListName', $arrayDetails['ListName']); + $this->db->where('BranchCode', $arrayDetails['BranchCode']); if($this->db->get(PICK_LIST_DETAILS)->first_row()){ $result['Status'] = false; $result['message'] = "Status name is already exist!"; @@ -52,10 +54,11 @@ class Status_model extends CI_Model { * created by Surendiran * */ - public function getStatus() - { + public function getStatus($reqBy, $reqBranch) + { $this->db->select('ListCode,ListName,IsActive'); $this->db->where('ListGroup','1'); + $this->db->where('BranchCode', $reqBranch); $this->db->order_by('ListCode','DESC'); $statusDetails = $this->db->get(PICK_LIST_DETAILS); if($statusDetails->result()){ @@ -76,10 +79,11 @@ class Status_model extends CI_Model { * created by Surendiran * */ - public function update($arrayDetails=null,$ListCode=null) + public function update($arrayDetails=null,$ListCode=null, $branch) { $this->db->select('ListName'); $this->db->where('ListName', $arrayDetails['ListName']); + $this->db->where('BranchCode', $branch); $this->db->where_not_in('ListCode', $ListCode); if($this->db->get(PICK_LIST_DETAILS)->first_row()){ $result['Status'] = false; diff --git a/Apollo/assets/js/controllers/statusCtrl.js b/Apollo/assets/js/controllers/statusCtrl.js index 2a264ef0..ce5cbb75 100755 --- a/Apollo/assets/js/controllers/statusCtrl.js +++ b/Apollo/assets/js/controllers/statusCtrl.js @@ -75,7 +75,8 @@ app.controller("statusCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$lo data: { statusName: myModel.StatusName, status: myModel.switchsetting, - createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID, + branch : localDetail.localBranchID } }; @@ -87,7 +88,7 @@ app.controller("statusCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$lo $state.go($state.current, {}, { reload: true }); } else { $scope.ldloading1[loading.replace('-', '_')] = false; - swal("", "Something went wrong, please try again.", "error"); + swal("", response.data.message, "error"); } }); @@ -123,6 +124,7 @@ app.controller("statusCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$lo 'Content-Type': 'application/json' }, data: { + requestBranch: localDetail.localBranchID, requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID } }; @@ -201,18 +203,20 @@ app.controller("statusCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$lo ListCode: myModel.ListCode, ListName: myModel.ListName, status: myModel.IsActive, + requestBranch: localDetail.localBranchID, updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID } }; $http(update).then(function (response) { - if (response.data.status == 200 && response.data.Status) { + if (response.data.Status) { $scope.ldloading[loading.replace('-', '_')] = false; swal("", "Updated Successfully", "success"); $scope.editId = -1; $scope.init(); } else { $scope.ldloading[loading.replace('-', '_')] = false; - swal("", "Something went wrong, please try again", "error"); + $scope.init(); + swal("", response.data.message, "error"); } }); }