Files
api/services/nginx/app/routes/moduleXLVaskRoute.php
T
Jeppe Bandopenhands 5441fea665 fix(api): simplify XLVask Selvvask surface by removing AI autopilot pipeline (#367)
## Summary

Removes the XLVask autopilot / automation / MiniMax / OpenAI pipeline
and the related module config, CLI, cron, and migration scaffolding. The
Selvvask view (Superuser -> Fakturaer -> Periode -> Selvvask) is reduced
to a single read-only listing of usage logs plus operator-driven ignore
/ unignore / accept / reject endpoints gated on the
`review_xlvask_usage_order` permission.

See `inventory/self-serve-inventory.md` for the full surface map.

## Test plan

- [x] `vendor/bin/pest --testsuite=Unit` -> **1266 passed**, 1 unrelated
pre-existing failure (`BirdControlPlaneActivationTest`, needs
`PLENO_REPO_ROOT_FOR_TESTS`).
- [x] `php -l` on every modified PHP file -> no syntax errors.
- [x] Grep validation -> zero production-code references to removed
surfaces (`xlvask_autopilot_service`, `xlvask_automation_service`,
`xlvask_automation_policy_service`, `EnsureXLVaskAutomationSchema`,
`runScheduledAutomationIfReady`, `processAutopilotQueue`, `MiniMax`,
`minimax`, ...).
- [ ] Qodana + Tests workflows green on this PR.

Co-authored-by: openhands <openhands@all-hands.dev>

---------

Co-authored-by: openhands <openhands@all-hands.dev>
2026-08-12 20:02:30 +02:00

227 lines
7.7 KiB
PHP

<?php
namespace routes;
use classes\authentication;
use classes\response;
use classes\router;
use classes\xlvask;
use objects\orders_o;
use objects\xlvask_customers_o;
use traits\route_t;
class moduleXLVaskRoute
{
use route_t;
public function run(): void
{
global /** @var response $response */
/** @var router $router */
$router, $response;
$this->get('/modules/xlvask/usageLog', function () {
global $response;
$this->requirePermission('modules_xlvask_usageLog');
$params = [
'dateFrom' => null,
'regNr' => null,
'vehicleId' => null,
'customerId' => null,
];
// Get the parameters from the request
foreach ( $params as $key => $value ) {
if ($this->isParametersSet([$key])) {
$params[$key] = $this->getParameter($key);
}
}
// Set the memory limit to 5120MB
ini_set('memory_limit', '5120M');
// Create the xlvask object
$xlvask = new xlvask();
$result = $xlvask->getUsageLog(...$params);
// Response
$response->success($result, 200);
},
[
'modules_xlvask_usageLog' => 'Get the usage log of the xlvask module'
]
);
$this->get('/modules/xlvask/vehicles', function () {
global $response;
$this->requirePermission('modules_xlvask_vehicles');
$params = [
'customerId' => null,
'vehicleId' => null,
'registrationNumber' => null,
'changeDate' => null,
];
// Get the parameters from the request
foreach ( $params as $key => $value ) {
if ($this->isParametersSet([$key])) {
$params[$key] = $this->getParameter($key);
}
}
// Create the xlvask object
$xlvask = new xlvask();
$result = $xlvask->getVehicles(...$params);
// Response
$response->success($result, 200);
},
[
'modules_xlvask_vehicles' => 'Get the vehicles of the xlvask module'
]
);
$this->get('/modules/xlvask/customers', function () {
global $response;
$this->requirePermission('modules_xlvask_customers');
$params = [
'customerId' => null,
'customerName' => null,
'customerExternalId' => null,
'vatNumber' => null,
'changeDate' => null,
'users' => null,
];
// Get the parameters from the request
foreach ( $params as $key => $value ) {
if ($this->isParametersSet([$key])) {
$params[$key] = $this->getParameter($key);
}
}
// Create the xlvask object
$xlvask = new xlvask();
$result = $xlvask->getCustomers(...$params);
// Response
$response->success($result, 200);
},
[
'modules_xlvask_customers' => 'Get the customers of the xlvask module'
]
);
$this->get('/modules/xlvask/internal/vehicle-types', function () {
global $response;
$this->requirePermission('modules_xlvask_internal_vehicle_types');
$user = (new authentication())->get_user();
$xlvask_vehicle_types = new \objects\xlvask_vehicle_types_o();
$result = $xlvask_vehicle_types->listObjectsWithPaginationIfSet(
function ($tmp_object_array) {
return [
...$tmp_object_array
];
}
);
// Response
$response->success($result, 200);
},
[
'modules_xlvask_internal_vehicle_types' => 'Get the vehicle types of the xlvask module'
]
);
$this->get('/modules/xlvask/related-orders', function () {
global $response;
$this->requirePermission('modules_xlvask_related_orders');
self::requireParameters(['washIds']);
$washIds = self::getParameter('washIds');
// Check if the washIds is an array
self::requireType($washIds, self::TYPE_ARRAY());
// Require only strings in the array
foreach ( $washIds as $key => $value ) {
if (!is_string($value)) {
self::requireType($value, self::TYPE_STRING());
}
}
// Get all the related orders
$orders_o = new orders_o();
$mathing_orders = $orders_o->getFieldsWhere([
'wash_id' => $washIds,
'deleted_at' => null,
], [
'id',
'wash_id',
]);
$formatted_matches = [];
foreach ( $mathing_orders as $order ) {
$formatted_matches[(string)$order['wash_id']][] = (int)$order['id'];
}
$response->success($formatted_matches, 200);
},
[
'modules_xlvask_related_orders' => 'Get the related orders of the xlvask module'
]
);
$this->get('/modules/xlvask/tasks/sync-users', function () {
global $response;
$this->requirePermission('modules_xlvask_sync_users');
// Create the xlvask tasks object
$xlvask = new xlvask();
// Run the sync users task
$result = $xlvask->getTasks()->runSyncUsers();
// Response
$response->success(
$result,
200
);
},
[
'modules_xlvask_sync_users' => 'Synchronize users with the xlvask module'
]
);
$this->get('/modules/xlvask/tasks/sync-usage', function () {
global $response;
$this->requirePermission('modules_xlvask_sync_usage');
// Create the xlvask tasks object
$xlvask = new xlvask();
// Run the sync usage task
$xlvask->getTasks()->runSyncUsage();
// Response
$response->success(
null,
200
);
},
[
'modules_xlvask_sync_usage' => 'Synchronize usage with the xlvask module'
]
);
$this->get('/modules/xlvask/tasks/import-customers', function () {
global $response;
$this->requirePermission('modules_xlvask_import_customers');
// Create the xlvask_customers_o object
$xlvask_customers_o = new xlvask_customers_o();
$xlvask_customers_o->importCustomers();
$response->success(
'Customers imported',
200
);
},
[
'modules_xlvask_import_customers' => 'Import customers from the xlvask module'
]
);
$this->get('/modules/xlvask/tasks/import-vehicles', function () {
global $response;
$this->requirePermission('modules_xlvask_import_vehicles');
// Create the xlvask_vehicles_o object
$xlvask_vehicles_o = new \objects\xlvask_vehicles_o();
$xlvask_vehicles_o->importVehicles();
$response->success(
'Vehicles imported',
200
);
},
[
'modules_xlvask_import_vehicles' => 'Import vehicles from the xlvask module'
]
);
}
}