35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../../modules/shared/db.php';
|
|
require_once __DIR__ . '/../../../modules/shared/auth/service.php';
|
|
require_once __DIR__ . '/../../../modules/erp/bestellungen/service.php';
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
$env = expand_env_values(parse_env_file(__DIR__ . '/../../../.env'));
|
|
$pdo = connect_database($env);
|
|
auth_bootstrap_session();
|
|
|
|
if (auth_current_user($pdo) === null) {
|
|
http_response_code(401);
|
|
echo json_encode(['ok' => false, 'error' => 'Unauthorized']);
|
|
exit;
|
|
}
|
|
|
|
$orderId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
|
|
if (!is_int($orderId) || $orderId <= 0) {
|
|
http_response_code(400);
|
|
echo json_encode(['ok' => false, 'error' => 'Invalid order id']);
|
|
exit;
|
|
}
|
|
|
|
$detail = get_sales_order_detail($pdo, $orderId);
|
|
if ($detail === null) {
|
|
http_response_code(404);
|
|
echo json_encode(['ok' => false, 'error' => 'Order not found']);
|
|
exit;
|
|
}
|
|
|
|
echo json_encode(['ok' => true, 'order' => $detail], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|