diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 80fd8c67b93e..b89d9a77ade4 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -694,7 +694,6 @@ class QuoteController extends BaseController echo Storage::get($file); }, basename($file), ['Content-Type' => 'application/pdf']); - //return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); break; case 'restore': diff --git a/app/Http/Controllers/VendorPortal/DocumentController.php b/app/Http/Controllers/VendorPortal/DocumentController.php new file mode 100644 index 000000000000..ab85e87f1c4c --- /dev/null +++ b/app/Http/Controllers/VendorPortal/DocumentController.php @@ -0,0 +1,97 @@ + $document, + 'settings' => auth()->guard('vendor')->user()->company->settings + ]); + } + + public function download(ShowDocumentRequest $request, Document $document) + { + return Storage::disk($document->disk)->download($document->url, $document->name); + } + + public function publicDownload(string $document_hash) + { + MultiDB::documentFindAndSetDb($document_hash); + + $document = Document::where('hash', $document_hash)->firstOrFail(); + + $headers = []; + + if (request()->input('inline') == 'true') { + $headers = array_merge($headers, ['Content-Disposition' => 'inline']); + } + + return Storage::disk($document->disk)->download($document->url, $document->name, $headers); + } + + public function downloadMultiple(DownloadMultipleDocumentsRequest $request) + { + $documents = Document::whereIn('id', $this->transformKeys($request->file_hash)) + ->where('company_id', auth()->guard('vendor')->user()->company_id) + ->get(); + + $zipFile = new \PhpZip\ZipFile(); + + try { + foreach ($documents as $document) { + $zipFile->addFile(TempFile::path($document->filePath()), $document->name); + } + + $filename = now().'-documents.zip'; + $filepath = sys_get_temp_dir().'/'.$filename; + + $zipFile->saveAsFile($filepath) // save the archive to a file + ->close(); // close archive + + return response()->download($filepath, $filename)->deleteFileAfterSend(true); + } catch (\PhpZip\Exception\ZipException $e) { + // handle exception + } finally { + $zipFile->close(); + } + } +} diff --git a/app/Http/Requests/VendorPortal/Documents/ShowDocumentRequest.php b/app/Http/Requests/VendorPortal/Documents/ShowDocumentRequest.php new file mode 100644 index 000000000000..f9594292f8fc --- /dev/null +++ b/app/Http/Requests/VendorPortal/Documents/ShowDocumentRequest.php @@ -0,0 +1,44 @@ +guard('vendor')->user()->client_id == $this->document->documentable_id + || $this->document->company_id == auth()->guard('vendor')->user()->company_id; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + // + ]; + } +} diff --git a/app/Services/Quote/SendEmail.php b/app/Services/Quote/SendEmail.php index acaf4b2ce2a8..9c319325a48c 100644 --- a/app/Services/Quote/SendEmail.php +++ b/app/Services/Quote/SendEmail.php @@ -40,13 +40,14 @@ class SendEmail if (! $this->reminder_template) { $this->reminder_template = $this->quote->calculateTemplate('quote'); } + + $this->quote->service()->markSent()->save(); $this->quote->invitations->each(function ($invitation) { if (! $invitation->contact->trashed() && $invitation->contact->email) { - EmailEntity::dispatchSync($invitation, $invitation->company, $this->reminder_template); + EmailEntity::dispatch($invitation, $invitation->company, $this->reminder_template); } }); - $this->quote->service()->markSent(); } } diff --git a/resources/views/portal/ninja2020/components/entity-documents.blade.php b/resources/views/portal/ninja2020/components/entity-documents.blade.php index efe5e7415db5..b288e9c9209f 100644 --- a/resources/views/portal/ninja2020/components/entity-documents.blade.php +++ b/resources/views/portal/ninja2020/components/entity-documents.blade.php @@ -6,9 +6,13 @@
{{ ctrans('texts.attachments') }}:
@foreach ($entity->documents as $document)