|
|
|
|
|
|
|
Verify pooled hours, warning, membership and teacher report data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
$rows = \Components\Commerce\Discounts::getAll(['filter' => ['discount_title', '=', 'Course exclusion - Presentation Demo'], 'limit' => 1]);
$discount = reset($rows);
\Components\Commerce\Discounts::save(['discount_id' => $discount['discount_id'], 'discount_entity_type' => '\Components\AF\Courses\CollectiveCourses']);
\Components\Marketing\Automation::save(['automation_id' => 75, 'automation_event_configuration' => ['onmembership_products' => 'products', 'onmembership_product_entities' => [519], 'attach_membership_card' => 1], 'automation_is_enabled' => 0]);
echo json_encode([
'discount' => $discount['discount_id'],
'private_purchased' => \Components\AF\Courses\Hours::getTotalForCourse(378),
'private_allocated' => \Components\AF\Courses\Units::getTotalAllocatedForCourse(378),
'private_remaining' => \Components\AF\Courses\PrivateCourses::getRemainingHourBalance(378),
'guard_enabled' => \Components\AF\Courses\PrivateCourses::configGetValue('prevent_scheduling_beyond_paid_hours'),
'missing_answer_key' => \Components\AF\PlacementTests::isMissingAnswerKey(\Components\AF\PlacementTests::get(32)),
'membership_valid' => \Components\AF\Memberships::isValid(\Components\AF\Memberships::get(144)),
'invoice_total' => \Components\Commerce\Sales::getColumn(1541, 'sale_total'),
'teacher_hours' => \Components\AF\Teachers\Hours::getFilteredHours(['teacher_id' => 1393, 'date_from' => strtotime('2026-10-01'), 'date_to' => strtotime('2026-10-31 23:59:59')]),
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
|
Here's what this will do, in everyday terms:
**Changes it makes (2 things):**
1. **Updates one discount record.** It finds the discount called "Course exclusion - Presentation Demo" and changes its type so it applies to group courses instead of whatever it applied to before. Only that one discount is affected.
2. **Turns off one automated message.** It finds the automation numbered 75 (an automatic action that sends a membership card when someone buys a certain product, number 519) and switches it off, so it will no longer run. It also rewrites that automation's settings — it will trigger on that product purchase and attach a membership card — but since it's switched off, nothing will actually happen until someone turns it back on.
**Things it only looks up (no changes):**
After making those two changes, it gathers information and shows it on screen:
- Details about course 378: how many hours were purchased, how many have been used/allocated, and how many paid hours are still left.
- Whether a safety setting is on that stops people booking lessons beyond the hours they've paid for.
- Whether placement test 32 is missing its answer key.
- Whether the membership of person 144 is currently valid.
- The total amount of invoice 1541.
- How many teaching hours teacher 1393 logged during October 2026.
**In short:** it re-points one discount at group courses, disables one automatic membership-card message, and then displays a status report about a specific course, student, membership, invoice, and teacher. Nothing is deleted, and no other records are touched.
|
|
|