diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 3d4b56c0988b..9b1bf584d66c 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -163,6 +163,6 @@ class ActivityController extends BaseController return response()->streamDownload(function () use ($pdf) { echo $pdf; - }, $filename); + }, $filename, ['Content-Type' => 'application/pdf']); } } diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 0905bf74605b..fd360b9c8554 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -174,7 +174,7 @@ class InvoiceController extends Controller // return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);; return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); } // enable output of HTTP headers diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index 39f2d5444da0..27deadf8c949 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -96,7 +96,7 @@ class QuoteController extends Controller // return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); } // enable output of HTTP headers diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index c8fb445a4293..6478dd1ebfbc 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -544,7 +544,7 @@ class CreditController extends BaseController return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); break; case 'archive': $this->credit_repository->archive($credit); @@ -596,8 +596,8 @@ class CreditController extends BaseController return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); - // return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); + }, basename($file), ['Content-Type' => 'application/pdf']); + } /** diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 4917e5e55e36..d7645f7b961d 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -672,16 +672,11 @@ class InvoiceController extends BaseController break; case 'download': - // $file = $invoice->pdf_file_path(); - // return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); - $file = $invoice->service()->getInvoicePdf(); - // return response()->download(Storage::get($file), basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); - return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); break; @@ -805,11 +800,9 @@ class InvoiceController extends BaseController $file = $invoice->service()->getInvoicePdf($contact); - // return response()->download(Storage::get($file), basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); - return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); } /** @@ -861,10 +854,9 @@ class InvoiceController extends BaseController $file = $invoice->service()->getInvoiceDeliveryNote($invoice, $invoice->invitations->first()->contact); - // return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); } diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 5eb60418a61b..9e87ba0bc291 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -13,12 +13,14 @@ namespace App\Http\Controllers; use App\Factory\InvoiceFactory; use App\Http\Requests\Invoice\StoreInvoiceRequest; +use App\Http\Requests\Preview\PreviewInvoiceRequest; use App\Jobs\Util\PreviewPdf; use App\Models\Client; use App\Models\ClientContact; use App\Models\Invoice; use App\Models\InvoiceInvitation; use App\Repositories\InvoiceRepository; +use App\Services\PdfMaker\Design as PdfMakerDesign; use App\Services\PdfMaker\Design; use App\Services\PdfMaker\PdfMaker; use App\Utils\HostedPDF\NinjaPdf; @@ -31,7 +33,6 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Lang; use Illuminate\Support\Facades\Response; -use App\Services\PdfMaker\Design as PdfMakerDesign; class PreviewController extends BaseController { @@ -153,7 +154,7 @@ class PreviewController extends BaseController return $this->blankEntity(); } - public function live(StoreInvoiceRequest $request) + public function live(PreviewInvoiceRequest $request) { if(request()->input('entity') == 'invoice'){ $repo = new InvoiceRepository(); diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index a867a7697168..3a073b374afd 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -682,7 +682,7 @@ class QuoteController extends BaseController return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); //return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); @@ -736,11 +736,10 @@ class QuoteController extends BaseController $quote = $invitation->quote; $file = $quote->service()->getQuotePdf($contact); -nlog($file); return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); // return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); } diff --git a/app/Http/Controllers/RecurringInvoiceController.php b/app/Http/Controllers/RecurringInvoiceController.php index aef6b5e2e6ed..3bf2ea4e0809 100644 --- a/app/Http/Controllers/RecurringInvoiceController.php +++ b/app/Http/Controllers/RecurringInvoiceController.php @@ -505,7 +505,7 @@ class RecurringInvoiceController extends BaseController return response()->streamDownload(function () use($file) { echo Storage::get($file); - }, basename($file)); + }, basename($file), ['Content-Type' => 'application/pdf']); } diff --git a/app/Http/Requests/Preview/PreviewInvoiceRequest.php b/app/Http/Requests/Preview/PreviewInvoiceRequest.php new file mode 100644 index 000000000000..e7dc8f147217 --- /dev/null +++ b/app/Http/Requests/Preview/PreviewInvoiceRequest.php @@ -0,0 +1,59 @@ +user()->can('create', Invoice::class); + } + + public function rules() + { + $rules = []; + + $rules['client_id'] = 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id; + + $rules['number'] = ['nullable']; + + return $rules; + } + + protected function prepareForValidation() + { + $input = $this->all(); + + $input = $this->decodePrimaryKeys($input); + + $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + $input['amount'] = 0; + $input['balance'] = 0; + + $this->replace($input); + } +} diff --git a/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php b/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php index 68bbdc11cb7c..9d5cdb31a4bb 100644 --- a/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php +++ b/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php @@ -4,7 +4,7 @@ @keydown.window.escape="sidebarOpen = false" id="main-sidebar"> - @if($client->getSetting('client_portal_enable')) + @if($settings->enable_client_portal) @include('portal.ninja2020.components.general.sidebar.mobile')