User Creation changes
This commit is contained in:
parent
b4583d80d3
commit
38e899cc6a
@ -10,15 +10,18 @@ class Login_model extends CI_Model
|
|||||||
*/
|
*/
|
||||||
function loginMe($email, $password)
|
function loginMe($email, $password)
|
||||||
{
|
{
|
||||||
$this->db->select('BaseTbl.userId, BaseTbl.password, BaseTbl.name, BaseTbl.roleId, Roles.role');
|
$this->db->select('BaseTbl.userId, BaseTbl.password, Emp.FirstName,Emp.Designation, BaseTbl.roleId, Roles.role,DEPT.DEPCode,DEPT.DepartmentName,DEPT.HeadDept');
|
||||||
$this->db->from('tbl_users as BaseTbl');
|
$this->db->from('tbl_users as BaseTbl');
|
||||||
$this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
|
$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->where('BaseTbl.email', $email);
|
||||||
$this->db->where('BaseTbl.isDeleted', 0);
|
$this->db->where('BaseTbl.isDeleted', 0);
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
|
print_r( $this->db->last_query());
|
||||||
$user = $query->result();
|
|
||||||
|
$user = $query->result();
|
||||||
|
|
||||||
if(!empty($user)){
|
if(!empty($user)){
|
||||||
if(verifyHashedPassword($password, $user[0]->password)){
|
if(verifyHashedPassword($password, $user[0]->password)){
|
||||||
return $user;
|
return $user;
|
||||||
|
|||||||
@ -9,17 +9,25 @@ class User_model extends CI_Model
|
|||||||
*/
|
*/
|
||||||
function userListingCount($searchText = '')
|
function userListingCount($searchText = '')
|
||||||
{
|
{
|
||||||
$this->db->select('BaseTbl.userId, BaseTbl.email, BaseTbl.name, BaseTbl.mobile, Role.role,BaseTbl.isDeleted');
|
$this->db->select('EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,
|
||||||
$this->db->from('tbl_users as BaseTbl');
|
DEPT.DEPCode,DEPT.DepartmentName,role.role,user.userId');
|
||||||
$this->db->join('tbl_roles as Role', 'Role.roleId = BaseTbl.roleId','left');
|
$this->db->from('T_Employee_Details EMP');
|
||||||
|
$this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode');
|
||||||
|
$this->db->join('tbl_users user', 'user.EmpID = EMP.EmpID');
|
||||||
|
$this->db->join('tbl_roles role', 'user.roleId = role.roleId');
|
||||||
if(!empty($searchText)) {
|
if(!empty($searchText)) {
|
||||||
$likeCriteria = "(BaseTbl.email LIKE '%".$searchText."%'
|
$likeCriteria = "(EMP.FirstName LIKE '%".$searchText."%'
|
||||||
OR BaseTbl.name LIKE '%".$searchText."%'
|
OR EMP.LastName LIKE '%".$searchText."%'
|
||||||
OR BaseTbl.mobile LIKE '%".$searchText."%')";
|
OR EMP.EmailId LIKE '%".$searchText."%'
|
||||||
|
OR EMP.ContactNumber LIKE '%".$searchText."%'
|
||||||
|
OR EMP.Designation LIKE '%".$searchText."%'
|
||||||
|
OR DEPT.DepartmentName LIKE '%".$searchText."%'
|
||||||
|
OR role.role LIKE '%".$searchText."%'
|
||||||
|
OR EMP.Designation LIKE '%".$searchText."%')";
|
||||||
$this->db->where($likeCriteria);
|
$this->db->where($likeCriteria);
|
||||||
}
|
}
|
||||||
//$this->db->where('BaseTbl.isDeleted', 0);
|
$this->db->where('user.isDeleted !=', 1);
|
||||||
$this->db->where('BaseTbl.roleId !=', 1);
|
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
|
|
||||||
return count($query->result());
|
return count($query->result());
|
||||||
@ -34,25 +42,44 @@ class User_model extends CI_Model
|
|||||||
*/
|
*/
|
||||||
function userListing($searchText = '', $page, $segment)
|
function userListing($searchText = '', $page, $segment)
|
||||||
{
|
{
|
||||||
$this->db->select('BaseTbl.userId, BaseTbl.email, BaseTbl.name, BaseTbl.mobile, Role.role, BaseTbl.isDeleted');
|
$this->db->select('EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,
|
||||||
$this->db->from('tbl_users as BaseTbl');
|
DEPT.DEPCode,DEPT.DepartmentName,role.role,user.userId');
|
||||||
$this->db->join('tbl_roles as Role', 'Role.roleId = BaseTbl.roleId','left');
|
$this->db->from('T_Employee_Details EMP');
|
||||||
|
$this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode');
|
||||||
|
$this->db->join('tbl_users user', 'user.EmpID = EMP.EmpID');
|
||||||
|
$this->db->join('tbl_roles role', 'user.roleId = role.roleId');
|
||||||
if(!empty($searchText)) {
|
if(!empty($searchText)) {
|
||||||
$likeCriteria = "(BaseTbl.email LIKE '%".$searchText."%'
|
$likeCriteria = "(EMP.FirstName LIKE '%".$searchText."%'
|
||||||
OR BaseTbl.name LIKE '%".$searchText."%'
|
OR EMP.LastName LIKE '%".$searchText."%'
|
||||||
OR BaseTbl.mobile LIKE '%".$searchText."%')";
|
OR EMP.EmailId LIKE '%".$searchText."%'
|
||||||
|
OR EMP.ContactNumber LIKE '%".$searchText."%'
|
||||||
|
OR EMP.Designation LIKE '%".$searchText."%'
|
||||||
|
OR DEPT.DepartmentName LIKE '%".$searchText."%'
|
||||||
|
OR role.role LIKE '%".$searchText."%'
|
||||||
|
OR EMP.Designation LIKE '%".$searchText."%')";
|
||||||
$this->db->where($likeCriteria);
|
$this->db->where($likeCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
//$this->db->where('BaseTbl.isDeleted', 0);
|
|
||||||
$this->db->where('BaseTbl.roleId !=', 1);
|
$this->db->where('user.isDeleted !=', 1);
|
||||||
$this->db->limit($page, $segment);
|
$this->db->limit($page, $segment);
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
|
|
||||||
$result = $query->result();
|
$result = $query->result();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetRoleNameByUserID($UserId)
|
||||||
|
{
|
||||||
|
$subQuery = 'select roleId, role from tbl_roles
|
||||||
|
where roleId = (select roleId from tbl_users where userId=?)';
|
||||||
|
|
||||||
|
$query = $this->db->query($subQuery, array($UserId));
|
||||||
|
|
||||||
|
|
||||||
|
return $query->result();
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This function is used to get the user roles information
|
* This function is used to get the user roles information
|
||||||
* @return array $result : This is result of the query
|
* @return array $result : This is result of the query
|
||||||
@ -61,7 +88,7 @@ class User_model extends CI_Model
|
|||||||
{
|
{
|
||||||
$this->db->select('roleId, role');
|
$this->db->select('roleId, role');
|
||||||
$this->db->from('tbl_roles');
|
$this->db->from('tbl_roles');
|
||||||
//$this->db->where('roleId !=', 1);
|
$this->db->where("roleid <", 4);
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
|
|
||||||
return $query->result();
|
return $query->result();
|
||||||
@ -97,7 +124,7 @@ class User_model extends CI_Model
|
|||||||
$this->db->trans_start();
|
$this->db->trans_start();
|
||||||
$this->db->insert('tbl_users', $userInfo);
|
$this->db->insert('tbl_users', $userInfo);
|
||||||
|
|
||||||
$insert_id = $this->db->insert_id();
|
$insert_id = $this->db->affected_rows();
|
||||||
|
|
||||||
$this->db->trans_complete();
|
$this->db->trans_complete();
|
||||||
|
|
||||||
@ -188,6 +215,41 @@ class User_model extends CI_Model
|
|||||||
|
|
||||||
return $this->db->affected_rows();
|
return $this->db->affected_rows();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This function is used to get Employee details based on Employee ID Selection
|
||||||
|
* @return array $result : This is result of the query
|
||||||
|
*/
|
||||||
|
function GetEmployeeDetails($UserId)
|
||||||
|
{
|
||||||
|
//echo $UserId;
|
||||||
|
$subQuery = 'select EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,DEPT.DEPCode,DEPT.DepartmentName from
|
||||||
|
T_Employee_Details EMP join T_DepartmentDetails DEPT on
|
||||||
|
EMP.Departmentcode = DEPT.DEPCode where EMP.EmpID= (select EmpID from tbl_users where userId=?)';
|
||||||
|
|
||||||
|
$query = $this->db->query($subQuery, array($UserId));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $query->result();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This function is used to get the All employees
|
||||||
|
* @return array $result : This is result of the query
|
||||||
|
*/
|
||||||
|
function getAllEmployees()
|
||||||
|
{
|
||||||
|
/*$this->db->select('EmpID,FirstName,LastName');
|
||||||
|
$this->db->from('T_Employee_Details');
|
||||||
|
$query = $this->db->get();
|
||||||
|
|
||||||
|
return $query->result(); */
|
||||||
|
$this->db->select('EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,DEPT.DEPCode,DEPT.DepartmentName');
|
||||||
|
$this->db->from('T_Employee_Details EMP');
|
||||||
|
$this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode');
|
||||||
|
$this->db->where('EMP.IsActive ',1 );
|
||||||
|
$query = $this->db->get();
|
||||||
|
return $query->result();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user