?
Current Path : /home1/savoy/public_html/oscarerp.com/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/oscarerp.com/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; $html = ""; $class = $this->mastermodel->get_data_srow('class_name', $postdata['class_name_id'], 'class_name_id'); ?> <html> <head> <style> table,tr,td,th{ border-collapse: collapse; } </style> <table width="100%"> <tr> <td colspan="2"></td> <td colspan="2"></td> <td align="right"><img src="<?= base_url() ?>assets/logo/<?= $logo ?>" style="float:right; max-height: 100px;"/></td> </tr> <tr> <td colspan="5" 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> <?php $teacher = $this->mastermodel->get_teacher_class($postdata['class_name_id'], $postdata['to_date']); if (!empty($teacher)) $teacher_name = $teacher->employee_name; else $teacher_name = ''; ?> <table width="100%"><tr><td colspan="3"> <tr> <td colspan="4" style="font-size:16px;">Class Code: <b><?= $class->class_name_code ?></b></td> <td></td> <td colspan="4" style="font-size:16px;">Teacher Name: <b><?= $teacher_name ?></b></td> </tr> </table> <body> <table style="border: 1px solid black;"> <thead> <tr style="border: 1px solid black;"> <th style="text-align:left;border: 1px solid black;" width="5px" bgcolor="#7FCEFF" >Sl No</th> <th style="text-align:left;width: 200px;border: 1px solid black;" bgcolor="#7FCEFF" >Student Name</th> <?php $date = $start_date; $att_dates_marked = array(); $combined_att_dates = array(); $sub = array(); $now = strtotime($start_date); // or your date as well $your_date = strtotime($end_date); $datediff = $your_date - $now; $days = floor($datediff/(60*60*24)); foreach ($report as $rep) { $att_date = explode(',', $rep['att_date']); $att_statys = explode(',', $rep['att_status']); $att_interval = explode(',', $rep['att_time']); foreach ($att_date as $id => $key) { // echo $key; $result[$key] = $att_statys[$id] . '-' . $att_interval[$id]; } $att_dates_marked[$rep['student_id']] = $result; $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; } ?> <th style="border: 1px solid black;text-align:left;" bgcolor="#7FCEFF" colspan="<?=++$days;?>"></th> <th rowspan="2" style="border: 1px solid black;text-align:left;width: 1000px" bgcolor="#7FCEFF">Total</th> </tr> <tr> <th width="10%" style="border: 1px solid black;text-align:left" bgcolor="#cdc9c9"></th> <th style="text-align:lef;border: 1px solid black;" bgcolor="#cdc9c9">Date</th> <?php $date = $start_date; $day_count = 1; $dat = ""; while (strtotime($date) <= strtotime($end_date)) { // if (in_array($date, $combined_att_dates)) // { echo '<th style="border: 1px solid black;text-align:left" bgcolor="#cdc9c9">' . date("D", strtotime($date)) . '<br/>' . date("d", strtotime($date)) . '</th>'; $day_count++; // } $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } echo '</tr>'; $k = 1; foreach ($report as $rep) { $total = 0; $student = $this->mastermodel->get_data_srow('student', $rep['student_id'], 'student_id'); echo '<tr> <td style="border: 1px solid black;" width="10%">' . $k . '</td> <td style="border: 1px solid black;">' . $student->first_name . ' ' . $student->last_name . '</td>'; $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)) // { $attendance = ""; $deactivate = $this->studentmodel->check_deactivate($postdata['class_name_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]; if ($at_status == 1) { $time = ""; $total++; $attendance = '<span><font color="green">P</font></span>' . $time; } elseif ($at_status == 2) $attendance = '<font color="blue">D</font>'; elseif ($at_status == 0) $attendance = '<font color="red">A</font>'; } if (date("D", strtotime($date)) == 'Fri' || date("D", strtotime($date)) == 'Sat') { echo'<td style="border: 1px solid black; background-color:#cdc9c9 ;">' . $attendance . '</td>'; } else { echo'<td style="border: 1px solid black;">' . $attendance . '</td>'; } $day_count++; // } $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } echo '<td>'.$total.'</td>'; echo '</tr>'; $k++; } ?> </thead> <tbody> </tbody> </table> </body> </html> <?php $filename = "Attendance report"; header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . $filename . ".xls"); header("Pragma: no-cache"); header("Expires: 0"); echo $html; exit; ?>