Files
unsupervised-scheduler/src/AdminMenu.php
T
thatguygriff 9873cb5e30
CI / No Debug Code (pull_request) Successful in 3s
CI / Coding Standards (pull_request) Successful in 46s
CI / Tests (PHP 8.1) (pull_request) Successful in 52s
CI / Tests (PHP 8.3) (pull_request) Successful in 52s
CI / Tests (PHP 8.2) (pull_request) Successful in 57s
CI / PHPStan (pull_request) Successful in 1m12s
CI / Build Plugin Zip (pull_request) Has been skipped
Add e-transfer destination email (studio default + offering/booking overrides)
The e-transfer destination is resolved at booking time (offering override ->
studio default) and frozen onto the payment, so each record keeps where the
student was directed. It can then be corrected per booking.

- StudioSettings: us_etransfer_email option + a Default e-transfer email field
  on the Studio Settings page.
- Offering: etransfer_email column/field (instructor override) across VO, repo,
  REST endpoint, admin controller, and form.
- Payment: etransfer_email column on the payment (frozen record) +
  PaymentRepository::updateEtransferEmail; PaymentService freezes it from the
  offering override or studio default at creation; booking/enrolment pass the
  offering override.
- My Lessons: instructors edit the e-transfer email per pending lesson payment
  (ownership-checked).
- Payments queue: studio admin can correct the email at confirmation (for when
  a student sends it to the wrong place).
- Docs updated.

Tests: Payment/Offering rows + PaymentService freezing. composer test (148),
cs, and PHPStan level 6 all pass.

Refs #7

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 10:47:06 -03:00

182 lines
6.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Unsupervised\Schedular;
use Unsupervised\Schedular\Availability\AvailabilityController;
use Unsupervised\Schedular\Availability\AvailabilityRepository;
use Unsupervised\Schedular\Auth\InviteRepository;
use Unsupervised\Schedular\Auth\RegistrationController;
use Unsupervised\Schedular\Auth\RoleManager;
use Unsupervised\Schedular\Auth\StudentController;
use Unsupervised\Schedular\Booking\BookingRepository;
use Unsupervised\Schedular\Booking\LessonController;
use Unsupervised\Schedular\GroupClass\EnrollmentRepository;
use Unsupervised\Schedular\GroupClass\GroupClassController;
use Unsupervised\Schedular\Offering\OfferingController;
use Unsupervised\Schedular\Offering\OfferingRepository;
use Unsupervised\Schedular\Payment\BillingMethodResolver;
use Unsupervised\Schedular\Payment\PaymentController;
use Unsupervised\Schedular\Payment\PaymentRepository;
use Unsupervised\Schedular\Payment\PaymentService;
use Unsupervised\Schedular\Payment\StudioSettings;
use Unsupervised\Schedular\Policy\PolicyController;
use Unsupervised\Schedular\Policy\PolicyRepository;
use Unsupervised\Schedular\Policy\PolicyService;
use Unsupervised\Schedular\Policy\PolicyVersionRepository;
use Unsupervised\Schedular\Registration\QuestionController;
use Unsupervised\Schedular\Registration\QuestionRepository;
class AdminMenu {
private AvailabilityController $availabilityController;
private LessonController $lessonController;
private OfferingController $offeringController;
private QuestionController $questionController;
private PolicyController $policyController;
private RegistrationController $registrationController;
private GroupClassController $groupClassController;
private StudentController $studentController;
private StudioSettings $settings;
private PaymentController $paymentController;
public function __construct( AvailabilityRepository $availability, BookingRepository $bookings, OfferingRepository $offerings, QuestionRepository $questions, PolicyRepository $policies, PolicyVersionRepository $policyVersions, PolicyService $policyService, InviteRepository $invites, EnrollmentRepository $enrollments, StudioSettings $settings, PaymentRepository $payments, PaymentService $paymentService, BillingMethodResolver $resolver ) {
$this->availabilityController = new AvailabilityController( $availability, $offerings );
$this->lessonController = new LessonController( $bookings, $payments );
$this->offeringController = new OfferingController( $offerings );
$this->questionController = new QuestionController( $questions, $offerings );
$this->policyController = new PolicyController( $policies, $policyVersions, $policyService );
$this->registrationController = new RegistrationController( $invites );
$this->groupClassController = new GroupClassController( $enrollments, $offerings );
$this->studentController = new StudentController( $bookings, $availability, $offerings, $enrollments, $resolver );
$this->settings = $settings;
$this->paymentController = new PaymentController( $payments, $paymentService );
}
public function register(): void {
add_action( 'admin_menu', [ $this, 'addPages' ] );
}
public function addPages(): void {
// Studio-wide dashboard: all upcoming lessons across instructors.
add_menu_page(
__( 'Scheduler', 'unsupervised-schedular' ),
__( 'Scheduler', 'unsupervised-schedular' ),
RoleManager::CAP_VIEW_ALL_LESSONS,
'us-scheduler',
[ $this->lessonController, 'renderAdminDashboard' ],
'dashicons-calendar-alt',
30
);
// Instructor: manage their own availability.
add_menu_page(
__( 'My Availability', 'unsupervised-schedular' ),
__( 'My Availability', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_AVAILABILITY,
'us-availability',
[ $this->availabilityController, 'renderPage' ],
'dashicons-clock',
31
);
// Studio admin / instructor: manage offerings.
add_menu_page(
__( 'Offerings', 'unsupervised-schedular' ),
__( 'Offerings', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_OFFERINGS,
'us-offerings',
[ $this->offeringController, 'renderPage' ],
'dashicons-tag',
33
);
// Studio admin / instructor: manage per-offering intake questions.
add_submenu_page(
'us-offerings',
__( 'Questions', 'unsupervised-schedular' ),
__( 'Questions', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_QUESTIONS,
'us-questions',
[ $this->questionController, 'renderPage' ]
);
// Studio admin: draft, version, and publish policies.
add_menu_page(
__( 'Policies', 'unsupervised-schedular' ),
__( 'Policies', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_POLICIES,
'us-policies',
[ $this->policyController, 'renderPage' ],
'dashicons-text-page',
34
);
// Studio admin: invite students to register.
add_menu_page(
__( 'Invites', 'unsupervised-schedular' ),
__( 'Invites', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_STUDENTS,
'us-invites',
[ $this->registrationController, 'renderPage' ],
'dashicons-email',
35
);
// Studio admin: all group-class enrolments.
add_menu_page(
__( 'Group Classes', 'unsupervised-schedular' ),
__( 'Group Classes', 'unsupervised-schedular' ),
RoleManager::CAP_VIEW_ALL_LESSONS,
'us-group-classes',
[ $this->groupClassController, 'renderPage' ],
'dashicons-groups',
36
);
// Studio admin: browse students and their activity.
add_menu_page(
__( 'Students', 'unsupervised-schedular' ),
__( 'Students', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_STUDENTS,
'us-students',
[ $this->studentController, 'renderPage' ],
'dashicons-id',
37
);
// Studio admin: confirm pending (e-transfer) payments.
add_menu_page(
__( 'Payments', 'unsupervised-schedular' ),
__( 'Payments', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_BILLING,
'us-payments',
[ $this->paymentController, 'renderPage' ],
'dashicons-money-alt',
38
);
// Studio admin: Stripe credentials and billing settings.
add_menu_page(
__( 'Studio Settings', 'unsupervised-schedular' ),
__( 'Studio Settings', 'unsupervised-schedular' ),
RoleManager::CAP_MANAGE_BILLING,
'us-settings',
[ $this->settings, 'renderPage' ],
'dashicons-admin-settings',
39
);
// Instructor: view their upcoming lessons.
add_menu_page(
__( 'My Lessons', 'unsupervised-schedular' ),
__( 'My Lessons', 'unsupervised-schedular' ),
RoleManager::CAP_VIEW_LESSONS,
'us-my-lessons',
[ $this->lessonController, 'renderInstructorLessons' ],
'dashicons-welcome-learn-more',
32
);
}
}