?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec/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/application/views/report/xls_sos_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'); $date_html = ""; $sub_html = ""; $class_html = ""; $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/img/' . $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.=" <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%"><tr><td colspan="3" class="sort"> <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.='<table style="border-collapse: collapse" width="100%" '. $border.'> <thead>'; // $html.='<tr> // <th style="text-align:left;" width="10%" bgcolor="#7FCEFF" >Sl No</th> // <th style="text-align:left;width: 1000px" bgcolor="#7FCEFF" >Student Name</th> '; $date = $start_date; $att_dates_marked = array(); $combined_att_dates = array(); $sub = array(); foreach ($report as $rep) { $att_date = explode(',', $rep['att_date']); $att_status = 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_status); // get sub per date foreach ($att_date as $id => $key) { $date_sub = explode('~', $att_subject[$id]); if (isset($date_sub[0])) { if (!isset($sub[$key])) { $sub[$key] = array($date_sub[2], $date_sub[1]); } } $result[$key] = $att_status[$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 = ""; $sub_temp = ""; $subject_count = 1; $sub_colspan = array(); $sub_per_date = array(); while (strtotime($date) <= strtotime($end_date)) { if (isset($sub[$date])) { if (in_array($date, $combined_att_dates)) { $sub_per_date[$sub[$date][0]][$date] = $sub[$date][1]; } if ($sub_temp != $sub[$date][0]) { $subject_count = 1; $sub_date = $date; } else { $subject_count = $subject_count + 1; } $sub_colspan[$sub_date] = $subject_count; $sub_temp = $sub[$date][0]; } $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } // var_dump($sub_colspan); // $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" bgcolor="#7FCEFF" colspan="' . $colspan . '" ></th> '; // $no_days = $no_days - $colspan; // } // $html.='</tr>'; $sub_html.='<tr> <th style="text-align:left;" width="8%" bgcolor="#7FCEFF" >Sl No</th> <th style="text-align:left;" width="20%" bgcolor="#7FCEFF" >Student Name</th> '; $date_html.='<tr> <th width="8%" style="text-align:left" bgcolor="#cdc9c9"></th> <th style="text-align:left" bgcolor="#cdc9c9">Date</th>'; $class_html.='<tr> <th width="10%" >No.</th> <th >Class Number</th>'; $date = $start_date; $no_days = $count_att_dates; $dat = ""; $colspan = ""; $class_count = 1; // foreach ($sub_per_date as $subject_id=>$date_of_sub) { // $colspan=""; // if(count($sub_per_date[$subject_id])>1) // $colspan='colspan="' . count($sub_per_date[$subject_id]) . '"'; // foreach($date_of_sub as $dt=>$subjectname){ //// echo $sub_name; // $sub_name=($subjectname=='no_sub')?"---":$subjectname; // $date_html.='<th style="text-align:left" bgcolor="#cdc9c9">' . date("d/M", strtotime($dt)). '</th>'; // $class_html.='<th style="text-align:left" >' . $class_count . '</th>'; // $class_count++; // } // $sub_html.='<th style="text-align:left;width: 1000px;" bgcolor="#7FCEFF" ' . $colspan . ' >'.$sub_name.'</th> '; // // } // $sub_html.='</tr>'; // $date_html.='</tr>'; // $class_html.='</tr>'; // $html.=$sub_html.$date_html.$class_html; $k = 1; $att_html = ""; foreach ($report as $rep) { $student = $this->mastermodel->get_data_srow('student', $rep['student_id'], 'student_id'); $att_html.=' <tr> <td width="8%">' . $k . '</td> <td width="20%">' . $student->first_name . ' ' . $student->last_name . '</td>'; $date = $start_date; $no_days = $count_att_dates; $att_check = 0; $dat = ""; $class_count = 1; foreach ($sub_per_date as $subject_id => $date_of_sub) { if ($k == 1) { $colspan = ""; if (count($sub_per_date[$subject_id]) > 1) $colspan = 'colspan="' . count($sub_per_date[$subject_id]) . '"'; } foreach ($date_of_sub as $date => $subjectname) { $dt = $date; if ($k == 1) { $sub_name = ($subjectname == 'no_sub') ? "---" : $subjectname; $date_html.='<th style="text-align:left" bgcolor="#cdc9c9">' . date("d/M", strtotime($dt)) . '</th>'; $class_html.='<th style="text-align:left" >' . $class_count . '</th>'; $class_count++; } $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']); // $status_interval=explode('-', $att_dates_marked[$rep['student_id']][$date]); $at_status = $status[$key]; if ($at_status == 0) { $attendance = '<font color="green">P</font>'; } elseif ($at_status == 2) $attendance = '<font color="blue">D</font>'; elseif ($at_status == 1 && $att_check == 0) $attendance = '<font color="red">A</font>'; } $att_html.='<td>' . $attendance . '</td>'; } if ($k == 1) { $sub_html.='<th style="text-align:left;" ' . $colspan . ' >' . $sub_name . '</th> '; } } $att_html.='</tr>'; $k++; } $sub_html.='</tr>'; $date_html.='</tr>'; $class_html.='</tr>'; $html.=$sub_html . $date_html . $class_html; $html.='</thead> <tbody>'; $html.=$att_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, 'SOSAttendance'); } print $html; exit; } ?>