Display PDF

This commit is contained in:
David Bomba 2019-09-05 09:52:49 +10:00
parent 76ba0624bc
commit 374cc88c06
5 changed files with 37 additions and 9 deletions

View File

@ -50,7 +50,7 @@ class InvoiceController extends Controller
if (request()->ajax()) {
return DataTables::of($invoices)->addColumn('action', function ($invoice) {
return '<a href="/client/invoices/'. $invoice->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
return '<a href="/client/invoices/'. $invoice->hashed_id .'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
})
->addColumn('checkbox', function ($invoice){
return '<input type="checkbox" name="hashed_ids[]" value="'. $invoice->hashed_id .'"/>';
@ -90,7 +90,7 @@ class InvoiceController extends Controller
'invoice' => $invoice
];
return view('portal.default.invoices.show', $invoice);
return view('portal.default.invoices.show', $data);
}
/**

View File

@ -11,6 +11,7 @@
namespace App\Models;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Helpers\Invoice\InvoiceCalc;
use App\Models\Currency;
use App\Models\Filterable;
@ -246,6 +247,7 @@ class Invoice extends BaseModel
* Returns the template for the invoice
*
* @return string Either the template view, OR the template HTML string
* @todo this needs attention, invoice->settings needs clarification
*/
public function design() :string
{
@ -265,4 +267,17 @@ class Invoice extends BaseModel
return $invoice_calc->build();
}
public function pdf_url()
{
$public_path = 'storage/' . $this->client->client_hash . '/invoices/'. $this->invoice_number . '.pdf';
$storage_path = 'public/' . $this->client->client_hash . '/invoices/'. $this->invoice_number . '.pdf';
if(!Storage::exists($storage_path)) {
event(new InvoiceWasUpdated($this));
}
return $public_path;
}
}

View File

@ -29,6 +29,7 @@
"laravel/framework": "5.8.*",
"laravel/socialite": "^3.1",
"laravel/tinker": "^1.0",
"laravelcollective/html": "5.8.*",
"league/fractal": "^0.17.0",
"league/omnipay": "^3",
"nwidart/laravel-modules": "^4.0",
@ -42,8 +43,7 @@
"webpatser/laravel-countries": "dev-master#75992ad",
"wildbit/postmark-php": "^2.6",
"yajra/laravel-datatables-html": "^4.0",
"yajra/laravel-datatables-oracle": "~9.0",
"laravelcollective/html": "5.8.*"
"yajra/laravel-datatables-oracle": "~9.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",

View File

@ -3,9 +3,22 @@
<main class="main">
<div class="container-fluid">
<object id="pdfObject" type="application/pdf" style="display:block;background-color:#525659;border:solid 2px #9a9a9a;" frameborder="1" width="100%" height="1180px"></object>
<div id="pdfCanvas" style="display:none;width:100%;background-color:#525659;border:solid 2px #9a9a9a;padding-top:40px;text-align:center">
<canvas id="theCanvas" style="max-width:100%;border:solid 1px #CCCCCC;"></canvas>
<div class="col-md-12 mt-4">
<div class="float-right">
<button class="btn btn-primary">{{ ctrans('texts.pay_now') }}</button>
</div>
</div>
<div class="col-md-12 mt-4">
<embed src="{{ asset($invoice->pdf_url()) }}#toolbar=1&navpanes=1&scrollbar=1" type="application/pdf" width="100%" height="1180px" />
<div id="pdfCanvas" style="display:none;width:100%;background-color:#525659;border:solid 2px #9a9a9a;padding-top:40px;text-align:center">
<canvas id="theCanvas" style="max-width:100%;border:solid 1px #CCCCCC;"></canvas>
</div>
</div>
</div>

View File

@ -18,8 +18,8 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c
Route::get('invoices', 'ClientPortal\InvoiceController@index')->name('invoices.index');
Route::post('invoices/payment', 'ClientPortal\InvoiceController@bulk')->name('invoices.bulk');
Route::get('invoice/{invoice}', 'ClientPortal\InvoiceController@show')->name('invoice.show');
Route::get('invoice/{invoice_invitation}', 'ClientPortal\InvoiceController@show')->name('invoice.show_invitation');
Route::get('invoices/{invoice}', 'ClientPortal\InvoiceController@show')->name('invoice.show');
Route::get('invoices/{invoice_invitation}', 'ClientPortal\InvoiceController@show')->name('invoice.show_invitation');
Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index');