19e663d6fa
CI / Coding Standards (pull_request) Successful in 50s
CI / PHPStan (pull_request) Successful in 1m2s
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 48s
CI / Tests (PHP 8.3) (pull_request) Successful in 46s
CI / No Debug Code (pull_request) Successful in 2s
CI / Build Plugin Zip (pull_request) Has been skipped
Availability (#2): - us_availability gains offering_id, duration_minutes (default 60), and recurrence_group; AvailabilitySlot carries the new fields. - AvailabilityRepository::createWeeklySeries() generates N weekly rows sharing a recurrence_group; findAvailable() filters by offering and duration. Date math uses DateTimeImmutable::modify() (the no-debug CI regex `dd\(` matches `->add(`). - REST GET filters by offering_id/duration_minutes; POST accepts duration_minutes, offering_id, recurrence (single|weekly) + weeks. - Admin form adds duration, an offering picker, and one-off/weekly options (OfferingRepository wired into AvailabilityController). - booking.js renders an agenda calendar (slots grouped by day, with duration). The richer booking UX lands with the booking-flow work. Offering price in dollars: - Switch us_offerings.price_cents (INT) to price DECIMAL(10,2); Offering uses float $price. Admin form and REST take dollars. - Fix a pre-existing misalignment in the Offering insert/update $wpdb format arrays (billing_mode/capacity/is_active were mapped to the wrong specifiers, which would corrupt values) via a single COLUMN_FORMATS list. Also bump PHPStan to --memory-limit=1G in the lint script; 128M now crashes analysis as the codebase has grown. Refs #2 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
102 lines
5.1 KiB
PHP
102 lines
5.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* @var list<\Unsupervised\Schedular\Availability\AvailabilitySlot> $slots
|
|
* @var list<\Unsupervised\Schedular\Offering\Offering> $offeringChoices
|
|
*/
|
|
?>
|
|
<div class="wrap">
|
|
<h1><?php esc_html_e('My Availability', 'unsupervised-schedular'); ?></h1>
|
|
|
|
<h2><?php esc_html_e('Add Slot', 'unsupervised-schedular'); ?></h2>
|
|
<form method="post">
|
|
<?php wp_nonce_field('usc_availability_action'); ?>
|
|
<input type="hidden" name="usc_action" value="add">
|
|
<table class="form-table">
|
|
<tr>
|
|
<th><label for="start_dt"><?php esc_html_e('Start', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="datetime-local" name="start_dt" id="start_dt" required></td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="end_dt"><?php esc_html_e('End', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="datetime-local" name="end_dt" id="end_dt" required></td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="duration_minutes"><?php esc_html_e('Lesson length (minutes)', 'unsupervised-schedular'); ?></label></th>
|
|
<td>
|
|
<select name="duration_minutes" id="duration_minutes">
|
|
<option value="30">30</option>
|
|
<option value="60" selected>60</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="offering_id"><?php esc_html_e('Offering', 'unsupervised-schedular'); ?></label></th>
|
|
<td>
|
|
<select name="offering_id" id="offering_id">
|
|
<option value="0"><?php esc_html_e('— Any private lesson —', 'unsupervised-schedular'); ?></option>
|
|
<?php foreach ($offeringChoices as $offering) : ?>
|
|
<option value="<?php echo esc_attr((string) $offering->id); ?>"><?php echo esc_html($offering->title); ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e('Repeat', 'unsupervised-schedular'); ?></th>
|
|
<td>
|
|
<label><input type="radio" name="recurrence" value="single" checked> <?php esc_html_e('One-off', 'unsupervised-schedular'); ?></label>
|
|
|
|
<label><input type="radio" name="recurrence" value="weekly"> <?php esc_html_e('Weekly for', 'unsupervised-schedular'); ?></label>
|
|
<input type="number" name="weeks" min="1" max="52" value="12" style="width:5em;"> <?php esc_html_e('weeks', 'unsupervised-schedular'); ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php submit_button(esc_html__('Add Slot', 'unsupervised-schedular')); ?>
|
|
</form>
|
|
|
|
<h2><?php esc_html_e('Current Slots', 'unsupervised-schedular'); ?></h2>
|
|
|
|
<?php if (empty($slots)) : ?>
|
|
<p><?php esc_html_e('No availability slots configured.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('Start', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('End', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Length', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Status', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Actions', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($slots as $slot) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($slot->startDt); ?></td>
|
|
<td><?php echo esc_html($slot->endDt); ?></td>
|
|
<td><?php echo esc_html((string) $slot->durationMinutes . ' min'); ?></td>
|
|
<td><?php echo $slot->isBooked ? esc_html__('Booked', 'unsupervised-schedular') : esc_html__('Available', 'unsupervised-schedular'); ?></td>
|
|
<td>
|
|
<?php if (! $slot->isBooked) : ?>
|
|
<form method="post" style="display:inline;">
|
|
<?php wp_nonce_field('usc_availability_action'); ?>
|
|
<input type="hidden" name="usc_action" value="delete">
|
|
<input type="hidden" name="slot_id" value="<?php echo esc_attr((string) $slot->id); ?>">
|
|
<button type="submit" class="button button-small button-link-delete">
|
|
<?php esc_html_e('Delete', 'unsupervised-schedular'); ?>
|
|
</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|