siddharth_application/application/models/employeedetails_model.php
2023-05-30 18:45:55 +05:30

210 lines
5.9 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
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function employeeListing()
{
$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');
$this->db->order_by("Emp.EmpID", "asc");
$query = $this->db->get();
$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($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;
}
function UpdateEmployee($Emp, $EmpID)
{
//echo $EmpID;
$this->db->where('EmpID', $EmpID);
$this->db->update('T_Employee_Details', $Emp);
//print_r($this->db->last_query());
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($EmployeeID);
$query = $this->db->get();
return $query->result_array();
}
function checkMailExists($email='',$Empid='')
{
$this->db->select('EmailId');
$this->db->from('T_Employee_Details');
$this->db->where('EmailId',$email);
if ($Empid != '')
{
$this->db->where('EmpID !=',$Empid);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function checkAadharExists($AadharNo,$Empid='')
{
$this->db->select('AadharNo');
$this->db->from('T_Employee_Details');
$this->db->where('AadharNo',$AadharNo);
if ($Empid != '')
{
$this->db->where('EmpID !=',$Empid);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function checkPANExists($PANNo,$Empid='')
{
$this->db->select('PANNo');
$this->db->from('T_Employee_Details');
$this->db->where('PANNo',$PANNo);
if ($Empid != '')
{
$this->db->where('EmpID !=',$Empid);
}
$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();
}
}
function getEmployeeCount( )
{
$this->db->select('count(*) as EmpCount');
$this->db->from('T_Employee_Details');
$this->db->where('IsActive ',1 );
$query = $this->db->get();
return $query->result();
}
function getBankDetails()
{
$this->db->select('*');
$this->db->from('T_Bank_Details');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function export_excel(){
$this->db->select(' det.*,Dep.DepartmentName as DepartmentName,det.firstname,emp1.firstname as UpdatedByName,emp1.firstname as CreatedByName');
$this->db->join('T_DepartmentDetails Dep', 'det.Departmentcode = Dep.DEPCode','left');
$this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left');
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
return $this->db->get('T_Employee_Details as det')->result_array();
}
}
?>