mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Engine for editing templates
This commit is contained in:
parent
2e66a4df83
commit
14dc3ea2aa
@ -173,7 +173,11 @@ class PreviewController extends BaseController
|
||||
|
||||
$html = new HtmlEngine(null, $invoice->invitations()->first(), 'invoice');
|
||||
|
||||
$design = new Design(strtolower(request()->design['name']));
|
||||
if (isset(request()->design['name'])) {
|
||||
$design = new Design(strtolower(request()->design['name']));
|
||||
} else {
|
||||
$design = new Design(Design::CUSTOM, ['custom_partials' => request()->design['design']]);
|
||||
}
|
||||
|
||||
// $designer = new Designer($entity_obj, $design_object, $entity_obj->client->getSetting('pdf_variables'), lcfirst($entity));
|
||||
// $html = $this->generateEntityHtml($designer, $entity_obj);
|
||||
@ -193,7 +197,7 @@ class PreviewController extends BaseController
|
||||
->design($design)
|
||||
->build();
|
||||
|
||||
info($maker->getCompiledHTML(true));
|
||||
// info($maker->getCompiledHTML(true));
|
||||
|
||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
||||
|
||||
|
@ -45,6 +45,7 @@ class Design extends BaseDesign
|
||||
const MODERN = 'modern';
|
||||
const PLAIN = 'plain';
|
||||
const PLAYFUL = 'playful';
|
||||
const CUSTOM = 'custom';
|
||||
|
||||
public function __construct(string $design = null, array $options = [])
|
||||
{
|
||||
@ -55,6 +56,12 @@ class Design extends BaseDesign
|
||||
|
||||
public function html(): ?string
|
||||
{
|
||||
if ($this->design == 'custom.html') {
|
||||
return $this->composeFromPartials(
|
||||
$this->options['custom_partials']
|
||||
);
|
||||
}
|
||||
|
||||
$path = isset($this->options['custom_path'])
|
||||
? $this->options['custom_path']
|
||||
: config('ninja.designs.base_path');
|
||||
|
@ -186,4 +186,15 @@ trait DesignHelpers
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function composeFromPartials(array $partials)
|
||||
{
|
||||
$html = '';
|
||||
|
||||
$html .= $partials['header'];
|
||||
$html .= $partials['body'];
|
||||
$html .= $partials['footer'];
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user