Skip to content

Commit

Permalink
refs #762 changes all pdf to html render
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Feb 13, 2019
1 parent 92aa7f7 commit e3207d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 44 deletions.
44 changes: 3 additions & 41 deletions app/Http/Controllers/Customers/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ public function printInvoice(Invoice $invoice)
{
$invoice = $this->prepareInvoice($invoice);

$logo = $this->getLogo();

return view($invoice->template_path, compact('invoice', 'logo'));
return view($invoice->template_path, compact('invoice'));
}

/**
Expand All @@ -108,9 +106,8 @@ public function pdfInvoice(Invoice $invoice)
{
$invoice = $this->prepareInvoice($invoice);

$logo = $this->getLogo();

$html = view($invoice->template_path, compact('invoice', 'logo'))->render();
$view = view($invoice->template_path, compact('invoice'))->render();
$html = mb_convert_encoding($view, 'HTML-ENTITIES');

$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
Expand Down Expand Up @@ -147,41 +144,6 @@ protected function prepareInvoice(Invoice $invoice)
return $invoice;
}

protected function getLogo()
{
$logo = '';

$media_id = setting('general.company_logo');

if (setting('general.invoice_logo')) {
$media_id = setting('general.invoice_logo');
}

$media = Media::find($media_id);

if (!empty($media)) {
$path = Storage::path($media->getDiskPath());

if (!is_file($path)) {
return $logo;
}
} else {
$path = asset('public/img/company.png');
}

$image = Image::make($path)->encode()->getEncoded();

if (empty($image)) {
return $logo;
}

$extension = File::extension($path);

$logo = 'data:image/' . $extension . ';base64,' . base64_encode($image);

return $logo;
}

public function link(Invoice $invoice, Request $request)
{
if (empty($invoice)) {
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Expenses/Bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ public function pdfBill(Bill $bill)

$currency_style = true;

$html = view($bill->template_path, compact('bill', 'currency_style'))->render();
$view = view($bill->template_path, compact('bill', 'currency_style'))->render();
$html = mb_convert_encoding($view, 'HTML-ENTITIES');

$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/Incomes/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ public function emailInvoice(Invoice $invoice)

$invoice = $this->prepareInvoice($invoice);

$html = mb_convert_encoding(view($invoice->template_path, compact('invoice'))->render(), 'HTML-ENTITIES');
$view = view($invoice->template_path, compact('invoice'))->render();
$html = mb_convert_encoding($view, 'HTML-ENTITIES');

$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
Expand Down Expand Up @@ -420,7 +421,8 @@ public function pdfInvoice(Invoice $invoice)

$currency_style = true;

$html = view($invoice->template_path, compact('invoice', 'currency_style'))->render();
$view = view($invoice->template_path, compact('invoice', 'currency_style'))->render();
$html = mb_convert_encoding($view, 'HTML-ENTITIES');

$pdf = app('dompdf.wrapper');
$pdf->loadHTML($html);
Expand Down

0 comments on commit e3207d6

Please sign in to comment.