CI / Coding Standards (pull_request) Successful in 2m47s
CI / PHPStan (pull_request) Successful in 2m56s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m39s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.2) (pull_request) Successful in 43s
CI / Tests (PHP 8.1) (pull_request) Successful in 44s
CI / No Debug Code (pull_request) Successful in 2s
The student-administration spec deferred three detail-view sections until Payments landed. Adds them now: policy-acceptance history (title, version, context, date), intake answers (label, answer, context), and — gated on manage_billing — payment history with HST breakdown and receipt numbers. New Auth\StudentHistory builds the display rows from per-student queries added to AcceptanceRepository, AnswerRepository, and PaymentRepository; the Payment model now carries created_at so unpaid rows still have a date. Closes #69 Co-Authored-By: Claude Fable 5 <[email protected]>
197 lines
9.5 KiB
PHP
197 lines
9.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* @var \WP_User $student
|
|
* @var list<array{start_dt: string, end_dt: string, offering: string, instructor: string, status: string}> $upcoming
|
|
* @var list<array{start_dt: string, end_dt: string, offering: string, instructor: string, status: string}> $past
|
|
* @var list<array{offering: string, status: string}> $enrolments
|
|
* @var list<array{policy: string, version: string, context: string, accepted_at: string}> $acceptances
|
|
* @var list<array{question: string, answer: string, context: string}> $intake
|
|
* @var list<array{created_at: string, context: string, method: string, status: string, amount: float, tax_amount: float, total: float, currency: string, receipt: string}> $payments
|
|
* @var string $backUrl
|
|
* @var bool $canBilling
|
|
* @var string $billingOverride
|
|
* @var string $billingDefault
|
|
*/
|
|
|
|
$renderLessons = static function (array $rows): void {
|
|
if (empty($rows)) {
|
|
echo '<p>' . esc_html__('None.', 'unsupervised-schedular') . '</p>';
|
|
return;
|
|
}
|
|
?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('When', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Offering', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Instructor', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Status', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($rows as $row) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($row['start_dt'] !== '' ? (string) mysql2date('M j, Y g:i A', $row['start_dt']) : '—'); ?></td>
|
|
<td><?php echo esc_html($row['offering']); ?></td>
|
|
<td><?php echo esc_html($row['instructor']); ?></td>
|
|
<td><?php echo esc_html($row['status']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
};
|
|
?>
|
|
<div class="wrap">
|
|
<h1>
|
|
<?php echo esc_html($student->display_name); ?>
|
|
<a href="<?php echo esc_url($backUrl); ?>" class="page-title-action"><?php esc_html_e('Back to students', 'unsupervised-schedular'); ?></a>
|
|
</h1>
|
|
|
|
<h2><?php esc_html_e('Account', 'unsupervised-schedular'); ?></h2>
|
|
<table class="form-table">
|
|
<tr><th><?php esc_html_e('Email', 'unsupervised-schedular'); ?></th><td><?php echo esc_html($student->user_email); ?></td></tr>
|
|
<tr><th><?php esc_html_e('Registered', 'unsupervised-schedular'); ?></th><td><?php echo esc_html($student->user_registered); ?></td></tr>
|
|
</table>
|
|
|
|
<?php if ($canBilling) : ?>
|
|
<h2><?php esc_html_e('Billing method', 'unsupervised-schedular'); ?></h2>
|
|
<form method="post">
|
|
<?php wp_nonce_field('usc_student_billing'); ?>
|
|
<input type="hidden" name="usc_action" value="set_billing">
|
|
<select name="payment_method">
|
|
<option value="">
|
|
<?php
|
|
/* translators: %s: the studio default billing method */
|
|
echo esc_html(sprintf(__('Studio default (%s)', 'unsupervised-schedular'), $billingDefault));
|
|
?>
|
|
</option>
|
|
<option value="card" <?php selected($billingOverride, 'card'); ?>><?php esc_html_e('Credit card', 'unsupervised-schedular'); ?></option>
|
|
<option value="etransfer" <?php selected($billingOverride, 'etransfer'); ?>><?php esc_html_e('E-transfer', 'unsupervised-schedular'); ?></option>
|
|
<option value="comp" <?php selected($billingOverride, 'comp'); ?>><?php esc_html_e('Comp (no charge)', 'unsupervised-schedular'); ?></option>
|
|
</select>
|
|
<?php submit_button(esc_html__('Save', 'unsupervised-schedular'), 'secondary', 'submit', false); ?>
|
|
</form>
|
|
<?php endif; ?>
|
|
|
|
<h2><?php esc_html_e('Upcoming lessons', 'unsupervised-schedular'); ?></h2>
|
|
<?php $renderLessons($upcoming); ?>
|
|
|
|
<h2><?php esc_html_e('Past lessons', 'unsupervised-schedular'); ?></h2>
|
|
<?php $renderLessons($past); ?>
|
|
|
|
<h2><?php esc_html_e('Group-class enrolments', 'unsupervised-schedular'); ?></h2>
|
|
<?php if (empty($enrolments)) : ?>
|
|
<p><?php esc_html_e('None.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('Class', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Status', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($enrolments as $enrolment) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($enrolment['offering']); ?></td>
|
|
<td><?php echo esc_html($enrolment['status']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
|
|
<h2><?php esc_html_e('Policy acceptances', 'unsupervised-schedular'); ?></h2>
|
|
<?php if (empty($acceptances)) : ?>
|
|
<p><?php esc_html_e('None.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('Policy', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Version', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Context', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Accepted', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($acceptances as $acceptance) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($acceptance['policy']); ?></td>
|
|
<td><?php echo esc_html($acceptance['version']); ?></td>
|
|
<td><?php echo esc_html($acceptance['context']); ?></td>
|
|
<td><?php echo esc_html($acceptance['accepted_at'] !== '' ? (string) mysql2date('M j, Y g:i A', $acceptance['accepted_at']) : '—'); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
|
|
<h2><?php esc_html_e('Intake answers', 'unsupervised-schedular'); ?></h2>
|
|
<?php if (empty($intake)) : ?>
|
|
<p><?php esc_html_e('None.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('Question', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Answer', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Context', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($intake as $row) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($row['question']); ?></td>
|
|
<td><?php echo esc_html($row['answer']); ?></td>
|
|
<td><?php echo esc_html($row['context']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($canBilling) : ?>
|
|
<h2><?php esc_html_e('Payment history', 'unsupervised-schedular'); ?></h2>
|
|
<?php if (empty($payments)) : ?>
|
|
<p><?php esc_html_e('None.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('Date', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Context', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Method', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Status', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Subtotal', '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('Receipt', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($payments as $payment) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($payment['created_at'] !== '' ? (string) mysql2date('M j, Y g:i A', $payment['created_at']) : '—'); ?></td>
|
|
<td><?php echo esc_html($payment['context']); ?></td>
|
|
<td><?php echo esc_html($payment['method']); ?></td>
|
|
<td><?php echo esc_html($payment['status']); ?></td>
|
|
<td><?php echo esc_html(number_format_i18n($payment['amount'], 2)); ?></td>
|
|
<td><?php echo esc_html(number_format_i18n($payment['tax_amount'], 2)); ?></td>
|
|
<td><?php echo esc_html(number_format_i18n($payment['total'], 2) . ' ' . $payment['currency']); ?></td>
|
|
<td><?php echo esc_html($payment['receipt']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|