274 lines
8.0 KiB
PHP
Executable File
274 lines
8.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class Employeedetails_model extends 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()
|
|
{
|
|
$builder = $this->db->table('t_employee_details Emp')
|
|
->select(' Emp.*,Dep.DepartmentName as DepartmentName')
|
|
->join('t_departmentdetails Dep', 'Emp.Departmentcode = Dep.DEPCode', 'left')
|
|
->orderBy("Emp.EmpID", "asc");
|
|
|
|
$query = $builder->get();
|
|
|
|
$result = $query->getResult();
|
|
return $result;
|
|
}
|
|
|
|
public function employeeHistory($emp)
|
|
{
|
|
$builder = $this->db->table('t_employee_history as h')
|
|
->select('h.old_value,h.new_value,h.column_name,DATE_FORMAT(h.created_at, "%d-%m-%Y") AS indian_date, DATE_FORMAT(h.created_at, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", ed.FirstName, ed.LastName) AS updater_name')
|
|
->join('tbl_users as u', 'u.userId = h.updated_by', 'left')
|
|
->join('t_employee_details as ed', 'ed on u.EmpID = ed.EmpID', 'left')
|
|
->where('h.empcode ', $emp)
|
|
->orderBy('h.created_at', 'asc');
|
|
$query = $builder->get();
|
|
$result = $query->getResult();
|
|
return $result;
|
|
}
|
|
|
|
function getUserRoles()
|
|
{
|
|
|
|
$builder = $this->db->table('tbl_roles')->select('roleId, role')
|
|
->where('roleId !=', 1);
|
|
$query = $builder->get();
|
|
|
|
return $query->getResult();
|
|
}
|
|
|
|
/**
|
|
* This function is used to get the Config value from configuration table
|
|
* @return array $result : This is result of the query
|
|
*/
|
|
function getConfigValue($ConfigID)
|
|
{
|
|
|
|
$builder = $this->db->table('t_configdetails')->select('ConfigValue')
|
|
->where('Config_id ', $ConfigID);
|
|
$query = $builder->get();
|
|
|
|
return $query->getResult();
|
|
}
|
|
|
|
function incomingSilicaSandTestedBy(){
|
|
|
|
|
|
$builder = $this->db->table('t_employee_details Emp')
|
|
->select(' Emp.*')
|
|
->whereIn('Designation', ['lab assistant', 'factory manager', 'lab head'])
|
|
->orderBy("Emp.EmpID", "asc");
|
|
|
|
$query = $builder->get();
|
|
|
|
$result = $query->getResult();
|
|
return $result;
|
|
|
|
}
|
|
|
|
function incomingSilicaSandApprovedBy(){
|
|
|
|
$builder = $this->db->table('t_employee_details Emp')
|
|
->select(' Emp.*')
|
|
->whereIn('Designation', ['factory manager', 'lab head'])
|
|
->orderBy("Emp.EmpID", "asc");
|
|
|
|
$query = $builder->get();
|
|
|
|
$result = $query->getResult();
|
|
return $result;
|
|
|
|
|
|
}
|
|
|
|
/* */
|
|
/**
|
|
* This function is used to get the Department details from t_departmentdetails
|
|
* @return array $result : This is result of the query
|
|
*/
|
|
function getDepartment()
|
|
{
|
|
|
|
$builder = $this->db->table('t_departmentdetails')
|
|
->select('DEPCode, DepartmentName')
|
|
->where('IsActive =', 1);
|
|
$query = $builder->get();
|
|
|
|
return $query->getResult();
|
|
}
|
|
/**
|
|
* 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)
|
|
{
|
|
|
|
$builder = $this->db->table('t_employee_details');
|
|
$builder->insert($Employee);
|
|
|
|
if ($this->db->affectedRows() > 0) {
|
|
$builder->select('*');
|
|
$builder->orderBy('created_date', 'DESC');
|
|
$builder->limit(1);
|
|
|
|
$query = $builder->get();
|
|
$result = $query->getRowArray();
|
|
return $result;
|
|
} else {
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
function UpdateEmployee($Emp, $EmpID)
|
|
{
|
|
$this->db->table('t_employee_details')
|
|
->where('EmpID', $EmpID)
|
|
->update($Emp);
|
|
$res = $this->db->affectedRows();
|
|
return $res;
|
|
}
|
|
|
|
|
|
function viewemployee($EmpID)
|
|
{
|
|
$builder = $this->db->table('t_employee_details AS Emp')->select('Emp.*,Dep.DepartmentName as DepartmentName')
|
|
|
|
->join('t_departmentdetails Dep', 'Emp.Departmentcode = Dep.DEPCode', 'left')
|
|
->where('Emp.EmpID', $EmpID);
|
|
$query = $builder->get();
|
|
|
|
$result = $query->getResult();
|
|
|
|
|
|
return $result;
|
|
}
|
|
|
|
/* This function to get the Employee department on respective Employee */
|
|
function GetEmployeeDepartment($EmployeeID)
|
|
{
|
|
|
|
$builder = $this->db->table('T_EmployeeDetails')
|
|
->select('DepartmentName')
|
|
->where($EmployeeID);
|
|
$query = $builder->get();
|
|
return $query->getResultArray();
|
|
}
|
|
|
|
function checkMailExists($emailId = '', $Empid = '')
|
|
{
|
|
|
|
$builder = $this->db->table('t_employee_details')->select('EmailId')
|
|
->where('EmailId', $emailId);
|
|
if ($Empid != '') {
|
|
$builder->where('EmpID !=', $Empid);
|
|
}
|
|
$query = $builder->get();
|
|
|
|
return $query;
|
|
}
|
|
|
|
function checkMobileExists($ContactNumber= '', $Empid = ''){
|
|
$builder = $this->db->table('t_employee_details')->select('ContactNumber')
|
|
->where('ContactNumber', $ContactNumber);
|
|
if ($Empid != '') {
|
|
$builder->where('EmpID !=', $Empid);
|
|
}
|
|
$query = $builder->get();
|
|
|
|
return $query;
|
|
}
|
|
|
|
function checkAadharExists($aadharNo, $Empid = '')
|
|
{
|
|
|
|
$builder = $this->db->table('t_employee_details')->select('AadharNo')
|
|
->where('AadharNo', $aadharNo);
|
|
if ($Empid != '') {
|
|
$builder->where('EmpID !=', $Empid);
|
|
}
|
|
$query = $builder->get();
|
|
|
|
return $query;
|
|
|
|
|
|
}
|
|
function checkPANExists($panNo, $Empid = '')
|
|
{
|
|
|
|
$builder = $this->db->table('t_employee_details')->select('PANNo')
|
|
->where('PANNo', $panNo);
|
|
if ($Empid != '') {
|
|
$builder->where('EmpID !=', $Empid);
|
|
}
|
|
|
|
$query = $builder->get();
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
function checkPhotoExists($Pic)
|
|
{
|
|
|
|
$builder = $this->db->table('t_employee_details')->select('ProfilePic')->where($Pic);
|
|
|
|
$query = $builder->get();
|
|
|
|
if ($query->getNumRows() > 0) {
|
|
return $query->getResultArray();
|
|
}
|
|
}
|
|
function getEmployeeCount()
|
|
{
|
|
|
|
$builder = $this->db->table('t_employee_details')
|
|
->select('count(*) as EmpCount')->where('IsActive ', 1);
|
|
$query = $builder->get();
|
|
return $query->getResult();
|
|
}
|
|
|
|
function getBankDetails()
|
|
{
|
|
$builder = $this->db->table('t_bank_details')->select('*');
|
|
$query = $builder->get();
|
|
$result = $query->getResult();
|
|
return $result;
|
|
}
|
|
|
|
function export_excel()
|
|
{
|
|
|
|
$builder = $this->db->table('t_employee_details as ed')
|
|
->select('CONCAT_WS(" ", ed.FirstName, ed.LastName) as Name, ed.*,Dep.DepartmentName as DepartmentName,CONCAT_WS(" ", emp1.FirstName, emp1.LastName) as UpdatedByName,CONCAT_WS(" ", emp.FirstName, emp.LastName) as CreatedByName')
|
|
->select('t_emp_pay_data.Pay_Data_ID,t_emp_pay_data.EmpID,t_emp_pay_data.Basic_Pay,t_emp_pay_data.HRA_Rate,t_emp_pay_data.Allowances,t_emp_pay_data.Food_Allowances,t_emp_pay_data.Incentives,t_emp_pay_data.PF_Rate,t_emp_pay_data.ESI_Rate,t_emp_pay_data.HRA_Amount,t_emp_pay_data.TotalSalary')
|
|
->join('t_departmentdetails Dep', 'ed.Departmentcode = Dep.DEPCode', 'left')
|
|
->join('tbl_users as tbl', ' ed.createdby = tbl.userid', 'left')
|
|
->join('t_employee_details as emp', 'emp.empid=tbl.empid', 'left')
|
|
->join('tbl_users as tbl1', ' ed.UpdatedBy = tbl1.userid', 'left')
|
|
->join('t_employee_details as emp1', 'emp1.empid=tbl1.empid', 'left')
|
|
->join('t_emp_pay_data', 'ed.EmpID=t_emp_pay_data.EmpID', 'left')
|
|
->groupBy('ed.EmpID');
|
|
|
|
return $builder->get()->getResultArray();
|
|
|
|
}
|
|
}
|