?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec_old/application/views/report/ |
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/public_html/savoyglobal.net/sec_old/application/views/report/xls_attendance_report.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); $start_date = $this->mastermodel->convertdateformat($postdata['from_date']); $end_date = $this->mastermodel->convertdateformat($postdata['to_date']); $diff = abs(strtotime($start_date) - strtotime($end_date)); $days = floor($diff / (60 * 60 * 24)) + 1; $extra_class = $this->reportmodel->get_extra_class_attendance($postdata); $batch = $this->mastermodel->get_data_srow('batch', $postdata['batch_id'], 'batch_id'); $html = ''; if ($view != 'view') { $border = ""; $html.= '<html> <head>'; $html.=' <table width="100%" class="sort"> <tr> <td colspan="2"></td> <td align="right"><img src="' . base_url() . 'assets/images/' . $logo . '" style="float:right;width:200px;"/></td> </tr> <tr> <td colspan="3" style="font-size:16px;" align="center"><b><u>Attendance Report</u></b></td> </tr> <tr> <td colspan="3">From: ' . $postdata['from_date'] . '</td> </tr> <tr> <td>To: ' . $postdata['to_date'] . '</td> </tr> <tr> <td colspan="3">Printout Date : ' . date('d-m-Y') . ', ' . date('h:i:s a') . '</td> </tr> </table><br><br>'; } else { $html.="<link rel='stylesheet' media='all' type='text/css' href='".base_url()."/assets/css/tablesort.css' /> <div style='width: 100%;border:1px solid #e4e4e4;padding:2px; height: auto; overflow-x: scroll;'> "; } if ($view != 'xls') { $border = "border='1'"; } $teacher = $this->mastermodel->get_teacher_batch($postdata['batch_id'], $postdata['to_date']); if (!empty($teacher)) $teacher_name = $teacher->employee_name; else $teacher_name = ''; $html.='<table width="100%" class="sort" ><tr><td colspan="3"> <tr> <td colspan="3" style="font-size:16px;">Batch Code</td> <td>' . $batch->batch_no . '</td> </tr> <tr> <td colspan="3" style="font-size:16px;">Facilitator</td> <td>' . $teacher_name . '</td> </tr> <tr> <td colspan="3" style="font-size:16px;">Batch Start Date</td> <td>' . $this->mastermodel->convertdatenormalformat($batch->start_date) . '</td> </tr> </table>'; $html.='<hr>'; $html.='<hr>'; $html.='<table ' . $border . '> <thead>'; $html.='<tr> <th style="text-align:left;" width="10%" >Sl No</th> <th style="text-align:left;width: 1000px" >Student Name</th> '; $date = $start_date; $att_dates_marked = array(); $combined_att_dates = array(); //echo "<pre>"; // var_dump($report); // echo "</pre>"; $sub = array(); foreach ($report as $rep) { $att_date = explode(',', $rep['att_date']); $att_statys = explode(',', $rep['att_status']); $att_interval = explode(',', $rep['att_time']); $att_subject = explode(',', $rep['att_subject']); // $att_dates_marked[$rep['student_id']] = array_combine($att_date, $att_statys); foreach ($att_date as $id => $key) { $date_sub = explode('~', $att_subject[$id]); if (isset($date_sub[0])) { if (!isset($sub[$key])) { $sub[$key] = $date_sub[1]; echo $date_sub[1]; } } $result[$key] = $att_statys[$id] . '-' . $att_interval[$id]; } $att_dates_marked[$rep['student_id']] = $result; if (isset($extra_class[$rep['student_id']])) $extra_class_date = explode(',', $extra_class[$rep['student_id']]['extra_att_date']); else $extra_class_date = array(); $combined_att_dates = array_merge($att_date, $extra_class_date, $combined_att_dates); } $combined_att_dates = array_unique($combined_att_dates); $count_att_dates = count($combined_att_dates); $dat = ""; while (strtotime($date) <= strtotime($end_date)) { $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); $date1[] = $date; } $no_days = $count_att_dates; while ($no_days > 0) { if ($no_days >= 7) { $colspan = 7; } else { $colspan = $no_days % 7; } $html.='<th style="text-align:left;width: 1000px" colspan="' . $colspan . '" ></th> <th style="text-align:left;width: 1000px" >Calculations</th> <th style="text-align:left;width: 1000px" >Student Type</th> '; $no_days = $no_days - $colspan; } $html.='</tr>'; $tution = ""; if ($main_course_id == 4) { $tution = "Hr"; } $html.=' <tr> <th width="10%" style="text-align:left" bgcolor="#cdc9c9"></th> <th style="text-align:left" bgcolor="#cdc9c9">Date</th>'; $date = $start_date; $no_days = $count_att_dates; $day_count = 1; $dat = ""; while (strtotime($date) <= strtotime($end_date)) { if (in_array($date, $combined_att_dates)) { $html.='<th style="text-align:left" bgcolor="#cdc9c9">' . date("d/m", strtotime($date)) . " " . $tution . '</th>'; if ($day_count % 7 == 0 || $day_count == $no_days) { $html.='<th style="text-align:left;width: 1000px" >& Remarks</th> '; } $day_count++; } $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } $html.='</tr>'; $html.='<td>' . $postdata['student_type'] . '</td>'; $html.='<tr> <th width="10%" >No.</th> <th >Class Number</th>'; $j = 1; // $T1 = count($date1); $no_days = $count_att_dates; $day_count = 1; while ($day_count <= $no_days) { $html.='<th style="text-align:left" >' . $day_count . '</th>'; if ($day_count % 7 == 0 || $day_count == $no_days) { $html.='<th></th>'; } $day_count++; } $html.='</tr>'; $k = 1; foreach ($report as $rep) { $student = $this->mastermodel->get_data_srow('student', $rep['student_id'], 'student_id'); $html.='<tr> <td width="10%">' . $k . '</td> <td>' . $student->first_name . ' ' . $student->last_name . '</td>'; $date = $start_date; $no_days = $count_att_dates; $day_count = 1; $att_check = 0; $dat = ""; while (strtotime($date) <= strtotime($end_date)) { if (in_array($date, $combined_att_dates)) { $attendance = ""; $att_check = 0; if (isset($extra_class[$rep['student_id']])) { if (in_array($date, explode(',', $extra_class[$rep['student_id']]['extra_att_date']))) { $attendance = '<font color="blue">E</font>'; $att_check = 1; } } $deactivate = $this->studentmodel->check_deactivate($postdata['batch_id'], $rep['student_id'], $date); if ($deactivate > 0) $attendance = '<font color="blue">D</font>'; elseif (in_array($date, explode(',', $rep['att_date']))) { $key = array_search($date, explode(',', $rep['att_date'])); $status = explode(',', $rep['att_status']); $interval = explode(',', $rep['att_time']); // $status_interval=explode('-', $att_dates_marked[$rep['student_id']][$date]); $at_status = $status[$key]; $at_interval = $interval[$key]; $time = ""; $time = " <font color='black'>" . date('h', strtotime($at_interval)) . '</font>'; if ($at_status == 0) { if ($main_course_id == 4) { $time = " <font color='black'>" . date('h', strtotime($at_interval)) . '</font>'; } $attendance = '<span><font color="green">P</font></span>' . $time; } elseif ($at_status == 2) $attendance = '<font color="blue">D</font>'; elseif ($at_status == 1 && $att_check == 0) $attendance = '<span><font color="red">A</font></span>' . $time; } $html.='<td>' . $attendance . '</td>'; if ($day_count % 7 == 0 || $day_count == $no_days) { $html.='<td></td>'; } $day_count++; } $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } $html.='<td>' . $postdata['student_type'] . '</td>'; $html.='</tr>'; $k++; } $html.='</thead> <tbody>'; $html.='</tbody> </table>'; $html.='<hr>'; if ($view == 'view') { $html.="</div>"; echo $html; } else { $html.='</body></html>'; //echo $html; //die(); if ($view == 'xls') { $filename = "Attendance report"; header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . $filename . ".xls"); header("Pragma: no-cache"); header("Expires: 0"); } if ($view == 'pdf') { pdf_create($html, 'Receipt'); } print $html; exit; } ?>