mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 22:34:31 -04:00
Fixes for delivery notes
This commit is contained in:
parent
adb6980c0a
commit
dd070747cf
@ -15,6 +15,7 @@ namespace App\Services\Invoice;
|
|||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\Design;
|
use App\Models\Design;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Services\Pdf\PdfService;
|
||||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||||
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
||||||
use App\Utils\HostedPDF\NinjaPdf;
|
use App\Utils\HostedPDF\NinjaPdf;
|
||||||
@ -54,62 +55,16 @@ class GenerateDeliveryNote
|
|||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$design_id = $this->invoice->design_id
|
|
||||||
? $this->invoice->design_id
|
|
||||||
: $this->decodePrimaryKey($this->invoice->client->getSetting('invoice_design_id'));
|
|
||||||
|
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$file_path = sprintf('%sdelivery_note.pdf', $this->invoice->client->invoice_filepath($invitation));
|
$file_path = sprintf('%sdelivery_note.pdf', $this->invoice->client->invoice_filepath($invitation));
|
||||||
|
|
||||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
$pdf = (new PdfService($invitation, 'delivery_note'))->getPdf();
|
||||||
return (new Phantom)->generate($this->invoice->invitations->first());
|
|
||||||
}
|
|
||||||
|
|
||||||
$design = Design::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));
|
|
||||||
}
|
|
||||||
|
|
||||||
$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' => $html->generateLabelsAndValues(),
|
|
||||||
'process_markdown' => $this->invoice->client->company->markdown_enabled,
|
|
||||||
];
|
|
||||||
|
|
||||||
$maker = new PdfMakerService($state);
|
|
||||||
|
|
||||||
$maker
|
|
||||||
->design($template)
|
|
||||||
->build();
|
|
||||||
|
|
||||||
// Storage::makeDirectory($this->invoice->client->invoice_filepath(), 0775);
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
Storage::disk($this->disk)->put($file_path, $pdf);
|
Storage::disk($this->disk)->put($file_path, $pdf);
|
||||||
|
|
||||||
$maker = null;
|
|
||||||
$state = null;
|
|
||||||
|
|
||||||
return $file_path;
|
return $file_path;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,16 +937,16 @@ class PdfBuilder
|
|||||||
//need to see where we don't pass all these particular variables. try and refactor thisout
|
//need to see where we don't pass all these particular variables. try and refactor thisout
|
||||||
$_variables = array_key_exists('variables', $this->service->options)
|
$_variables = array_key_exists('variables', $this->service->options)
|
||||||
? $this->service->options['variables']
|
? $this->service->options['variables']
|
||||||
: ['values' => ['$this->service->config->entity.public_notes' => $this->service->config->entity->public_notes, '$this->service->config->entity.terms' => $this->service->config->entity->terms, '$this->service->config->entity_footer' => $this->service->config->entity->footer], 'labels' => []];
|
: ['values' => ['$entity.public_notes' => $this->service->config->entity->public_notes, '$entity.terms' => $this->service->config->entity->terms, '$entity_footer' => $this->service->config->entity->footer], 'labels' => []];
|
||||||
|
|
||||||
$variables = $this->service->config->pdf_variables['total_columns'];
|
$variables = $this->service->config->pdf_variables['total_columns'];
|
||||||
|
|
||||||
$elements = [
|
$elements = [
|
||||||
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
|
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
|
||||||
['element' => 'p', 'content' => strtr(str_replace(["labels","values"], ["",""], $_variables['values']['$this->service->config->entity.public_notes']), $_variables), 'properties' => ['data-ref' => 'total_table-public_notes', 'style' => 'text-align: left;']],
|
['element' => 'p', 'content' => strtr(str_replace(["labels","values"], ["",""], $_variables['values']['$entity.public_notes']), $_variables), 'properties' => ['data-ref' => 'total_table-public_notes', 'style' => 'text-align: left;']],
|
||||||
['element' => 'p', 'content' => '', 'properties' => ['style' => 'text-align: left; display: flex; flex-direction: column; page-break-inside: auto;'], 'elements' => [
|
['element' => 'p', 'content' => '', 'properties' => ['style' => 'text-align: left; display: flex; flex-direction: column; page-break-inside: auto;'], 'elements' => [
|
||||||
['element' => 'span', 'content' => '$this->service->config->entity.terms_label: ', 'properties' => ['hidden' => $this->entityVariableCheck('$this->service->config->entity.terms'), 'data-ref' => 'total_table-terms-label', 'style' => 'font-weight: bold; text-align: left; margin-top: 1rem;']],
|
['element' => 'span', 'content' => '$entity.terms_label: ', 'properties' => ['hidden' => $this->entityVariableCheck('$entity.terms'), 'data-ref' => 'total_table-terms-label', 'style' => 'font-weight: bold; text-align: left; margin-top: 1rem;']],
|
||||||
['element' => 'span', 'content' => strtr(str_replace("labels", "", $_variables['values']['$this->service->config->entity.terms']), $_variables['labels']), 'properties' => ['data-ref' => 'total_table-terms', 'style' => 'text-align: left;']],
|
['element' => 'span', 'content' => strtr(str_replace("labels", "", $_variables['values']['$entity.terms']), $_variables['labels']), 'properties' => ['data-ref' => 'total_table-terms', 'style' => 'text-align: left;']],
|
||||||
]],
|
]],
|
||||||
['element' => 'img', 'properties' => ['style' => 'max-width: 50%; height: auto;', 'src' => '$contact.signature', 'id' => 'contact-signature']],
|
['element' => 'img', 'properties' => ['style' => 'max-width: 50%; height: auto;', 'src' => '$contact.signature', 'id' => 'contact-signature']],
|
||||||
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: flex; align-items: flex-start; page-break-inside: auto;'], 'elements' => [
|
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: flex; align-items: flex-start; page-break-inside: auto;'], 'elements' => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user