recreate project

This commit is contained in:
root
2026-02-10 22:11:06 -05:00
commit 663c0cdbda
10149 changed files with 1379710 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
<?php
/** @var string $title */
/** @var string $body_html */
?>
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<?= $body_html ?> <!-- raw HTML on purpose -->
<?= $this->endSection() ?>
@@ -0,0 +1,26 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<h2>🎓 New Student Registered</h2>
<p>
<strong>Student Name:</strong>
<?= esc($student['firstname'] ?? '') . ' ' . esc($student['lastname'] ?? '') ?>
</p>
<?php if (!empty($student['parents']) && is_array($student['parents'])): ?>
<h3>👪 Parent Info</h3>
<?php $parent = $student['parents']; ?>
<p>
<strong>Parent:</strong>
<?= esc($parent['firstname'] ?? '') . ' ' . esc($parent['lastname'] ?? '') ?>
<br>
<strong>Email:</strong>
<?= esc($parent['email'] ?? 'N/A') ?>
</p>
<?php endif; ?>
<p>
The student has just been registered. Please review their information and verify if needed.
</p>
<?= $this->endSection() ?>
@@ -0,0 +1,63 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<div style="font-size:16px; font-family:Arial, Helvetica, sans-serif; color:#333;">
<p style="margin:0 0 12px 0;line-height:1.5;">
Dear <?= esc($parent_name ?? 'Parent/Guardian') ?>,
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
We are reaching out about <strong><?= esc($student_name ?? 'your student') ?></strong>
<?php if (!empty($class_section_name)): ?>(<?= esc($class_section_name) ?>)<?php endif; ?>
<?php if (!empty($semester) || !empty($school_year)): ?>
for <?= esc(trim(($semester ?? '') . ' ' . ($school_year ?? ''))) ?>.
<?php endif; ?>
The current semester performance is below 60.
</p>
<?php $scores = is_array($scores ?? null) ? $scores : []; ?>
<table style="width:100%; border-collapse:collapse; margin:12px 0; font-size:14px;">
<thead>
<tr>
<th style="border:1px solid #ddd; padding:6px; text-align:left;">Item</th>
<th style="border:1px solid #ddd; padding:6px; text-align:left;">Score</th>
</tr>
</thead>
<tbody>
<?php
$rows = [
'Homework Avg' => $scores['homework_avg'] ?? null,
'Project Avg' => $scores['project_avg'] ?? null,
'Participation' => $scores['participation_score'] ?? null,
'Test Avg' => $scores['test_avg'] ?? null,
'PTAP Score' => $scores['ptap_score'] ?? null,
'Attendance' => $scores['attendance_score'] ?? null,
'Midterm Score' => $scores['midterm_exam_score'] ?? null,
'Semester Score' => $scores['semester_score'] ?? null,
];
?>
<?php foreach ($rows as $label => $val): ?>
<tr>
<td style="border:1px solid #ddd; padding:6px;"><?= esc($label) ?></td>
<td style="border:1px solid #ddd; padding:6px;"><?= esc($val === null || $val === '' ? '—' : number_format((float)$val, 2, '.', '')) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($comment)): ?>
<p style="margin:0 0 12px 0;line-height:1.5;">
<strong>Teacher Comment:</strong> <?= esc($comment) ?>
</p>
<?php endif; ?>
<p style="margin:0 0 12px 0;line-height:1.5;">
Please contact the school to discuss support plans for your child.
</p>
<p style="margin:0;line-height:1.5;">
Thank you,<br>
Al Rahma Sunday School
</p>
</div>
<?= $this->endSection() ?>
+6
View File
@@ -0,0 +1,6 @@
<?= $this->extend('layout/email_layout') ?>
<?php // Passes HTML body into the section your layout expects ?>
<?= $this->section('email_content') ?>
<?= $content ?? '' ?>
<?= $this->endSection() ?>
@@ -0,0 +1,14 @@
<?php
$eventTitle = !empty($event['title']) ? $event['title'] : 'School Calendar Update';
$eventType = !empty($event['event_type']) ? $event['event_type'] : 'General';
$eventDate = !empty($event['date']) ? date('F j, Y', strtotime($event['date'])) : 'TBD';
?>
<div style="font-family: sans-serif; line-height: 1.6;">
<h1 style="font-size: 1.5rem; margin-bottom: 0.5rem;"><?= esc($eventTitle) ?></h1>
<p style="margin:0.25rem 0;"><strong>Date:</strong> <?= esc($eventDate) ?></p>
<p style="margin:0.25rem 0;"><strong>Type:</strong> <?= esc($eventType) ?></p>
<?php if (!empty($event['description'])): ?>
<p style="margin:0.25rem 0;"><?= nl2br(esc($event['description'])) ?></p>
<?php endif; ?>
<p style="margin:0.25rem 0;">Visit the <a href="<?= esc($calendarUrl) ?>"><?= esc($calendarUrl) ?></a> to see the calendar.</p>
</div>
+27
View File
@@ -0,0 +1,27 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<div style="font-size:16px; font-family:Arial, Helvetica, sans-serif; color:#333;">
<p style="margin:0 0 12px 0;line-height:1.5;">
Dear <?= esc($parent_name ?? 'Parent/Guardian') ?>,
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
We regret to inform you that <strong><?= esc($student_name ?? 'your student') ?></strong>
<?php if (!empty($class_section_name)): ?>(<?= esc($class_section_name) ?>)<?php endif; ?>
has been <strong>dismissed</strong>
<?php if (!empty($semester) && !empty($school_year)): ?> for <?= esc($semester) ?> <?= esc($school_year) ?><?php endif; ?>
due to repeated unexcused absences<?php if (!empty($date_fmt)): ?> as of <?= esc($date_fmt) ?><?php endif; ?>.
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
If you believe this decision was made in error or wish to discuss next steps, please contact the school at
<a href="mailto:alrahma.isgl@gmail.com">school email</a>.
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
Sincerely,<br>
Al Rahma Sunday School
</p>
</div>
<?= $this->endSection() ?>
+100
View File
@@ -0,0 +1,100 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<?php
/**
* $emailData keys (aligned with your payment receipt view style):
* - title, parentName, schoolYear, semester
* - invoiceId, invoiceNumber
* - typeLabel, chargeTitle, chargeDesc, chargeType
* - amountSigned, amountAbs
* - invoiceTotal, preBalance, postBalance
* - createdAt, dueDate
* - portalLink, invoiceLink
* - students (optional array)
*/
?>
<div style="font-family:Arial,Helvetica,sans-serif; font-size:14px; color:#212529; line-height:1.5;">
<h2 style="margin:0 0 10px; font-size:18px;"><?= esc($title ?? 'Account Charge Update') ?></h2>
<p style="margin:0 0 12px;">Hello <?= esc($parentName ?? 'Parent') ?>,</p>
<p style="margin:0 0 12px;">
An update was made to your account for
<strong><?= esc($schoolYear ?? '') ?> <?= !empty($semester) ? '(' . esc($semester) . ')' : '' ?></strong>.
</p>
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-collapse:collapse; margin:8px 0 16px;">
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa; width:35%;">Type</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= esc($typeLabel ?? '') ?></td>
</tr>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Title</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= esc($chargeTitle ?? '') ?></td>
</tr>
<?php if (!empty($chargeDesc)): ?>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Details</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= nl2br(esc($chargeDesc)) ?></td>
</tr>
<?php endif; ?>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Amount</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><strong><?= esc($amountSigned ?? '') ?></strong> (absolute: <?= esc($amountAbs ?? '') ?>)</td>
</tr>
<?php if (!empty($dueDate)): ?>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Due Date</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= esc($dueDate) ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($invoiceNumber) || !empty($invoiceId)): ?>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Invoice</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= esc($invoiceNumber ?? ('INV-' . (string)($invoiceId ?? ''))) ?></td>
</tr>
<?php endif; ?>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Invoice Total</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= esc($invoiceTotal ?? '$0.00') ?></td>
</tr>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Previous Balance</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= esc($preBalance ?? '$0.00') ?></td>
</tr>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">New Balance</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><strong><?= esc($postBalance ?? '$0.00') ?></strong></td>
</tr>
<?php if (!empty($createdAt)): ?>
<tr>
<td style="padding:8px 10px; border:1px solid #e9ecef; background:#f8f9fa;">Recorded At</td>
<td style="padding:8px 10px; border:1px solid #e9ecef;"><?= esc($createdAt) ?></td>
</tr>
<?php endif; ?>
</table>
<p style="margin:0 0 18px;">
<a href="<?= esc($portalLink ?? base_url()) ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<?php if (!empty($students) && is_array($students)): ?>
<p style="margin:16px 0 8px;"><strong>Students on your account:</strong></p>
<ul style="margin:0; padding-left:20px;">
<?php foreach ($students as $s): ?>
<li><?= esc($s['name'] ?? '') ?><?= !empty($s['class']) ? ' - ' . esc($s['class']) : '' ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<p style="margin:18px 0 6px;">Thank you,</p>
<p style="margin-top:20px;">Warm regards,<br>
<strong>Al Rahma Sunday School</strong>
</p>
</div>
<?= $this->endSection() ?>
+28
View File
@@ -0,0 +1,28 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<div style="font-size:16px; font-family:Arial, Helvetica, sans-serif; color:#333;">
<p style="margin:0 0 12px 0;line-height:1.5;">
Dear <?= esc($parent_name ?? 'Parent/Guardian') ?>,
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
This is a <strong>final warning</strong> concerning the attendance of
<strong><?= esc($student_name ?? 'your student') ?></strong>
<?php if (!empty($class_section_name)): ?>(<?= esc($class_section_name) ?>)<?php endif; ?>
<?php if (!empty($date_fmt)): ?> as of <?= esc($date_fmt) ?><?php endif; ?>.
Continued unexcused absences<?php if (!empty($semester) && !empty($school_year)): ?> during
<?= esc($semester) ?> <?= esc($school_year) ?><?php endif; ?> may result in dismissal from the program.
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
If there are special circumstances we should be aware of, please contact the school at
<a href="mailto:alrahma.isgl@gmail.com">school email</a>.
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
Sincerely,<br>
Al Rahma Sunday School
</p>
</div>
<?= $this->endSection() ?>
+27
View File
@@ -0,0 +1,27 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<div style="font-size:16px; font-family:Arial, Helvetica, sans-serif; color:#333;">
<p style="margin:0 0 12px 0;line-height:1.5;">
Dear <?= esc($parent_name ?? 'Parent/Guardian') ?>,
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
Were reaching out regarding <strong><?= esc($student_name ?? 'your student') ?></strong>
<?php if (!empty($class_section_name)): ?>(<?= esc($class_section_name) ?>)<?php endif; ?>
<?php if (!empty($date_fmt)): ?> on <?= esc($date_fmt) ?><?php endif; ?>.
We noticed recent unexcused absences<?php if (!empty($semester) && !empty($school_year)): ?> during
<?= esc($semester) ?> <?= esc($school_year) ?><?php endif; ?>. Please let us know in advance about any upcoming absences.
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
If there are special circumstances we should be aware of, please contact the school at
<a href="mailto:alrahma.isgl@gmail.com">school email</a>.
</p>
<p style="margin:0 0 12px 0;line-height:1.5;">
Thank you,<br>
Al Rahma Sunday School
</p>
</div>
<?= $this->endSection() ?>
@@ -0,0 +1,89 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<?php
$submitter = $recipient_parent ?? [];
$primary = $primary_parent ?? [];
$students = $students ?? [];
$typeLabel = $type_label ?? 'Attendance Update';
$reportDateFmt = $report_date_fmt ?? $report_date ?? '';
$dateLabels = $date_labels ?? [];
if (empty($dateLabels) && $reportDateFmt) {
$dateLabels = [$reportDateFmt];
}
$submitterName = trim(($submitter['firstname'] ?? '') . ' ' . ($submitter['lastname'] ?? '')) ?: 'Parent/Guardian';
$primaryName = trim(($primary['firstname'] ?? '') . ' ' . ($primary['lastname'] ?? ''));
?>
<div style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333; line-height:1.5;">
<p><strong>Parent Submission Received</strong></p>
<p>
<?= esc($submitterName) ?> submitted an <?= esc(strtolower($typeLabel)) ?> request:
</p>
<?php if (!empty($students)): ?>
<table style="width:100%; border-collapse:collapse; margin:12px 0; font-size:14px;">
<thead>
<tr>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Student</th>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Date</th>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Class</th>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Notes</th>
</tr>
</thead>
<tbody>
<?php foreach ($students as $student): ?>
<?php
$dateDisplay = $student['date_label'] ?? '';
if ($dateDisplay === '') {
$dateDisplay = !empty($student['date']) ? local_date($student['date'], 'm-d-Y') : '—';
}
?>
<tr>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($student['name'] ?? 'Student') ?></td>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($dateDisplay) ?></td>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($student['class_label'] ?? 'Not Assigned') ?></td>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;">
<?= esc($student['type_label'] ?? '') ?><br>
<?php if (!empty($student['arrival_time'])): ?>
Arrive ~ <?= esc($student['arrival_time']) ?><br>
<?php endif; ?>
<?php if (!empty($student['dismiss_time'])): ?>
Pickup @ <?= esc($student['dismiss_time']) ?><br>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php if (!empty($reason)): ?>
<p><strong>Reason:</strong> <?= esc($reason) ?></p>
<?php endif; ?>
<p style="margin-top:16px;"><strong>Contact Info</strong></p>
<ul style="padding-left:20px; margin-top:0;">
<li>Submitter Email: <?= esc($submitter['email'] ?? 'N/A') ?></li>
<?php if (!empty($submitter['cellphone'])): ?>
<li>Submitter Phone: <?= esc($submitter['cellphone']) ?></li>
<?php endif; ?>
<?php if ($primaryName && $primaryName !== $submitterName): ?>
<li>Primary Parent: <?= esc($primaryName) ?> (<?= esc($primary['email'] ?? 'N/A') ?>)</li>
<?php endif; ?>
</ul>
<?php if (!empty($semester) || !empty($school_year)): ?>
<p style="margin-top:0;">Semester/Year: <?= esc(trim($semester . ' ' . $school_year)) ?></p>
<?php endif; ?>
<?php if (!empty($submitted_at)): ?>
<p style="margin-top:0;">Submitted: <?= esc($submitted_at) ?></p>
<?php endif; ?>
<p style="margin-top:20px; font-size:14px; color:#555;">
Logged automatically by the Parent Attendance Report form.
</p>
</div>
<?= $this->endSection() ?>
@@ -0,0 +1,87 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<?php
$recipient = $recipient_parent ?? [];
$parentName = trim(($recipient['firstname'] ?? '') . ' ' . ($recipient['lastname'] ?? ''));
if ($parentName === '') {
$parentName = 'Parent/Guardian';
}
$typeLabel = $type_label ?? 'Attendance Update';
$reportDateFmt = $report_date_fmt ?? $report_date ?? '';
$students = $students ?? [];
$dateLabels = $date_labels ?? [];
if (empty($dateLabels) && $reportDateFmt) {
$dateLabels = [$reportDateFmt];
}
?>
<div style="font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333; line-height:1.5;">
<p>Dear <?= esc($parentName) ?>,</p>
<p>
Thank you for letting us know about your child's <?= esc(strtolower($typeLabel)) ?>.
We have recorded your submission.
</p>
<?php if (!empty($students)): ?>
<table style="width:100%; border-collapse:collapse; margin:12px 0; font-size:14px;">
<thead>
<tr>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Student</th>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Date</th>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Class</th>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Details</th>
</tr>
</thead>
<tbody>
<?php foreach ($students as $student): ?>
<?php
$dateDisplay = $student['date_label'] ?? '';
if ($dateDisplay === '') {
$dateDisplay = !empty($student['date']) ? local_date($student['date'], 'm-d-Y') : '—';
}
?>
<tr>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($student['name'] ?? 'Student') ?></td>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($dateDisplay) ?></td>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($student['class_label'] ?? 'Not Assigned') ?></td>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;">
<?= esc($student['type_label'] ?? '') ?><br>
<?php if (!empty($student['arrival_time'])): ?>
Arrive ~ <?= esc($student['arrival_time']) ?><br>
<?php endif; ?>
<?php if (!empty($student['dismiss_time'])): ?>
Pickup @ <?= esc($student['dismiss_time']) ?><br>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php if (!empty($reason)): ?>
<p><strong>Reason provided:</strong> <?= esc($reason) ?></p>
<?php endif; ?>
<?php if (!empty($semester) || !empty($school_year)): ?>
<p style="margin-top:0;">
Semester/Year: <?= esc(trim($semester . ' ' . $school_year)) ?>
</p>
<?php endif; ?>
<?php if (!empty($submitted_at)): ?>
<p style="margin-top:0;">Submitted: <?= esc($submitted_at) ?></p>
<?php endif; ?>
<p>
Our admin team and your child's teacher will be notified. If you need to make a change,
please update the form before the cutoff time or contact the school office.
</p>
<p style="margin-top:20px;">
Jazakum Allahu khairan,<br>
Al Rahma Sunday School
</p>
</div>
<?= $this->endSection() ?>
+313
View File
@@ -0,0 +1,313 @@
<?= $this->extend('layout/management_layout') ?>
<?= $this->section('content') ?>
<div class="container my-4">
<h2 class="text-center mb-2">Parent Email Extractor</h2>
<p class="text-center mb-4">Upload a CSV file with emails, compare against your database emails, and see matches and gaps.</p>
<div class="row g-3">
<!-- Card: Upload CSV -->
<div class="col-12 col-lg-6">
<div class="card shadow-sm">
<div class="card-body">
<h5 class="card-title mb-3">1) Upload CSV of emails (source)</h5>
<div class="row g-2 align-items-center">
<div class="col-12 col-md-8">
<input id="csvFile" type="file" accept=".csv" class="form-control" />
</div>
<div class="col-12 col-md-4 text-md-end">
<button id="parseCsvBtn" class="btn btn-primary w-100">Parse CSV</button>
</div>
</div>
<p class="text-muted small mt-2 mb-0">The CSV can be a single column of emails or multi-column. This tool extracts any values that look like emails.</p>
<div id="csvSummary" class="text-muted small mt-2"></div>
</div>
</div>
</div>
<!-- Card: Provide DB emails -->
<div class="col-12 col-lg-6">
<div class="card shadow-sm h-100">
<div class="card-body">
<h5 class="card-title mb-3">2) Provide database emails</h5>
<div class="mb-2"><span class="fw-semibold">Option A:</span> Paste emails (one per line)</div>
<label class="form-label small-muted">First parent's email</label>
<textarea id="usersTextarea" class="form-control" placeholder="user1@example.com&#10;user2@example.com"></textarea>
<label class="form-label small-muted mt-3">Second parent's email</label>
<textarea id="parentsTextarea" class="form-control" placeholder="parent1@example.com&#10;parent2@example.com"></textarea>
<div class="text-center text-muted my-2">— or —</div>
<div class="mb-2"><span class="fw-semibold">Option B:</span> Fetch from API</div>
<div class="row g-2 align-items-center">
<div class="col-12 col-md-8">
<input id="apiUrl" type="url" value="<?= site_url('api/emails') ?>" class="form-control" />
</div>
<div class="col-12 col-md-4 text-md-end">
<button id="fetchApiBtn" class="btn btn-outline-secondary w-100">Fetch</button>
</div>
</div>
<p class="text-muted small mt-2 mb-0">Provide a backend endpoint that returns JSON like:
<code>{"users": [...], "parents": [...]}</code>
</p>
</div>
</div>
</div>
</div>
<!-- Card: Compare -->
<div class="card shadow-sm mt-3">
<div class="card-body">
<h5 class="card-title mb-3">3) Compare</h5>
<div class="d-flex flex-wrap gap-2">
<button id="compareBtn" class="btn btn-primary">Run Comparison</button>
<button id="resetBtn" class="btn btn-outline-secondary">Reset</button>
</div>
<div id="compareSummary" class="text-muted small mt-2"></div>
<div class="row g-3 mt-2">
<!-- Existed -->
<div class="col-12 col-lg-6">
<div class="p-3 border rounded-3 bg-light">
<h6 class="d-flex align-items-center gap-2 mb-2">
Existed emails <span class="badge bg-success-subtle text-success" id="countExisted">0</span>
</h6>
<table id="tableExisted" class="table table-striped table-hover table-sm w-100">
<thead>
<tr><th>Email</th></tr>
</thead>
<tbody></tbody>
</table>
<div class="d-flex justify-content-end">
<button id="downloadExisted" class="btn btn-outline-secondary btn-sm">Download CSV</button>
</div>
</div>
</div>
<!-- Need to add -->
<div class="col-12 col-lg-6">
<div class="p-3 border rounded-3 bg-light">
<h6 class="d-flex align-items-center gap-2 mb-2">
Need to add email <span class="badge bg-danger-subtle text-danger" id="countNeedToAdd">0</span>
</h6>
<div class="text-muted small mb-2">Emails present in database (users or parents) but <strong>NOT</strong> in your uploaded CSV.</div>
<table id="tableNeedToAdd" class="table table-striped table-hover table-sm w-100">
<thead>
<tr><th>Email</th><th>Source</th></tr>
</thead>
<tbody></tbody>
</table>
<div class="d-flex justify-content-end">
<button id="downloadNeedToAdd" class="btn btn-outline-secondary btn-sm">Download CSV</button>
</div>
</div>
</div>
</div>
<div class="alert alert-info mt-3 mb-0 p-2">
<ul class="mb-0 small">
<li>Comparison is case-insensitive and trims whitespace.</li>
<li>Duplicates are removed within each source before comparison.</li>
<li>CSV parsing extracts any values that resemble valid email addresses from any column.</li>
</ul>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<?= $this->section('scripts') ?>
<script>
// Email regex (case-insensitive)
const emailRegex = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi;
let csvEmails = new Set();
let usersEmails = new Set();
let parentsEmails = new Set();
// DataTable instances
let dtExisted = null;
let dtNeedToAdd = null;
function normalizeEmail(e) {
return (e || '').trim().toLowerCase();
}
function extractEmailsFromCSVText(text) {
const found = text.match(emailRegex) || [];
return Array.from(new Set(found.map(normalizeEmail)));
}
function extractEmailsFromTextarea(text) {
return Array.from(new Set(
(text || '')
.split(/\n|,|;|\t/)
.map(normalizeEmail)
.filter(x => x && x.includes('@'))
));
}
function downloadCSV(filename, rows) {
const csvContent = 'data:text/csv;charset=utf-8,' + rows.map(r => '"' + r.replace(/"/g, '""') + '"').join('\n');
const encodedUri = encodeURI(csvContent);
const link = document.createElement('a');
link.setAttribute('href', encodedUri);
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
// Generic DT renderer
function renderDataTable(tableId, data, columns, existingInstanceRefSetter) {
const $table = $('#' + tableId);
if ($.fn.DataTable.isDataTable($table)) {
const inst = $table.DataTable();
inst.clear();
inst.rows.add(data);
inst.draw();
existingInstanceRefSetter(inst);
return;
}
const inst = $table.DataTable({
data,
columns,
pageLength: 100,
dom:
"<'row'<'col-sm-12 col-md-6'B><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
buttons: [
{ extend: 'copy', className: 'btn btn-sm btn-outline-secondary' },
{ extend: 'csv', className: 'btn btn-sm btn-outline-secondary' },
{ extend: 'excel', className: 'btn btn-sm btn-outline-secondary' },
{ extend: 'print', className: 'btn btn-sm btn-outline-secondary' }
],
order: []
});
existingInstanceRefSetter(inst);
}
function renderExistedTable(rows) {
renderDataTable(
'tableExisted',
rows.map(e => [e]), // single column
[{ title: 'Email' }],
inst => { dtExisted = inst; }
);
}
function renderNeedToAddTable(rowsWithSource) {
// rowsWithSource: [{email, source}]
const data = rowsWithSource.map(r => [r.email, r.source]);
renderDataTable(
'tableNeedToAdd',
data,
[{ title: 'Email' }, { title: 'Source' }],
inst => { dtNeedToAdd = inst; }
);
}
async function handleParseCsv() {
const fileInput = document.getElementById('csvFile');
const file = fileInput.files?.[0];
if (!file) {
alert('Please choose a CSV file.');
return;
}
const text = await file.text();
const emails = extractEmailsFromCSVText(text);
csvEmails = new Set(emails);
document.getElementById('csvSummary').textContent = `Found ${emails.length} unique emails in CSV.`;
}
async function handleFetchApi() {
const url = document.getElementById('apiUrl').value.trim();
if (!url) {
alert('Enter your /api/emails endpoint URL.');
return;
}
try {
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
const users = (data.users || []).map(normalizeEmail).filter(Boolean);
const parents = (data.parents || []).map(normalizeEmail).filter(Boolean);
usersEmails = new Set(users);
parentsEmails = new Set(parents);
document.getElementById('usersTextarea').value = users.join('\n');
document.getElementById('parentsTextarea').value = parents.join('\n');
alert(`Fetched ${users.length} users and ${parents.length} parents emails.`);
} catch (e) {
console.error(e);
alert('Failed to fetch API. See console for details.');
}
}
function handleCompare() {
const usersArr = extractEmailsFromTextarea(document.getElementById('usersTextarea').value);
const parentsArr = extractEmailsFromTextarea(document.getElementById('parentsTextarea').value);
usersEmails = new Set(usersArr);
parentsEmails = new Set(parentsArr);
const dbSet = new Set([...usersEmails, ...parentsEmails]);
const existed = [...csvEmails].filter(e => dbSet.has(e)).sort();
const needToAddEmails = [...dbSet].filter(e => !csvEmails.has(e)).sort();
const needToAddWithSource = needToAddEmails.map(e => {
const inUsers = usersEmails.has(e);
const inParents = parentsEmails.has(e);
let source = '';
if (inUsers && inParents) source = 'Users + Parents';
else if (inUsers) source = 'Users';
else if (inParents) source = 'Parents';
return { email: e, source };
});
document.getElementById('countExisted').textContent = existed.length;
document.getElementById('countNeedToAdd').textContent = needToAddEmails.length;
document.getElementById('compareSummary').textContent =
`Compared CSV (${csvEmails.size}) vs DB (${dbSet.size} unique: ${usersEmails.size} users + ${parentsEmails.size} parents).`;
renderExistedTable(existed);
renderNeedToAddTable(needToAddWithSource);
// Optional: keep your custom CSV buttons
document.getElementById('downloadExisted').onclick = () => downloadCSV('existed_emails.csv', existed);
document.getElementById('downloadNeedToAdd').onclick = () =>
downloadCSV('need_to_add_emails.csv', needToAddEmails);
}
function handleReset() {
csvEmails = new Set();
usersEmails = new Set();
parentsEmails = new Set();
// Clear inputs
document.getElementById('csvFile').value = '';
document.getElementById('csvSummary').textContent = '';
document.getElementById('usersTextarea').value = '';
document.getElementById('parentsTextarea').value = '';
document.getElementById('apiUrl').value = '<?= site_url('api/emails') ?>';
// Reset counters and summary
document.getElementById('countExisted').textContent = '0';
document.getElementById('countNeedToAdd').textContent = '0';
document.getElementById('compareSummary').textContent = '';
// Clear tables if initialized
if (dtExisted) { dtExisted.clear().draw(); }
if (dtNeedToAdd) { dtNeedToAdd.clear().draw(); }
}
// Bind events
document.getElementById('parseCsvBtn').addEventListener('click', handleParseCsv);
document.getElementById('fetchApiBtn').addEventListener('click', handleFetchApi);
document.getElementById('compareBtn').addEventListener('click', handleCompare);
document.getElementById('resetBtn').addEventListener('click', handleReset);
</script>
<?= $this->endSection() ?>
+90
View File
@@ -0,0 +1,90 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<div style="font-size:16px; font-family:Arial, Helvetica, sans-serif; color:#333;">
<p>Dear <?= esc($parentName ?? '') ?>,</p>
<p>We have received your payment. Below are the details of your transaction:</p>
<table border="0" cellpadding="8" cellspacing="0" style="border-collapse:collapse; width:100%; font-size:16px;">
<tr style="background-color:#f5f5f5;">
<td><strong>Invoice Number:</strong></td>
<td>
#<?= esc(($invoiceNumber ?? null) !== null && $invoiceNumber !== '' ? $invoiceNumber : ($invoiceId ?? '')) ?>
</td>
</tr>
<tr>
<td><strong>Transaction ID:</strong></td>
<td><?= esc($transactionId ?? '') ?></td>
</tr>
<tr style="background-color:#f5f5f5;">
<td><strong>Payment Date:</strong></td>
<td><?= esc($paymentDate ?? '') ?></td>
</tr>
<tr>
<td><strong>Payment Method:</strong></td>
<td>
<?= esc($method ?? '') ?>
<?php if (!empty($checkNumber)): ?>
(Check #<?= esc($checkNumber) ?>)
<?php endif; ?>
</td>
</tr>
<tr style="background-color:#f5f5f5;">
<td><strong>Installment #:</strong></td>
<td><?= esc((string)($installmentSeq ?? '')) ?></td>
</tr>
<tr>
<td><strong>Amount Paid:</strong></td>
<td><strong style="color:green;"><?= esc($amount ?? '$0.00') ?></strong></td>
</tr>
<?php if (!empty($invoiceDiscount)): ?>
<tr style="background-color:#f5f5f5;">
<td><strong>Discount Applied (This Invoice):</strong></td>
<td><?= esc($invoiceDiscount) ?></td>
</tr>
<?php endif; ?>
<tr style="background-color:#f5f5f5;">
<td><strong>Total Invoice Amount:</strong></td>
<td><?= esc($invoiceTotal ?? '$0.00') ?></td>
</tr>
<tr>
<td><strong>Previous Balance:</strong></td>
<td><?= esc($preBalance ?? '$0.00') ?></td>
</tr>
<tr style="background-color:#f5f5f5;">
<td><strong>New Balance:</strong></td>
<td><strong><?= esc($postBalance ?? '$0.00') ?></strong></td>
</tr>
</table>
<?php if (!empty($students) && is_array($students)): ?>
<p style="margin-top:20px;"><strong>Students linked to this invoice:</strong></p>
<ul>
<?php foreach ($students as $s): ?>
<li><?= esc(trim(($s['firstname'] ?? '') . ' ' . ($s['lastname'] ?? ''))) ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<p style="margin-top:16px;">
You can view this invoice and your full payment history in your account:
</p>
<p>
<a href="<?= esc($portalLink ?? base_url()) ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<p>Thank you for your payment and continued support.</p>
<p style="margin-top:20px;">Warm regards,<br>
<strong>Al Rahma Sunday School</strong>
</p>
</div>
<?= $this->endSection() ?>
+25
View File
@@ -0,0 +1,25 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<p style="font-size: 18px;">Hello,</p>
<p style="font-size: 18px;">
We received a request to reset your password. If you initiated this request, please click on the link below to set a new password:
</p>
<p style="font-size: 18px;">
<a href="<?= esc($resetLink) ?>" style="color: #007bff;">Reset Password</a>
</p>
<p style="font-size: 18px;">
If you did not request a password reset, please discard this email.
</p>
<p style="font-size:18px">
Warm regards,<br>
<strong><?= esc($orgName ?? 'Al Rahma Sunday School') ?></strong>
</p>
</p>
<?= $this->endSection() ?>
@@ -0,0 +1,45 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<h2 style="font-size:22px; font-weight:bold;">Admission Under Review</h2>
<p style="font-size:16px;">Dear <?= $parentName ?>,</p>
<?php if (is_array($studentName)): ?>
<p style="font-size:16px;">
Thank you for submitting the enrollment application for the following <?= count($studentName) ?> students:
</p>
<ul style="font-size:16px;">
<?php foreach ($studentName as $student): ?>
<li><?= $student ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p style="font-size:16px;">
Thank you for submitting the enrollment application for <?= $studentName ?>.
</p>
<?php endif; ?>
<p style="font-size:16px;">
Your application<?= is_array($studentName) ? 's are' : ' is' ?> currently under review by our admissions committee. This process typically takes 12 business days.
</p>
<p style="font-size:16px;">
You will be notified immediately once a decision has been made.
</p>
<p style="font-size:16px;">
You can check your application status at any time through the parent portal.
</p>
<p>
<!-- make sure helper('url') is loaded -->
<p style="margin:16px 0;">
<a href="<?= base_url() ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<p style="font-size:16px;">
Best regards,<br>Admissions Team
</p>
<?= $this->endSection() ?>
+68
View File
@@ -0,0 +1,68 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<div style="font-size:16px; line-height:1.5;">
<h2>Admission Decision</h2>
<?php
// Normalize: $studentName may be string or array
$isMulti = isset($studentName) && is_array($studentName) && !empty($studentName);
// Build a human-friendly label for singular sentences when needed
$studentLabel = '';
if ($isMulti) {
$names = array_map(static fn($n) => trim($n), $studentName);
if (count($names) === 1) {
$studentLabel = $names[0];
$isMulti = false;
} elseif (count($names) === 2) {
$studentLabel = $names[0] . ' and ' . $names[1];
} else {
$last = array_pop($names);
$studentLabel = implode(', ', $names) . ', and ' . $last;
}
} else {
$studentLabel = $studentName ?? 'your student';
}
?>
<p>Dear <?= esc($parentName ?? 'Parent') ?>,</p>
<?php if ($isMulti): ?>
<p>Thank you for your interest in our school and for applying for admission for the following <?= count($studentName) ?> students:</p>
<ul style="padding-left:20px;">
<?php foreach ($studentName as $name): ?>
<li><?= esc($name) ?></li>
<?php endforeach; ?>
</ul>
<p>After careful consideration, we regret to inform you that we are unable to grant admission at this time.</p>
<?php else: ?>
<p>Thank you for your interest in our school and for applying for <?= esc($studentLabel) ?>'s admission.</p>
<p>After careful consideration, we regret to inform you that we are unable to grant admission at this time.</p>
<?php endif; ?>
<?php if (!empty($students) && is_array($students)): ?>
<?php
// If reasons were provided by the handler, show them
$hasReasons = array_reduce($students, fn($c, $s) => $c || !empty($s['reason']), false);
?>
<?php if ($hasReasons): ?>
<p>Where available, weve included brief context for your reference:</p>
<ul style="padding-left:20px;">
<?php foreach ($students as $s): ?>
<li>
<strong><?= esc($s['name'] ?? '') ?>:</strong>
<?= esc($s['reason'] ?? 'No additional details provided.') ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endif; ?>
<p>This decision was made after a thorough review of all applications received, and we acknowledge that it may be disappointing.</p>
<p>We encourage you to consider applying again in the future as circumstances may change.</p>
<p>If you would like feedback on your application, please contact us at <a href="mailto:alrahma.isgl@gmail.com">alrahma.isgl@gmail.com</a>.</p>
<p>Best regards,<br>Admissions&nbsp;Committee</p>
</div>
<?= $this->endSection() ?>
+124
View File
@@ -0,0 +1,124 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<?php
// ---------------------------
// Normalization & helpers
// ---------------------------
$year = $schoolYear ?? date('Y');
$btnUrl = !empty($portalLink) ? $portalLink : base_url('/login');
// Normalize $students into a clean array of details if present
$studentsArr = [];
if (!empty($students) && is_array($students)) {
foreach ($students as $st) {
$studentsArr[] = [
'name' => trim((string)($st['name'] ?? '')),
'studentId' => trim((string)($st['studentId'] ?? '')),
'gradeLevel' => trim((string)($st['gradeLevel'] ?? '')),
'teacherName' => trim((string)($st['teacherName'] ?? '')),
'startDate' => trim((string)($st['startDate'] ?? '')),
];
}
// Remove empties by name
$studentsArr = array_values(array_filter($studentsArr, fn($r) => $r['name'] !== ''));
}
// If $studentName is given, it can be string or array
// Use it only when we don't have a useful $students array
$singleFromNameField = null;
if (empty($studentsArr)) {
if (is_array($studentName ?? null)) {
$singleFromNameField = trim((string)($studentName[0] ?? ''));
} else {
$singleFromNameField = trim((string)($studentName ?? ''));
}
}
// If students array has exactly one entry, treat as single
$isMulti = count($studentsArr) > 1;
// Date formatter
$fmtDate = function ($d) {
if (!$d) return null;
$ts = strtotime($d);
if ($ts) {
try {
$dt = (new DateTime('@' . $ts)); // UTC epoch-based
return local_date($dt, 'm-d-Y');
} catch (Throwable $e) {
// fall back to raw string if conversion fails
}
}
return $d;
};
// Build single-student detail fallbacks (from controller or first student)
$singleDetails = [
'name' => $singleFromNameField ?: trim((string)($studentsArr[0]['name'] ?? '')),
'studentId' => trim((string)($studentId ?? ($studentsArr[0]['studentId'] ?? ''))),
'gradeLevel' => trim((string)($gradeLevel ?? ($studentsArr[0]['gradeLevel'] ?? ''))),
'teacherName' => trim((string)($teacherName ?? ($studentsArr[0]['teacherName'] ?? ''))),
'startDate' => trim((string)($startDate ?? ($studentsArr[0]['startDate'] ?? ''))),
];
?>
<div style="font-size:18px; line-height:1.6;">
<h2>Enrollment Confirmed</h2>
<p>Dear <?= esc($parentName ?? 'Parent') ?>,</p>
<?php if ($isMulti): ?>
<p>We are pleased to inform you that the following <?= count($studentsArr) ?> students are now officially enrolled for the <?= esc($year) ?> school year:</p>
<ul style="margin: 0 0 16px 20px;">
<?php foreach ($studentsArr as $st): ?>
<?php
$bits = array_filter([
$st['gradeLevel'] ? 'Grade: ' . esc($st['gradeLevel']) : null,
$st['teacherName'] ? 'Teacher: ' . esc($st['teacherName']) : null,
$fmtDate($st['startDate']) ? 'Start: ' . esc($fmtDate($st['startDate'])) : null,
]);
?>
<li>
<strong><?= esc($st['name']) ?></strong>
<?php if ($bits): ?>
<span style="color:#6c757d"> (<?= implode(' • ', $bits) ?>)</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>
We are pleased to inform you that
<strong><?= esc($singleDetails['name'] ?: 'your student') ?></strong>
is now officially enrolled for the <?= esc($year) ?> school year.
</p>
<?php
$singleBits = array_filter([
$singleDetails['gradeLevel'] ? 'Grade: ' . esc($singleDetails['gradeLevel']) : null,
$singleDetails['teacherName'] ? 'Teacher: ' . esc($singleDetails['teacherName']) : null,
$fmtDate($singleDetails['startDate']) ? 'Start: ' . esc($fmtDate($singleDetails['startDate'])) : null,
]);
?>
<?php if ($singleBits): ?>
<!--p style="margin-top: -6px; color:#6c757d;"><? //= implode(' • ', $singleBits)
?></p-->
<?php endif; ?>
<?php endif; ?>
<p style="margin:16px 0;">
<a href="<?= esc($btnUrl) ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:12px 18px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:18px;">
Access My Account
</a>
</p>
<p>Welcome to our school community!</p>
<p>Best regards,<br>Admissions Team</p>
</div>
<?= $this->endSection() ?>
+11
View File
@@ -0,0 +1,11 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<h2>Enrollment Not Started</h2>
<p>Dear <?= $parentName ?>,</p>
<p>We noticed that you haven't started the enrollment process for <?= $studentName ?> yet.</p>
<p>To begin the enrollment process, please log in to your parent portal and complete the application form.</p>
<p><a href="<?= $portalLink ?>" class="button">Access Parent Portal</a></p>
<p>If you need any assistance, please contact our admissions office.</p>
<p>Best regards,<br>Admissions Team</p>
<?= $this->endSection() ?>
+101
View File
@@ -0,0 +1,101 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<div style="font-size:16px; line-height:1.5;">
<?php
// Normalize $studentName into an array of names (accept array or a label like "A, B, and C")
$names = [];
if (isset($studentName)) {
if (is_array($studentName)) {
$names = array_values(array_filter(
array_map(static fn($n) => trim((string)$n), $studentName),
static fn($n) => $n !== ''
));
} else {
$s = trim((string)$studentName);
if ($s !== '') {
$parts = preg_split('/\s*,\s*|\s*,?\s+and\s+/i', $s);
if ($parts !== false) {
$names = array_values(array_filter(array_map('trim', $parts), static fn($x) => $x !== ''));
}
}
}
}
$count = count($names);
// Non-possessive label: "A", "A and B", "A, B, and C"
if ($count === 0) {
$label = 'your student';
} elseif ($count === 1) {
$label = $names[0];
} elseif ($count === 2) {
$label = "{$names[0]} and {$names[1]}";
} else {
$label = implode(', ', array_slice($names, 0, -1)) . ', and ' . $names[$count - 1];
}
// Possessive label with possessive only on the last item: "A and Bs", "A, B, and Cs"
$labelPoss = ($count === 0)
? 'your student&#8217;s'
: ($count === 1
? $names[0] . '&#8217;s'
: $label . '&#8217;s');
$verb = ($count > 1) ? 'have' : 'has';
?>
<p>Dear <?= esc($parentName ?? 'Parent') ?>,</p>
<?php if ($count > 1): ?>
<p>
Congratulations! We are pleased to inform you that the following students have been accepted
for admission to our school:
</p>
<!-- Bullet list via table for email-client reliability -->
<!-- left indent spacer -->
<td>
<table role="presentation" cellpadding="0" cellspacing="0" style="border-collapse:collapse; padding-left:0;">
<?php foreach ($names as $n): ?>
<tr>
<td style="width:24px; font-size:0; line-height:0;">&nbsp;</td>
<td style="font-size:16px; line-height:1.5; padding:0 8px 2px 0; vertical-align:top;">&bull;</td>
<td style="font-size:16px; line-height:1.5; padding:0 0 2px 0; vertical-align:top;"><?= esc($n) ?></td>
</tr>
<?php endforeach; ?>
</table>
<p>
We are excited to welcome your family to our community and look forward to supporting
your children's growth in both faith and learning.
</p>
<?php elseif ($count === 1): ?>
<p>
Congratulations! We are pleased to inform you that <?= esc($names[0]) ?> <?= $verb ?> been
accepted for admission to our school.
</p>
<p>
We are excited to welcome your family to our community and look forward to supporting
your child's growth in both faith and learning.
</p>
<?php endif; ?>
<p>
<strong>Next steps:</strong> Please log in to the parent portal and visit the <em>Invoice</em> tab
to review your invoice details. The balance must be paid in person on the first day of school
to complete the enrollment process.
</p>
<p style="margin:16px 0;">
<a href="<?= base_url() ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<p>Best regards,<br>Admissions Committee</p>
</div>
<?= $this->endSection() ?>
@@ -0,0 +1,40 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<h2>Refund Processing</h2>
<p>Dear <?= esc($parentName ?? 'Parent') ?>,</p>
<?php if (isset($studentName) && is_array($studentName) && !empty($studentName)): ?>
<p>Your withdrawal requests for the following <?= count($studentName) ?> students have been approved:</p>
<ul style="padding-left:20px;">
<?php foreach ($studentName as $name): ?>
<li><?= esc($name) ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>Your withdrawal request for <?= esc($studentName ?? 'your student') ?> has been approved.</p>
<?php endif; ?>
<p>
<?php if (!empty($refundAmount)): ?>
A refund in the amount of <?= esc($refundAmount) ?> is being processed.
<?php else: ?>
A refund is being processed.
<?php endif; ?>
Please allow 710 business days for the refund to be issued to your original payment method.
</p>
<p>You will receive a confirmation email once the refund has been processed.</p>
<p>If you have any questions, please contact our billing department.</p>
<p style="margin:16px 0;">
<a href="<?= base_url() ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<p>Best regards,<br>Billing Department</p>
<?= $this->endSection() ?>
+70
View File
@@ -0,0 +1,70 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<div style="font-size:16px; line-height:1.5;">
<?php
// Normalize: $studentName may be string or array
$isMulti = isset($studentName) && is_array($studentName) && !empty($studentName);
// Build a readable “A and B”/“A, B, and C” label for singular spots if needed
$studentLabel = '';
if ($isMulti) {
$names = array_map(static fn($n) => trim($n), $studentName);
if (count($names) === 1) {
$studentLabel = $names[0];
$isMulti = false; // effectively single
} elseif (count($names) === 2) {
$studentLabel = $names[0] . ' and ' . $names[1];
} else {
$last = array_pop($names);
$studentLabel = implode(', ', $names) . ', and ' . $last;
}
} else {
$studentLabel = $studentName ?? 'your student';
}
?>
<p>Dear <?= esc($parentName ?? 'Parent') ?>,</p>
<?php if ($isMulti): ?>
<p>
Thank you for your interest in our school and for applying for admission for the following <?= count($studentName) ?> students:
</p>
<ul style="padding-left:20px;">
<?php foreach ($studentName as $name): ?>
<li><?= esc($name) ?></li>
<?php endforeach; ?>
</ul>
<p>
After careful review, we are unable to grant immediate admission at this time. However, we are pleased to place these students on our waitlist for the upcoming school year. Should seats become available, we will notify you right away.
</p>
<p>
We understand this may not be the outcome you had hoped for, but please know that your applications remain active and under consideration. In the meantime, you may check the status of your applications at any time through the parent portal.
</p>
<?php else: ?>
<p>
Thank you for your interest in our school and for applying for <?= esc($studentLabel) ?>s admission.
</p>
<p>
After careful review, we are unable to grant immediate admission at this time. However, we are pleased to place <?= esc($studentLabel) ?> on our waitlist for the upcoming school year. Should a seat become available, we will notify you right away.
</p>
<p>
We understand this may not be the outcome you had hoped for, but please know that the application remains active and under consideration. In the meantime, you may check the status of the application at any time through the parent portal.
</p>
<?php endif; ?>
<p style="margin:16px 0;">
<a href="<?= base_url() ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<p>Best regards,<br>Admissions Committee</p>
</div>
<?= $this->endSection() ?>
@@ -0,0 +1,32 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<h2>Withdrawal Request Under Review</h2>
<p>Dear <?= esc($parentName ?? 'Parent') ?>,</p>
<?php if (isset($studentName) && is_array($studentName) && !empty($studentName)): ?>
<p>We have received your request to withdraw the following <?= count($studentName) ?> students from our school:</p>
<ul style="padding-left:20px; font-size:14px;">
<?php foreach ($studentName as $name): ?>
<li><?= esc($name) ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>We have received your request to withdraw <?= esc($studentName ?? 'your student') ?> from our school.</p>
<?php endif; ?>
<p>This request is currently under review by our administration. We will contact you within 35 business days regarding the next steps.</p>
<p>If you have any questions or need to provide additional information, please contact our registrar's office.</p>
<p style="margin:16px 0;">
<a href="<?= base_url() ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<p>Best regards,<br>Registrar's Office</p>
<?= $this->endSection() ?>
+77
View File
@@ -0,0 +1,77 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('email_content') ?>
<h2>Withdrawal Complete</h2>
<p>Dear <?= esc($parentName ?? 'Parent') ?>,</p>
<?php if (!empty($withdrawals) && is_array($withdrawals)): ?>
<p>This email confirms the following students have been officially withdrawn from our school:</p>
<table style="width:100%; border-collapse:collapse; font-size:14px;">
<thead>
<tr>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Student</th>
<th style="text-align:left; border-bottom:1px solid #ddd; padding:6px;">Effective Date</th>
</tr>
</thead>
<tbody>
<?php foreach ($withdrawals as $w): ?>
<tr>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($w['name'] ?? '') ?></td>
<td style="padding:6px; border-bottom:1px solid #f1f1f1;"><?= esc($w['withdrawalDate'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<?php
// $studentName can be string or array; $withdrawalDate is a single date (optional)
$isMulti = isset($studentName) && is_array($studentName) && !empty($studentName);
?>
<?php if ($isMulti): ?>
<p>This email confirms the following <?= count($studentName) ?> students have been officially withdrawn from our school<?= !empty($withdrawalDate) ? ' effective ' . esc($withdrawalDate) : '' ?>:</p>
<ul style="padding-left:20px;">
<?php foreach ($studentName as $name): ?>
<li><?= esc($name) ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>
This email confirms that <?= esc($studentName ?? 'your student') ?>
has been officially withdrawn from our school<?= !empty($withdrawalDate) ? ' effective ' . esc($withdrawalDate) : '' ?>.
</p>
<?php endif; ?>
<?php endif; ?>
<p>The refund process has been completed. You should see the credit in your account within 35 business days.</p>
<?php
// Build a readable label for the farewell line if multiple names
if (isset($studentName) && is_array($studentName) && !empty($studentName)) {
$names = array_map(static fn($n) => trim($n), $studentName);
if (count($names) === 1) {
$farewell = $names[0];
} elseif (count($names) === 2) {
$farewell = $names[0] . ' and ' . $names[1];
} else {
$last = array_pop($names);
$farewell = implode(', ', $names) . ', and ' . $last;
}
} else {
$farewell = $studentName ?? 'your student';
}
?>
<p>We're sorry to see you go and wish <?= esc($farewell) ?> all the best in their future educational endeavors.</p>
<p>If you would like to re-enroll in the future, please don't hesitate to contact us.</p>
<p style="margin:16px 0;">
<a href="<?= base_url() ?>" target="_blank" rel="noopener"
style="display:inline-block; padding:10px 16px; text-decoration:none; border-radius:6px;
background:#198754; color:#ffffff; font-weight:600; font-size:16px;">
Access My Account
</a>
</p>
<p>Best regards,<br>Registrar's Office</p>
<?= $this->endSection() ?>
+26
View File
@@ -0,0 +1,26 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<div style="font-family:Arial, Helvetica, sans-serif; color:#222; font-size:16px; line-height:1.6;">
<p style="margin:0 0 12px 0;">
Dear <?= esc($parent_name ?? 'Parent/Guardian') ?>,
</p>
<p style="margin:0 0 12px 0;">
We are writing to inform you that <?= $student_name ? 'your child, <strong>' . esc($student_name) . '</strong>' : 'your child' ?> has been officially withdrawn from the school's enrollment list, effective immediately.
</p>
<p style="margin:0 0 12px 0;">
To ensure confidentiality and accuracy, we kindly request that you contact the school directly. This will allow us to provide complete information and discuss any necessary next steps.
</p>
<p style="margin:0 0 12px 0;">
Thank you for your understanding. We look forward to speaking with you soon.
</p>
<p style="margin:0;">
Sincerely,<br>
<?= esc($signature ?? 'AlRahma School Administration') ?>
</p>
</div>
<?= $this->endSection() ?>
+22
View File
@@ -0,0 +1,22 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<h2>📬 New Account Created</h2>
<p>
<strong>Name:</strong>
<?= esc($user['firstname'] ?? '') . ' ' . esc($user['lastname'] ?? '') ?>
</p>
<p>
<strong>Email:</strong>
<?= esc($user['email'] ?? 'N/A') ?>
</p>
<p>
<strong>User ID:</strong>
<?= esc($user['id'] ?? 'N/A') ?>
</p>
<p>
This user has just completed account setup. Please verify and take any necessary actions.
</p>
<?= $this->endSection() ?>
+39
View File
@@ -0,0 +1,39 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<p style="font-size:18px">Dear <?= esc($recipientName ?? 'Parent') ?>,</p>
<p style="font-size:18px">
Thank you for creating an account with us — were thrilled to welcome you to
<strong><?= esc($orgName ?? 'Al Rahma Sunday School') ?></strong> community!
</p>
<p style="font-size:18px">To activate your account, click the link below:</p>
<p>
<a href="<?= esc($activationLink ?? '#') ?>" style="font-size:18px; color:#007bff;">
Activate my account
</a>
</p>
<p style="font-size:18px">Once activated you will be able to:</p>
<ul style="font-size:18px">
<li>Access your dashboard</li>
<li>Register and enroll your child(ren) in classes</li>
<li>Receive school notifications and updates</li>
</ul>
<p style="font-size:18px">
Contact us at
<a href="mailto:<?= esc($contactInfo ?? 'alrahma.isgl@gmail.com') ?>" style="color:#0000EE;">
<?= esc($contactInfo ?? 'alrahma.isgl@gmail.com') ?>
</a>
if you have any questions.
</p>
<p style="font-size:18px">
Warm regards,<br>
<strong><?= esc($orgName ?? 'Al Rahma Sunday School') ?></strong>
</p>
<?= $this->endSection() ?>
+29
View File
@@ -0,0 +1,29 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<p style="font-size:18px">Dear <?= esc($recipientName) ?>,</p>
<p style="font-size:18px">
Thank you for creating an account with us — were thrilled to welcome you to
<strong><?= esc($orgName) ?></strong> community!
</p>
<p style="font-size:18px">To activate your account, click the link below:</p>
<p>
<a href="<?= esc($activationLink) ?>" style="font-size:18px; color:#007bff;">Activate my account</a>
</p>
<p style="font-size:18px">Once activated you will be able to:</p>
<ul style="font-size:18px">
<li>Access your dashboard</li>
<li>Receive school notifications and updates</li>
</ul>
<p style="font-size:18px">
Contact us at <a href="mailto:<?= esc($contactInfo) ?>" style="color:#0000EE;"><?= esc($contactInfo) ?></a>
if you have any questions.
</p>
<p style="font-size:18px">Warm regards,<br><strong><?= esc($orgName) ?></strong></p>
<?= $this->endSection() ?>
+31
View File
@@ -0,0 +1,31 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<h2>Welcome, <?= esc(ucfirst($user['firstname'] ?? 'User')) ?>!</h2>
<p>Thank you for registering with <strong>Al Rahma Sunday School</strong>! 🎉 Were excited to have you as part of our growing community.</p>
<p>At Al Rahma, were committed to nurturing spiritual growth, knowledge and strong Islamic values in a welcoming and engaging environment. Whether youre a new student, a parent or a community member, were thrilled to begin this journey with you.</p>
<p>Heres what you can expect as a new member:</p>
<ul>
<li>📚 Access to enriching Islamic studies and Quranic education</li>
<li>🤝 A warm and supportive learning environment</li>
<li>🕌 Regular events, announcements and community updates</li>
</ul>
<p style="font-size:16px;">
Click <a href="<?= base_url('login') ?>" target="_blank" rel="noopener">here</a> to login to your account securely to access your parent portal.
There you can register and enroll your child(ren) in classes, check their enrollment status and track their academic progress,
view/print your invoice, and check school events and calendar.
</p>
<p>Need help or have questions? Dont hesitate to <a href="mailto:alrahma.isgl@gmail.com">contact us</a>. Were here to support you every step of the way.</p>
<p>Once again, welcome to the Al Rahma Sunday School family. We look forward to a wonderful and meaningful experience together!</p>
<p>Warm regards,<br>
<strong>Al Rahma Sunday School Team</strong>
</p>
<?= $this->endSection() ?>
@@ -0,0 +1,26 @@
titile : Invitation to Join Youth WhatsApp Group
Assalam Alaikum Parents and Guardians,
We are excited to welcome you to this school year at Al Rahma Sunday School.
We are heading towards the 4th week of learning this coming Sunday and we ask Allah swt to make this year successful and beneficial for our children.
You have been identified as a parent/guardian to at least one child in Youth this year, and we are inviting you to join the WhatsApp group that will be hosting all other parents who have their children in the same grade along with their respective instructors Br Sheraz, Br Umar Farooq, Br Hassan, Br Nabil, Sr Mariama and Sr Zainab. The WhatsApp group will be used to communicate important matters about curriculum, assignments and events.
Also, by joining Youth, you are automatically joining Al Rahma Sunday School Community which hosts all grade groups within the school, you will be able to receive important alerts and messages from school administration through the WhatsApp community as well.
Two ways to join:
1- If you are seeing this email in your desktop/laptop, then use your smart phone to scan the QR code below:
image.png
2- If you are seeing this email in your smart phone, then simply click on this link below to join:
Youth WhatsApp Invitation Link
Jazakum Allah Khair,
-Al Rahma Admin
+176
View File
@@ -0,0 +1,176 @@
<?= $this->extend('layout/email_layout') ?>
<?= $this->section('content') ?>
<?php
/**
* Expected:
* - $parent: ['firstname','lastname']
* - $items: array of [
* 'class_section_name' => string,
* 'invite_link' => string,
* 'qr_src' => string (data-URI or public URL)
* ]
* Optional legacy:
* - $sections, $links, $qrImageUrl
* Optional:
* - $teacherNames (array)
* - $title
*/
$displayName = trim(($parent['firstname'] ?? '') . ' ' . ($parent['lastname'] ?? ''));
$items = $items ?? [];
$teacherNames = $teacherNames ?? [];
$sections = $sections ?? [];
$links = $links ?? [];
$sectionNames = array_map(fn($s) => $s['class_section_name'] ?? '', $sections);
$linkFallback = $links[0] ?? ($sections[0]['invite_link'] ?? '#');
$introSections = !empty($items)
? array_map(fn($i) => $i['class_section_name'] ?? 'Class', $items)
: $sectionNames;
/**
* Closures instead of named functions (avoids redeclare):
* - $formatSectionName: normalizes labels to "Grade X[-Y]" except KG/Youth or already "Grade ..."
* - $joinWithAnd: joins items with "and" (no Oxford comma)
*/
$formatSectionName = function (string $section): string {
$raw = trim($section);
if ($raw === '') return 'Class';
// If already starts with "Grade", keep it (normalize spacing/casing lightly)
if (preg_match('/^\s*grade\s+/i', $raw)) {
// Capitalize "Grade" word only
return 'Grade ' . trim(preg_replace('/^\s*grade\s+/i', '', $raw));
}
// Normalize special groups
$up = strtoupper($raw);
if ($up === 'KG') return 'KG';
if ($up === 'YOUTH') return 'Youth';
// Common forms: "2-A", "5-B", "6", "3 a" -> make "Grade 3-A" or "Grade 6"
// Keep hyphen part as uppercase if present.
if (preg_match('/^\s*(\d{1,2})(?:\s*-\s*([A-Za-z]))?\s*$/', $raw, $m)) {
$grade = (int)$m[1];
$sec = isset($m[2]) ? strtoupper($m[2]) : '';
return 'Grade ' . $grade . ($sec ? '-' . $sec : '');
}
// Fallback: Title-case but prefix as Grade
return 'Grade ' . ucfirst($raw);
};
$joinWithAnd = function (array $arr): string {
$arr = array_values(array_filter($arr, fn($v) => $v !== null && $v !== ''));
$n = count($arr);
if ($n === 0) return '';
if ($n === 1) return $arr[0];
if ($n === 2) return $arr[0] . ' and ' . $arr[1];
return implode(', ', array_slice($arr, 0, -1)) . ' and ' . $arr[$n - 1];
};
?>
<div style="background-color:#fff;border-radius:8px;padding:30px;max-width:720px;margin:auto;
box-shadow:0 2px 8px rgba(0,0,0,0.12);font-family:'Segoe UI',Arial,sans-serif;color:#333;line-height:1.8;">
<p style="font-size:18px;">Assalamu Alaikum <?= esc($displayName) ?>,</p>
<p style="font-size:18px;">
We are excited to welcome you to this school year at
<strong>Al Rahma Sunday School</strong>. As we approach our fourth week of learning,
we ask Allah (SWT) to make this year successful and beneficial for all our children.
</p>
<?php
// Prepare section display for intro using closure
$formattedSections = array_map($formatSectionName, $introSections);
$sectionList = $joinWithAnd(array_filter($formattedSections));
?>
<p style="font-size:18px;">
You have been identified as a parent or guardian of at least one child in
<strong><?= esc($sectionList ?: 'your class') ?></strong> this year.
We are inviting you to join the WhatsApp group(s) that include other parents and your childs instructors.
The WhatsApp group(s) will be used to share important information about curriculum assignments and school events.
</p>
<p style="font-size:18px;">
Additionally, by joining these groups, you automatically become part of the
<strong>Al Rahma Sunday School Community</strong>, which hosts all grade groups within the school.
Through this community, you will receive important alerts and messages from the school administration.
</p>
<h2 style="font-size:22px;color:#1c5f2c;font-weight:600;margin-top:22px;">
Your WhatsApp Group(s)<?= !empty($items) ? ' (' . count($items) . ')' : '' ?>
</h2>
<?php if (!empty($items)): ?>
<?php foreach ($items as $i => $it):
$sectionLabel = $formatSectionName($it['class_section_name'] ?? 'Class');
$inviteLink = (string)($it['invite_link'] ?? '#');
$qrSrc = (string)($it['qr_src'] ?? '');
?>
<div style="border:1px solid #e8e8e8;border-radius:10px;padding:16px;margin:16px 0;background:#fff;">
<div style="font-weight:700;margin-bottom:10px;font-size:22px;">
<?= $i + 1 ?>) <?= esc($sectionLabel) ?>
</div>
<div style="text-align:center; margin-top:10px; margin-bottom:20px;">
<a href="<?= esc($inviteLink) ?>" target="_blank" rel="noopener"
style="display:inline-block; background-color:#25D366; color:#fff; padding:14px 28px; border-radius:8px; text-decoration:none; font-weight:600; font-size:20px;">
Join WhatsApp Group
</a>
<div style="margin-top:15px;">
<?php if ($qrSrc !== ''): ?>
<img src="<?= esc($qrSrc) ?>"
alt="QR for <?= esc($sectionLabel) ?>"
width="260" height="260"
style="display:block; margin:auto;">
<?php else: ?>
<div style="color:#777; font-size:20px;"><em>QR unavailable</em></div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<!-- Legacy single-class fallback -->
<?php
$fallbackFormatted = array_map($formatSectionName, $sectionNames);
$fallbackLabel = $joinWithAnd(array_filter($fallbackFormatted)) ?: 'Class';
?>
<div style="border:1px solid #e8e8e8;border-radius:10px;padding:16px;margin:16px 0;background:#fff;">
<div style="font-weight:700;margin-bottom:10px;font-size:22px;">
<?= esc($fallbackLabel) ?>
</div>
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:16px;">
<div style="flex:1 1 280px;min-width:260px;">
<a href="<?= esc($linkFallback) ?>" target="_blank" rel="noopener"
style="display:inline-block;background-color:#25D366;color:#fff;padding:14px 24px;
border-radius:8px;text-decoration:none;font-weight:600;font-size:20px;">
Join WhatsApp Group
</a>
<div style="margin-top:10px;">
<a href="<?= esc($linkFallback) ?>" target="_blank" rel="noopener"
style="font-size:18px;color:#0b6ef6;word-break:break-all;">
<?= esc($linkFallback) ?>
</a>
</div>
</div>
<div style="flex:0 0 260px;text-align:center;">
<?php if (!empty($qrImageUrl)): ?>
<img src="<?= esc($qrImageUrl) ?>" alt="WhatsApp QR Code"
width="260" height="260" style="display:block;margin:auto;">
<?php else: ?>
<div style="color:#777;font-size:20px;"><em>QR unavailable</em></div>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<p style="margin-top:22px;font-size:18px;color:#555;text-align:center;">
Jazakum Allah Khair,<br>
<strong>Al Rahma Sunday School Administration</strong>
</p>
</div>
<?= $this->endSection() ?>