Tweak values for show/hide shipping
This commit is contained in:
parent
09dffc6920
commit
b607493b94
|
|
@ -20,15 +20,12 @@ use App\Models\Credit;
|
||||||
use App\Models\Design;
|
use App\Models\Design;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
|
||||||
use App\Services\PdfMaker\PdfMaker;
|
|
||||||
use App\Utils\HostedPDF\NinjaPdf;
|
use App\Utils\HostedPDF\NinjaPdf;
|
||||||
use App\Utils\HtmlEngine;
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use App\Utils\PhantomJS\Phantom;
|
use App\Utils\PhantomJS\Phantom;
|
||||||
use App\Utils\Traits\MakesDates;
|
use App\Utils\Traits\MakesDates;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\Pdf\PdfMaker as PdfMakerTrait;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,60 +67,66 @@ class GenerateDeliveryNote
|
||||||
|
|
||||||
// return (new \App\Services\Pdf\PdfService($invitation, 'delivery_note'))->boot()->getPdf();
|
// return (new \App\Services\Pdf\PdfService($invitation, 'delivery_note'))->boot()->getPdf();
|
||||||
|
|
||||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
// if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||||
return (new Phantom())->generate($this->invoice->invitations->first());
|
// return (new Phantom())->generate($this->invoice->invitations->first());
|
||||||
}
|
// }
|
||||||
|
|
||||||
$design = Design::withTrashed()->find($design_id);
|
$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();
|
$ps = new \App\Services\Pdf\PdfService($invitation, 'delivery_note');
|
||||||
$variables['labels']['$entity_label'] = ctrans('texts.delivery_note');
|
return $ps->boot()->getPdf();
|
||||||
$variables['labels']['$invoice.date_label'] = ctrans('texts.date');
|
|
||||||
$variables['labels']['$invoice.number_label'] = ctrans('texts.number');
|
|
||||||
|
|
||||||
$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);
|
// $html = new HtmlEngine($invitation);
|
||||||
$maker
|
|
||||||
->design($template)
|
|
||||||
->build();
|
|
||||||
|
|
||||||
if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') {
|
// if ($design->is_custom) {
|
||||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
// $options = ['custom_partials' => json_decode(json_encode($design->design), true)];
|
||||||
} else {
|
// $template = new PdfMakerDesign(PdfMakerDesign::CUSTOM, $options);
|
||||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML());
|
// } else {
|
||||||
}
|
// $template = new PdfMakerDesign(strtolower($design->name));
|
||||||
|
// }
|
||||||
|
|
||||||
if (config('ninja.log_pdf_html')) {
|
// $variables = $html->generateLabelsAndValues();
|
||||||
info($maker->getCompiledHTML());
|
// $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 = [
|
||||||
$state = null;
|
// '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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1770,6 +1770,11 @@ class PdfBuilder
|
||||||
return $elements;
|
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 = [
|
$elements = [
|
||||||
['element' => 'div', 'content' => ctrans('texts.delivery_note'), 'properties' => ['data-ref' => 'delivery_note-label', 'style' => 'font-weight: bold; text-transform: uppercase']],
|
['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']],
|
['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 = [];
|
$elements = [];
|
||||||
|
|
||||||
if (!$this->service->config->client) {
|
if (!$this->service->config->client || $this->service->document_type == PdfService::DELIVERY_NOTE) {
|
||||||
return $elements;
|
return $elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue