diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 9693945b..8101a656 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -188,6 +188,9 @@ $route['filterYear'] = 'Dashboard_Controller/filterYear'; /*login page announcement*/ $route['getLoginAnnouncementDetails'] = 'Login_Controller/getLoginAnnouncementDetails'; +$route['VerifyEmpOTP'] = 'Login_Controller/VerifyEmpOTP'; + + /* status */ $route['addStatusDetails'] = 'Status_Controller/addStatusDetails'; $route['getStatusDetails'] = 'Status_Controller/getStatusDetails'; diff --git a/Apollo/api/application/controllers/Login_Controller.php b/Apollo/api/application/controllers/Login_Controller.php index c454d201..af0db637 100755 --- a/Apollo/api/application/controllers/Login_Controller.php +++ b/Apollo/api/application/controllers/Login_Controller.php @@ -139,5 +139,33 @@ class Login_Controller extends REST_Controller { ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code } } + + + public function VerifyEmpOTP_post() + { + $EmpID = $this->post('EmpID'); + $OTP = $this->post('OTP'); + $Password = $this->post('Password'); + + $getstudent = $this->login_model->Emplogin($EmpID,$OTP,$Password); + + if ($getstudent) + { + $getstudent['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getstudent, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + + } } \ No newline at end of file diff --git a/Apollo/api/application/models/Login_model.php b/Apollo/api/application/models/Login_model.php index ddad06f2..19f895f3 100755 --- a/Apollo/api/application/models/Login_model.php +++ b/Apollo/api/application/models/Login_model.php @@ -32,7 +32,7 @@ class Login_model extends CI_Model $loginDetails = $this->db->get(LOGIN)->first_row(); // print_r($this->db->last_query());die(); - // print_r($loginDetails); + //print_r($loginDetails);die(); if($loginDetails) { $mobileno= $loginDetails->MobileNumber; @@ -140,66 +140,131 @@ class Login_model extends CI_Model //echo 'NO_SUPER_ADMIN';die(); if ($mobile == $loginDetails->MobileNumber || strtoupper($mobile) == strtoupper($loginDetails->StaffID)) { - //echo 'no _if';die(); + // echo $mobile; + // echo $password; + + $this->db->select('*'); + $this->db->from('T_Login'); + $this->db->where('MobileNumber',$mobile); + $this->db->where('Password',$password); + $this->db->where('IsActive','1'); + $details = $this->db->get()->first_row(); + + //print_r($details); + if($details) + { + + $this->db->select('MobileNumber'); + $this->db->from('T_StaffDetails'); + $this->db->where('StaffID',$loginDetails->StaffID); + $searchDetails = $this->db->get(); + // print_r($searchDetails->result());die(); + + $contact =''; + + foreach($searchDetails->result() as $mo) + { + $contact = $mo->MobileNumber; + } + + + $string2 = str_shuffle('1234567890'); + $otp = substr($string2,0,6); + //$otp = '431528'; + + $save['OTP'] = $otp; + $save['UpdatedOn'] = date('Y-m-d H:i:s'); + + $this->db->where('MobileNumber',$mobile); + $query = $this->db->update('T_Login',$save); + + $mobileno = $contact; + + + if($query == 1) + { + $sms = $this->smssend($mobileno,$otp); + } + + $result['details'] = 'role check'; + $result['pwdcheck']=true; + $result['loginemployee']=true; + $result['loginStatus'] =true; + + } + else + { + $result['pwdcheck']=false; + $result['loginemployee']=false; + $result['loginStatus'] =false; + $result['message'] = "Please Check the Password !!"; + } + + + + + + + /// die(); // print_r($loginDetails);die(); - $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess'); - $this->db->from('' . LOGIN . ' as LO'); - $this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID'); - $this->db->join('' . STAFF_BRANCH . ' as SC', 'SC.StaffID = ST.StaffID'); - $this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchCode'); - $this->db->where('LO.MobileNumber', $mobile); - $this->db->where('LO.OTP',$password); - $this->db->where('ST.IsActive', 1); - // $this->db->where('BR.Is_StudentWebAccessActive', 1); - $responseDetails = $this->db->get()->first_row(); + // $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess'); + // $this->db->from('' . LOGIN . ' as LO'); + // $this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID'); + // $this->db->join('' . STAFF_BRANCH . ' as SC', 'SC.StaffID = ST.StaffID'); + // $this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchCode'); + // $this->db->where('LO.MobileNumber', $mobile); + // $this->db->where('LO.OTP',$password); + // $this->db->where('ST.IsActive', 1); + // // $this->db->where('BR.Is_StudentWebAccessActive', 1); + // $responseDetails = $this->db->get()->first_row(); - // print_r($responseDetails);die(); + // // print_r($responseDetails);die(); - //print_r($this->db->last_query());die(); + // //print_r($this->db->last_query());die(); - if($responseDetails) - { + // if($responseDetails) + // { - $save['OTP'] = ''; - $this->db->where('MobileNumber',$mobile); - $this->db->where('StaffID',$mobile); - // $this->db->where('ListCode',ADMIN); - // $this->db->or_where('ListCode',EMPLOYEE); - // $this->db->or_where('ListCode',TRAINEE); - $this->db->update('T_Login',$save);//print_r($this->db->last_query());die(); - if($responseDetails->IsActive == 1) - { - $result['loginStatus'] = true; - $result['details'] = $responseDetails; - } - else - { - $result['loginStatus'] = false; - $result['loginemployee'] = false; - $result['checkemp'] = false; - $result['message'] = "Please Enter The Correct OTP."; - } - } + // $save['OTP'] = ''; + // $this->db->where('MobileNumber',$mobile); + // $this->db->where('StaffID',$mobile); + // // $this->db->where('ListCode',ADMIN); + // // $this->db->or_where('ListCode',EMPLOYEE); + // // $this->db->or_where('ListCode',TRAINEE); + // $this->db->update('T_Login',$save);//print_r($this->db->last_query());die(); + // if($responseDetails->IsActive == 1) + // { + // $result['loginStatus'] = true; + // $result['details'] = $responseDetails; + // } + // else + // { + // $result['loginStatus'] = false; + // $result['loginemployee'] = false; + // $result['checkemp'] = false; + // $result['message'] = "Please Enter The Correct OTP."; + // } + // } - else - { - $result['loginStatus'] = false; - $result['loginemployee'] = false; - $result['checkemp'] = false; - $result['message'] = "Please Enter The Correct OTP."; - } + // else + // { + // $result['loginStatus'] = false; + // $result['loginemployee'] = false; + // $result['checkemp'] = false; + // $result['message'] = "Please Enter The Correct OTP."; + // } - } + // } - else - { // echo 'no _else';die(); - $result['loginStatus'] = false; - $result['loginemployee'] = false; - $result['checkemp'] = false; - $result['message'] = "Please Enter Register Mobile Number !!"; + // else + // { // echo 'no _else';die(); + // $result['loginStatus'] = false; + // $result['loginemployee'] = false; + // $result['checkemp'] = false; + // $result['message'] = "Please Enter Register Mobile Number !!"; } } @@ -294,6 +359,83 @@ class Login_model extends CI_Model } + + + + + public function Emplogin($EmpID,$OTP,$Password) + { + + + $this->db->select('MobileNumber'); + $this->db->from('T_StaffDetails'); + $this->db->where('StaffID',$EmpID); + $searchDetails = $this->db->get(); + // print_r($searchDetails->result());die(); + + $contact =''; + + foreach($searchDetails->result() as $mo) + { + $contact = $mo->MobileNumber; + } + + + + + $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess'); + $this->db->from('' . LOGIN . ' as LO'); + $this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID'); + $this->db->join('' . STAFF_BRANCH . ' as SC', 'SC.StaffID = ST.StaffID'); + $this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchCode'); + $this->db->where('LO.MobileNumber', $EmpID); + $this->db->where('LO.OTP',$OTP); + $this->db->where('LO.Password',$Password); + $this->db->where('ST.IsActive', 1); + // $this->db->where('BR.Is_StudentWebAccessActive', 1); + $responseDetails = $this->db->get()->first_row(); + + // print_r($responseDetails);die(); + + //print_r($this->db->last_query());die(); + + + if($responseDetails) + { + + $save['OTP'] = ''; + $this->db->where('MobileNumber',$EmpID); + $this->db->where('StaffID',$EmpID); + + $this->db->update('T_Login',$save); + if($responseDetails->IsActive == 1) + { + $result['loginStatus'] = true; + $result['details'] = $responseDetails; + } + else + { + $result['loginStatus'] = false; + $result['loginemployee'] = false; + $result['checkemp'] = false; + $result['message'] = "Please Enter The Correct OTP."; + } + } + + else + { + $result['loginStatus'] = false; + $result['loginemployee'] = false; + $result['checkemp'] = false; + $result['message'] = "Please Enter The Correct OTP."; + } + + return $result; + //} + + + } + public function change_Password( $userId, $newPassword, $oldPassword, $updateOn) { $this->db->select('Password'); $this->db->from(LOGIN); diff --git a/Apollo/assets/js/controllers/loginCtrl.js b/Apollo/assets/js/controllers/loginCtrl.js index 7befff75..908198ee 100755 --- a/Apollo/assets/js/controllers/loginCtrl.js +++ b/Apollo/assets/js/controllers/loginCtrl.js @@ -11,7 +11,8 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc */ $scope.myModel = { 'userMobile': '', - 'password': '' + 'password': '', + 'passwordemp':'' }; $scope.typeInput = 'password'; @@ -23,11 +24,16 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc $scope.responseData = ''; - $scope.form = { - submit: function (form) { + // $scope.form = { + + $scope.Login=function(myModel) + { + // alert($scope.Empcheck); + //alert('in');return false; + var firstError = null; if (form.$invalid) { var field = null, firstError = null; @@ -64,11 +70,25 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc }; $http(req).then(function (response) { if (response.data.loginStatus == true) { + + $scope.responseData = response.data.details; - + //console.log($scope.responseData) + + + + if($scope.responseData == 'role check') + { + $scope.Empcheck = true; + + swal("Your OTP is sent !", response.data.message); + } /* * After logined user details store to local client detail */ + else + { + var localDateTime = new Date(); $scope.localStore = { "localUserID": $scope.responseData.ID, @@ -87,12 +107,19 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc if($scope.responseData.ListCode=='R001'){ $state.go('app.studentView'); } + + else if($scope.responseData.ListCode !='R004') + { + console.log('in') + } else{ // $window.location.reload(); $state.go('app.dashboard'); // $window.location.reload(); } + } + } else { // alert(response.data.message); if($scope.Empcheck == false) @@ -110,12 +137,12 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc } }); } - }, - reset: function (form) { - $scope.myModel = angular.copy($scope.master); - form.$setPristine(true); } - } + // reset: function (form) { + // $scope.myModel = angular.copy($scope.master); + // form.$setPristine(true); + // } + //} $scope.myInterval = 2000; // load when html page load @@ -141,6 +168,64 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc } }); } + + + +$scope.EmpLogin=function(myModel) +{ + //console.log(myModel) + + var empid= myModel.userMobile; + var password = myModel.password; + var otp = myModel.passwordemp; + + var md5password = md5.createHash(password); + + var verify = { + method: 'POST', + url: apiPoint.url + 'VerifyEmpOTP/', + headers: { 'Content-Type': 'application/json' }, + data: {EmpID:empid,Password:md5password,OTP:otp} + }; + + $http(verify).then(function (response) + { + + if (response.data.loginStatus == true) + { + if (response.data.loginStatus == true) + { + + $scope.responseData = response.data.details; + + var localDateTime = new Date(); + $scope.localStore = { + "localUserID": $scope.responseData.ID, + "localBranchID": $scope.responseData.BranchCode, + 'localType': $scope.responseData.ListCode, + 'is_DayBookApproval_Access': $scope.responseData.FinanceModuleAccess, + 'is_CalltrackApproval_Access': $scope.responseData.CallModuleAccess, + 'localOn': localDateTime, + 'status': 'active' + } + ipCookie('cookiechk', $scope.localStore, { expires: 21 }); + localStorage.setItem('localObj', JSON.stringify($scope.localStore)); + + $state.go('app.dashboard'); + } + } + + + + }); + + +} + + + + + /** * Checkstudent change function * * created_by : sriram @@ -149,10 +234,7 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc $scope.Empcheck = false; $scope.OTP_or_PWD = 0; $scope.checkMobileNumber = function (MobileNumber) { - //alert($scope.myModel.userMobile); - // var studentNumber = $scope.myModel.userMobile; - - // alert(MobileNumber); + $scope.OTP_or_PWD = MobileNumber; @@ -173,7 +255,7 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc $http(req).then(function(response){ //alert(otpcheck); -console.log(response) +//console.log(response) if(otpcheck == undefined) { swal.close(); @@ -189,15 +271,15 @@ console.log(response) $scope.info = true; } - else if(response.data.checkemp== true) + else if(response.data.pwdcheck== true) { - // console.log('in'); + console.log('in'); - $scope.Empcheck = true; - $scope.typeInput = 'text'; - $scope.place = 'OTP'; - $scope.icon = 'fa fa-key'; - $scope.info = false; + // $scope.Empcheck = true; + //$scope.typeInput = 'text'; + //$scope.place = 'OTP'; + //$scope.icon = 'fa fa-key'; + //$scope.info = false; } else diff --git a/Apollo/assets/views/login_login.html b/Apollo/assets/views/login_login.html index 4a37cc7f..23ff72d4 100755 --- a/Apollo/assets/views/login_login.html +++ b/Apollo/assets/views/login_login.html @@ -381,7 +381,7 @@ - + @@ -404,7 +404,7 @@