264 lines
7.1 KiB
PHP
Executable File
264 lines
7.1 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class monthlypay_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 monthlyListing($current="")
|
|
{
|
|
//echo $current;
|
|
$this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Payroll.Key');
|
|
$this->db->from('T_Monthly_Pay_Inputs');
|
|
$this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID');
|
|
$this->db->join('T_Payroll','T_Monthly_Pay_Inputs.EmpID=T_Payroll.EmpID','left');
|
|
$this->db->where('Month_Year',$current);
|
|
|
|
$query = $this->db->get();
|
|
// print_r($query->result());
|
|
$result = $query->result();
|
|
|
|
return $result;
|
|
}
|
|
|
|
function getEmpPayDetails($current="",$s="")
|
|
{
|
|
//echo $s;die();
|
|
if($s == ''){
|
|
|
|
$current = '01-'.$current;
|
|
$current = date_create($current);
|
|
$current = date_format($current,"Y-m-d");
|
|
}
|
|
$this->db->select('T_Emp_Pay_Data.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.DateofJoining');
|
|
$this->db->from('T_Emp_Pay_Data');
|
|
$this->db->join('T_Employee_Details ','T_Emp_Pay_Data.EmpID=T_Employee_Details.EmpID');
|
|
$this->db->where('T_Employee_Details.DateofJoining <=',$current);
|
|
$this->db->order_by('EmpID','asc');
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
return $result;
|
|
}
|
|
|
|
function getEmpPayDetailsforMonthInputs($current="")
|
|
{
|
|
|
|
$current = '01-'.$current;
|
|
//echo $current;
|
|
$current = date_create($current);
|
|
$current = date_format($current,'Y-m-d');
|
|
$sql = "select T_Emp_Pay_Data.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.DateofJoining,T_Attendance.Days_Worked as Days_worked,T_Attendance.Absent as LOP_Days,T_Attendance.Paid_Leave as Paid_leave,T_Attendance.Total_OTHrs as OT_Hrs_Worked,T_Attendance.NoofDays from T_Emp_Pay_Data
|
|
left join T_Employee_Details on T_Employee_Details.EmpID = T_Emp_Pay_Data.EmpID
|
|
left join T_Attendance on T_Emp_Pay_Data.EmpID = T_Attendance.EmpID
|
|
where T_Employee_Details.DateofJoining <= CURRENT_DATE
|
|
and month(T_Attendance.Month_Year) = month(?)";
|
|
|
|
$query = $this->db->query($sql,array($current));
|
|
return $query->result();
|
|
}
|
|
|
|
function getPublicHoldays($current="")
|
|
{
|
|
if(!empty($current))
|
|
{
|
|
$sql = "select * from T_Public_Holidays where month(H_Date) = month(?) and year(H_Date) = year(?)";
|
|
$query = $this->db->query($sql,array($current,$current));
|
|
return $query->result();
|
|
}
|
|
else
|
|
{
|
|
$sql = "select * from T_Public_Holidays where year(H_Date)=year(CURRENT_DATE) order by H_Date";
|
|
$query = $this->db->query($sql);
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
function checkHoliday($Date)
|
|
{
|
|
$Date = date('Y-m-d',strtotime($Date));
|
|
//echo $Date;die();[
|
|
|
|
$sql="select count(*) as count from T_Public_Holidays where H_Date = ?";
|
|
$query = $this->db->query($sql,array($Date));
|
|
return $query->result_array();
|
|
}
|
|
|
|
function saveHolidays($data,$string)
|
|
{
|
|
//print_r($data);
|
|
if($string == 'i')
|
|
{
|
|
$this->db->insert('T_Public_Holidays',$data);
|
|
$i= $this->db->affected_rows();
|
|
return $i;
|
|
}
|
|
else if($string == 'u')
|
|
{
|
|
$this->db->where('H_date',$data['H_Date']);
|
|
$this->db->update('T_Public_Holidays',$data);
|
|
$i = $this->db->affected_rows();
|
|
return $i;
|
|
}
|
|
}
|
|
|
|
|
|
function deleteHoliday($d)
|
|
{
|
|
$d = date_format(date_create($d),'Y-m-d');
|
|
$this->db->where('H_date',$d);
|
|
$this->db->delete('T_Public_Holidays');
|
|
return $this->db->affected_rows();
|
|
}
|
|
function monthlyAttendance($current="")
|
|
{
|
|
|
|
$this->db->select('T_Attendance.*,T_Employee_Details.FirstName,T_Employee_Details.LastName');
|
|
$this->db->from('T_Attendance');
|
|
$this->db->join('T_Employee_Details','T_Attendance.EmpID=T_Employee_Details.EmpID');
|
|
$this->db->where('Month_Year',$current);
|
|
|
|
$query = $this->db->get();
|
|
|
|
$result = $query->result();
|
|
|
|
return $result;
|
|
}
|
|
function saveMonthlyData_model($data)
|
|
{
|
|
|
|
$month = $data['Month_Year'];
|
|
$empid = $data['EmpID'];
|
|
$count=0;
|
|
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('T_Monthly_Pay_Inputs');
|
|
$this->db->where('Month_Year',$month);
|
|
$this->db->where('EmpID',$empid);
|
|
$isExits = $this->db->get();
|
|
$res = $isExits->result_array();
|
|
|
|
if(!empty($res))
|
|
{
|
|
|
|
$count = $res[0]['count'];
|
|
}
|
|
|
|
|
|
if($count == 0 )
|
|
{
|
|
$i = $this->db->insert('T_Monthly_Pay_Inputs',$data);
|
|
return $i;
|
|
|
|
}
|
|
elseif($count == 1)
|
|
{
|
|
$this->db->where('Month_Year',$month);
|
|
$this->db->where('EmpID',$empid);
|
|
$i = $this->db->update('T_Monthly_Pay_Inputs',$data);
|
|
return $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function saveAttendance($monthattendance,$Month_Year,$EmpID)
|
|
{
|
|
$this->db->select('count(*) as c');
|
|
$this->db->from('T_Attendance');
|
|
$this->db->where('Month_Year',$Month_Year);
|
|
$this->db->where('EmpID',$EmpID);
|
|
$isExist = $this->db->get();
|
|
$isExist = $isExist->result_array();
|
|
$ans = $isExist[0]['c'];
|
|
|
|
if($ans == 0)
|
|
{
|
|
|
|
//array_pop();
|
|
$this->db->insert('T_Attendance',$monthattendance);
|
|
return $this->db->affected_rows();
|
|
//echo "INS";
|
|
// if($this->db->affected_rows() > 0)
|
|
// {
|
|
|
|
// return true;
|
|
// }
|
|
// else
|
|
// {
|
|
// return false;
|
|
// }
|
|
}
|
|
else
|
|
{
|
|
$this->db->where('Month_Year',$Month_Year);
|
|
$this->db->where('EmpID',$EmpID);
|
|
$this->db->update('T_Attendance',$monthattendance);
|
|
//echo "UPDATE";
|
|
return $this->db->affected_rows();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function addNewmonthlisting($m_list)
|
|
{
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_Monthly_Pay_Inputs', $asset);
|
|
|
|
$Asset_Code = $this->db->insert_id();
|
|
|
|
$this->db->trans_complete();
|
|
|
|
return $m_list;
|
|
}
|
|
function getUserInfo($EmpID,$month_year)
|
|
{
|
|
$this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName');
|
|
$this->db->from('T_Monthly_Pay_Inputs');
|
|
$this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID');
|
|
|
|
$this->db->where('T_Monthly_Pay_Inputs.EmpID', $EmpID);
|
|
$this->db->where('T_Monthly_Pay_Inputs.Month_Year', $month_year);
|
|
$query = $this->db->get();
|
|
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
function editmonth($monthdata, $EmpID)
|
|
{
|
|
$monthyear=$monthdata['Month_Year'];
|
|
|
|
|
|
|
|
$this->db->where('EmpID' ,$EmpID);
|
|
|
|
$this->db->where('Month_Year',$monthyear);
|
|
$this->db->update('T_Monthly_Pay_Inputs',$monthdata);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
function viewmonth($monthdata, $employeeid)
|
|
{
|
|
$this->db->order_by('Month_Year');
|
|
$this->db->where('EmpID', $employeeid);
|
|
$this->db->update('T_Monthly_Pay_Inputs', $monthdata);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
}
|
|
?>
|