update code

This commit is contained in:
root
2026-02-26 23:27:50 -05:00
parent 663c0cdbda
commit a6880ea14f
10 changed files with 807 additions and 138 deletions
+137 -71
View File
@@ -1,8 +1,21 @@
<?= $this->extend('layout/management_layout') ?>
<?= $this->section('content') ?>
<style>
#adminProgressTable thead th {
.admin-progress-table thead th {
position: static !important;
top: auto !important;
z-index: auto !important;
background: #f8f9fa;
white-space: nowrap;
line-height: 1.2;
padding-top: .75rem;
padding-bottom: .75rem;
}
.admin-progress-table td {
vertical-align: top;
}
.bg-orange {
background-color: #fd7e14 !important;
}
</style>
<div class="container py-4">
@@ -56,79 +69,132 @@
</form>
<div class="card shadow-sm mt-5">
<div class="card-body pt-4 px-0">
<div class="table-responsive px-4" style="margin-top: 1.5rem;">
<table id="adminProgressTable" class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>Week</th>
<th>Subjects</th>
<th>Teacher</th>
<th class="text-end">Action</th>
</tr>
</thead>
<tbody>
<div class="card-body pt-4">
<?php
$reportGroupsBySection = $reportGroupsBySection ?? [];
$subjectSections = $subjectSections ?? [];
$classSections = $classSections ?? [];
$sectionStats = $sectionStats ?? [];
$expectedDays = (int) ($expectedDays ?? 0);
?>
<?php if (empty($classSections)): ?>
<div class="text-center text-muted py-4">No class sections found.</div>
<?php else: ?>
<div class="accordion" id="adminProgressAccordion">
<?php foreach ($classSections as $index => $cs): ?>
<?php
$reportGroups = $reportGroups ?? [];
$subjectSections = $subjectSections ?? [];
$sectionId = (int) ($cs['class_section_id'] ?? 0);
$sectionName = $cs['class_section_name'] ?? 'Unknown Section';
$sectionGroups = $reportGroupsBySection[$sectionId] ?? [];
$hasReports = ! empty($sectionGroups);
$collapseId = 'progress-section-' . $sectionId;
$headingId = 'progress-heading-' . $sectionId;
$stat = $sectionStats[$sectionId] ?? null;
if (! $stat) {
if ($expectedDays === 0) {
$stat = [
'submitted' => 0,
'expected' => 0,
'percent' => 0,
'badgeClass' => 'bg-secondary',
'labelClass' => 'text-muted',
];
} else {
$stat = [
'submitted' => 0,
'expected' => $expectedDays,
'percent' => 0,
'badgeClass' => 'bg-danger',
'labelClass' => 'text-danger',
];
}
}
$percentLabel = $expectedDays > 0 ? number_format((float) $stat['percent'], 1) . '%' : 'N/A';
$submissionLabel = $expectedDays > 0
? ('Submitted: ' . (int) $stat['submitted'] . ' / ' . (int) $expectedDays . ' (' . $percentLabel . ')')
: 'Submitted: N/A';
?>
<?php if (empty($reportGroups)): ?>
<tr><td colspan="4" class="text-center text-muted py-4">No reports found.</td></tr>
<?php else: ?>
<?php foreach ($reportGroups as $group): ?>
<?php
$weekLabel = $group['week_start'] ? date('M d, Y', strtotime($group['week_start'])) : '-';
if (!empty($group['week_end'])) {
$weekLabel .= ' ' . date('M d, Y', strtotime($group['week_end']));
}
$reports = $group['reports'] ?? [];
$teacherName = '';
foreach ($reports as $report) {
if (!empty($report['teacher_name'])) {
$teacherName = $report['teacher_name'];
break;
}
}
$exampleId = $reports ? reset($reports)['id'] : null;
?>
<tr>
<td>
<div class="fw-semibold"><?= esc($weekLabel) ?></div>
<?php if (!empty($group['class_section_name'])): ?>
<div class="text-muted small">Class: <?= esc($group['class_section_name']) ?></div>
<?php endif; ?>
</td>
<td>
<div class="d-flex flex-column gap-2">
<?php foreach ($subjectSections as $slug => $section): ?>
<?php
$subjectName = $section['db_subject'] ?? $section['label'] ?? $slug;
$report = $reports[$subjectName] ?? null;
$statusTag = $report ? ($report['status_label'] ?? 'Unknown') : 'No entry';
$badgeClass = $report ? 'bg-secondary' : 'bg-light text-muted';
?>
<div class="border rounded-3 p-2">
<div class="d-flex justify-content-between align-items-center">
<strong class="small mb-0"><?= esc($section['label'] ?? $subjectName) ?></strong>
<span class="badge <?= $badgeClass ?>"><?= esc($statusTag) ?></span>
</div>
<div class="small text-muted"><?= $report ? esc($report['unit_title'] ?: '-') : 'No submission' ?></div>
</div>
<?php endforeach; ?>
<div class="accordion-item mb-2">
<h2 class="accordion-header" id="<?= esc($headingId) ?>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#<?= esc($collapseId) ?>" aria-expanded="false" aria-controls="<?= esc($collapseId) ?>">
<?= esc($sectionName) ?>
<span class="badge <?= esc($stat['badgeClass']) ?> ms-2"><?= esc($submissionLabel) ?></span>
<?php if ($hasReports): ?>
<span class="badge bg-secondary ms-2"><?= count($sectionGroups) ?> weeks</span>
<?php endif; ?>
</button>
</h2>
<div id="<?= esc($collapseId) ?>" class="accordion-collapse collapse" aria-labelledby="<?= esc($headingId) ?>" data-bs-parent="#adminProgressAccordion">
<div class="accordion-body">
<?php if (! $hasReports): ?>
<div class="text-muted">No reports found for this section.</div>
<?php else: ?>
<div class="table-responsive">
<table class="table table-hover align-middle mb-0 admin-progress-table no-mgmt-sticky" data-no-mgmt-sticky>
<thead class="table-light">
<tr>
<th>Week</th>
<th>Subjects</th>
<th>Teacher</th>
<th class="text-end">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($sectionGroups as $group): ?>
<?php
$weekLabel = $group['week_start'] ? date('M d, Y', strtotime($group['week_start'])) : '-';
if (! empty($group['week_end'])) {
$weekLabel .= ' ' . date('M d, Y', strtotime($group['week_end']));
}
$reports = $group['reports'] ?? [];
$teacherName = '';
foreach ($reports as $report) {
if (! empty($report['teacher_name'])) {
$teacherName = $report['teacher_name'];
break;
}
}
$exampleId = $reports ? reset($reports)['id'] : null;
?>
<tr>
<td><div class="fw-semibold"><?= esc($weekLabel) ?></div></td>
<td>
<div class="d-flex flex-column gap-2">
<?php foreach ($subjectSections as $slug => $section): ?>
<?php
$subjectName = $section['db_subject'] ?? $section['label'] ?? $slug;
$report = $reports[$subjectName] ?? null;
$statusTag = $report ? ($report['status_label'] ?? 'Unknown') : 'No entry';
$badgeClass = $report ? 'bg-secondary' : 'bg-light text-muted';
?>
<div class="border rounded-3 p-2">
<div class="d-flex justify-content-between align-items-center">
<strong class="small mb-0"><?= esc($section['label'] ?? $subjectName) ?></strong>
<span class="badge <?= $badgeClass ?>"><?= esc($statusTag) ?></span>
</div>
<div class="small text-muted"><?= $report ? esc($report['unit_title'] ?: '-') : 'No submission' ?></div>
</div>
<?php endforeach; ?>
</div>
</td>
<td><?= esc($teacherName ?: '-') ?></td>
<td class="text-end">
<?php if ($exampleId): ?>
<a class="btn btn-sm btn-outline-primary" href="<?= base_url('admin/progress/view/' . $exampleId) ?>">View</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</td>
<td><?= esc($teacherName ?: '-') ?></td>
<td class="text-end">
<?php if ($exampleId): ?>
<a class="btn btn-sm btn-outline-primary" href="<?= base_url('admin/progress/view/' . $exampleId) ?>">View</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>