From f37620300b4f15424e9120acf70179f09e48eca5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 11 Jul 2023 17:18:12 +1000 Subject: [PATCH] Working on client portal --- app/Http/Livewire/PdfSlot.php | 89 ++++++++++++++----- .../components/html-viewer.blade.php | 33 ++----- .../components/livewire/pdf-slot.blade.php | 1 + 3 files changed, 76 insertions(+), 47 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 8942eb0d7596..b13fd1a24a0c 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -43,18 +43,32 @@ class PdfSlot extends Component return render('components.livewire.pdf-slot', [ 'invitation' => $this->invitation, 'entity' => $this->entity, + 'data' => $this->invitation->company->settings ]); } public function getPdf() { - $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + // $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); } public function getHtml() + { + $pdf_service = new PdfService($this->invitation); + + $pdf_service->config = (new PdfConfiguration($pdf_service))->init(); + + $pdf_service->html_variables = $pdf_service->config->client ? + (new HtmlEngine($this->invitation))->generateLabelsAndValues() : + (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); + + + } + + public function getHtmlX() { $pdf_service = new PdfService($this->invitation); @@ -66,33 +80,66 @@ class PdfSlot extends Component (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); $pdf_service->designer = (new PdfDesigner($pdf_service)); - $pdf_service->designer->template = '
'; $pdf_service->builder = (new PdfBuilder($pdf_service)); - $section = [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $pdf_service->builder->companyDetails(), - ] - ]; + $data = []; - $document = new \DOMDocument(); - $document->validateOnParse = true; - @$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8')); + foreach(['company-details', 'company-address','client-details','entity-details','product-table','table-totals'] as $item) { - $pdf_service->builder->document = $document; - $pdf_service->builder->sections = $section; - $html = $pdf_service->builder - ->getEmptyElements() - ->updateElementProperties() - ->updateVariables(); + $pdf_service->designer->template = '
'; - $pdf_service->builder->document->removeChild($pdf_service->builder->document->doctype); - $pdf_service->builder->document->replaceChild($pdf_service->builder->document->firstChild->firstChild->firstChild, $pdf_service->builder->document->firstChild); - - nlog($pdf_service->builder->document->saveHTML()); + match($item){ + 'company-details' => $block = $pdf_service->builder->companyDetails(), + 'company-address' => $block = $pdf_service->builder->companyAddress(), + 'client-details' => $block = $pdf_service->builder->clientDetails(), + 'entity-details' => $block = $pdf_service->builder->invoiceDetails(), + 'product-table' => $block = $this->productTable(), + 'table-totals' => $block = $pdf_service->builder->getTableTotals(), + default => $block = [], + }; + + $section = [ + $item => [ + 'id' => $item, + 'elements' => $block, + ] + ]; + + $document = new \DOMDocument(); + $document->validateOnParse = true; + @$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8')); + + $pdf_service->builder->document = $document; + $pdf_service->builder->sections = $section; + + $html = $pdf_service->builder + ->getEmptyElements() + ->updateElementProperties() + ->updateVariables(); + + // $pdf_service->builder->document->removeChild($pdf_service->builder->document->doctype); + // $pdf_service->builder->document->replaceChild($pdf_service->builder->document->firstChild->firstChild->firstChild, $pdf_service->builder->document->firstChild); + + $data[$item] = $pdf_service->builder->document->saveHTML(); + + $section = []; + } + // nlog($pdf_service->builder->document->saveHTML()); + + nlog($data); + + return $data; + } + + private function productTable() + { } + + private function sectionBuilder($tag) + { + + } } diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 2221732931fd..fad5cb38c549 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -1,30 +1,11 @@ +
+
-
- @foreach($settings->pdf_variables->company_details as $variable) -

{{ $variable }}

+
+ @foreach($data->pdf_variables->company_details as $cd) +
{{ $cd }}
@endforeach -
- - -
- @foreach($settings->pdf_variables->company_address as $variable) -

{{ $variable }}

- @endforeach -
- -
- -
- -
+ +
-
- -
- -
- -
- -
\ No newline at end of file diff --git a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php index bd8885707fe8..d37fcd773640 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -41,3 +41,4 @@ @endif + @include('portal.ninja2020.components.html-viewer', ['data' => $data])