1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Working on client portal

This commit is contained in:
David Bomba 2023-07-10 22:52:03 +10:00
parent 6a2600b7dc
commit 97ce699879
4 changed files with 119 additions and 3 deletions

View File

@ -12,8 +12,14 @@
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Libraries\MultiDB;
use Livewire\Component; 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 class PdfSlot extends Component
{ {
@ -44,6 +50,73 @@ class PdfSlot extends Component
{ {
$this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); $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 = '<div id="company-details"></div>';
$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('<div></div>', '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()
{
} }
} }

View File

@ -102,7 +102,12 @@ class PdfBuilder
$this->document = $document; $this->document = $document;
// $this->xpath = new DOMXPath($document); return $this;
}
public function setDocument($document): self
{
$this->document = $document;
return $this; return $this;
} }
@ -131,6 +136,13 @@ class PdfBuilder
return $this; return $this;
} }
public function setSections($sections): self
{
$this->sections = $sections;
return $this;
}
/** /**
* Generates delivery note sections * Generates delivery note sections
* *
@ -1641,6 +1653,7 @@ class PdfBuilder
public function updateVariables() public function updateVariables()
{ {
$html = strtr($this->getCompiledHTML(), $this->service->html_variables['labels']); $html = strtr($this->getCompiledHTML(), $this->service->html_variables['labels']);
$html = strtr($html, $this->service->html_variables['values']); $html = strtr($html, $this->service->html_variables['values']);

View File

@ -0,0 +1,30 @@
<div>
<div id="company-details">
@foreach($settings->pdf_variables->company_details as $variable)
<p>{{ $variable }}</p>
@endforeach
</div>
<div id="company-address">
@foreach($settings->pdf_variables->company_address as $variable)
<p>{{ $variable }}</p>
@endforeach
</div>
<div id="entity-details"></div>
<div id="user-details"></div>
<div id="product-details"></div>
<div id="task-details"></div>
<div id="totals"></div>
<div id="notes"></div>
<div id="terms"></div>
<div id="footer"></div>
</div>