Fixes for client portal enabled and content type

This commit is contained in:
David Bomba 2021-07-26 08:22:29 +10:00
parent ecd2525fd8
commit a28aa9f7ec
10 changed files with 75 additions and 24 deletions

View File

@ -163,6 +163,6 @@ class ActivityController extends BaseController
return response()->streamDownload(function () use ($pdf) {
echo $pdf;
}, $filename);
}, $filename, ['Content-Type' => 'application/pdf']);
}
}

View File

@ -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

View File

@ -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

View File

@ -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']);
}
/**

View File

@ -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']);
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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']);
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Requests\Preview;
use App\Http\Requests\Request;
use App\Http\ValidationRules\Project\ValidProjectForClient;
use App\Models\Invoice;
use App\Utils\Traits\CleanLineItems;
use App\Utils\Traits\MakesHash;
use Illuminate\Validation\Rule;
class PreviewInvoiceRequest extends Request
{
use MakesHash;
use CleanLineItems;
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return auth()->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);
}
}

View File

@ -4,7 +4,7 @@
@keydown.window.escape="sidebarOpen = false"
id="main-sidebar">
@if($client->getSetting('client_portal_enable'))
@if($settings->enable_client_portal)
<!-- Off-canvas menu for mobile -->
@include('portal.ninja2020.components.general.sidebar.mobile')