fix all issues

This commit is contained in:
root
2026-03-24 01:02:36 -04:00
parent 0f8a1fa0b1
commit 58445b2a48
19 changed files with 674 additions and 167 deletions
@@ -250,6 +250,54 @@
$analysisSectionTotals[] = (int)($s['total_students'] ?? 0);
}
// ---- Student absences/late list ----
$sectionLabelByKey = [];
foreach ($grades as $classId => $sections) {
foreach ($sections as $section) {
$sectionKey = (string)($section['class_section_id'] ?? ($section['id'] ?? ''));
if ($sectionKey === '') continue;
$secNameRaw = trim((string)($section['class_section_name'] ?? ''));
$sectionLabelByKey[$sectionKey] = $secNameRaw !== '' ? $secNameRaw : ('Section ' . $sectionKey);
}
}
$studentIssueRows = [];
foreach ($studentsBySection as $sectionKey => $students) {
foreach ($students as $stu) {
$sid = (int)($stu['id'] ?? 0);
if ($sid <= 0) continue;
$entries = $attendanceData[$sectionKey][$sid] ?? [];
if (!is_array($entries)) continue;
$abs = 0;
$late = 0;
foreach ($entries as $e) {
$d = substr((string)($e['date'] ?? ''), 0, 10);
if ($d === '') continue;
if ($filterStart !== '' && $d < $filterStart) continue;
if ($filterEnd !== '' && $d > $filterEnd) continue;
$st = strtolower(trim((string)($e['status'] ?? '')));
if ($st === 'absent') {
$abs++;
} elseif ($st === 'late') {
$late++;
}
}
if (($abs + $late) <= 0) continue;
$studentIssueRows[] = [
'name' => trim((string)($stu['firstname'] ?? '') . ' ' . (string)($stu['lastname'] ?? '')),
'section' => $sectionLabelByKey[(string)$sectionKey] ?? ('Section ' . $sectionKey),
'absent' => $abs,
'late' => $late,
];
}
}
usort($studentIssueRows, static function ($a, $b) {
$sec = strcmp($a['section'], $b['section']);
if ($sec !== 0) return $sec;
return strcmp($a['name'], $b['name']);
});
$totalDaysForPercent = 0;
if ($filterStart === '' && $filterEnd === '' && !empty($totalPassedDays)) {
$totalDaysForPercent = (int)$totalPassedDays;
@@ -373,6 +421,37 @@
</table>
</div>
</div>
<div class="attn-analysis-card attn-analysis-wide">
<h6>Students With Absences / Late</h6>
<div class="attn-analysis-scroll">
<table id="studentIssueTable" class="attn-analysis-table no-mgmt-sticky" data-no-mgmt-sticky>
<thead>
<tr>
<th>Student Name</th>
<th>Class Section</th>
<th class="text-end">Nbr of ABS</th>
<th class="text-end">Nbr of LATE</th>
</tr>
</thead>
<tbody>
<?php if (empty($studentIssueRows)): ?>
<tr>
<td colspan="4" class="text-center text-muted">No absences or late records in the selected range.</td>
</tr>
<?php else: ?>
<?php foreach ($studentIssueRows as $row): ?>
<tr>
<td><?= esc($row['name']) ?></td>
<td><?= esc($row['section']) ?></td>
<td class="text-end"><?= (int)$row['absent'] ?></td>
<td class="text-end"><?= (int)$row['late'] ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@@ -480,6 +559,13 @@
info: false,
order: [[0, 'asc']]
});
$('#studentIssueTable').DataTable({
paging: true,
searching: true,
info: true,
order: [[1, 'asc'], [0, 'asc']],
pageLength: 25
});
}
});
</script>
+10 -3
View File
@@ -107,7 +107,10 @@
<td><?= esc($flag['flag_state']) ?></td>
<td>
<form id="flagForm_<?= $flag['id'] ?>" method="post">
<form id="flagForm_<?= $flag['id'] ?>" method="post"
action="<?= site_url('flags/update_state/' . (int) $flag['id']) ?>"
data-action-close="<?= site_url('flags/closeFlag/' . (int) $flag['id']) ?>"
data-action-cancel="<?= site_url('flags/cancelFlag/' . (int) $flag['id']) ?>">
<?= csrf_field() ?>
<select name="flag_state" class="form-select" id="flag_state_<?= $flag['id'] ?>"
@@ -347,9 +350,9 @@
// Set form action based on flag state
if (flagState === "Closed") {
form.action = `/flags/closeFlag/${currentFlagId}`;
form.action = form.dataset.actionClose || form.action;
} else if (flagState === "Canceled") {
form.action = `/flags/cancelFlag/${currentFlagId}`;
form.action = form.dataset.actionCancel || form.action;
}
console.log("Description set for form submission:", description); // For debugging
@@ -357,6 +360,10 @@
const modal = bootstrap.Modal.getInstance(document.getElementById('descriptionModal'));
modal.hide();
if (form && form.action) {
form.submit();
}
}
document.getElementById('flagStateDescription').addEventListener('input', function() {
+1 -1
View File
@@ -93,7 +93,7 @@
<option value="Open" <?= ($row['status'] ?? 'Open') === 'Open' ? 'selected' : '' ?>>Open</option>
<option value="Closed" <?= ($row['status'] ?? '') === 'Closed' ? 'selected' : '' ?>>Closed</option>
</select>
<input type="text" name="note" class="form-control form-control-sm" style="width: 140px;" placeholder="Note (optional)">
<input type="text" name="note" class="form-control form-control-sm" style="width: 140px;" placeholder="Note (optional)" value="<?= esc((string)($row['note'] ?? '')) ?>">
<button type="submit" class="btn btn-sm btn-outline-secondary">Update</button>
</form>
</td>
@@ -0,0 +1,142 @@
<?= $this->extend('layout/register_layout') ?>
<?= $this->section('content') ?>
<div class="registration-form container mt-5 mb-5">
<form method="post" action="<?= base_url('set_authorized_user_password/' . $userId) ?>" onsubmit="return validatePassword()" autocomplete="off">
<?= csrf_field(); ?>
<div class="text-center mb-4">
<a href="<?= base_url('/') ?>">
<img src="<?= base_url('assets/images/alrahma_logo.png') ?>" alt="" style="width: 180px; height: 120px;">
</a>
</div>
<h3 class="text-center text-success" style="font-family: Arial, sans-serif;">Create Your Password</h3>
<br>
<input type="hidden" name="user_id" value="<?= esc($userId); ?>" required>
<input type="hidden" name="token" value="<?= esc($token ?? ''); ?>" required>
<div class="mb-3">
<div class="input-with-icon">
<input type="password"
class="form-control item"
id="password"
name="password"
placeholder="Enter new password"
maxlength="40"
required
autocomplete="new-password"
oncopy="return false"
oncut="return false"
onpaste="return false">
<span class="toggle-password" onclick="togglePassword('password', this)">
<i class="fa-solid fa-eye"></i>
</span>
</div>
<small id="passwordHelp" class="text-danger d-none">
Password must be at least 8 characters long, contain a number, an uppercase letter, a lowercase letter, and one special character: @, -, =, +, *, #, $, %, &, !
</small>
<small id="passwordCopyWarning" class="text-muted d-none">
Copy and paste are disabled for security reasons.
</small>
</div>
<div class="mb-3">
<div class="input-with-icon">
<input type="password"
class="form-control item"
id="password_confirm"
name="password_confirm"
placeholder="Confirm new password"
maxlength="40"
required
autocomplete="new-password"
oncopy="return false"
oncut="return false"
onpaste="return false">
<span class="toggle-password" onclick="togglePassword('password_confirm', this)">
<i class="fa-solid fa-eye"></i>
</span>
</div>
<small id="confirmPasswordHelp" class="text-danger d-none">
Passwords do not match.
</small>
<small id="confirmCopyWarning" class="text-muted d-none">
Copy and paste are disabled for security reasons.
</small>
</div>
<div class="mb-3 d-grid">
<button type="submit" class="btn btn-success item">Save Password</button>
</div>
</form>
</div>
<?= $this->endSection() ?>
<?= $this->section('scripts') ?>
<script>
document.addEventListener('DOMContentLoaded', () => {
const showWarning = (inputId, warningId) => {
const input = document.getElementById(inputId);
const warning = document.getElementById(warningId);
['copy', 'paste', 'cut'].forEach(eventName => {
input.addEventListener(eventName, (e) => {
e.preventDefault();
warning.classList.remove('d-none');
if (warning.timeout) clearTimeout(warning.timeout);
warning.timeout = setTimeout(() => {
warning.classList.add('d-none');
}, 4000);
});
});
};
showWarning('password', 'passwordCopyWarning');
showWarning('password_confirm', 'confirmCopyWarning');
});
function togglePassword(fieldId, iconContainer) {
const input = document.getElementById(fieldId);
const icon = iconContainer.querySelector('i');
if (input.type === 'password') {
input.type = 'text';
icon.classList.remove('fa-eye');
icon.classList.add('fa-eye-slash');
} else {
input.type = 'password';
icon.classList.remove('fa-eye-slash');
icon.classList.add('fa-eye');
}
}
function validatePassword() {
const password = document.getElementById('password').value;
const passwordConfirm = document.getElementById('password_confirm').value;
const passwordHelp = document.getElementById('passwordHelp');
const confirmPasswordHelp = document.getElementById('confirmPasswordHelp');
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@\-=\+*#$%&!?])[A-Za-z\d@\-=\+*#$%&!?]{8,}$/;
let valid = true;
if (!passwordRegex.test(password)) {
passwordHelp.classList.remove('d-none');
valid = false;
} else {
passwordHelp.classList.add('d-none');
}
if (password !== passwordConfirm) {
confirmPasswordHelp.classList.remove('d-none');
valid = false;
} else {
confirmPasswordHelp.classList.add('d-none');
}
return valid;
}
</script>
<?= $this->endSection() ?>