From 5b1c6865edb761972aaac1de6418222688ab3548 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Tue, 24 Apr 2018 15:47:20 +0530 Subject: [PATCH] reset password --- api/application/models/Employee_model.php | 8 ++++---- api/application/models/Forgot_model.php | 7 +++++-- api/application/models/Login_model.php | 25 ++++++++++++++++++----- assets/views/login_forgot.html | 4 ++-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/api/application/models/Employee_model.php b/api/application/models/Employee_model.php index 73b4bb1..c8a2848 100755 --- a/api/application/models/Employee_model.php +++ b/api/application/models/Employee_model.php @@ -363,8 +363,8 @@ class Employee_model extends CI_Model if ($this->db->affected_rows() == '1') { $loginArr['StaffID'] = $empArr['StaffID']; $loginArr['ListCode'] = $empArr['ListCode']; - // $loginArr['MobileNumber'] = $empArr['MobileNumber']; - $loginArr['MobileNumber'] = $empArr['StaffID']; + $loginArr['MobileNumber'] = $empArr['MobileNumber']; + //$loginArr['MobileNumber'] = $empArr['StaffID']; $loginArr['EmailId'] = $empArr['EmailID']; $loginArr['IsActive'] = $empArr['IsActive']; $loginArr['CreatedBy'] = $createdBy; @@ -404,8 +404,8 @@ class Employee_model extends CI_Model if ($this->db->affected_rows() == '1') { $loginArr['StaffID'] = $empArr['StaffID']; $loginArr['ListCode'] = $empArr['ListCode']; - // $loginArr['MobileNumber'] = $empArr['MobileNumber']; - $loginArr['MobileNumber'] = $empArr['StaffID']; + $loginArr['MobileNumber'] = $empArr['MobileNumber']; + //$loginArr['MobileNumber'] = $empArr['StaffID']; $loginArr['EmailId'] = $empArr['EmailID']; $loginArr['IsActive'] = $empArr['IsActive']; $loginArr['CreatedBy'] = $createdBy; diff --git a/api/application/models/Forgot_model.php b/api/application/models/Forgot_model.php index cbeada8..06fc3a4 100755 --- a/api/application/models/Forgot_model.php +++ b/api/application/models/Forgot_model.php @@ -15,13 +15,16 @@ class Forgot_model extends CI_Model { $this->db->select('ID,Emailid,MobileNumber,Password'); $this->db->from(LOGIN); $this->db->where('MobileNumber', $user['MobileNumber']); + $this->db->or_where('StaffID', $user['MobileNumber']); $forgotDetails1 = $this->db->get()->first_row(); // echo $forgotDetails->MobileNumber;exit(); + $mobile=$forgotDetails1->MobileNumber; + // $result = $query->result_array(); if($forgotDetails1){ $this->db->select('ID,Emailid,MobileNumber,Password'); $this->db->from(LOGIN); - $this->db->where('MobileNumber', $user['MobileNumber']); + $this->db->where('MobileNumber', $mobile); $this->db->where('IsActive', 1); $forgotDetails = $this->db->get()->first_row(); if($forgotDetails) { @@ -31,7 +34,7 @@ class Forgot_model extends CI_Model { // print_r ($upatePassword) ; //exit(); if($upatePassword) { - $this->smssend($user['MobileNumber'], $password); + $this->smssend($mobile, $password); $result['forgotstatus'] = true; $result['resPass'] = "Check your registered Mobile Number!!"; $result['message'] = "Password updated successfully"; diff --git a/api/application/models/Login_model.php b/api/application/models/Login_model.php index fa2c1e7..6d6c91f 100755 --- a/api/application/models/Login_model.php +++ b/api/application/models/Login_model.php @@ -22,26 +22,39 @@ class Login_model extends CI_Model public function login($mobile = null, $password = null) { - $this->db->select('t1.MobileNumber, t1.Password,t1.ListCode'); + + + $this->db->select('t1.MobileNumber, t1.Password,t1.ListCode,t1.StaffID'); $this->db->from('' . LOGIN . ' as t1'); $this->db->where('t1.MobileNumber', $mobile); + $this->db->or_where('t1.StaffID', $mobile); // $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); $this->db->where('t1.IsActive', 1); //$this->db->where('t2.IsActive', 1); $loginDetails = $this->db->get(LOGIN)->first_row(); - // print_r($loginDetails);exit(); + $mobileno= $loginDetails->MobileNumber; + // echo $mobileno; + // die(); + //print_r($loginDetails);exit(); if ($loginDetails) { - if ($mobile == $loginDetails->MobileNumber) { - + + if ($mobile == $loginDetails->MobileNumber || $mobile == $loginDetails->StaffID) { + if ($password == $loginDetails->Password) { + if($loginDetails->ListCode == SUPER_ADMIN){ - //print_r($loginDetails);exit(); + // echo "Super"; + // print_r($loginDetails);exit(); $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode, t2.FinanceModuleAccess'); $this->db->from('' . LOGIN . ' as t1'); $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); $this->db->where('t1.MobileNumber', $mobile); + $this->db->or_where('t1.StaffID', $mobile); $this->db->where('t2.IsActive', 1); $responseDetails = $this->db->get()->first_row(); + + // print_r($responseDetails); + // die(); if($responseDetails){ if ($responseDetails->ListCode == SUPER_ADMIN) { // For First time Super admin login, will set all branch detail @@ -58,12 +71,14 @@ class Login_model extends CI_Model $result['message'] = "Your login is de-activated."; } } else if ($loginDetails->ListCode == ADMIN || $loginDetails->ListCode == EMPLOYEE) { + //print_r($loginDetails);exit(); $this->db->select('t1.MobileNumber, t3.ListCode, t1.ID, t3.BranchCode, t3.FinanceModuleAccess'); $this->db->from('' . LOGIN . ' as t1'); $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); $this->db->join('' . STAFF_BRANCH . ' as t3', 't3.StaffID = t2.StaffID', 'LEFT'); $this->db->where('t1.MobileNumber', $mobile); + $this->db->or_where('t1.StaffID', $mobile); $this->db->where('t2.IsActive', 1); $this->db->where('t3.IsActive', 1); $this->db->order_by('t3.CreatedOn', 'ASC'); diff --git a/assets/views/login_forgot.html b/assets/views/login_forgot.html index 684cd49..8dc75a0 100755 --- a/assets/views/login_forgot.html +++ b/assets/views/login_forgot.html @@ -14,11 +14,11 @@ Forget Password?

- Enter your Registered Mobile Number below to reset your password. + Enter your Registered Mobile Number/EmpID below to reset your password.

- + mobile number is required.