fix is_new issue with enrollment fixes
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
.enrollment-stepper {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: .5rem;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
border-bottom: 3px solid #dee2e6;
|
||||
color: #6c757d;
|
||||
font-size: .85rem;
|
||||
line-height: 1.2;
|
||||
overflow-wrap: anywhere;
|
||||
padding: .35rem 0;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -92,6 +94,38 @@
|
||||
gap: .5rem;
|
||||
}
|
||||
|
||||
.enrollment-summary-card {
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.enrollment-summary-lines {
|
||||
display: grid;
|
||||
gap: .35rem;
|
||||
}
|
||||
|
||||
.enrollment-summary-line {
|
||||
align-items: baseline;
|
||||
display: flex;
|
||||
gap: .5rem;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.enrollment-summary-label {
|
||||
color: #6c757d;
|
||||
flex: 0 0 auto;
|
||||
font-size: .875rem;
|
||||
}
|
||||
|
||||
.enrollment-summary-value {
|
||||
font-size: .875rem;
|
||||
font-weight: 600;
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@media (max-width: 575.98px) {
|
||||
.enrollment-stepper {
|
||||
gap: .25rem;
|
||||
@@ -177,6 +211,16 @@
|
||||
.enrollment-status-table td[data-label="Withdraw"] .enrollment-withdraw-control {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.enrollment-summary-line {
|
||||
align-items: flex-start;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.enrollment-summary-value {
|
||||
display: block;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<?= $this->endSection() ?>
|
||||
@@ -231,15 +275,21 @@ foreach (($students ?? []) as $student) {
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (session()->getFlashdata('error')): ?>
|
||||
<div class="alert alert-danger"><?= esc(session()->getFlashdata('error')) ?></div>
|
||||
<?php
|
||||
$flashError = session()->getFlashdata('error');
|
||||
$flashSuccess = session()->getFlashdata('success');
|
||||
?>
|
||||
<?php if ($flashError): ?>
|
||||
<div class="alert alert-danger"><?= esc($flashError) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($flashSuccess): ?>
|
||||
<div class="alert alert-success"><?= esc($flashSuccess) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="alert alert-info mb-3">
|
||||
<p>Enrollment is the process of officially signing up your child for the upcoming school year.</p>
|
||||
<ul class="mb-0">
|
||||
<li>Last Day for Enrollment is <strong><?= esc(local_date($lastDayOfRegistration, 'm-d-Y')) ?></strong>.</li>
|
||||
<li>After submit, enrollment status changes to <strong>admission under review</strong>.</li>
|
||||
<li>Payments are processed on the first day of school: <strong><?= esc(local_date($schoolStartDate, 'm-d-Y')) ?></strong>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -254,7 +304,7 @@ foreach (($students ?? []) as $student) {
|
||||
<div class="col-lg">
|
||||
<div class="fw-semibold">Enrollment process</div>
|
||||
<div class="text-muted small">
|
||||
Review student information, acknowledge policies, review tuition and balances, then submit enrollment.
|
||||
Review student information, confirm your home address and phone, acknowledge policies, review tuition and balances, then submit enrollment.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-auto">
|
||||
@@ -338,9 +388,10 @@ foreach (($students ?? []) as $student) {
|
||||
<div class="modal-body">
|
||||
<div class="enrollment-stepper mb-3" aria-label="Enrollment steps">
|
||||
<div class="enrollment-step is-active" data-step-indicator="0">Student Info</div>
|
||||
<div class="enrollment-step" data-step-indicator="1">Policies</div>
|
||||
<div class="enrollment-step" data-step-indicator="2">Tuition</div>
|
||||
<div class="enrollment-step" data-step-indicator="3">Submit</div>
|
||||
<div class="enrollment-step" data-step-indicator="1">Contact</div>
|
||||
<div class="enrollment-step" data-step-indicator="2">Policies</div>
|
||||
<div class="enrollment-step" data-step-indicator="3">Tuition</div>
|
||||
<div class="enrollment-step" data-step-indicator="4">Submit</div>
|
||||
</div>
|
||||
|
||||
<div data-step-panel="0">
|
||||
@@ -450,6 +501,7 @@ foreach (($students ?? []) as $student) {
|
||||
data-current-grade="<?= esc($gradeLabel) ?>"
|
||||
data-required-action="<?= esc($student['required_action_label'] ?? 'Contact administration') ?>"
|
||||
data-expected-placement="<?= esc($student['expected_placement_label'] ?? $gradeLabel) ?>"
|
||||
data-is-new="<?= (string) ($student['is_new'] ?? '1') === '1' ? '1' : '0' ?>"
|
||||
data-selectable="<?= $canEnroll ? '1' : '0' ?>">
|
||||
<div class="d-flex gap-3 align-items-start">
|
||||
<span class="student-select-icon" aria-hidden="true"><i class="bi bi-check2"></i></span>
|
||||
@@ -463,10 +515,13 @@ foreach (($students ?? []) as $student) {
|
||||
<div>School ID: <?= esc($student['school_id'] ?? 'N/A') ?></div>
|
||||
<div>Date of birth: <?= esc($dobDisplay) ?><?php if (isset($student['age'])): ?> · Age: <?= esc($student['age']) ?><?php endif; ?></div>
|
||||
<div>Gender: <?= esc($student['gender'] ?? 'N/A') ?></div>
|
||||
<div>Registration grade: <?= esc($student['registration_grade'] ?? 'N/A') ?></div>
|
||||
<div>Current grade: <?= esc($gradeLabel) ?></div>
|
||||
<div>Expected placement: <?= esc($student['expected_placement_label'] ?? $gradeLabel) ?></div>
|
||||
<div>Required action: <?= esc($student['required_action_label'] ?? 'Contact administration') ?></div>
|
||||
<?php if ((string) ($student['is_new'] ?? '1') === '1'): ?>
|
||||
<div>Registration grade: <?= esc($student['registration_grade'] ?? 'N/A') ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ((string) ($student['is_new'] ?? '0') === '0'): ?>
|
||||
<div>Expected placement: <?= esc($student['expected_placement_label'] ?? $gradeLabel) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ($canEnroll): ?>
|
||||
@@ -478,7 +533,7 @@ foreach (($students ?? []) as $student) {
|
||||
|
||||
<div class="row g-2 mt-3" data-student-edit-fields>
|
||||
<div class="col-12">
|
||||
<div class="fw-semibold small mb-1">Editable health information</div>
|
||||
<div class="fw-semibold small mb-1">Editable information</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-semibold" for="student-photo-consent-<?= esc($student['id']) ?>">Photo consent</label>
|
||||
@@ -533,6 +588,95 @@ foreach (($students ?? []) as $student) {
|
||||
</div>
|
||||
|
||||
<div class="d-none" data-step-panel="1">
|
||||
<?php
|
||||
$parentContact = is_array($parentContact ?? null) ? $parentContact : [];
|
||||
$parentContactStates = [
|
||||
'CT' => 'Connecticut',
|
||||
'ME' => 'Maine',
|
||||
'MA' => 'Massachusetts',
|
||||
'NH' => 'New Hampshire',
|
||||
'NY' => 'New York',
|
||||
'RI' => 'Rhode Island',
|
||||
'VT' => 'Vermont',
|
||||
];
|
||||
$currentParentState = strtoupper(trim((string) ($parentContact['state'] ?? '')));
|
||||
if ($currentParentState !== '' && ! isset($parentContactStates[$currentParentState])) {
|
||||
$parentContactStates[$currentParentState] = $currentParentState;
|
||||
}
|
||||
$parentDisplayName = trim((string) ($parentContact['firstname'] ?? '') . ' ' . (string) ($parentContact['lastname'] ?? ''));
|
||||
?>
|
||||
<h6 class="fw-semibold">Confirm home address and phone</h6>
|
||||
<div class="text-muted small mb-3">
|
||||
Please review and update your contact information before continuing enrollment.
|
||||
<?php if ($parentDisplayName !== ''): ?>
|
||||
This account is for <?= esc($parentDisplayName) ?>.
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label small fw-semibold" for="parent-contact-cellphone">Phone</label>
|
||||
<input type="tel"
|
||||
class="form-control"
|
||||
id="parent-contact-cellphone"
|
||||
name="parent_contact[cellphone]"
|
||||
value="<?= esc($parentContact['cellphone'] ?? '') ?>"
|
||||
maxlength="12"
|
||||
inputmode="numeric"
|
||||
required>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<label class="form-label small fw-semibold" for="parent-contact-street">Home street address</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="parent-contact-street"
|
||||
name="parent_contact[address_street]"
|
||||
value="<?= esc($parentContact['address_street'] ?? '') ?>"
|
||||
maxlength="255"
|
||||
required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-semibold" for="parent-contact-apt">Apt / Unit</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="parent-contact-apt"
|
||||
name="parent_contact[apt]"
|
||||
value="<?= esc($parentContact['apt'] ?? '') ?>"
|
||||
maxlength="15">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-semibold" for="parent-contact-city">City</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="parent-contact-city"
|
||||
name="parent_contact[city]"
|
||||
value="<?= esc($parentContact['city'] ?? '') ?>"
|
||||
maxlength="100"
|
||||
required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-semibold" for="parent-contact-zip">ZIP code</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="parent-contact-zip"
|
||||
name="parent_contact[zip]"
|
||||
value="<?= esc($parentContact['zip'] ?? '') ?>"
|
||||
maxlength="5"
|
||||
inputmode="numeric"
|
||||
required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-semibold" for="parent-contact-state">State</label>
|
||||
<select class="form-select" id="parent-contact-state" name="parent_contact[state]" required>
|
||||
<option value="">Select</option>
|
||||
<?php foreach ($parentContactStates as $abbr => $stateName): ?>
|
||||
<option value="<?= esc($abbr) ?>" <?= $currentParentState === $abbr ? 'selected' : '' ?>><?= esc($stateName) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-none" data-step-panel="2">
|
||||
<h6 class="fw-semibold">Acknowledge school policies</h6>
|
||||
<div class="text-muted small mb-3">Review the current school policies before submitting enrollment.</div>
|
||||
<iframe src="<?= base_url('policy/school_policy') ?>" class="enrollment-policy-frame" frameborder="0" title="School Policies"></iframe>
|
||||
@@ -544,7 +688,7 @@ foreach (($students ?? []) as $student) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-none" data-step-panel="2">
|
||||
<div class="d-none" data-step-panel="3">
|
||||
<h6 class="fw-semibold">Review tuition, fees and balance</h6>
|
||||
<div class="text-muted small mb-3">Review the family account information before submitting enrollment.</div>
|
||||
<?php if ($familyFinancialSummary !== []): ?>
|
||||
@@ -559,7 +703,7 @@ foreach (($students ?? []) as $student) {
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="d-none" data-step-panel="3">
|
||||
<div class="d-none" data-step-panel="4">
|
||||
<h6 class="fw-semibold">Submit enrollment</h6>
|
||||
<div class="text-muted small mb-3">Review the enrollment summary before submitting.</div>
|
||||
|
||||
@@ -568,6 +712,20 @@ foreach (($students ?? []) as $student) {
|
||||
<div id="enrollmentFeeReviewList" class="d-grid gap-2"></div>
|
||||
</div>
|
||||
|
||||
<div class="enrollment-summary-card mb-3" id="parentContactReviewCard">
|
||||
<div class="fw-semibold mb-2">Parent contact</div>
|
||||
<div class="enrollment-summary-lines">
|
||||
<div class="enrollment-summary-line">
|
||||
<span class="enrollment-summary-label">Phone:</span>
|
||||
<span class="enrollment-summary-value" data-parent-review="cellphone"></span>
|
||||
</div>
|
||||
<div class="enrollment-summary-line">
|
||||
<span class="enrollment-summary-label">Home address:</span>
|
||||
<span class="enrollment-summary-value" data-parent-review="address"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-3 mb-3">
|
||||
<div class="col-md-6">
|
||||
<div class="border rounded p-3 h-100">
|
||||
@@ -582,10 +740,7 @@ foreach (($students ?? []) as $student) {
|
||||
<div class="fw-semibold mb-2">Financial information</div>
|
||||
<?php if ($familyFinancialSummary !== []): ?>
|
||||
<div class="small"><span class="text-muted">Carry-over balance:</span> <strong data-financial-value="carry_over_balance"><?= esc($money($familyFinancialSummary['carry_over_balance'] ?? 0)) ?></strong></div>
|
||||
<div class="small"><span class="text-muted">Registration fee:</span> <strong data-financial-value="registration_fee"><?= esc($money($familyFinancialSummary['registration_fee'] ?? 0)) ?></strong></div>
|
||||
<div class="small"><span class="text-muted">Tuition due now:</span> <strong data-financial-value="tuition_due_at_registration"><?= esc($money($familyFinancialSummary['tuition_due_at_registration'] ?? 0)) ?></strong></div>
|
||||
<div class="small"><span class="text-muted">Mandatory fees:</span> <strong data-financial-value="mandatory_fees"><?= esc($money($familyFinancialSummary['mandatory_fees'] ?? 0)) ?></strong></div>
|
||||
<div class="small"><span class="text-muted">Current-year account balance:</span> <strong data-financial-value="current_balance"><?= esc($money($familyFinancialSummary['current_balance'] ?? 0)) ?></strong></div>
|
||||
<div class="small"><span class="text-muted">Total currently due:</span> <strong data-financial-value="amount_due"><?= esc($money($familyFinancialSummary['amount_due'] ?? 0)) ?></strong></div>
|
||||
<?php else: ?>
|
||||
<div class="small text-muted">Financial information is not available.</div>
|
||||
@@ -597,7 +752,8 @@ foreach (($students ?? []) as $student) {
|
||||
<div class="alert alert-warning mb-0 small">
|
||||
<div class="fw-semibold mb-1">Important information</div>
|
||||
<ul class="mb-0 ps-3">
|
||||
<li>For newly registered students, enrollment status changes to admission under review after submitting the request.</li>
|
||||
<li>Submitting sends the selected enrollment(s) for newly registered students to Admissions for review.</li>
|
||||
<li>Returning students who passed last year grade are automatically granted admission.</li>
|
||||
<li>Payments are processed on the first day of school.</li>
|
||||
<?php if (!empty($fallMakeupExamOn)): ?>
|
||||
<li>Students with a make-up exam decision may initially remain in the same grade until the make-up exam result is confirmed.</li>
|
||||
@@ -656,7 +812,15 @@ foreach (($students ?? []) as $student) {
|
||||
const nextButton = document.getElementById('enrollmentNextButton');
|
||||
const submitButton = document.getElementById('enrollmentSubmitButton');
|
||||
const feeReviewList = document.getElementById('enrollmentFeeReviewList');
|
||||
const finalStep = 3;
|
||||
const parentPhoneInput = document.getElementById('parent-contact-cellphone');
|
||||
const parentStreetInput = document.getElementById('parent-contact-street');
|
||||
const parentAptInput = document.getElementById('parent-contact-apt');
|
||||
const parentCityInput = document.getElementById('parent-contact-city');
|
||||
const parentStateInput = document.getElementById('parent-contact-state');
|
||||
const parentZipInput = document.getElementById('parent-contact-zip');
|
||||
const finalStep = 4;
|
||||
const enrollmentStartStep = <?= (int) ($enrollmentStartStep ?? 0) ?>;
|
||||
const preselectedStudentIds = <?= json_encode(array_values(array_map('intval', $preselectedStudentIds ?? [])), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) ?>;
|
||||
const feeSchedule = <?= json_encode([
|
||||
'currency' => (string) ($enrollmentFeeSchedule['currency'] ?? '$'),
|
||||
'firstStudentFee' => (float) ($enrollmentFeeSchedule['first_student_fee'] ?? 0),
|
||||
@@ -690,7 +854,7 @@ foreach (($students ?? []) as $student) {
|
||||
backButton.classList.toggle('d-none', currentStep === 0);
|
||||
nextButton.classList.toggle('d-none', currentStep === finalStep);
|
||||
submitButton.classList.toggle('d-none', currentStep !== finalStep);
|
||||
if (currentStep >= 2) {
|
||||
if (currentStep >= 3) {
|
||||
updateFinancialReview();
|
||||
}
|
||||
if (currentStep === finalStep) {
|
||||
@@ -736,20 +900,19 @@ foreach (($students ?? []) as $student) {
|
||||
const lastName = card ? card.querySelector("input[name$='[lastname]']")?.value?.trim() : '';
|
||||
const dob = card ? card.querySelector("input[name$='[dob]']")?.value?.trim() : '';
|
||||
const grade = card ? card.querySelector("input[name$='[registration_grade]']")?.value?.trim() : '';
|
||||
const gender = card ? card.querySelector("select[name$='[gender]']")?.value?.trim() : '';
|
||||
const gender = card ? card.querySelector("input[name$='[gender]']")?.value?.trim() : '';
|
||||
const schoolId = card?.dataset.schoolId || 'N/A';
|
||||
const currentGrade = card?.dataset.currentGrade || '';
|
||||
const expectedPlacement = card?.dataset.expectedPlacement || '';
|
||||
const requiredAction = card?.dataset.requiredAction || '';
|
||||
const isNewStudent = card?.dataset.isNew === '1';
|
||||
const name = (firstName + ' ' + lastName).trim() || card?.querySelector('.fw-semibold')?.textContent?.trim() || 'Student';
|
||||
const metaParts = [];
|
||||
if (grade) metaParts.push('Registration grade: ' + grade);
|
||||
if (dob) metaParts.push('DOB: ' + dob);
|
||||
if (gender) metaParts.push('Gender: ' + gender);
|
||||
if (schoolId) metaParts.push('School ID: ' + schoolId);
|
||||
return {
|
||||
name,
|
||||
meta: metaParts.join(' - '),
|
||||
schoolId,
|
||||
dob,
|
||||
gender,
|
||||
registrationGrade: isNewStudent ? grade : '',
|
||||
currentGrade,
|
||||
expectedPlacement,
|
||||
requiredAction,
|
||||
@@ -762,26 +925,35 @@ foreach (($students ?? []) as $student) {
|
||||
|
||||
if (!cards.length) {
|
||||
feeReviewList.innerHTML = '<div class="alert alert-warning mb-0">No students selected.</div>';
|
||||
renderParentContactReview();
|
||||
return;
|
||||
}
|
||||
|
||||
feeReviewList.innerHTML = cards.map((student, index) => {
|
||||
const tuitionFee = index === 0 ? feeSchedule.firstStudentFee : feeSchedule.secondStudentFee;
|
||||
const tier = index === 0 ? 'First student tuition tier' : 'Additional student tuition tier';
|
||||
return '<div class="border rounded p-3">' +
|
||||
'<div class="d-flex flex-wrap justify-content-between gap-2">' +
|
||||
'<div><div class="fw-semibold">' + escapeHtml(student.name) + '</div>' +
|
||||
'<div class="small text-muted">' + escapeHtml(student.meta) + '</div></div>' +
|
||||
'<div class="text-md-end"><div class="fw-semibold">' + escapeHtml(formatMoney(tuitionFee)) + '</div>' +
|
||||
'<div class="small text-muted">' + escapeHtml(tier) + '</div></div>' +
|
||||
'</div>' +
|
||||
'<div class="row g-2 small mt-2">' +
|
||||
'<div class="col-md-4"><span class="text-muted">Current grade:</span> ' + escapeHtml(student.currentGrade || 'N/A') + '</div>' +
|
||||
'<div class="col-md-4"><span class="text-muted">Expected placement:</span> ' + escapeHtml(student.expectedPlacement || 'Pending') + '</div>' +
|
||||
'<div class="col-md-4"><span class="text-muted">Required action:</span> ' + escapeHtml(student.requiredAction || 'Contact administration') + '</div>' +
|
||||
const lines = [
|
||||
['Student', student.name],
|
||||
['School ID', student.schoolId || 'N/A'],
|
||||
['Date of birth', student.dob || 'N/A'],
|
||||
['Gender', student.gender || 'N/A'],
|
||||
['Tuition', formatMoney(tuitionFee)],
|
||||
['Current grade', student.currentGrade || 'N/A'],
|
||||
['Expected placement', student.expectedPlacement || 'Pending'],
|
||||
];
|
||||
|
||||
return '<div class="enrollment-summary-card">' +
|
||||
'<div class="enrollment-summary-lines">' +
|
||||
lines.map(([label, value]) => {
|
||||
return '<div class="enrollment-summary-line">' +
|
||||
'<span class="enrollment-summary-label">' + escapeHtml(label) + ':</span>' +
|
||||
'<span class="enrollment-summary-value">' + escapeHtml(value) + '</span>' +
|
||||
'</div>';
|
||||
}).join('') +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
}).join('');
|
||||
renderParentContactReview();
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
@@ -795,6 +967,108 @@ foreach (($students ?? []) as $student) {
|
||||
return String(feeSchedule.currency || '$') + numericAmount.toFixed(2);
|
||||
}
|
||||
|
||||
function digitsOnly(value) {
|
||||
return String(value || '').replace(/\D/g, '');
|
||||
}
|
||||
|
||||
function formatPhoneDisplay(value) {
|
||||
const digits = digitsOnly(value).substring(0, 10);
|
||||
if (digits.length > 6) {
|
||||
return digits.substring(0, 3) + '-' + digits.substring(3, 6) + '-' + digits.substring(6);
|
||||
}
|
||||
if (digits.length > 3) {
|
||||
return digits.substring(0, 3) + '-' + digits.substring(3);
|
||||
}
|
||||
return digits;
|
||||
}
|
||||
|
||||
function parentContactAddress() {
|
||||
const street = parentStreetInput?.value?.trim() || '';
|
||||
const apt = parentAptInput?.value?.trim() || '';
|
||||
const city = parentCityInput?.value?.trim() || '';
|
||||
const state = parentStateInput?.value?.trim() || '';
|
||||
const zip = parentZipInput?.value?.trim() || '';
|
||||
const line = [street, apt].filter(Boolean).join(', ');
|
||||
const cityLine = [city, state, zip].filter(Boolean).join(' ');
|
||||
return [line, cityLine].filter(Boolean).join(', ') || 'N/A';
|
||||
}
|
||||
|
||||
function renderParentContactReview() {
|
||||
const phoneNode = document.querySelector('[data-parent-review="cellphone"]');
|
||||
const addressNode = document.querySelector('[data-parent-review="address"]');
|
||||
if (phoneNode) {
|
||||
phoneNode.textContent = formatPhoneDisplay(parentPhoneInput?.value || '') || 'N/A';
|
||||
}
|
||||
if (addressNode) {
|
||||
addressNode.textContent = parentContactAddress();
|
||||
}
|
||||
}
|
||||
|
||||
function validateParentContact() {
|
||||
const phone = digitsOnly(parentPhoneInput?.value || '');
|
||||
if (phone.length !== 10) {
|
||||
alert('Please enter a valid 10-digit phone number.');
|
||||
parentPhoneInput?.focus();
|
||||
return false;
|
||||
}
|
||||
if (!parentStreetInput || parentStreetInput.value.trim().length < 5) {
|
||||
alert('Please enter your home street address.');
|
||||
parentStreetInput?.focus();
|
||||
return false;
|
||||
}
|
||||
if (!parentCityInput || parentCityInput.value.trim().length < 2) {
|
||||
alert('Please enter your city.');
|
||||
parentCityInput?.focus();
|
||||
return false;
|
||||
}
|
||||
if (!parentStateInput || parentStateInput.value.trim() === '') {
|
||||
alert('Please select your state.');
|
||||
parentStateInput?.focus();
|
||||
return false;
|
||||
}
|
||||
if (!parentZipInput || digitsOnly(parentZipInput.value).length !== 5) {
|
||||
alert('Please enter a valid 5-digit ZIP code.');
|
||||
parentZipInput?.focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function selectStudentsForEnrollment(ids) {
|
||||
const wanted = Array.isArray(ids) ? ids.map(Number).filter(id => id > 0) : [];
|
||||
document.querySelectorAll('[data-student-card]').forEach(card => {
|
||||
if (card.dataset.selectable !== '1') {
|
||||
return;
|
||||
}
|
||||
const studentId = Number(card.dataset.studentId || 0);
|
||||
if (wanted.length && !wanted.includes(studentId)) {
|
||||
return;
|
||||
}
|
||||
const input = card.querySelector('[data-enroll-input]');
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
input.checked = true;
|
||||
card.classList.add('is-selected');
|
||||
setStudentFieldsEnabled(card, true);
|
||||
});
|
||||
}
|
||||
|
||||
function openEnrollmentAtStep(step) {
|
||||
if (!flowModal || deadlinePassed) {
|
||||
return false;
|
||||
}
|
||||
if (selectedEnrollInputs().length === 0) {
|
||||
selectStudentsForEnrollment(preselectedStudentIds);
|
||||
}
|
||||
if (selectedEnrollInputs().length === 0) {
|
||||
return false;
|
||||
}
|
||||
setStep(step);
|
||||
flowModal.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
function syncPolicyAccepted() {
|
||||
hasAcceptedSchoolPolicy = !!(policyAcceptedCheckbox && policyAcceptedCheckbox.checked);
|
||||
if (policyAcceptedInput) {
|
||||
@@ -966,7 +1240,10 @@ foreach (($students ?? []) as $student) {
|
||||
if (currentStep === 0 && !validateSelectedStudentHealth()) {
|
||||
return;
|
||||
}
|
||||
if (currentStep === 1) {
|
||||
if (currentStep === 1 && !validateParentContact()) {
|
||||
return;
|
||||
}
|
||||
if (currentStep === 2) {
|
||||
syncPolicyAccepted();
|
||||
if (!hasAcceptedSchoolPolicy) {
|
||||
alert('Please read and accept the school policies before continuing.');
|
||||
@@ -1013,13 +1290,27 @@ foreach (($students ?? []) as $student) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (anyEnroll && !hasAcceptedSchoolPolicy) {
|
||||
if (anyEnroll && !validateSelectedStudentHealth()) {
|
||||
e.preventDefault();
|
||||
setStep(0);
|
||||
if (flowModal) flowModal.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (anyEnroll && !validateParentContact()) {
|
||||
e.preventDefault();
|
||||
setStep(1);
|
||||
if (flowModal) flowModal.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (anyEnroll && !hasAcceptedSchoolPolicy) {
|
||||
e.preventDefault();
|
||||
setStep(2);
|
||||
if (flowModal) flowModal.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!anyEnroll && anyWithdraw) {
|
||||
const ok = confirm('Confirm withdrawal request for the selected student(s)?');
|
||||
if (!ok) {
|
||||
@@ -1028,6 +1319,22 @@ foreach (($students ?? []) as $student) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (parentPhoneInput) {
|
||||
parentPhoneInput.addEventListener('input', function() {
|
||||
this.value = formatPhoneDisplay(this.value);
|
||||
});
|
||||
}
|
||||
|
||||
if (parentZipInput) {
|
||||
parentZipInput.addEventListener('input', function() {
|
||||
this.value = digitsOnly(this.value).substring(0, 5);
|
||||
});
|
||||
}
|
||||
|
||||
if (enrollmentStartStep >= 2 && startButton && !startButton.disabled && !<?= $flashError ? 'true' : 'false' ?>) {
|
||||
openEnrollmentAtStep(enrollmentStartStep - 1);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
Reference in New Issue
Block a user