mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 19:14:41 -04:00
Resolve design template
This commit is contained in:
parent
1d28a98a55
commit
bce476977b
@ -12,6 +12,7 @@
|
|||||||
namespace App\Services\Pdf;
|
namespace App\Services\Pdf;
|
||||||
|
|
||||||
use App\Services\Pdf\PdfConfiguration;
|
use App\Services\Pdf\PdfConfiguration;
|
||||||
|
use App\Utils\HtmlEngine;
|
||||||
|
|
||||||
class PdfService
|
class PdfService
|
||||||
{
|
{
|
||||||
@ -20,6 +21,12 @@ class PdfService
|
|||||||
|
|
||||||
public PdfConfiguration $config;
|
public PdfConfiguration $config;
|
||||||
|
|
||||||
|
public PdfBuilder $builder;
|
||||||
|
|
||||||
|
public PdfDesigner $designer;
|
||||||
|
|
||||||
|
public array $html_variables;
|
||||||
|
|
||||||
public function __construct($invitation)
|
public function __construct($invitation)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -27,6 +34,17 @@ class PdfService
|
|||||||
|
|
||||||
$this->config = (new PdfConfiguration($this))->init();
|
$this->config = (new PdfConfiguration($this))->init();
|
||||||
|
|
||||||
|
$this->html_variables = (new HtmlEngine($invitation))->generateLabelsAndValues();
|
||||||
|
|
||||||
|
$this->builder = (new PdfBuilder($this));
|
||||||
|
|
||||||
|
$this->designer = (new PdfDesigner($this))->build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
$this->builder->build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPdf()
|
public function getPdf()
|
||||||
@ -39,4 +57,30 @@ class PdfService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// $state = [
|
||||||
|
// 'template' => $template->elements([
|
||||||
|
// 'client' => $this->client,
|
||||||
|
// 'entity' => $this->entity,
|
||||||
|
// 'pdf_variables' => (array) $this->company->settings->pdf_variables,
|
||||||
|
// '$product' => $design->design->product,
|
||||||
|
// 'variables' => $variables,
|
||||||
|
// ]),
|
||||||
|
// 'variables' => $variables,
|
||||||
|
// 'options' => [
|
||||||
|
// 'all_pages_header' => $this->entity->client->getSetting('all_pages_header'),
|
||||||
|
// 'all_pages_footer' => $this->entity->client->getSetting('all_pages_footer'),
|
||||||
|
// ],
|
||||||
|
// 'process_markdown' => $this->entity->client->company->markdown_enabled,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// $maker = new PdfMakerService($state);
|
||||||
|
|
||||||
|
// $maker
|
||||||
|
// ->design($template)
|
||||||
|
// ->build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -65,4 +65,24 @@ class PdfServiceTest extends TestCase
|
|||||||
$this->assertEquals(2, $service->config->design->id);
|
$this->assertEquals(2, $service->config->design->id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHtmlIsArray()
|
||||||
|
{
|
||||||
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
|
$service = new PdfService($invitation);
|
||||||
|
|
||||||
|
$this->assertIsArray($service->html_variables);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTemplateResolution()
|
||||||
|
{
|
||||||
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
|
$service = new PdfService($invitation);
|
||||||
|
|
||||||
|
$this->assertIsString($service->designer->template);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user