diff --git a/application/models/monthlypay_model.php b/application/models/monthlypay_model.php index 832d5c04..24870b46 100755 --- a/application/models/monthlypay_model.php +++ b/application/models/monthlypay_model.php @@ -31,33 +31,21 @@ class monthlypay_model extends CI_Model function getEmpPayDetails($current="",$s="") { - // $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->join('T_Emp_Pay_Data','T_Emp_Pay_Data.EmpID=T_Employee_Details.EmpID','Left'); - // $this->db->where('T_Employee_Details.IsActive',1); - // $this->db->order_by('EmpID','asc'); - // $query = $this->db->get(); - // $result = $query->result(); - - // return $result; $month_val = date('m',strtotime($current)); $year_val = date('Y',strtotime($current)); $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val); //$monthyear_val = date('Y-m',strtotime($current)); $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->join('T_Emp_Pay_Data','T_Emp_Pay_Data.EmpID=T_Employee_Details.EmpID','Left'); + $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; - $sql = "select Emp.EmpID, Emp.FirstName,Emp.LastName,Emp.DateofJoining,Emp.IsActive - from T_Employee_Details as Emp - where Emp.DateofJoining <= ? - and Emp.IsActive = 1 - order by Emp.EmpID - asc "; - $query = $this->db->query($sql,array($lastdate)); - - $result = $query->result(); - - return $result; - } @@ -140,37 +128,23 @@ class monthlypay_model extends CI_Model 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->order_by('T_Attendance.EmpID', 'asc'); - // $this->db->where('Month_Year',$current); - // $this->db->where('T_Employee_Details.IsActive',1); - - // $query = $this->db->get(); - - // $result = $query->result(); - - // return $result; - $month_val = date('m',strtotime($current)); + $month_val = date('m',strtotime($current)); $year_val = date('Y',strtotime($current)); - - $sql = "select Emp.DateofJoining, Emp.FirstName,Emp.LastName,Att.* - from T_Attendance as Att - join T_Employee_Details as Emp - on Emp.EmpID = Att.EmpID - where year(Emp.DateofJoining) <= year(?) - and month(Emp.DateofJoining) <= month(?) - and Emp.IsActive = 1 - and Att.Month_Year = ? - order by Att.EmpID - asc "; - - $query = $this->db->query($sql,array($current,$current,$current)); - + $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_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('year(T_Employee_Details.DateofJoining) <= ',$year_val); + // $this->db->where('month(T_Employee_Details.DateofJoining) <= ',$month_val); + $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; - + + return $result; } function saveMonthlyData_model($data) {