diff --git a/app/Filament/Pages/UploadDailyReport.php b/app/Filament/Pages/UploadDailyReport.php index b98400e3..ccb1d900 100644 --- a/app/Filament/Pages/UploadDailyReport.php +++ b/app/Filament/Pages/UploadDailyReport.php @@ -59,31 +59,47 @@ class UploadDailyReport extends Page implements HasForms $path = 'task_updates/' . $filename; - // $duplicateExists = Storage::disk('local')->exists($path); + $expectedEmployees = [ + 'Dhanabalan Saravanan', + 'Ranjith', + 'Srimathi Ramamoorthy', + ]; - // if ($duplicateExists) { - // // Remove the just-uploaded file since it's a duplicate - // // Storage::disk('local')->delete($currentFile); + $filename = pathinfo(basename($currentFile), PATHINFO_FILENAME); - // Notification::make() - // ->title('File already exists') - // ->body("A file named \"{$filename}\" is already uploaded.") - // ->danger() - // ->send(); + $isValid = collect($expectedEmployees)->contains( + fn ($name) => strcasecmp(trim($filename), $name) == 0 + ); - // $this->form->fill(['report_pdf' => null]); - // return; - // } - // else{ + if (! $isValid) { Notification::make() - ->title('PDF uploaded successfully') - ->success() - ->send(); + ->title('Invalid PDF filename') + ->body( + 'Please upload a PDF with one of these names: ' + . implode(', ', array_map( + fn ($name) => $name . '.pdf', + $expectedEmployees + )) + ) + ->danger() + ->send(); $this->form->fill(['report_pdf' => null]); - // } + + return; + } + else{ + Notification::make() + ->title('PDF uploaded successfully') + ->success() + ->send(); + + $this->form->fill(['report_pdf' => null]); + } + } + public function removeTaskPdf(){ $fileName = $this->filters['file_name'] ?? null;