Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $abFirstExam = 0;
- $absecondExam = 0;
- $abThirdExam = 0;
- $abFourthExam = 0;
- $absences = array(
- '0' => 0,
- '1' => 0,
- '2' => 0,
- '3' => 0,
- );
- $studentAttendance = $this->db->get_where('attendance', array(
- 'section_id' => $section_id,
- 'class_id' => $class_id,
- 'year' => $running_year,
- 'student_id' => $student_id
- ))->result_array();
- for ($i = 1; $i <= 12; $i++) {
- $year = explode('-', $running_year);
- $days = cal_days_in_month(CAL_GREGORIAN, $i, $sessional_year);
- for ($d = 1; $d <= $days; $d++) {
- $timestamp = strtotime($d . '-' . $i . '-' . $sessional_year);
- $attendance = array_filter($studentAttendance, function($v) use ($timestamp) {
- return ($v['timestamp'] == $timestamp);
- });
- for ($ab = 0; $ab < sizeof($attendance); $ab++) {
- if ($attendance[$ab]['status'] == 2) {
- $attd = gmdate("Y-m-dTH:i:sZ", $attendance[$ab]['timestamp']);
- $attTimestamp = new DateTime($attd);
- // echo $attTimestamp->format('d/m/Y');
- $dateBegin = new DateTime($period_data->first_start);
- $dateEnd = new DateTime($period_data->first_end);
- if ($attTimestamp->getTimestamp() > $dateBegin->getTimestamp() && $attTimestamp->getTimestamp() < $dateEnd->getTimestamp())
- $absences[0]++;
- $dateBegin = new DateTime($period_data->second_start);
- $dateEnd = new DateTime($period_data->second_end);
- if ($attTimestamp->getTimestamp() > $dateBegin->getTimestamp() && $attTimestamp->getTimestamp() < $dateEnd->getTimestamp())
- $absences[1]++;
- $dateBegin = new DateTime($period_data->third_start);
- $dateEnd = new DateTime($period_data->third_end);
- if ($attTimestamp->getTimestamp() > $dateBegin->getTimestamp() && $attTimestamp->getTimestamp() < $dateEnd->getTimestamp())
- $absences[2]++;
- $dateBegin = new DateTime($period_data->fourth_start);
- $dateEnd = new DateTime($period_data->fourth_end);
- if ($attTimestamp->getTimestamp() > $dateBegin->getTimestamp() && $attTimestamp->getTimestamp() < $dateEnd->getTimestamp())
- $absences[3]++;
- }
- }
- }
- }
- ?>
- <div class="col-xs-5" style="padding-left: 0px;">
- <div style="margin-left: -1px" class="col-xs-3 header-goal text-center border-bottom border-left">
- <?php
- $abFirstExam = $absences[0];
- print_r($abFirstExam);
- ?>
- </div>
- <div style="margin-left: 0px" class="col-xs-3 header-goal text-center border-bottom border-left">
- <?php
- $absecondExam = $absences[1];
- print_r($absecondExam);
- ?>
- </div>
- <div style="margin-left: 0px" class="col-xs-3 header-goal text-center border-bottom border-left">
- <?php
- $abThirdExam = $absences[2];
- print_r($abThirdExam);
- ?>
- </div>
- <div style="margin-left: 1px" class="col-xs-3 header-goal border-left text-center border-bottom border-right">
- <?php
- $abFourthExam = $absences[3];
- print_r($abFourthExam);
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement