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>
108 lines
6.1 KiB
PHP
108 lines
6.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Unsupervised\Schedular\Offering\Offering;
|
|
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/** @var list<\Unsupervised\Schedular\Offering\Offering> $offerings */
|
|
?>
|
|
<div class="wrap">
|
|
<h1><?php esc_html_e('Offerings', 'unsupervised-schedular'); ?></h1>
|
|
|
|
<h2><?php esc_html_e('Add Offering', 'unsupervised-schedular'); ?></h2>
|
|
<form method="post">
|
|
<?php wp_nonce_field('usc_offering_action'); ?>
|
|
<input type="hidden" name="usc_action" value="add">
|
|
<table class="form-table">
|
|
<tr>
|
|
<th><label for="title"><?php esc_html_e('Title', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="text" name="title" id="title" class="regular-text" required></td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="kind"><?php esc_html_e('Kind', 'unsupervised-schedular'); ?></label></th>
|
|
<td>
|
|
<select name="kind" id="kind">
|
|
<option value="<?php echo esc_attr(Offering::KIND_PRIVATE_LESSON); ?>"><?php esc_html_e('Private lesson', 'unsupervised-schedular'); ?></option>
|
|
<option value="<?php echo esc_attr(Offering::KIND_GROUP_CLASS); ?>"><?php esc_html_e('Group class', 'unsupervised-schedular'); ?></option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="duration_minutes"><?php esc_html_e('Duration (minutes)', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="number" name="duration_minutes" id="duration_minutes" min="0" step="1"></td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="price"><?php esc_html_e('Price (dollars)', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="number" name="price" id="price" min="0" step="0.01" value="0.00"></td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="billing_mode"><?php esc_html_e('Billing', 'unsupervised-schedular'); ?></label></th>
|
|
<td>
|
|
<select name="billing_mode" id="billing_mode">
|
|
<option value="<?php echo esc_attr(Offering::BILLING_ONE_TIME); ?>"><?php esc_html_e('One-time at booking', 'unsupervised-schedular'); ?></option>
|
|
<option value="<?php echo esc_attr(Offering::BILLING_FULL_TERM); ?>"><?php esc_html_e('Full term upfront', 'unsupervised-schedular'); ?></option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th><?php esc_html_e('Weekly reservation', 'unsupervised-schedular'); ?></th>
|
|
<td><label><input type="checkbox" name="allow_weekly" value="1"> <?php esc_html_e('Allow weekly recurring reservation (private)', 'unsupervised-schedular'); ?></label></td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="capacity"><?php esc_html_e('Capacity', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="number" name="capacity" id="capacity" min="0" step="1"> <span class="description"><?php esc_html_e('Group classes only', 'unsupervised-schedular'); ?></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th><label for="schedule_note"><?php esc_html_e('Schedule note', 'unsupervised-schedular'); ?></label></th>
|
|
<td><input type="text" name="schedule_note" id="schedule_note" class="regular-text" placeholder="<?php esc_attr_e('e.g. Tuesdays 4:00pm', 'unsupervised-schedular'); ?>"></td>
|
|
</tr>
|
|
</table>
|
|
<?php submit_button(esc_html__('Add Offering', 'unsupervised-schedular')); ?>
|
|
</form>
|
|
|
|
<h2><?php esc_html_e('Current Offerings', 'unsupervised-schedular'); ?></h2>
|
|
|
|
<?php if (empty($offerings)) : ?>
|
|
<p><?php esc_html_e('No offerings configured.', 'unsupervised-schedular'); ?></p>
|
|
<?php else : ?>
|
|
<table class="wp-list-table widefat fixed striped">
|
|
<thead>
|
|
<tr>
|
|
<th><?php esc_html_e('Title', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Kind', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Duration', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Price', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Billing', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Active', 'unsupervised-schedular'); ?></th>
|
|
<th><?php esc_html_e('Actions', 'unsupervised-schedular'); ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($offerings as $offering) : ?>
|
|
<tr>
|
|
<td><?php echo esc_html($offering->title); ?></td>
|
|
<td><?php echo esc_html($offering->kind); ?></td>
|
|
<td><?php echo $offering->durationMinutes ? esc_html((string) $offering->durationMinutes . ' min') : '—'; ?></td>
|
|
<td><?php echo esc_html(number_format($offering->price, 2) . ' ' . $offering->currency); ?></td>
|
|
<td><?php echo esc_html($offering->billingMode); ?></td>
|
|
<td><?php echo $offering->isActive ? esc_html__('Yes', 'unsupervised-schedular') : esc_html__('No', 'unsupervised-schedular'); ?></td>
|
|
<td>
|
|
<form method="post" style="display:inline;">
|
|
<?php wp_nonce_field('usc_offering_action'); ?>
|
|
<input type="hidden" name="usc_action" value="delete">
|
|
<input type="hidden" name="offering_id" value="<?php echo esc_attr((string) $offering->id); ?>">
|
|
<button type="submit" class="button button-small button-link-delete">
|
|
<?php esc_html_e('Delete', 'unsupervised-schedular'); ?>
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|