fix logs issues

This commit is contained in:
root
2026-04-18 11:44:02 -04:00
parent 5fc4d8be30
commit 35988e9ce1
10 changed files with 73 additions and 51 deletions
+29 -15
View File
@@ -182,7 +182,7 @@ class ExamDraftController extends BaseController
} }
$classSectionId = (int) ($this->request->getPost('class_section_id') ?? session()->get('class_section_id') ?? 0); $classSectionId = (int) ($this->request->getPost('class_section_id') ?? session()->get('class_section_id') ?? 0);
$examType = trim((string) $this->request->getPost('exam_type')); $examType = $this->normalizeExamType($this->request->getPost('exam_type'));
$authorComment = trim((string) $this->request->getPost('author_comment')); $authorComment = trim((string) $this->request->getPost('author_comment'));
if ($classSectionId <= 0) { if ($classSectionId <= 0) {
@@ -226,7 +226,11 @@ class ExamDraftController extends BaseController
->orderBy('version', 'DESC') ->orderBy('version', 'DESC')
->first(); ->first();
$title = $examType ?: 'Exam Draft'; if ($examType === '') {
return redirect()->back()->withInput()->with('error', 'Select an exam type before submitting.');
}
$title = $examType;
if ($saveAsDraft) { if ($saveAsDraft) {
if ($teacherFile === null && (empty($existingDraft) || empty($this->draftTeacherFile($existingDraft)))) { if ($teacherFile === null && (empty($existingDraft) || empty($this->draftTeacherFile($existingDraft)))) {
@@ -235,7 +239,7 @@ class ExamDraftController extends BaseController
if (!empty($existingDraft) && strtolower((string) ($existingDraft['status'] ?? '')) === 'draft') { if (!empty($existingDraft) && strtolower((string) ($existingDraft['status'] ?? '')) === 'draft') {
$draftRowId = (int) ($existingDraft['id'] ?? 0); $draftRowId = (int) ($existingDraft['id'] ?? 0);
$updateDraft = [ $updateDraft = [
'exam_type' => $examType ?: null, 'exam_type' => $examType,
'draft_title' => $title, 'draft_title' => $title,
'author_comment' => $authorComment === '' ? null : $authorComment, 'author_comment' => $authorComment === '' ? null : $authorComment,
'status' => 'draft', 'status' => 'draft',
@@ -263,7 +267,7 @@ class ExamDraftController extends BaseController
'class_section_id' => $classSectionId, 'class_section_id' => $classSectionId,
'semester' => $this->semester, 'semester' => $this->semester,
'school_year' => $this->schoolYear, 'school_year' => $this->schoolYear,
'exam_type' => $examType ?: null, 'exam_type' => $examType,
'draft_title' => $title, 'draft_title' => $title,
'author_comment' => $authorComment === '' ? null : $authorComment, 'author_comment' => $authorComment === '' ? null : $authorComment,
'status' => 'draft', 'status' => 'draft',
@@ -280,9 +284,6 @@ class ExamDraftController extends BaseController
} }
$existingStatus = strtolower((string) ($existingDraft['status'] ?? '')); $existingStatus = strtolower((string) ($existingDraft['status'] ?? ''));
if ($examType === '') {
return redirect()->back()->withInput()->with('error', 'Select an exam type before submitting.');
}
if ($teacherFile === null) { if ($teacherFile === null) {
return redirect()->back()->withInput()->with('error', 'Upload a DOC/DOCX file to submit the exam draft.'); return redirect()->back()->withInput()->with('error', 'Upload a DOC/DOCX file to submit the exam draft.');
} }
@@ -291,7 +292,7 @@ class ExamDraftController extends BaseController
if (!empty($existingDraft) && $existingStatus === 'submitted') { if (!empty($existingDraft) && $existingStatus === 'submitted') {
$draftRowId = (int) ($existingDraft['id'] ?? 0); $draftRowId = (int) ($existingDraft['id'] ?? 0);
$updateSubmit = [ $updateSubmit = [
'exam_type' => $examType ?: null, 'exam_type' => $examType,
'draft_title' => $title, 'draft_title' => $title,
'author_comment' => $authorComment === '' ? null : $authorComment, 'author_comment' => $authorComment === '' ? null : $authorComment,
'status' => 'submitted', 'status' => 'submitted',
@@ -322,7 +323,7 @@ class ExamDraftController extends BaseController
'class_section_id' => $classSectionId, 'class_section_id' => $classSectionId,
'semester' => $this->semester, 'semester' => $this->semester,
'school_year' => $this->schoolYear, 'school_year' => $this->schoolYear,
'exam_type' => $examType ?: null, 'exam_type' => $examType,
'draft_title' => $title, 'draft_title' => $title,
'author_comment' => $authorComment === '' ? null : $authorComment, 'author_comment' => $authorComment === '' ? null : $authorComment,
'status' => 'submitted', 'status' => 'submitted',
@@ -499,7 +500,7 @@ class ExamDraftController extends BaseController
$classSectionIds = array_values(array_filter(array_map('intval', $classSectionIds))); $classSectionIds = array_values(array_filter(array_map('intval', $classSectionIds)));
$schoolYear = trim((string) ($this->request->getPost('school_year') ?? $this->schoolYear)); $schoolYear = trim((string) ($this->request->getPost('school_year') ?? $this->schoolYear));
$semester = trim((string) ($this->request->getPost('semester') ?? $this->semester)); $semester = trim((string) ($this->request->getPost('semester') ?? $this->semester));
$examType = trim((string) $this->request->getPost('exam_type')); $examType = $this->normalizeExamType($this->request->getPost('exam_type'));
if (empty($classSectionIds)) { if (empty($classSectionIds)) {
return redirect()->back()->withInput()->with('error', 'Select at least one class section.'); return redirect()->back()->withInput()->with('error', 'Select at least one class section.');
@@ -510,6 +511,9 @@ class ExamDraftController extends BaseController
if ($semester === '') { if ($semester === '') {
return redirect()->back()->withInput()->with('error', 'Semester is required.'); return redirect()->back()->withInput()->with('error', 'Semester is required.');
} }
if ($examType === '') {
return redirect()->back()->withInput()->with('error', 'Exam type is required.');
}
$file = $this->request->getFile('old_exam_file'); $file = $this->request->getFile('old_exam_file');
if (!$file || !$file->isValid()) { if (!$file || !$file->isValid()) {
@@ -534,8 +538,8 @@ class ExamDraftController extends BaseController
$this->authorIdColumn => $adminId, // store under admin user since legacy uploads are admin-only $this->authorIdColumn => $adminId, // store under admin user since legacy uploads are admin-only
'semester' => ucfirst(strtolower($semester)), 'semester' => ucfirst(strtolower($semester)),
'school_year' => $schoolYear, 'school_year' => $schoolYear,
'exam_type' => $examType === '' ? null : $examType, 'exam_type' => $examType,
'draft_title' => $examType === '' ? 'Legacy Exam' : $examType, 'draft_title' => $examType,
'author_comment' => null, 'author_comment' => null,
'final_file' => $stored, 'final_file' => $stored,
'final_filename' => $file->getClientName(), 'final_filename' => $file->getClientName(),
@@ -646,13 +650,18 @@ class ExamDraftController extends BaseController
$baseVersion = 1; $baseVersion = 1;
} }
$reviewRevision = $this->nextReviewRevision($draft, $baseVersion); $reviewRevision = $this->nextReviewRevision($draft, $baseVersion);
$reviewExamType = $this->normalizeExamType($draft['exam_type'] ?? $draft['draft_title'] ?? '');
if ($reviewExamType === '') {
return redirect()->back()->with('error', 'This draft is missing an exam type. Update the exam type before reviewing.');
}
$newRow = [ $newRow = [
$this->authorIdColumn => $this->draftTeacherId($draft), $this->authorIdColumn => $this->draftTeacherId($draft),
'class_section_id' => (int) ($draft['class_section_id'] ?? 0), 'class_section_id' => (int) ($draft['class_section_id'] ?? 0),
'semester' => (string) ($draft['semester'] ?? ''), 'semester' => (string) ($draft['semester'] ?? ''),
'school_year' => (string) ($draft['school_year'] ?? ''), 'school_year' => (string) ($draft['school_year'] ?? ''),
'exam_type' => $draft['exam_type'] ?? null, 'exam_type' => $reviewExamType,
'draft_title' => $draft['draft_title'] ?? $draft['exam_type'] ?? 'Exam Draft', 'draft_title' => $draft['draft_title'] ?? $reviewExamType,
'author_comment' => $draft['author_comment'] ?? null, 'author_comment' => $draft['author_comment'] ?? null,
'status' => $status, 'status' => $status,
'reviewed_at' => $update['reviewed_at'], 'reviewed_at' => $update['reviewed_at'],
@@ -1309,7 +1318,7 @@ class ExamDraftController extends BaseController
// Attempt conversion via LibreOffice if available // Attempt conversion via LibreOffice if available
$cmd = 'soffice --headless --convert-to pdf --outdir ' . escapeshellarg($targetDir) . ' ' . escapeshellarg($sourcePath) . ' 2>/dev/null'; $cmd = 'soffice --headless --convert-to pdf --outdir ' . escapeshellarg($targetDir) . ' ' . escapeshellarg($sourcePath) . ' 2>/dev/null';
@exec($cmd); @\exec($cmd);
return is_file($targetPath) ? basename($targetPath) : null; return is_file($targetPath) ? basename($targetPath) : null;
} }
@@ -1358,6 +1367,11 @@ class ExamDraftController extends BaseController
); );
} }
private function normalizeExamType($value): string
{
return trim((string) $value);
}
private function copyDraftToFinal(string $draftFilename): ?string private function copyDraftToFinal(string $draftFilename): ?string
{ {
$source = $this->fullUploadPath(self::TEACHER_UPLOAD_DIR, $draftFilename); $source = $this->fullUploadPath(self::TEACHER_UPLOAD_DIR, $draftFilename);
@@ -13,17 +13,19 @@
</a> </a>
</div> </div>
<!-- Search Form --> <!-- Search Form -->
<!--form method="get" action="<--?= base_url('admin/paypal-transactions') ?>" class="mb-3"> <!--
<--?= csrf_field(); ?> <form method="get" action="<?= base_url('admin/paypal-transactions') ?>" class="mb-3">
<?= csrf_field(); ?>
<div class="input-group"> <div class="input-group">
<input type="text" name="q" value="<--?= esc($keyword) ?>" class="form-control" <input type="text" name="q" value="<?= esc($keyword) ?>" class="form-control"
placeholder="Search by transaction ID, email, order ID, or event type"> placeholder="Search by transaction ID, email, order ID, or event type">
<button type="submit" class="btn btn-primary">Search</button> <button type="submit" class="btn btn-primary">Search</button>
<--?php if ($keyword): ?> <?php if ($keyword): ?>
<a href="<--?= base_url('admin/paypal-transactions') ?>" class="btn btn-secondary">Clear</a> <a href="<?= base_url('admin/paypal-transactions') ?>" class="btn btn-secondary">Clear</a>
<--?php endif; ?> <?php endif; ?>
</div> </div>
</form--> </form>
-->
<!-- Transactions Table --> <!-- Transactions Table -->
<table id="myTable" class="display table table-striped"> <table id="myTable" class="display table table-striped">
+2 -2
View File
@@ -80,10 +80,10 @@
<?php endif; ?> <?php endif; ?>
</td> </td>
<td><?= esc($e['approver_firstname'] . ' ' . $e['approver_lastname'] ?? '-') ?></td> <td><?= esc($e['approver_firstname'] . ' ' . $e['approver_lastname'] ?? '-') ?></td>
<!--td><--?= esc($e['status_reason'] ?? '-') ?></td--> <!-- <td><?= esc($e['status_reason'] ?? '-') ?></td> -->
<td> <td>
<?php if ($e['receipt_path']): ?> <?php if ($e['receipt_path']): ?>
<!--a href="<--?= base_url('writable/' . $e['receipt_path']) ?>" target="_blank">View</a--> <!-- <a href="<?= base_url('writable/' . $e['receipt_path']) ?>" target="_blank">View</a> -->
<a href="<?= site_url('receipts/' . $e['receipt_path']) ?>" target="_blank">View receipt</a> <a href="<?= site_url('receipts/' . $e['receipt_path']) ?>" target="_blank">View receipt</a>
<?php else: ?> <?php else: ?>
N/A N/A
+1 -1
View File
@@ -140,7 +140,7 @@
<strong>Enrollment deadline:</strong> <strong>Enrollment deadline:</strong>
<?= $lastDayOfRegistration ? local_date($lastDayOfRegistration, 'm-d-Y') : 'N/A' ?> <?= $lastDayOfRegistration ? local_date($lastDayOfRegistration, 'm-d-Y') : 'N/A' ?>
</div> </div>
<!--div><strong>Withdrawal:</strong> <--?= esc($withdrawalDeadline ?? 'N/A') ?></div--> <!-- <div><strong>Withdrawal:</strong> <?= esc($withdrawalDeadline ?? 'N/A') ?></div> -->
<hr class="my-2"> <hr class="my-2">
<?php if (!empty($enrollments)): ?> <?php if (!empty($enrollments)): ?>
<ul class="mb-0 ps-3"> <ul class="mb-0 ps-3">
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<!--meta name="csrf-token" content="<--?= csrf_hash() ?>"--> <!-- <meta name="csrf-token" content="<?= csrf_hash() ?>"> -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Al Rahma Sunday School</title> <title>Al Rahma Sunday School</title>
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<!-- Meta Information --> <!-- Meta Information -->
<!--meta name="csrf-token" content="<--?= csrf_hash() ?>"--> <!-- <meta name="csrf-token" content="<?= csrf_hash() ?>"> -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Prevent back/forward cache issues on management pages --> <!-- Prevent back/forward cache issues on management pages -->
+1 -1
View File
@@ -11,7 +11,7 @@ $disableEmergencyBtn = count($emergencies) >= $maxEmergency;
<div class="alert alert-info mt-2">You've reached the maximum number of students (<?= $maxChilds ?>).</div> <div class="alert alert-info mt-2">You've reached the maximum number of students (<?= $maxChilds ?>).</div>
<?php endif; ?> <?php endif; ?>
<?php if ($disableEmergencyBtn): ?> <?php if ($disableEmergencyBtn): ?>
<!--div class="alert alert-info mt-2">You've reached the maximum number of emergency contacts (<--?= $maxEmergency ?>).</div--> <!-- <div class="alert alert-info mt-2">You've reached the maximum number of emergency contacts (<?= esc((string) $maxEmergency) ?>).</div> -->
<?php endif; ?> <?php endif; ?>
<?php if (session()->getFlashdata('error')): ?> <?php if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger"> <div class="alert alert-danger">
+8 -6
View File
@@ -22,16 +22,18 @@
<input type="tel" name="phone" class="form-control" value="<?= esc($user['phone'] ?? '') ?>" placeholder="Enter phone number"> <input type="tel" name="phone" class="form-control" value="<?= esc($user['phone'] ?? '') ?>" placeholder="Enter phone number">
</div> </div>
<!--div class="mb-3"> <!--
<div class="mb-3">
<label>Role</label> <label>Role</label>
<select name="role_id" class="form-control" required> <select name="role_id" class="form-control" required>
<--?php foreach ($roles as $role): ?> <?php foreach ($roles as $role): ?>
<option value="<--?= $role['id'] ?>" <--?= $roleId == $role['id'] ? 'selected' : '' ?>> <option value="<?= $role['id'] ?>" <?= $roleId == $role['id'] ? 'selected' : '' ?>>
<--?= esc($role['name']) ?> <?= esc($role['name']) ?>
</option> </option>
<--?php endforeach ?> <?php endforeach ?>
</select> </select>
</div--> </div>
-->
<button type="submit" class="btn btn-primary">Update</button> <button type="submit" class="btn btn-primary">Update</button>
</form> </form>
</div> </div>
+1 -1
View File
@@ -11,7 +11,7 @@
</div> </div>
<?php endif; ?> <?php endif; ?>
<!--a href="<--?= site_url('staff/create') ?>" class="btn btn-primary mb-3">Add Staff</a--> <!-- <a href="<?= site_url('staff/create') ?>" class="btn btn-primary mb-3">Add Staff</a> -->
<div class="table-responsive"> <div class="table-responsive">
<table id="myTable" class="display table table-striped table-bordered table-hover w-100" style="width:100%"> <table id="myTable" class="display table table-striped table-bordered table-hover w-100" style="width:100%">
+20 -16
View File
@@ -38,9 +38,9 @@
<div id="collapse<?= $index ?>" class="collapse <?= $index === 0 ? 'show' : '' ?>" aria-labelledby="heading<?= $index ?>" data-bs-parent="#classAccordion"> <div id="collapse<?= $index ?>" class="collapse <?= $index === 0 ? 'show' : '' ?>" aria-labelledby="heading<?= $index ?>" data-bs-parent="#classAccordion">
<div class="card-body"> <div class="card-body">
<!--h5>Semester: <--?= esc($classSection['semester'] ?? '') ?></h5--> <!-- <h5>Semester: <?= esc($classSection['semester'] ?? '') ?></h5> -->
<!--h5>School Year: <--?= esc($classSection['school_year'] ?? '') ?></h5--> <!-- <h5>School Year: <?= esc($classSection['school_year'] ?? '') ?></h5> -->
<!--p><--?= esc($classSection['description'] ?? '') ?></p--> <!-- <p><?= esc($classSection['description'] ?? '') ?></p> -->
<?php if (!empty($classSection['parents'])): ?> <?php if (!empty($classSection['parents'])): ?>
<div class="table-responsive"> <div class="table-responsive">
@@ -92,13 +92,15 @@
<option value="0" <?= ((string)$pm === '0') ? 'selected' : '' ?>>No</option> <option value="0" <?= ((string)$pm === '0') ? 'selected' : '' ?>>No</option>
</select> </select>
</td> </td>
<!--td> <!--
<--?php if (!empty($p['primary_email'])): ?> <td>
<a href="mailto:<--?= esc($p['primary_email']) ?>"><--?= esc($p['primary_email']) ?></a> <?php if (!empty($p['primary_email'])): ?>
<--?php else: ?> <a href="mailto:<?= esc($p['primary_email']) ?>"><?= esc($p['primary_email']) ?></a>
<?php else: ?>
<span class="text-muted">—</span> <span class="text-muted">—</span>
<--?php endif; ?> <?php endif; ?>
</td--> </td>
-->
<td><?= esc($p['second_name']) ?></td> <td><?= esc($p['second_name']) ?></td>
<td> <td>
<?php if (!empty($p['second_phone'])): ?> <?php if (!empty($p['second_phone'])): ?>
@@ -109,13 +111,15 @@
<span class="text-muted">—</span> <span class="text-muted">—</span>
<?php endif; ?> <?php endif; ?>
</td> </td>
<!--td> <!--
<--?php if (!empty($p['second_email'])): ?> <td>
<--a href="mailto:<--?= esc($p['second_email']) ?>"><--?= esc($p['second_email']) ?></a> <?php if (!empty($p['second_email'])): ?>
<--?php else: ?> <a href="mailto:<?= esc($p['second_email']) ?>"><?= esc($p['second_email']) ?></a>
<--span class="text-muted">—</span> <?php else: ?>
<--?php endif; ?> <span class="text-muted">—</span>
</td--> <?php endif; ?>
</td>
-->
<td class="text-center"> <td class="text-center">
<?php if (!empty($p['second_id'])): ?> <?php if (!empty($p['second_id'])): ?>