Add documents to stock lots

This commit is contained in:
gitea_admin committed 2026-09-08 11:38:10 +02:00
1 parent e47990dfe0
commit 2bec934732
5 files changed
+294 -2

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
<?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/lager/service.php';
$env = expand_env_values(parse_env_file(__DIR__ . '/../../../.env'));
try {
$pdo = connect_database($env);
auth_bootstrap_session();
if (auth_current_user($pdo) === null) {
http_response_code(401);
exit('Unauthorized');
}
$document = get_stock_lot_document($pdo, (int) ($_GET['id'] ?? 0));
$path = dirname(__DIR__, 2) . '/runtime/uploads/lager/' . basename((string) $document['stored_filename']);
if (!is_file($path)) {
http_response_code(404);
exit('Not Found');
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . (string) filesize($path));
header("Content-Disposition: attachment; filename*=UTF-8''" . rawurlencode((string) $document['original_filename']));
readfile($path);
} catch (Throwable) {
http_response_code(404);
exit('Not Found');
}