1. Teaching Load
@php
/*
|--------------------------------------------------------------------------
| TOTAL LECTURE : Semester 1 + 2 + 3
|--------------------------------------------------------------------------
|
| Credits
| = ผลรวม course_lecture ของทั้ง 3 Semester
|
| Hours/Week
| = ผลรวม course_contact ของทั้ง 3 Semester
|
*/
$totalLectureCredit = 0;
$totalLectureContact = 0;
foreach ([1, 2, 3] as $lectureSemester) {
$lectureRows =
$lecture[$lectureSemester]
?? collect();
$totalLectureCredit +=
$lectureRows->sum(function ($row) {
return (float) (
$row->course_lecture
?? 0
);
});
$totalLectureContact +=
$lectureRows->sum(function ($row) {
return (float) (
$row->course_contact
?? 0
);
});
}
/*
|--------------------------------------------------------------------------
| จัดรูปแบบตัวเลข
|--------------------------------------------------------------------------
|
| 12.00 -> 12
| 12.50 -> 12.5
|
*/
$formatTeachingNumber = function ($value) {
if (
floor($value)
==
$value
) {
return number_format(
$value,
0
);
}
return rtrim(
rtrim(
number_format(
$value,
2,
'.',
''
),
'0'
),
'.'
);
};
@endphp
a) Lecture
=
{{ $formatTeachingNumber($totalLectureCredit) }}
Credits,
{{ $formatTeachingNumber($totalLectureContact) }}
Hours/Week
TOR
=
6 Credits, 12 Hours/Week
{{-- ================================================= --}}
{{-- 1a Lecture --}}
{{-- ================================================= --}}
@foreach([1,2,3] as $semester)
@php
$rows =
$lecture[$semester]
?? collect();
@endphp
Academic Year
{{ $teachingLoad->teaching_load_year }}
- Semester {{ $semester }}
| No. |
Course No.
|
Course
|
Course Level |
Portions (%)
|
Sec.No.
|
No. of Students
|
No. of Weeks
|
Lecture (Hr/Wk)
|
Credits
|
Contact (Hr/Wk)
|
Source
|
@forelse($rows as $key => $row)
|
{{ $key + 1 }}
|
{{ $row->course_code }}
|
{{ $row->course_name }}
|
{{ $row->course_level ?? '-' }} |
{{ $row->course_portions }}
|
{{ $row->course_section }}
|
{{ $row->course_student }}
|
{{ $row->course_week }}
|
{{ $row->course_lecture }}
|
{{ $row->course_credit }}
|
{{ $row->course_contact }}
|
@if(($row->source ?? 'AUTO') == 'AUTO')
AUTO
@else
MANUAL
@endif
|
@empty
|
No lecture data.
|
@endforelse
@endforeach
{{-- ================================================= --}}
{{-- 1b Laboratory --}}
{{-- ================================================= --}}
{{-- Section Title --}}
@php
/*
|--------------------------------------------------------------------------
| TOTAL LABORATORY : Semester 1 + 2 + 3
|--------------------------------------------------------------------------
|
| รวม Contact (Hr/Wk) for Lab
| จาก course_lab_lect ของทั้ง 3 Semester
|
*/
$totalLabContact = 0;
foreach ([1, 2, 3] as $labSemester) {
$labRows =
$laboratory[$labSemester]
?? collect();
$totalLabContact +=
$labRows->sum(function ($row) {
return (float) (
$row->course_lab_lect
?? 0
);
});
}
$formatLabNumber = function ($value) {
if (floor($value) == $value) {
return number_format(
$value,
0
);
}
return rtrim(
rtrim(
number_format(
$value,
2,
'.',
''
),
'0'
),
'.'
);
};
@endphp
b) Laboratory
=
{{ $formatLabNumber($totalLabContact) }}
Credits,
{{ $formatLabNumber($totalLabContact) }}
Hours/Week
TOR
=
7 Credits, 24 Hours/Week
@foreach([1,2,3] as $semester)
@php
$rows =
$laboratory[$semester]
?? collect();
/* Same Total a + b formula as teachingload_fixed.blade.php:
Semester Lecture Contact + Semester Laboratory Contact. */
$labContactTotal =
($lecture[$semester] ?? collect())->sum(function ($row) {
return (float) ($row->course_contact ?? 0);
})
+ $rows->sum(function ($row) {
return (float) ($row->course_lab_lect ?? 0);
});
@endphp
Academic Year
{{ $teachingLoad->teaching_load_year }}
- Semester {{ $semester }}
| No. |
Course No.
|
Course
|
Course Level |
Portions (%)
|
Sec.No.
|
No. of Students
|
No. of Lecturers
|
Lab.&Lect (Hr/Wk)
|
Credits
|
Contact (Hr/Wk)
|
Source
|
@forelse($rows as $key => $row)
|
{{ $key + 1 }}
|
{{ $row->course_code }}
|
{{ $row->course_name }}
|
{{ $row->course_level ?? '-' }} |
{{ $row->course_portions }}
|
{{ $row->course_section }}
|
{{ $row->course_student }}
|
{{ $row->course_lect_ta }}
|
{{ $row->course_lab_lect }}
|
{{ $row->course_credit }}
|
{{ $row->course_lab_lect }}
|
@if(($row->source ?? 'AUTO') == 'AUTO')
AUTO
@else
MANUAL
@endif
|
@empty
|
No laboratory data.
|
@endforelse
{{-- View/Preview: 12 visible columns. Align label under Credits
and the result under Contact, as on Teaching Load. --}}
|
Total a + b |
{{ $formatTeachingNumber($labContactTotal) }}
|
|
@endforeach