diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 9b52146a3412..6a4aae34799a 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -12,8 +12,14 @@ namespace App\Http\Livewire; -use App\Libraries\MultiDB; use Livewire\Component; +use App\Utils\HtmlEngine; +use App\Libraries\MultiDB; +use App\Utils\VendorHtmlEngine; +use App\Services\Pdf\PdfBuilder; +use App\Services\Pdf\PdfService; +use App\Services\Pdf\PdfDesigner; +use App\Services\Pdf\PdfConfiguration; class PdfSlot extends Component { @@ -44,6 +50,73 @@ class PdfSlot extends Component { $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + $pdf_service = new PdfService($this->invitation); + + + // $company_details = $pdf_service->config->settings->pdf_variables->company_details; + + + $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(); + + $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(), + ] +]; + + + +$document = new \DOMDocument(); +$document->validateOnParse = true; +@$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); +$pdf_service->builder->document = $document; + +$pdf_service->builder->sections = $section; + +$html = $pdf_service->builder + ->getEmptyElements() + ->updateElementProperties() + ->updateVariables(); + +nlog($html->getCompiledHTML()); + + + + + // nlog($section); + + // $document = new \DOMDocument(); + // @$document->loadHTML(mb_convert_encoding('
', 'HTML-ENTITIES', 'UTF-8')); + // $pdf_service->designer->template = ''; + // $pdf_service->builder->document = $document; + + // $pdf_service->builder + // ->sections = $section; + + // nlog($pdf_service->builder->sections); + + // $html = $pdf_service->builder + // ->getEmptyElements() + // ->updateElementProperties() + // ->updateVariables(); + + // nlog($html->getCompiledHTML()); + } + + public function getHtml() + { + } } diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 78d8d38fb2a9..0e55f97433f7 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -102,7 +102,12 @@ class PdfBuilder $this->document = $document; - // $this->xpath = new DOMXPath($document); + return $this; + } + + public function setDocument($document): self + { + $this->document = $document; return $this; } @@ -131,6 +136,13 @@ class PdfBuilder return $this; } + public function setSections($sections): self + { + $this->sections = $sections; + + return $this; + } + /** * Generates delivery note sections * @@ -1641,6 +1653,7 @@ class PdfBuilder public function updateVariables() { + $html = strtr($this->getCompiledHTML(), $this->service->html_variables['labels']); $html = strtr($html, $this->service->html_variables['values']); diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php new file mode 100644 index 000000000000..2221732931fd --- /dev/null +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -0,0 +1,30 @@ +
+
+ @foreach($settings->pdf_variables->company_details as $variable) +

{{ $variable }}

+ @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 05b2ef44b044..bd8885707fe8 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -40,4 +40,4 @@ @endif - \ No newline at end of file +