?
Current Path : /home1/savoy/www/savoyglobal.net/sgms/application/views/HR/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyglobal.net/sgms/application/views/HR/xls_report_monthly_attendance.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $company_details= $this->mastermodel->get_data_srow('company','1','company_id'); $html='<html><head><body>'; $html.='<table width="100%"><tr><td colspan="3"> <tr><td colspan="3" style="font-size:16px;"><b>Monthly Attendance Report</b></td></tr> <tr><td colspan="3">Period: '.$postdata['month'].' '.$postdata['year'].'</td></tr> </table>'; $html.='<hr><br><br><table>'; $ts = strtotime($postdata['month']." ".$postdata['year']); $start_date=date('Y-m-01', $ts); $end_date=date('Y-m-t', $ts); $diff = abs(strtotime($start_date) - strtotime($end_date)); $days = floor($diff/(60*60*24)); $days++; $i=1; $weekly_holidays=$this->mastermodel->getdatas('timesheet_weekly_holiday','weekly_holiday_id'); $holiday=array(); foreach ($weekly_holidays as $weekly) { $holiday[]=$weekly['weekly_holiday']; } $temp_dept=''; foreach($report as $rep) { if($rep['department_id'] != $temp_dept) { $temp_dept=$rep['department_id']; $i=1; $html.="</table><table><tr><td>Department:</td><td>".$rep['department_name']."</td></tr></table>"; $html.='<table cellspacing="-1" border=1 style="width:100%;text-align:left"> <thead> <tr><th style="text-align:left" bgcolor="#cdc9c9">Sl No</th> <th style="text-align:left" bgcolor="#cdc9c9">Employee Name</th> <th style="text-align:left" bgcolor="#cdc9c9">Employee No</th> <th style="text-align:left" bgcolor="#cdc9c9">Designation</th>'; $date=$start_date; while (strtotime($date) <= strtotime($end_date)) { $html.='<th style="text-align:left" bgcolor="#cdc9c9">'.date ("d", strtotime($date)).'</th>'; $date = date ("Y-m-d", strtotime("+1 day", strtotime($date))); } $html .='<th style="text-align:left" bgcolor="#cdc9c9">P</th>'; $html .='<th style="text-align:left" bgcolor="#cdc9c9">A</th>'; $html .='<th style="text-align:left" bgcolor="#cdc9c9">H</th>'; $leave_types=$this->mastermodel->getdatas('leave_type','leave_type_id'); foreach ($leave_types as $leaves) { $html .='<th style="text-align:left" bgcolor="#cdc9c9">'.$leaves['leave_code'].'</th>'; } $html .='</tr></thead><tbody>'; } $date=$start_date; $employee_device_id=$this->mastermodel->getSingleFieldValue('employee','device_no','employee_id',$rep['employee_id']); $html.='<tr><td>'.$i.'</td>'; $html.='<td>'.$rep['employee_name'].'</td>'; $html.='<td>'.$rep['employee_no'].'</td>'; $html.='<td>'.$rep['designation_name'].'</td>'; $no_present = 0; $no_absent = 0; $no_holiday = 0; $leavet=array(); foreach ($leave_types as $leaves) { $leavet[$leaves['leave_type_id']]=0; } while (strtotime($date) <= strtotime($end_date)) { if($this->hrmodel->get_attendance_day($employee_device_id,$date)>0) { $day_type='P'; $no_present++; } else if(in_array(date('l', strtotime($date)), $holiday)) { $day_type= "<b>".substr(date('l', strtotime($date)), 0,1)."</b>"; $no_holiday++; } else if($this->hrmodel->is_special_holiday($date)>0) { $day_type='H'; $no_holiday++; } else { $res=$this->hrmodel->get_leave_day($rep['employee_id'],$date); if(is_numeric($res)) { if($date<=date("Y-m-d")) { $day_type='<font color="red">A</font>'; $no_absent++; } else $day_type=''; } else { $day_type=$res->leave_code; $leavet[$res->leave_type_id]+=1; } } $html.='<td>'.$day_type.'</td>'; $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } $html.='<td>'.$no_present.'</td>'; $html.='<td>'.$no_absent.'</td>'; $html.='<td>'.$no_holiday.'</td>'; foreach ($leave_types as $leaves) { $html.='<td>'.$leavet[$leaves['leave_type_id']].'</td>'; } $html.='</tr>'; $i++; } $html.='</tbody></table>'; $html.='<hr>'; $html.='<table><tr><td>Present</td><td>P</td></tr>'; $html.='<tr><td>Holiday</td><td>H</td></tr>'; $html.='<tr><td>Absent</td><td>A</td></tr>'; foreach ($leave_types as $leaves) { $html.='<tr><td>'.$leaves['leave_type_name'].'</td><td>'.$leaves['leave_code'].'</td></tr>'; } $html.='</table></body></html>'; $filename = "Monthly-Attendance"; header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename.".xls"); header("Pragma: no-cache"); header("Expires: 0"); print $html; exit; ?>