Added download button in upload daily report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 3m8s
Laravel Larastan / larastan (pull_request) Failing after 4m27s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 3m8s
Laravel Larastan / larastan (pull_request) Failing after 4m27s
This commit is contained in:
@@ -145,6 +145,55 @@ class UploadDailyReport extends Page implements HasForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadTaskPdf(){
|
||||||
|
$fileName = $this->filters['file_name'] ?? null;
|
||||||
|
|
||||||
|
if (!$fileName) {
|
||||||
|
Notification::make()
|
||||||
|
->title('File Name Required')
|
||||||
|
->body('Please enter a file name before removing the PDF.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filePath = "task_updates/{$fileName}.pdf";
|
||||||
|
|
||||||
|
if (!Storage::disk('local')->exists($filePath)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('PDF Not Found')
|
||||||
|
->body('The selected PDF does not exist.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->form->fill(['file_name' => null]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Storage::disk('local')->exists($filePath)) {
|
||||||
|
if($filePath){
|
||||||
|
$fullPath = Storage::disk('local')->path($filePath);
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('PDF Downloaded Successfully')
|
||||||
|
->body('The PDF was downloaded successfully.')
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return response()->download($fullPath, "{$fileName}.pdf");
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Notification::make()
|
||||||
|
->title('PDF downloaded Failed')
|
||||||
|
->body('Unable to download the PDF. Please try again...')
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
{
|
{
|
||||||
return Auth::check() && Auth::user()->can('view upload daily report page');
|
return Auth::check() && Auth::user()->can('view upload daily report page');
|
||||||
|
|||||||
@@ -16,5 +16,12 @@
|
|||||||
>
|
>
|
||||||
Remove Task PDF
|
Remove Task PDF
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="downloadTaskPdf"
|
||||||
|
class="px-3 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||||
|
>
|
||||||
|
Download Task PDF
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</x-filament-panels::page>
|
</x-filament-panels::page>
|
||||||
|
|||||||
Reference in New Issue
Block a user