diff --git a/app/Listeners/Invoice/CreateInvoicePdf.php b/app/Listeners/Invoice/CreateInvoicePdf.php index 3ef7f5a5de84..18649a739415 100644 --- a/app/Listeners/Invoice/CreateInvoicePdf.php +++ b/app/Listeners/Invoice/CreateInvoicePdf.php @@ -57,7 +57,7 @@ class CreateInvoicePdf } - private function makePdf($header, $footer, $html, $pdf) + private function makePdf($header, $footer, $html, $pdf) : void { Browsershot::html($html) //->showBrowserHeaderAndFooter() @@ -68,8 +68,20 @@ class CreateInvoicePdf ->savePdf($pdf); } - private function generateInvoiceHtml($template, $invoice) + /** + * Generate the HTML invoice parsing variables + * and generating the final invoice HTML + * + * @param string $template either the path to the design template, OR the full design template string + * @param Collection $invoice The invoice object + * @return string The invoice string in HTML format + */ + private function generateInvoiceHtml($template, $invoice) :string { + //swap labels + + $html = view(.$template, $invoice)->render(); + return view('pdf.stub', $html); } } diff --git a/app/Models/Presenters/ClientPresenter.php b/app/Models/Presenters/ClientPresenter.php index bc5055a5dac0..b2f301b51fe1 100644 --- a/app/Models/Presenters/ClientPresenter.php +++ b/app/Models/Presenters/ClientPresenter.php @@ -47,6 +47,27 @@ class ClientPresenter extends EntityPresenter return $str; } + public function shipping_address() + { + $str = ''; + $client = $this->entity; + + if ($address1 = $client->shipping_address1) { + $str .= e($address1) . '
'; + } + if ($address2 = $client->shipping_address2) { + $str .= e($address2) . '
'; + } + if ($cityState = $this->getCityState()) { + $str .= e($cityState) . '
'; + } + if ($country = $client->country) { + $str .= e($country->name) . '
'; + } + + return $str; + } + } diff --git a/resources/views/pdf/stub.blade.php b/resources/views/pdf/stub.blade.php new file mode 100644 index 000000000000..d05847828592 --- /dev/null +++ b/resources/views/pdf/stub.blade.php @@ -0,0 +1 @@ +{!! $pdf !!} \ No newline at end of file