diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 65783bb506e5..8eda7b1c4ded 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -26,6 +26,7 @@ use App\Services\Pdf\PdfDesigner; use App\Services\Pdf\PdfConfiguration; use App\Models\PurchaseOrderInvitation; use App\Models\RecurringInvoiceInvitation; +use App\Jobs\Vendor\CreatePurchaseOrderPdf; class PdfSlot extends Component { @@ -45,13 +46,11 @@ class PdfSlot extends Component private $entity_type; - public $download_button_text; + protected $listeners = ['viewportChanged' => 'getPdf']; public function mount() { MultiDB::setDb($this->db); - - $this->download_button_text = ctrans('texts.download_pdf'); } public function getPdf() @@ -62,11 +61,12 @@ class PdfSlot extends Component public function downloadPdf() { - $this->download_button_text = ctrans('texts.working'); - $file_name = $this->entity->numberFormatter().'.pdf'; - $file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle(); + if($this->entity instanceof \App\Models\PurchaseOrder) + $file = (new CreatePurchaseOrderPdf($this->invitation, $this->invitation->company->db))->rawPdf(); + else + $file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle(); $headers = ['Content-Type' => 'application/pdf']; @@ -74,8 +74,6 @@ class PdfSlot extends Component echo $file; }, $file_name, $headers); - $this->download_button_text = ctrans('texts.download_pdf'); - } public function render() @@ -110,7 +108,6 @@ class PdfSlot extends Component { $html = strtr($string, $this->html_variables['labels']); - $html = strtr($html, $this->html_variables['values']); return $html; @@ -148,20 +145,20 @@ class PdfSlot extends Component if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { foreach($this->settings->pdf_variables->invoice_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'quote'){ foreach($this->settings->pdf_variables->quote_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'credit') { foreach($this->settings->pdf_variables->credit_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'purchase_order'){ foreach($this->settings->pdf_variables->purchase_order_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } return $this->convertVariables($entity_details); diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 94b20c8d0dbb..8b27738e3a54 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -39,7 +39,7 @@ span {
-
{!! $entity_details !!}
+
{!! $entity_details !!}
@@ -118,27 +118,13 @@ span { @endif
- - - - + + - - + + @@ -190,4 +176,51 @@ span { - @endif \ No newline at end of file + @endif + +
-
-
-

{{ ctrans('texts.total') }}

-
-
-
{{ ctrans('texts.total') }} {{ $amount }}
-
-
-

{{ ctrans('texts.balance') }}

-
-
-
{{ ctrans('texts.balance') }} {{ $balance }}