diff --git a/Apollo/api/application/controllers/Login_Controller.php b/Apollo/api/application/controllers/Login_Controller.php index 5d6e8550..c454d201 100755 --- a/Apollo/api/application/controllers/Login_Controller.php +++ b/Apollo/api/application/controllers/Login_Controller.php @@ -121,7 +121,9 @@ class Login_Controller extends REST_Controller { */ public function checkMobileNumber_post(){ $studentnum = $this->post('mobilenum'); - $getstudent = $this->login_model->checkstudnetnumber($studentnum); + $otpcheck = $this->post('otpcheck'); + $password = $this->post('pwd'); + $getstudent = $this->login_model->checkstudnetnumber($studentnum,$otpcheck,$password); if ($getstudent) { $getstudent['status'] = REST_Controller::HTTP_OK; diff --git a/Apollo/api/application/models/Login_model.php b/Apollo/api/application/models/Login_model.php index 5dac5f9d..a1429607 100755 --- a/Apollo/api/application/models/Login_model.php +++ b/Apollo/api/application/models/Login_model.php @@ -140,7 +140,7 @@ 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 'no _if';die(); // print_r($loginDetails);die(); $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess'); @@ -312,7 +312,7 @@ class Login_model extends CI_Model * Studnet Check function* * created_by : sriram */ - public function checkstudnetnumber($mobile){ + public function checkstudnetnumber($mobile,$otpcheck,$password){ $this->db->select('t1.MobileNumber, t1.Password,t1.ListCode'); $this->db->from('' . LOGIN . ' as t1'); @@ -371,23 +371,43 @@ class Login_model extends CI_Model } else if(($loginDetails->ListCode == ADMIN)||($loginDetails->ListCode == EMPLOYEE)||(($loginDetails->ListCode == TRAINEE))) - { + { + + $result['loginstudent'] = false; - $result['loginstudent'] = true; + $result['loginemployee'] = true; + + if($otpcheck == 1) + { + $adminpwd= md5($password); + } + + $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.IsActive,LO.StaffID,ST.MobileNumber as Mobile'); $this->db->from('' . LOGIN . ' as LO'); $this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID'); $this->db->where('LO.MobileNumber', $mobile); + + if($otpcheck == 1) + { + $this->db->where('LO.Password', $adminpwd); + } $this->db->where('ST.IsActive', 1); $responseDetails = $this->db->get()->first_row(); - //print_r($responseDetails);die(); + if($otpcheck == 1) + { + //print_r($this->db->last_query()); + } + + if(!empty($responseDetails)) + { if($responseDetails->IsActive ==1){ - $string2 = str_shuffle('1234567890'); + $string2 = str_shuffle('1234567890'); $otp = substr($string2,0,6); //$otp = '431528'; // //echo $otp;die; @@ -402,11 +422,20 @@ class Login_model extends CI_Model // $query =1; if($query == 1){ + + if($otpcheck == 1) + { + + $sms = $this->smssend($mobileno,$otp); + } - $result['checkstudent'] = true; + $result['checkemp'] = true; + $result['loginstudent'] = false; + + $result['loginemployee'] = true; }else{ - $result['checkstudent'] = false; + $result['checkemp'] = false; } @@ -414,7 +443,13 @@ class Login_model extends CI_Model $result['loginStatus'] = false; $result['message'] = "Your login is de-activated."; } + } + else { + $result['loginStatus'] = false; + $result['loginemployee'] = false; + $result['message'] = "Your login is de-activated."; + } @@ -433,12 +468,12 @@ class Login_model extends CI_Model $result['checkstudent'] = false; $result['message'] = "Your login is de-activated or don't have login."; } - //print_r($result);die; + //print_r($result);die; return $result; } public function smssend($mobile,$OTP) { - + //echo $mobile; $message ="Your One Time Password to Login to apollodec.com is $OTP. This is valid for 10 minutes."; $mobile = "91$mobile"; diff --git a/Apollo/assets/js/controllers/loginCtrl.js b/Apollo/assets/js/controllers/loginCtrl.js index 69679fd5..a850c1c2 100755 --- a/Apollo/assets/js/controllers/loginCtrl.js +++ b/Apollo/assets/js/controllers/loginCtrl.js @@ -25,6 +25,8 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc $scope.form = { submit: function (form) { + + // alert('in'); var firstError = null; if (form.$invalid) { var field = null, firstError = null; @@ -94,7 +96,7 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc // alert(response.data.message); swal("Warning!", response.data.message, "warning"); $scope.show = true; - $(".alert").delay(200).addClass("in").fadeOut(3500); + //$(".alert").delay(200).addClass("in").fadeOut(3500); } }); } @@ -133,9 +135,13 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc * Checkstudent change function * * created_by : sriram */ + + $scope.Empcheck = false; $scope.checkMobileNumber = function (MobileNumber) { //alert($scope.myModel.userMobile); // var studentNumber = $scope.myModel.userMobile; + + var otpcheck= MobileNumber; if($scope.myModel.userMobile !=''){ // swal({ // title:"Please Wait..", @@ -147,27 +153,50 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc url:apiPoint.url + 'checkmobilenumber', header:{'Content-Type':'application/json'}, - data:{mobilenum:$scope.myModel.userMobile} + data:{mobilenum:$scope.myModel.userMobile,otpcheck:otpcheck,pwd:$scope.myModel.passwordemp} }; $http(req).then(function(response){ - //console.log(response); + //console.log(response); swal.close(); - if(response.data.loginstudent ==true){ - if(response.data.checkstudent == true){ + if((response.data.loginstudent ==true)||(response.data.loginemployee ==true)){ + + console.log('if'); + if(response.data.checkstudent == true) + { $scope.typeInput = 'text'; $scope.place = 'OTP'; $scope.icon = 'fa fa-key'; $scope.info = true; - }else{ + } + + else if(response.data.checkemp== true) + { + console.log('in'); + + $scope.Empcheck = true; + $scope.typeInput = 'text'; + $scope.place = 'OTP'; + $scope.icon = 'fa fa-key'; + $scope.info = false; + } + + else + { swal("Warning!", response.data.message, "warning"); $scope.show = true; - $(".alert").delay(200).addClass("in").fadeOut(3500); + // $(".alert").delay(200).addClass("in").fadeOut(3500); } - }else{ + }else{ $scope.typeInput = 'password'; $scope.place = 'password'; - $scope.icon = 'fa fa-lock'; - $scope.info = false; + $scope.icon = 'fa fa-lock'; + $scope.info = false; + + swal("Warning!", response.data.message, "warning"); + // $scope.show = true; + // $(".alert").delay(200).addClass("in").fadeOut(3500); + + //alert(response.data.message); } }); } diff --git a/Apollo/assets/views/login_login.html b/Apollo/assets/views/login_login.html index aa97ddaa..48e20d42 100755 --- a/Apollo/assets/views/login_login.html +++ b/Apollo/assets/views/login_login.html @@ -379,6 +379,34 @@ Enter a valid mobile number / Employee Id + + + +
+ + + + + Password Required +
+ +
+ + +
+ + + + + + + + + +