diff --git a/app/Controllers/OrderController.php b/app/Controllers/OrderController.php index 61dac0b..c3b1197 100644 --- a/app/Controllers/OrderController.php +++ b/app/Controllers/OrderController.php @@ -72,12 +72,38 @@ class OrderController public function store() { + // Detect post_max_size overflow + if (empty($_POST) && empty($_FILES) && isset($_SERVER['CONTENT_LENGTH']) && (int)$_SERVER['CONTENT_LENGTH'] > 0) { + $_SESSION['flash_error'] = "O tamanho total dos arquivos enviados excede o limite permitido pelo servidor."; + View::redirect('/admin/orders/create'); + return; + } + if (!isset($_FILES['csv_file']) || $_FILES['csv_file']['error'] !== UPLOAD_ERR_OK) { $_SESSION['flash_error'] = "Erro no upload do arquivo CSV."; View::redirect('/admin/orders/create'); return; } + // Validate attachments before inserting the order + if (isset($_FILES['attachments']) && !empty($_FILES['attachments']['name'][0])) { + $attachments = $_FILES['attachments']; + $count = count($attachments['name']); + for ($i = 0; $i < $count; $i++) { + $error = $attachments['error'][$i]; + if ($error !== UPLOAD_ERR_OK && $error !== UPLOAD_ERR_NO_FILE) { + $fileName = $attachments['name'][$i]; + if ($error === UPLOAD_ERR_INI_SIZE || $error === UPLOAD_ERR_FORM_SIZE) { + $_SESSION['flash_error'] = "O anexo '{$fileName}' excede o tamanho máximo permitido."; + } else { + $_SESSION['flash_error'] = "Erro no upload do anexo '{$fileName}': código {$error}."; + } + View::redirect('/admin/orders/create'); + return; + } + } + } + $title = $_POST['title']; $type = $_POST['type']; $content = \App\Utils\TextFormatter::normalizeLineBreaks($_POST['content']); diff --git a/resources/views/partials/toast.php b/resources/views/partials/toast.php index 1be9908..0196ae1 100644 --- a/resources/views/partials/toast.php +++ b/resources/views/partials/toast.php @@ -8,9 +8,9 @@ type = $event.detail.type; title = $event.detail.title; message = $event.detail.message; - setTimeout(() => show = false, 5000) + setTimeout(() => show = false, type === \'error\' ? 15000 : 8000) " x-init=" - if (show) setTimeout(() => show = false, 5000); + if (show) setTimeout(() => show = false, type === \'error\' ? 15000 : 8000); window.notify = (type, title, message) => { $dispatch('notify', { type, title, message }); }