1 parent
f7dcbdf786
commit
d640f3656d
5 files changed
+2
-294
No files matched your search
@@ -20,32 +20,6 @@ try {
|
||||
json_response(405, ['ok' => false, 'error' => 'Method Not Allowed']);
|
||||
}
|
||||
|
||||
$contentType = (string) ($_SERVER['CONTENT_TYPE'] ?? '');
|
||||
if (str_starts_with($contentType, 'multipart/form-data')) {
|
||||
if (!auth_validate_csrf_token($_POST['csrfToken'] ?? null)) {
|
||||
json_response(403, ['ok' => false, 'error' => 'Invalid security token']);
|
||||
}
|
||||
if (($_POST['action'] ?? '') !== 'upload_document') {
|
||||
json_response(422, ['ok' => false, 'error' => 'Unsupported action']);
|
||||
}
|
||||
$file = $_FILES['document'] ?? null;
|
||||
if (!is_array($file)) {
|
||||
throw new InvalidArgumentException('Dokumentdatei fehlt');
|
||||
}
|
||||
$document = upload_stock_lot_document(
|
||||
$pdo,
|
||||
(int) ($_POST['lotId'] ?? 0),
|
||||
$file,
|
||||
(string) ($_POST['comment'] ?? ''),
|
||||
(string) ($currentUser['username'] ?? $currentUser['email'] ?? 'unknown')
|
||||
);
|
||||
json_response(201, ['ok' => true, 'document' => [
|
||||
'id' => (int) $document['id'],
|
||||
'original_filename' => (string) $document['original_filename'],
|
||||
'comment' => $document['comment'] === null ? '' : (string) $document['comment'],
|
||||
]]);
|
||||
}
|
||||
|
||||
$jsonInput = file_get_contents('php://input');
|
||||
if ($jsonInput === false || trim($jsonInput) === '') {
|
||||
json_response(400, ['ok' => false, 'error' => 'Empty payload']);
|
||||
@@ -103,16 +77,6 @@ try {
|
||||
json_response(200, ['ok' => true, 'productId' => $productId, 'availableQty' => get_lager_product_available_qty($pdo, $productId)]);
|
||||
}
|
||||
|
||||
if ($action === 'update_document_comment') {
|
||||
update_stock_lot_document_comment($pdo, (int) ($data['documentId'] ?? 0), (string) ($data['comment'] ?? ''));
|
||||
json_response(200, ['ok' => true]);
|
||||
}
|
||||
|
||||
if ($action === 'delete_document') {
|
||||
delete_stock_lot_document($pdo, (int) ($data['documentId'] ?? 0));
|
||||
json_response(200, ['ok' => true]);
|
||||
}
|
||||
|
||||
if ($action === 'prepare_lot') {
|
||||
$productId = (int) ($data['productId'] ?? 0);
|
||||
$lotNumber = trim((string) ($data['lotNumber'] ?? ''));
|
||||
|
||||
Reference in new issue
Block a user