CI / Tests (PHP 8.1) (pull_request) Successful in 6m39s
CI / Tests (PHP 8.2) (pull_request) Successful in 57s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m59s
CI / Tests (PHP 8.5) (pull_request) Successful in 3m31s
CI / No Debug Code (pull_request) Successful in 3s
CI / Coding Standards & Static Analysis (pull_request) Successful in 3m28s
CI / Build Plugin Zip (pull_request) Skipped
Two related gaps, closed together because the second is created by the first. A private lesson could only be booked by the student or their guardian, so a booking taken over the phone had no way in — where group classes have had "Add students directly" all along. "Book a lesson for a student" is now a panel on Scheduler and My Lessons: student, open time, lesson type, with weekly term reservations and a no-charge option for make-up lessons. The booking core is extracted to Booking\LessonBooker and shared with POST /bookings, so the two paths cannot drift on offering rules, slot claiming, or billing. That leaves a registration with no intake answers and no policy acceptances, because nobody was at a keyboard to give them — already true of every directly added group-class student. Ticking the boxes on a student's behalf would be an audit trail that says something untrue, so instead the answers are collected another way and recorded afterwards, from a lesson's or an enrolment's detail page. Every recording must say how it was collected, which is stamped on each row along with who typed it and shown in a new "How it was given" column: a policy ticked online and one transcribed from paper must never look alike. Only staff-made registrations qualify (us_lessons.booked_by, us_group_enrollments.enrolled_by) — one the student made already holds their own answers. Only what is still missing can be recorded, re-checked at write time, so a stale or double-posted form cannot duplicate or overwrite. No IP is stored for a transcription, and accepted_by stays the student while recorded_by names the staff member. Intake is now generic over Registration\IntakeSubject, which Lesson and Enrollment both implement; LessonDetail became Registration\IntakeAudit and is shared by both detail views rather than duplicated. Closes #182 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfHt6CyJHz6KkA4RuaS7WK
236 lines
15 KiB
PHP
236 lines
15 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* @var list<array{lesson_id: int, student: string, instructor: string, offering: string, duration: int, recurrence: string, time: string, day: string, time_short: string, status: string, notes: string, payment_id: int, currency: string, amount: float, tax_rate: float, tax_amount: float, total: float, etransfer_email: string, etransfer_editable: bool, tax_editable: bool}> $rows
|
|
* @var 'list'|'week' $view
|
|
* @var string $weekStart
|
|
* @var list<array{date: string, items: list<array{lesson_id: int, student: string, offering: string, time_short: string, status: string}>}> $weekDays
|
|
* @var string $prevWeek
|
|
* @var string $nextWeek
|
|
* @var string $baseUrl
|
|
* @var string $notice
|
|
* @var string $error
|
|
* @var array{students: list<array{id: int, name: string}>, offerings: list<array{id: int, label: string}>, slots: list<array{id: int, label: string, weekly: bool}>} $bookForm
|
|
*/
|
|
?>
|
|
<div class="wrap">
|
|
<h1><?php esc_html_e('Lessons', 'unsupervised-schedular'); ?></h1>
|
|
|
|
<?php if ('' !== $notice) : ?>
|
|
<div class="notice notice-success"><p><?php echo esc_html($notice); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ('' !== $error) : ?>
|
|
<div class="notice notice-error"><p><?php echo esc_html($error); ?></p></div>
|
|
<?php endif; ?>
|
|
|
|
<details class="usc-book-for-student" style="margin:12px 0;" <?php echo '' !== $error ? 'open' : ''; ?>>
|
|
<summary style="cursor:pointer; font-weight:600;"><?php esc_html_e('Book a lesson for a student', 'unsupervised-schedular'); ?></summary>
|
|
|
|
<?php if (empty($bookForm['students']) || empty($bookForm['slots'])) : ?>
|
|
<p class="description" style="margin-top:8px;">
|
|
<?php
|
|
echo empty($bookForm['students'])
|
|
? esc_html__('There are no students to book for yet.', 'unsupervised-schedular')
|
|
: esc_html__('There are no open times in the next eight weeks. Add availability first.', 'unsupervised-schedular');
|
|
?>
|
|
</p>
|
|
<?php else : ?>
|
|
<form method="post" style="margin-top:8px;">
|
|
<?php wp_nonce_field('usc_lesson_action'); ?>
|
|
<input type="hidden" name="usc_action" value="book_for_student">
|
|
<p class="description">
|
|
<?php esc_html_e('Books on the student\'s behalf, without the intake questions and policy agreements they would answer themselves.', 'unsupervised-schedular'); ?>
|
|
</p>
|
|
<table class="form-table" role="presentation">
|
|
<tr>
|
|
<th scope="row"><label for="usc-book-student"><?php esc_html_e('Student', 'unsupervised-schedular'); ?></label></th>
|
|
<td>
|
|
<select name="student_id" id="usc-book-student" required>
|
|
<option value=""><?php esc_html_e('Choose a student', 'unsupervised-schedular'); ?></option>
|
|
<?php foreach ($bookForm['students'] as $student) : ?>
|
|
<option value="<?php echo esc_attr((string) $student['id']); ?>"><?php echo esc_html($student['name']); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><label for="usc-book-slot"><?php esc_html_e('Time', 'unsupervised-schedular'); ?></label></th>
|
|
<td>
|
|
<select name="slot_id" id="usc-book-slot" required style="max-width:100%;">
|
|
<option value=""><?php esc_html_e('Choose an open time', 'unsupervised-schedular'); ?></option>
|
|
<?php foreach ($bookForm['slots'] as $slot) : ?>
|
|
<option value="<?php echo esc_attr((string) $slot['id']); ?>"><?php echo esc_html($slot['label']); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><label for="usc-book-offering"><?php esc_html_e('Lesson type', 'unsupervised-schedular'); ?></label></th>
|
|
<td>
|
|
<select name="offering_id" id="usc-book-offering" style="max-width:100%;">
|
|
<option value="0"><?php esc_html_e('Use the time\'s own lesson type', 'unsupervised-schedular'); ?></option>
|
|
<?php foreach ($bookForm['offerings'] as $offering) : ?>
|
|
<option value="<?php echo esc_attr((string) $offering['id']); ?>"><?php echo esc_html($offering['label']); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<p class="description"><?php esc_html_e('A time already tied to a lesson type is booked as that type; a general time needs one chosen here.', 'unsupervised-schedular'); ?></p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php esc_html_e('Options', 'unsupervised-schedular'); ?></th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="recurrence_weekly" value="1">
|
|
<?php esc_html_e('Reserve this time weekly for the rest of the term', 'unsupervised-schedular'); ?>
|
|
</label>
|
|
<p class="description"><?php esc_html_e('Only for a time that repeats weekly. Billed upfront as one payment.', 'unsupervised-schedular'); ?></p>
|
|
<label>
|
|
<input type="checkbox" name="no_charge" value="1">
|
|
<?php esc_html_e('No charge — book it free and confirm it now', 'unsupervised-schedular'); ?>
|
|
</label>
|
|
<p class="description"><?php esc_html_e('For a make-up or goodwill lesson. Otherwise a pending payment is raised at the lesson type\'s price.', 'unsupervised-schedular'); ?></p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><label for="usc-book-notes"><?php esc_html_e('Notes', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="text" name="notes" id="usc-book-notes" class="regular-text" maxlength="500"></td>
|
|
</tr>
|
|
</table>
|
|
<p>
|
|
<button type="submit" class="button button-primary"><?php esc_html_e('Book lesson', 'unsupervised-schedular'); ?></button>
|
|
</p>
|
|
</form>
|
|
<?php endif; ?>
|
|
</details>
|
|
|
|
<ul class="subsubsub" style="margin-bottom:12px;">
|
|
<li>
|
|
<a href="<?php echo esc_url($baseUrl); ?>" <?php echo 'week' === $view ? 'class="current"' : ''; ?>><?php esc_html_e('Week', 'unsupervised-schedular'); ?></a> |
|
|
</li>
|
|
<li>
|
|
<a href="<?php echo esc_url(add_query_arg('usc_view', 'list', $baseUrl)); ?>" <?php echo 'list' === $view ? 'class="current"' : ''; ?>><?php esc_html_e('List', 'unsupervised-schedular'); ?></a>
|
|
</li>
|
|
</ul>
|
|
<div class="clear"></div>
|
|
|
|
<?php if ('week' === $view) : ?>
|
|
<p>
|
|
<a class="button" href="<?php echo esc_url(add_query_arg('usc_week', $prevWeek, $baseUrl)); ?>">‹ <?php esc_html_e('Previous week', 'unsupervised-schedular'); ?></a>
|
|
<strong style="margin:0 12px;">
|
|
<?php
|
|
/* translators: %s: date of the first day of the displayed week */
|
|
echo esc_html(sprintf(__('Week of %s', 'unsupervised-schedular'), (string) mysql2date('M j, Y', $weekStart)));
|
|
?>
|
|
</strong>
|
|
<a class="button" href="<?php echo esc_url(add_query_arg('usc_week', $nextWeek, $baseUrl)); ?>"><?php esc_html_e('Next week', 'unsupervised-schedular'); ?> ›</a>
|
|
</p>
|
|
<table class="wp-list-table widefat fixed">
|
|
<thead>
|
|
<tr>
|
|
<?php foreach ($weekDays as $day) : ?>
|
|
<th><?php echo esc_html((string) mysql2date('D M j', $day['date'])); ?></th>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<?php foreach ($weekDays as $day) : ?>
|
|
<td style="vertical-align:top;">
|
|
<?php if (empty($day['items'])) : ?>
|
|
<span aria-hidden="true">—</span>
|
|
<?php endif; ?>
|
|
<?php foreach ($day['items'] as $item) : ?>
|
|
<p style="margin:0 0 8px;">
|
|
<strong><?php echo esc_html($item['time_short']); ?></strong><br>
|
|
<?php echo esc_html($item['student']); ?><br>
|
|
<span><?php echo esc_html($item['offering']); ?></span><br>
|
|
<em><?php echo esc_html($item['status']); ?></em><br>
|
|
<a href="<?php echo esc_url(add_query_arg('lesson_id', (string) $item['lesson_id'], $baseUrl)); ?>"><?php esc_html_e('Details', 'unsupervised-schedular'); ?></a>
|
|
</p>
|
|
<?php endforeach; ?>
|
|
</td>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<?php elseif (empty($rows)) : ?>
|
|
<p><?php esc_html_e('No upcoming lessons.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('Student', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Instructor', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Lesson', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Date/Time', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Status', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('HST', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Total', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('E-transfer email', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Notes', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Details', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($rows as $row) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($row['student']); ?></td>
|
|
<td><?php echo esc_html($row['instructor']); ?></td>
|
|
<td>
|
|
<?php echo esc_html($row['offering']); ?>
|
|
<?php if ($row['duration'] > 0) : ?>
|
|
<span style="color:#666;">
|
|
<?php
|
|
/* translators: %d: lesson length in minutes */
|
|
echo esc_html(sprintf(__('(%d min)', 'unsupervised-schedular'), $row['duration']));
|
|
?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?php echo esc_html($row['time']); ?></td>
|
|
<td><?php echo esc_html($row['status']); ?></td>
|
|
<td>
|
|
<?php if ($row['tax_editable']) : ?>
|
|
<form method="post" style="display:flex; gap:4px; align-items:center;">
|
|
<?php wp_nonce_field('usc_lesson_action'); ?>
|
|
<input type="hidden" name="usc_action" value="set_tax">
|
|
<input type="hidden" name="payment_id" value="<?php echo esc_attr((string) $row['payment_id']); ?>">
|
|
<input type="number" name="tax_rate" min="0" max="100" step="0.01" style="width:5em;" value="<?php echo esc_attr(number_format($row['tax_rate'], 2)); ?>">
|
|
<span>%</span>
|
|
<button type="submit" class="button button-small"><?php esc_html_e('Save', 'unsupervised-schedular'); ?></button>
|
|
</form>
|
|
<?php else : ?>
|
|
<?php echo esc_html(number_format($row['tax_rate'], 2) . '% (' . $row['currency'] . ' ' . number_format($row['tax_amount'], 2) . ')'); ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?php echo $row['payment_id'] > 0 ? esc_html($row['currency'] . ' ' . number_format($row['total'], 2)) : esc_html('—'); ?></td>
|
|
<td>
|
|
<?php if ($row['etransfer_editable']) : ?>
|
|
<form method="post" style="display:flex; gap:4px;">
|
|
<?php wp_nonce_field('usc_lesson_action'); ?>
|
|
<input type="hidden" name="usc_action" value="set_etransfer">
|
|
<input type="hidden" name="payment_id" value="<?php echo esc_attr((string) $row['payment_id']); ?>">
|
|
<input type="email" name="etransfer_email" value="<?php echo esc_attr($row['etransfer_email']); ?>">
|
|
<button type="submit" class="button button-small"><?php esc_html_e('Save', 'unsupervised-schedular'); ?></button>
|
|
</form>
|
|
<?php else : ?>
|
|
<?php echo esc_html('' !== $row['etransfer_email'] ? $row['etransfer_email'] : '—'); ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?php echo esc_html($row['notes']); ?></td>
|
|
<td>
|
|
<a href="<?php echo esc_url(add_query_arg('lesson_id', (string) $row['lesson_id'], $baseUrl)); ?>"><?php esc_html_e('View', 'unsupervised-schedular'); ?></a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|