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}
{$variable}_label
{$variable}
{$variable}_label
{$variable}
{$variable}_label
{$variable}
{$variable}_label
{$variable}
{$variable}_label
{$variable}
{$variable}_label
{$variable}
{$variable}_label
{$variable}
-
-
-
-
- {{ ctrans('texts.total') }} - |
+ |
{{ ctrans('texts.total') }} | {{ $amount }} |
-
-
-
-
- {{ ctrans('texts.balance') }} - |
+ |
{{ ctrans('texts.balance') }} | {{ $balance }} |