siddharth_application/application/models/Employeedetails_model.php
gandhimathi Bharathirajan 6f3ed7fa32 Search Issue fixed
2017-04-08 17:41:24 +05:30

203 lines
6.4 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Employeedetails_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @return number $count : This is row count
*/
function employeeListingCount($searchText = ''){
$this->db->select('count(*) as Count');
$this->db->from('T_Employee_Details Emp');
//$likeCriteria = '';
$this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left');
if(!empty($searchText)) {
$likeCriteria = "(Emp.EmpID LIKE '%".$searchText."%'
OR Emp.FirstName LIKE '%".$searchText."%'
OR Emp.LastName LIKE '%".$searchText."%'
OR Emp.ContactNumber LIKE '%".$searchText."%'
OR Emp.EmailId LIKE '%".$searchText."%'
OR Emp.Designation LIKE '%".$searchText."%'
OR Dep.DepartmentName LIKE '%".$searchText."%'
)";
$this->db->where($likeCriteria);
}
// print_r( $this->db->last_query());
$query = $this->db->get();
// print_r( $this->db->last_query());
return $query->result_array();
}
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function employeeListing($searchText = '', $page, $segment)
{
$this->db->select(' Emp.*,Dep.DepartmentName as DepartmentName');
$this->db->from('T_Employee_Details Emp');
$this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left');
if(!empty($searchText)) {
$likeCriteria = "(Emp.EmpID LIKE '%".$searchText."%'
OR Emp.FirstName LIKE '%".$searchText."%'
OR Emp.LastName LIKE '%".$searchText."%'
OR Emp.ContactNumber LIKE '%".$searchText."%'
OR Emp.EmailId LIKE '%".$searchText."%'
OR Emp.Designation LIKE '%".$searchText."%'
OR Dep.DepartmentName LIKE '%".$searchText."%'
)";
$this->db->where($likeCriteria);
}
$this->db->order_by("Emp.EmpID", "asc");
$this->db->limit($page, $segment);
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getUserRoles()
{
$this->db->select('roleId, role');
$this->db->from('tbl_roles');
$this->db->where('roleId !=', 1);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to get the Config value from configuration table
* @return array $result : This is result of the query
*/
function getConfigValue(string $ConfigID )
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
$query = $this->db->get();
return $query->result();
}
/* *//**
* This function is used to get the Department details from T_DepartmentDetails
* @return array $result : This is result of the query
*/
function getDepartment()
{
$this->db->select('DEPCode, DepartmentName');
$this->db->from('T_DepartmentDetails');
$this->db->where('IsActive =', 1);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addNewemployee($Employee)
{
$this->db->insert('T_Employee_Details', $Employee);
$EmpID = $this->db->affected_rows();
return $EmpID;
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getuserInfo($EmpID)
{
$this->db->select('EmpID,FirstName,LastName,DateofBirth,ContactNumber,EmailId,DateofJoining,Role,Address1,Address2,
Place,City,State,Pin,DepartmentName,User_Comments,Created_date');
$this->db->from('T_EmpDetails');
$this->db->where('EmpID', $EmpID);
$query = $this->db->get();
return $query->result();
}
function UpdateEmployee($Emp, $EmpID)
{
echo $EmpID;
$this->db->where('EmpID', $EmpID);
$this->db->update('T_Employee_Details', $Emp);
return TRUE;
}
function viewemployee( $EmpID)
{
$this->db->select('Emp.*,Dep.DepartmentName as DepartmentName');
$this->db->from('T_Employee_Details AS Emp');
$this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left');
$this->db->where('Emp.EmpID', $EmpID);
$query = $this->db->get();
$result = $query->result();
// print_r($this->db->last_query());
return $result;
}
/* This function to get the Employee department on respective Employee */
function GetEmployeeDepartment($EmployeeID)
{
$this->db->select('DepartmentName');
$this->db->from('T_EmployeeDetails');
$this->db->where('EmpID', $EmployeeID);
$query = $this->db->get();
return $query->result_array();
}
function checkMailExists($email)
{
$this->db->select('EmailId');
$this->db->from('T_Employee_Details');
$this->db->where('EmailId',$email);
$query = $this->db->get();
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function checkPhotoExists($Pic)
{
$this->db->select('ProfilePic');
$this->db->from('T_Employee_Details');
$this->db->where($Pic);
$query = $this->db->get();
// print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result_array();
}
}
}
?>