diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index 2c01f20bac..a056e7294f 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -20,15 +20,12 @@ use App\Models\Credit; use App\Models\Design; use App\Models\Invoice; use App\Models\Payment; -use App\Services\PdfMaker\Design as PdfMakerDesign; -use App\Services\PdfMaker\PdfMaker; use App\Utils\HostedPDF\NinjaPdf; use App\Utils\HtmlEngine; use App\Utils\Number; use App\Utils\PhantomJS\Phantom; use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesHash; -use App\Utils\Traits\Pdf\PdfMaker as PdfMakerTrait; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Carbon; diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 0c1cf2dc38..db373f6520 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -67,60 +67,66 @@ class GenerateDeliveryNote // return (new \App\Services\Pdf\PdfService($invitation, 'delivery_note'))->boot()->getPdf(); - if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { - return (new Phantom())->generate($this->invoice->invitations->first()); - } + // if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { + // return (new Phantom())->generate($this->invoice->invitations->first()); + // } $design = Design::withTrashed()->find($design_id); - $html = new HtmlEngine($invitation); - if ($design->is_custom) { - $options = ['custom_partials' => json_decode(json_encode($design->design), true)]; - $template = new PdfMakerDesign(PdfMakerDesign::CUSTOM, $options); - } else { - $template = new PdfMakerDesign(strtolower($design->name)); - } - $variables = $html->generateLabelsAndValues(); - $variables['labels']['$entity_label'] = ctrans('texts.delivery_note'); - $variables['labels']['$invoice.date_label'] = ctrans('texts.date'); - $variables['labels']['$invoice.number_label'] = ctrans('texts.number'); + $ps = new \App\Services\Pdf\PdfService($invitation, 'delivery_note'); + return $ps->boot()->getPdf(); - $state = [ - 'template' => $template->elements([ - 'client' => $this->invoice->client, - 'entity' => $this->invoice, - 'pdf_variables' => (array) $this->invoice->company->settings->pdf_variables, - 'contact' => $this->contact, - ], 'delivery_note'), - 'variables' => $variables, - 'options' => [ - 'client' => $this->invoice->client, - 'entity' => $this->invoice, - 'contact' => $this->contact, - ], - 'process_markdown' => $this->invoice->client->company->markdown_enabled, - ]; - $maker = new PdfMakerService($state); - $maker - ->design($template) - ->build(); + // $html = new HtmlEngine($invitation); - if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') { - $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true)); - } else { - $pdf = $this->makePdf(null, null, $maker->getCompiledHTML()); - } + // if ($design->is_custom) { + // $options = ['custom_partials' => json_decode(json_encode($design->design), true)]; + // $template = new PdfMakerDesign(PdfMakerDesign::CUSTOM, $options); + // } else { + // $template = new PdfMakerDesign(strtolower($design->name)); + // } - if (config('ninja.log_pdf_html')) { - info($maker->getCompiledHTML()); - } + // $variables = $html->generateLabelsAndValues(); + // $variables['labels']['$entity_label'] = ctrans('texts.delivery_note'); + // $variables['labels']['$invoice.date_label'] = ctrans('texts.date'); + // $variables['labels']['$invoice.number_label'] = ctrans('texts.number'); - $maker = null; - $state = null; + // $state = [ + // 'template' => $template->elements([ + // 'client' => $this->invoice->client, + // 'entity' => $this->invoice, + // 'pdf_variables' => (array) $this->invoice->company->settings->pdf_variables, + // 'contact' => $this->contact, + // ], 'delivery_note'), + // 'variables' => $variables, + // 'options' => [ + // 'client' => $this->invoice->client, + // 'entity' => $this->invoice, + // 'contact' => $this->contact, + // ], + // 'process_markdown' => $this->invoice->client->company->markdown_enabled, + // ]; - return $pdf; + // $maker = new PdfMakerService($state); + // $maker + // ->design($template) + // ->build(); + + // if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') { + // $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true)); + // } else { + // $pdf = $this->makePdf(null, null, $maker->getCompiledHTML()); + // } + + // if (config('ninja.log_pdf_html')) { + // info($maker->getCompiledHTML()); + // } + + // $maker = null; + // $state = null; + + // return $pdf; } } diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 9991f5a794..0d992a08af 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -1770,6 +1770,11 @@ class PdfBuilder return $elements; } + + $this->service->html_variables['values']['$show_shipping_address_block'] = 'none'; + $this->service->html_variables['values']['$show_shipping_address'] = 'none'; + $this->service->html_variables['values']['$show_shipping_address_visibility'] = 'hidden'; + $elements = [ ['element' => 'div', 'content' => ctrans('texts.delivery_note'), 'properties' => ['data-ref' => 'delivery_note-label', 'style' => 'font-weight: bold; text-transform: uppercase']], ['element' => 'div', 'content' => $this->service->config->client->name, 'show_empty' => false, 'properties' => ['data-ref' => 'delivery_note-client.name']], @@ -1816,7 +1821,7 @@ class PdfBuilder { $elements = []; - if (!$this->service->config->client) { + if (!$this->service->config->client || $this->service->document_type == PdfService::DELIVERY_NOTE) { return $elements; }