🐛 Fix invoice preview with custom designs

This commit is contained in:
Clément Gayot 2020-10-22 01:18:50 +02:00
parent 0a0cbba373
commit 5458bf83b0
2 changed files with 9 additions and 5 deletions

View File

@ -196,8 +196,6 @@ class PreviewController extends BaseController
->design($design)
->build();
info($maker->getCompiledHTML(true));
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
DB::rollBack();

View File

@ -19,6 +19,7 @@ use App\Libraries\MultiDB;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\Design;
use App\Services\PdfMaker\Design as PdfDesignModel;
use App\Models\Invoice;
use App\Services\PdfMaker\Design as PdfMakerDesign;
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
@ -87,7 +88,14 @@ class CreateInvoicePdf implements ShouldQueue
$design = Design::find($invoice_design_id);
$html = new HtmlEngine(null, $this->invitation, 'invoice');
$template = new PdfMakerDesign(strtolower($design->name));
if ($design->is_custom) {
$options = [
'custom_partials' => json_decode(json_encode($design->design), true)
];
$template = new PdfMakerDesign(PdfDesignModel::CUSTOM, $options);
} else {
$template = new PdfMakerDesign(strtolower($design->name));
}
$state = [
'template' => $template->elements([
@ -109,8 +117,6 @@ class CreateInvoicePdf implements ShouldQueue
->design($template)
->build();
info($maker->getCompiledHTML());
//todo - move this to the client creation stage so we don't keep hitting this unnecessarily
Storage::makeDirectory($path, 0775);