diff --git a/Apollo/api/application/models/Employee_model.php b/Apollo/api/application/models/Employee_model.php index e11eb719..863c96e1 100755 --- a/Apollo/api/application/models/Employee_model.php +++ b/Apollo/api/application/models/Employee_model.php @@ -452,8 +452,24 @@ class Employee_model extends CI_Model public function update_employee($empArr, $updateFor, $imageName, $imageSource, $imageSize) { if( $imageSource == '') { // update Employee without image - $this->db->where('StaffID', $updateFor); - $this->db->update(STAFF, $empArr); + $this->db->select('*'); + $this->db->from(STAFF); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StaffID', $updateFor); + if ($this->db->get()->first_row()) { + $result['updateEmpStatus'] = false; + $result['message'] = "This Mobile Number Already Exist"; + }else { + $this->db->select('*'); + $this->db->from(LOGIN); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StaffID', $updateFor); + if($this->db->get()->first_row()) { + $result['updateEmpStatus'] = false; + $result['message'] = "This Mobile Number Already Exist"; + } else { + $this->db->where('StaffID', $updateFor); + $this->db->update(STAFF, $empArr); if ($this->db->affected_rows() == '1') { $mobile = $empArr['MobileNumber']; $email = $empArr['EmailID']; @@ -472,7 +488,31 @@ class Employee_model extends CI_Model $result['updateEmpStatus'] = false; $result['message'] = "Something went wrong.please try again"; } + + + } + } + + + } else { // update employee with image + + $this->db->select('*'); + $this->db->from(STAFF); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StaffID', $updateFor); + if ($this->db->get()->first_row()) { + $result['updateEmpStatus'] = false; + $result['message'] = "This Mobile Number Already Exist"; + }else { + $this->db->select('*'); + $this->db->from(LOGIN); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StaffID', $updateFor); + if($this->db->get()->first_row()) { + $result['updateEmpStatus'] = false; + $result['message'] = "This Mobile Number Already Exist"; + } else { $target = "../images/employee/"; $getUploadStatus = $this->upload_image($imageSource, $imageSize, $target); $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg'; @@ -508,6 +548,8 @@ class Employee_model extends CI_Model $result['message'] = "Something went wrong.please try again"; } } + } + } return $result; } diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php index 34c7ac20..7ea1b72f 100755 --- a/Apollo/api/application/models/Student_model.php +++ b/Apollo/api/application/models/Student_model.php @@ -598,27 +598,68 @@ if($StuStatus == '' ){ // print_r($empArr); // print_r($updateFor); // exit(); - $this->db->where('StudentID', $updateFor); - $this->db->update(STUDENTS, $empArr); - if ($this->db->affected_rows() == '1') { - $mobile = $empArr['MobileNumber']; - $email = $empArr['EmailID']; - $active = $empArr['IsActive']; - $updatedBy = $empArr['UpdatedBy']; - $updatedOn = $empArr['UpdatedOn']; - $sql = "UPDATE ".LOGIN." SET MobileNumber='$mobile', EmailId='$email', IsActive='$active', UpdatedBy='$updatedBy', UpdatedOn='$updatedOn' WHERE StaffID='$updateFor'"; - if($this->db->query($sql) == '1'){ - $result['updateStuStatus'] = true; - $result['message'] = "Successfully student details Updated"; - } else { - $result['updateStuStatus'] = false; - $result['message'] = "Something went wrong.please try again"; - } - } else { + + + $this->db->select('*'); + $this->db->from(STUDENTS); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StudentID', $updateFor); + if ($this->db->get()->first_row()) { $result['updateStuStatus'] = false; - $result['message'] = "Something went wrong.please try again"; + $result['message'] = "This Mobile Number Already Exist"; + } else { + $this->db->select('*'); + $this->db->from(LOGIN); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StaffID', $updateFor); + if($this->db->get()->first_row()) { + $result['updateStuStatus'] = false; + $result['message'] = "This Mobile Number Already Exist"; + } else { + $this->db->where('StudentID', $updateFor); + $this->db->update(STUDENTS, $empArr); + if ($this->db->affected_rows() == '1') { + + + + $mobile = $empArr['MobileNumber']; + $email = $empArr['EmailID']; + $active = $empArr['IsActive']; + $updatedBy = $empArr['UpdatedBy']; + $updatedOn = $empArr['UpdatedOn']; + $sql = "UPDATE ".LOGIN." SET MobileNumber='$mobile', EmailId='$email', IsActive='$active', UpdatedBy='$updatedBy', UpdatedOn='$updatedOn' WHERE StaffID='$updateFor'"; + if($this->db->query($sql) == '1'){ + $result['updateStuStatus'] = true; + $result['message'] = "Successfully student details Updated"; + } else { + $result['updateStuStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } else { + $result['updateStuStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } + } } else { + + $this->db->select('*'); + $this->db->from(STUDENTS); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StudentID', $updateFor); + if ($this->db->get()->first_row()) { + $result['updateStuStatus'] = false; + $result['message'] = "This Mobile Number Already Exist"; + } else { + $this->db->select('*'); + $this->db->from(LOGIN); + $this->db->where('MobileNumber', $empArr['MobileNumber']); + $this->db->where_not_in('StaffID', $updateFor); + if($this->db->get()->first_row()) { + $result['updateStuStatus'] = false; + $result['message'] = "This Mobile Number Already Exist"; + } else { $target = "../images/student/"; $getUploadStatus = $this->upload_image($imageSource, $size, $target); $imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg'; @@ -653,6 +694,8 @@ if($StuStatus == '' ){ $result['updateStuStatus'] = false; $result['message'] = "Something went wrong.please try again"; } + } + } } return $result; } diff --git a/Apollo/assets/js/controllers/employeeCtrl.js b/Apollo/assets/js/controllers/employeeCtrl.js index bcff7819..2bbc6929 100755 --- a/Apollo/assets/js/controllers/employeeCtrl.js +++ b/Apollo/assets/js/controllers/employeeCtrl.js @@ -568,7 +568,7 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ } }; $http(req).then(function (response) { - if (response.data.updateEmpStatus = true) { + if (response.data.updateEmpStatus == true) { swal("", "Updated Successfully.", "success"); $scope.getEmployeeList(); $scope.editId = -1; diff --git a/Apollo/assets/js/controllers/sessionCtrl.js b/Apollo/assets/js/controllers/sessionCtrl.js index 647e48aa..e5f89193 100755 --- a/Apollo/assets/js/controllers/sessionCtrl.js +++ b/Apollo/assets/js/controllers/sessionCtrl.js @@ -3,7 +3,7 @@ * controllers used for the session */ -app.controller('sessionCtrl', ["$scope", "$localStorage", "$state", 'ipCookie', '$window', function ($scope, $localStorage, $state, ipCookie, $window) { +app.controller('sessionCtrl', ["$scope", "$localStorage", "$state", 'ipCookie', '$window', '$location', function ($scope, $localStorage, $state, ipCookie, $window, $location) { /** * checking the session settings and logout for the function */ @@ -18,10 +18,10 @@ app.controller('sessionCtrl', ["$scope", "$localStorage", "$state", 'ipCookie', if (localDetail.localType == 'R004') { $scope.getLoginDash = 'superAdmin'; } else if (localDetail.localType == 'R003') { - $scope.getLoginDash = 'Admin'; + $scope.getLoginDash = 'Admin'; } else if (localDetail.localType == 'R002') { - $scope.getLoginDash = 'staff'; - $scope.is_active_DayBookAprlAccess = localDetail.is_DayBookApproval_Access; + $scope.getLoginDash = 'staff'; + $scope.is_active_DayBookAprlAccess = localDetail.is_DayBookApproval_Access; } else if (localDetail.localType == 'R001') { $scope.getLoginDash = 'student'; @@ -37,6 +37,86 @@ app.controller('sessionCtrl', ["$scope", "$localStorage", "$state", 'ipCookie', $state.go('login.signin'); } + // check login user as Super Admin + $scope.checkSuperAdmin = function () { + var inlocalDetails = JSON.parse(localStorage.getItem('localObj')); + var inlocalDetailss = ipCookie('cookiechk'); + if (inlocalDetails != null) { + + if (inlocalDetails.localType == 'R004' && inlocalDetailss.localType == 'R004') { + } else { + if (inlocalDetails.localType == '' && inlocalDetailss.localType == '') { + ipCookie.remove('cookiechk'); + $window.localStorage.clear(); + $state.go('login.signin'); + } else { + $location.url('/dashboard').replace(); + $window.location.reload(); + $state.go('app.dashboard'); + } + // alert(inlocalDetails.localType); + // $state.go('login.signin'); + // $state.go($state.current, {}, { reload: true }); + + } + } else { + $state.go('login.signin'); + } + } + + // check login user as Admin + $scope.checkAdmin = function () { + var inlocalDetails = JSON.parse(localStorage.getItem('localObj')); + var inlocalDetailss = ipCookie('cookiechk'); + if (inlocalDetails != null) { + + if (inlocalDetails.localType == 'R003' && inlocalDetailss.localType == 'R003') { + } else { + if (inlocalDetails.localType == '' && inlocalDetailss.localType == '') { + ipCookie.remove('cookiechk'); + $window.localStorage.clear(); + $state.go('login.signin'); + } else { + $location.url('/dashboard').replace(); + $window.location.reload(); + $state.go('app.dashboard'); + } + // alert(inlocalDetails.localType); + // $state.go('login.signin'); + // $state.go($state.current, {}, { reload: true }); + + } + } else { + $state.go('login.signin'); + } + } + + // check login user as Staff + $scope.checkStaff = function () { + var inlocalDetails = JSON.parse(localStorage.getItem('localObj')); + var inlocalDetailss = ipCookie('cookiechk'); + if (inlocalDetails != null) { + + if (inlocalDetails.localType == 'R002' && inlocalDetailss.localType == 'R002') { + } else { + if (inlocalDetails.localType == '' && inlocalDetailss.localType == '') { + ipCookie.remove('cookiechk'); + $window.localStorage.clear(); + $state.go('login.signin'); + } else { + $location.url('/dashboard').replace(); + $window.location.reload(); + $state.go('app.dashboard'); + } + // alert(inlocalDetails.localType); + // $state.go('login.signin'); + // $state.go($state.current, {}, { reload: true }); + + } + } else { + $state.go('login.signin'); + } + } }]); app.controller('topnavCtrl', ["$scope", "$http", "API_POINTS", "$localStorage", "$state", 'ipCookie', '$window', function ($scope, $http, apiPoint, $localStorage, $state, ipCookie, $window) { @@ -48,11 +128,11 @@ app.controller('topnavCtrl', ["$scope", "$http", "API_POINTS", "$localStorage", var localDetail = JSON.parse(localStorage.getItem('localObj')); var localDetails = ipCookie('cookiechk'); $scope.init = function () { - if (localDetail != null) { - $scope.getProfile(); - } else { + if (localDetail != null) { + $scope.getProfile(); + } else { - } + } } $scope.loginUser = { @@ -65,48 +145,48 @@ app.controller('topnavCtrl', ["$scope", "$http", "API_POINTS", "$localStorage", 'branchList': '', }; - - // client side logined details - $scope.getProfile = function () { - var req = { - method: 'POST', - url: apiPoint.url + 'employee/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - employeeLoginID: localDetails.localUserID, - } - }; - $http(req).then(function (response) { - if (response.data.empStatus == true) { - /* - * Get Top Nav user details - */ - $scope.resultData = response.data.details; - $scope.loginImage = $scope.resultData.ProfilePicPath; - $scope.loginUser = { - 'staffID': $scope.resultData.StaffID, - 'fName': $scope.resultData.Firstname, - 'lName': $scope.resultData.Lastname, - 'mobileNumber': $scope.resultData.MobileNumber, - 'gender': $scope.resultData.Gender, - 'branchCode': $scope.resultData.BranchCode, - 'branchList': response.data.branch_details, - }; - if(response.data.branch_details.length > 0){ - var currArr = response.data.branch_details; - $scope.getCurrentBran = currArr.find(item => item.BranchCode === localDetails.localBranchID); - } - } else { - } - }); + // client side logined details + $scope.getProfile = function () { + var req = { + method: 'POST', + url: apiPoint.url + 'employee/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + employeeLoginID: localDetails.localUserID, + } }; - + $http(req).then(function (response) { + if (response.data.empStatus == true) { + /* + * Get Top Nav user details + */ + $scope.resultData = response.data.details; + $scope.loginImage = $scope.resultData.ProfilePicPath; + $scope.loginUser = { + 'staffID': $scope.resultData.StaffID, + 'fName': $scope.resultData.Firstname, + 'lName': $scope.resultData.Lastname, + 'mobileNumber': $scope.resultData.MobileNumber, + 'gender': $scope.resultData.Gender, + 'branchCode': $scope.resultData.BranchCode, + 'branchList': response.data.branch_details, + }; + if (response.data.branch_details.length > 0) { + var currArr = response.data.branch_details; + $scope.getCurrentBran = currArr.find(item => item.BranchCode === localDetails.localBranchID); + } + + } else { + } + }); + }; + $scope.upDateLocalBran = function (Id) { - + localDetail.localBranchID = Id; localDetails.localBranchID = Id; ipCookie('cookiechk', localDetails, { expires: 21 }); diff --git a/Apollo/assets/views/partials/nav.html b/Apollo/assets/views/partials/nav.html index ae057e76..f0cede1d 100755 --- a/Apollo/assets/views/partials/nav.html +++ b/Apollo/assets/views/partials/nav.html @@ -29,51 +29,51 @@