db->query($sql,array($lastdate,$current)); $result = $query->result(); return $result; } /** * To get employee payment details * @param date $current - Optional * @param array $s - Optional * @return array $result : result of the query (return as active employee details) */ function getEmpPayDetails($current="",$s="") { $month_val = date('m',strtotime($current)); $year_val = date('Y',strtotime($current)); $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val); $lastdate = $year_val.'-'.$month_val.'-'.$date_val; $this->db->select('T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.DateofJoining'); $this->db->from('T_Employee_Details'); $this->db->where('T_Employee_Details.IsActive',1); $this->db->where('T_Employee_Details.DateofJoining <=',$lastdate); $this->db->order_by('EmpID','asc'); $query = $this->db->get(); $result = $query->result(); return $result; } /** * To get employee payment month wise details * @param date $current - Optional : This is current month and year value * @return array $result : result of the query (return employee payment details) */ function getEmpPayDetailsforMonthInputs($current="") { $current = '01-'.$current; $current = date_create($current); $current = date_format($current,'Y-m-d'); $month_val = date('m',strtotime($current)); $year_val = date('Y',strtotime($current)); $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val); $lastdate = $year_val.'-'.$month_val.'-'.$date_val; $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,T_Loan_Master.Loan_ID,T_Payroll.Key from T_Emp_Pay_Data left join T_Employee_Details on T_Employee_Details.EmpID = T_Emp_Pay_Data.EmpID left join T_Payroll on T_Employee_Details.EmpID = T_Payroll.EmpID and month(T_Payroll.PayOn) = month(?) and year(T_Payroll.PayOn) = year(?) left join T_Attendance on T_Emp_Pay_Data.EmpID = T_Attendance.EmpID left join T_Loan_Master on T_Emp_Pay_Data.EmpID = T_Loan_Master.EmpID and T_Loan_Master.is_Active = 1 where T_Employee_Details.DateofJoining <= ? and month(T_Attendance.Month_Year) = month(?) and year(T_Attendance.Month_Year) = year(?) order by T_Employee_Details.EmpID"; $query = $this->db->query($sql,array($current,$current,$lastdate,$current,$current)); return $query->result(); } /** * To get public holiday details for attendances * @param date $current - Optional : This is current month and year value * @return array $query->result() : result of the query (returns public holiday information) */ 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(); } } /** * To declare date is holiday * @param date $Date : This is date * @return array $query->result() : result of the query (returns public holiday rowcount) */ function checkHoliday($Date) { $Date = date('Y-m-d',strtotime($Date)); $sql="select count(*) as count from T_Public_Holidays where H_Date = ?"; $query = $this->db->query($sql,array($Date)); return $query->result_array(); } /** * To store holiday date * @param array $data : This is date * @param string $String : it has 'i' and 'u' ('i' handles insertion and 'u' handles updation) * @return array $i : result of the query (returns as count in number) */ function saveHolidays($data,$string) { 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; } } /** * To delete holiday date * @param date $d : This is date * @return $this->db->affected_rows() : result of the query (return as count in number) */ 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(); } /** * To get details for attendances * @param date $current - Optional : This is date * @return $result : result of the query(return as monthwise attendances datas) */ function monthlyAttendance($current="") { $month_val = date('m',strtotime($current)); $year_val = date('Y',strtotime($current)); $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val); $lastdate = $year_val.'-'.$month_val.'-'.$date_val; $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('T_Employee_Details.DateofJoining <= ',$lastdate); $this->db->where('Month_Year',$current); $this->db->where('T_Employee_Details.IsActive',1); $this->db->order_by('T_Attendance.EmpID', 'asc'); $query = $this->db->get(); $result = $query->result(); return $result; } /** * To store attendances Information (its handles insertion and updation operation) * @param array $data : this will have all attendances inforamtion * @var number $res : gets count * @return array $i : result of the query (returns as count in numbers) */ 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; } } /** * To store attendances data (its handle both insertion and updation operation) * @param array $monthattendance : this will have attendances information * @param number $Month_Year : this have month and date value * @param number $EmpID : this is empid * @var $isExist : exists value count * @return array $this->db->affected_rows() : result of the query (returns as count in numbers) */ 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) { $this->db->insert('T_Attendance',$monthattendance); return $this->db->affected_rows(); } else { $this->db->where('Month_Year',$Month_Year); $this->db->where('EmpID',$EmpID); $this->db->update('T_Attendance',$monthattendance); return $this->db->affected_rows(); } } /** * To store employees monthly payment datas * @param array $m_list : this will have all employee monthlypayment details */ 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; } /** * To get employee monthly payment details * @param number $month_year : this have month and date value * @param number $EmpID : this is empid * @return array $query->result() : result of the query (returns as count in numbers) */ 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(); } /** * To store edited employee monthly payment details * @param number $monthdata : this will have all the edited employee monthly payment details * @param number $EmpID : this is employee Id */ 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; } /** * To store edited monthyear data * @param number $monthdata : this will have edited monthyear data * @param number $EmpID : this is employee Id */ 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; } /* permissionslip models */ /** * To get employee list of permission slip * @return array $query->result() : result of the query (returns employee details with department name) */ function emplist() { $sql="select Emp.EmpID,CONCAT(FirstName,' ',LastName)as name ,Emp.Departmentcode, Dep.DepartmentName FROM T_Employee_Details as Emp join T_DepartmentDetails as Dep on Dep.DEPCode=Emp.Departmentcode where Emp.IsActive = 1;"; $query =$this->db->query($sql); return $query->result(); } /** * To store permissionslip datas * @param array $Permissiondata : this will have all permissionslip data * @return numbers $Permission : result of the query (returns as count in numbers) */ function addper($Permissiondata) { $this->db->trans_start(); $this->db->insert('T_Permission', $Permissiondata); $Permission = $this->db->affected_rows(); $this->db->trans_complete(); return $Permission; } /** * To get the permission data for list * @return array $query->result() : result of the query (returns permission slip details) */ function perlist() { $this->db->select('*'); $this->db->from('T_Permission'); $query =$this->db->get(); return $query->result(); } /** * To get permitted employee list * @param number $SNO : this is sno * @return array $query->result() : result of the query (returns permitted employee details) */ function pdf($SNO) { $this->db->select('per.*,emp.FirstName,LastName,dep.DepartmentName'); $this->db->from('T_Permission per'); $this->db->join('T_Employee_Details emp','emp.EmpID = per.EmpID'); $this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode'); $this->db->where('per.SNO',$SNO ); $query =$this->db->get(); return $query->result(); } /* Ends permissionslip models */ function reportvalue($fin_year) { $curr_split = explode('-',$fin_year); $pre_year = $curr_split[0]; $curr_year = $curr_split[1]; $sql= "select T_Monthly_Pay_Inputs.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus from T_Monthly_Pay_Inputs join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID = T_Employee_Details.EmpID where substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) >= 4 or substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) <= 3 group by T_Monthly_Pay_Inputs.EmpID"; $query = $this->db->query($sql,array($pre_year,$curr_year)); return $query->result(); } function Monthwisereportvalue($Fin_year,$EmployeeID) { $curr_split = explode('-',$Fin_year); $pre_year = $curr_split[0]; $curr_year = $curr_split[1]; $sql= "select T_Monthly_Pay_Inputs.EmpID,T_Monthly_Pay_Inputs.Month_Year,T_Employee_Details.FirstName,T_Employee_Details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus from T_Monthly_Pay_Inputs join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID = T_Employee_Details.EmpID and T_Monthly_Pay_Inputs.EmpID = ? where substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) >= 4 or substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) <= 3 group by T_Monthly_Pay_Inputs.Month_Year"; $query = $this->db->query($sql,array($EmployeeID,$pre_year,$curr_year)); return $query->result(); } } ?>