123 lines
3.7 KiB
PHP
Executable File
123 lines
3.7 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Login_model extends CI_Model
|
|
{
|
|
|
|
/**
|
|
* This function used to check the login credentials of the user
|
|
* @param string $email : This is email of the user
|
|
* @param string $password : This is encrypted password of the user
|
|
*/
|
|
function loginMe($email, $password)
|
|
{
|
|
$this->db->select('BaseTbl.userId, BaseTbl.password, Emp.EmpID,Emp.FirstName,Emp.Designation, BaseTbl.roleId, Roles.role,DEPT.DEPCode,DEPT.DepartmentName,DEPT.HeadDept');
|
|
$this->db->from('tbl_users as BaseTbl');
|
|
$this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
|
|
$this->db->join('T_Employee_Details as Emp','BaseTbl.EmpID = Emp.EmpID');
|
|
$this->db->join('T_DepartmentDetails as DEPT','Emp.Departmentcode = DEPT.DEPCode');
|
|
$this->db->where('BaseTbl.email', $email);
|
|
$this->db->or_where('Emp.ContactNumber', $email);
|
|
$this->db->where('BaseTbl.isDeleted', 0);
|
|
$query = $this->db->get();
|
|
|
|
|
|
$user = $query->result();
|
|
|
|
if(!empty($user)){
|
|
if(verifyHashedPassword($password, $user[0]->password)){
|
|
return $user;
|
|
} else {
|
|
return array();
|
|
}
|
|
} else {
|
|
return array();
|
|
}
|
|
}
|
|
|
|
function Accessdep($EmpID)
|
|
{
|
|
|
|
$this->db->select('Departmentcode as AssDep');
|
|
$this->db->from('T_AccessDepartments');
|
|
$this->db->where('EmpID', $EmpID);
|
|
|
|
|
|
$query = $this->db->get();
|
|
// print_r( $this->db->last_query());
|
|
return $query->result();
|
|
}
|
|
/**
|
|
* get the user dtl
|
|
*/
|
|
function getuserid($mobileno,$emailid)
|
|
{
|
|
$this->db->select('UsrTbl.userId,UsrTbl.email,EmpTbl.ContactNumber,EmpTbl.FirstName');
|
|
$this->db->from('tbl_users as UsrTbl');
|
|
$this->db->join('T_Employee_Details as EmpTbl','UsrTbl.EmpID = EmpTbl.EmpID');
|
|
$this->db->where('EmpTbl.ContactNumber', $mobileno);
|
|
$this->db->where('UsrTbl.email',$emailid);
|
|
$this->db->where('UsrTbl.isDeleted', 0);
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
|
|
}
|
|
|
|
/**
|
|
* To update opt in our database
|
|
**/
|
|
function temp2($userId,$otp){
|
|
$this->db->set('OTP',$otp);
|
|
$this->db->where('userId',$userId);
|
|
$this->db->update('tbl_users');
|
|
$count = $this->db->affected_rows();
|
|
|
|
if($count > 0)
|
|
{
|
|
$subQuery = "select OTP from tbl_users where userId = '".$userId."'";
|
|
$query = $this->db->query($subQuery);
|
|
return $query->result();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* To get user id
|
|
**/
|
|
function getuserdtl($phno){
|
|
$this->db->select('BaseTbl.userId');
|
|
$this->db->from('tbl_users as BaseTbl');
|
|
$this->db->join('T_Employee_Details as Emp','BaseTbl.EmpID = Emp.EmpID');
|
|
$this->db->where('Emp.ContactNumber', $phno);
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* To update password and otp
|
|
**/
|
|
function resetpassword($Array,$userid){
|
|
|
|
$this->db->where('userId',$userid);
|
|
$this->db->update('tbl_users',$Array);
|
|
$count = $this->db->affected_rows();
|
|
return $count;
|
|
|
|
}
|
|
|
|
/**
|
|
* To update password only
|
|
**/
|
|
function updatepassword($userid,$password){
|
|
|
|
$this->db->set('password',$password);
|
|
$this->db->where('userId',$userid);
|
|
$this->db->update('tbl_users');
|
|
$count = $this->db->affected_rows();
|
|
return $count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|