mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
- Accept every design as CUSTOM in PreviewController
- Logic for excluding elements in table footer - PdfMaker will now return plain HTML + str_replace filter - HTMLEngine updated variables and aliases - Added 'payment_due' translation - Hipster: Updated variables
This commit is contained in:
parent
455c604ecd
commit
6288529907
@ -173,14 +173,7 @@ class PreviewController extends BaseController
|
||||
|
||||
$html = new HtmlEngine(null, $invoice->invitations()->first(), 'invoice');
|
||||
|
||||
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);
|
||||
$design = new Design(Design::CUSTOM, ['custom_partials' => request()->design['design']]);
|
||||
|
||||
$state = [
|
||||
'template' => $design->elements([
|
||||
|
@ -67,7 +67,7 @@ class Design extends BaseDesign
|
||||
: config('ninja.designs.base_path');
|
||||
|
||||
return file_get_contents(
|
||||
$path.$this->design
|
||||
$path . $this->design
|
||||
);
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ class Design extends BaseDesign
|
||||
|
||||
foreach ($variables as $variable) {
|
||||
$elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'elements' => [
|
||||
['element' => 'th', 'content' => $variable.'_label'],
|
||||
['element' => 'th', 'content' => $variable . '_label'],
|
||||
['element' => 'th', 'content' => $variable],
|
||||
]];
|
||||
}
|
||||
@ -187,7 +187,7 @@ class Design extends BaseDesign
|
||||
$elements = [];
|
||||
|
||||
foreach ($this->context['pdf_variables']["{$this->type}_columns"] as $column) {
|
||||
$elements[] = ['element' => 'th', 'content' => $column.'_label'];
|
||||
$elements[] = ['element' => 'th', 'content' => $column . '_label'];
|
||||
}
|
||||
|
||||
return $elements;
|
||||
@ -226,6 +226,22 @@ class Design extends BaseDesign
|
||||
]],
|
||||
];
|
||||
|
||||
foreach (['discount', 'custom_surcharge1', 'custom_surcharge2', 'custom_surcharge3', 'custom_surcharge4'] as $property) {
|
||||
$variable = sprintf('%s%s', '$', $property);
|
||||
|
||||
if (
|
||||
!is_null($this->entity->{$property}) ||
|
||||
!empty($this->entity->{$property}) ||
|
||||
$this->entity->{$property} !== 0
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$variables = array_filter($variables, function ($m) use ($variable) {
|
||||
return $m != $variable;
|
||||
});
|
||||
}
|
||||
|
||||
foreach ($variables as $variable) {
|
||||
if ($variable == '$total_taxes' || $variable == '$line_taxes') {
|
||||
continue;
|
||||
@ -233,7 +249,7 @@ class Design extends BaseDesign
|
||||
|
||||
$elements[] = ['element' => 'div', 'elements' => [
|
||||
['element' => 'span', 'content' => 'This is placeholder for the 3rd fraction of element.', 'properties' => ['style' => 'opacity: 0%']], // Placeholder for fraction of element (3fr)
|
||||
['element' => 'span', 'content' => $variable.'_label'],
|
||||
['element' => 'span', 'content' => $variable . '_label'],
|
||||
['element' => 'span', 'content' => $variable],
|
||||
]];
|
||||
}
|
||||
|
@ -79,7 +79,9 @@ trait DesignHelpers
|
||||
$document->importNode($element, true)
|
||||
);
|
||||
|
||||
return $document->saveXML();
|
||||
$html = $this->document->saveHTML();
|
||||
|
||||
return str_replace('%24', '$', $html);
|
||||
}
|
||||
|
||||
return '';
|
||||
|
@ -71,14 +71,8 @@ class PdfMaker
|
||||
|
||||
public function getCompiledHTML($final = false)
|
||||
{
|
||||
if ($final) {
|
||||
$html = $this->document->saveXML();
|
||||
|
||||
$filtered = strtr($html, $this->filters);
|
||||
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
return $this->document->saveXML();
|
||||
$html = $this->document->saveHTML();
|
||||
|
||||
return str_replace('%24', '$', $html);
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ class HtmlEngine
|
||||
//$data['$invoice_date'] = ['value' => $this->date ?: ' ', 'label' => ctrans('texts.invoice_date')];
|
||||
$data['$invoice.date'] = &$data['$date'];
|
||||
$data['$due_date'] = ['value' => $this->entity->due_date ?: ' ', 'label' => ctrans('texts.'.$this->entity_string.'_due_date')];
|
||||
$data['$payment_due'] = ['value' => $this->entity->due_date ?: ' ', 'label' => ctrans('texts.payment_due')];
|
||||
$data['$invoice.due_date'] = &$data['$due_date'];
|
||||
$data['$invoice.number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
|
||||
$data['$invoice.po_number'] = ['value' => $this->entity->po_number ?: ' ', 'label' => ctrans('texts.po_number')];
|
||||
@ -154,6 +155,7 @@ class HtmlEngine
|
||||
$data['$partial_due'] = ['value' => Number::formatMoney($this->entity->partial, $this->client) ?: ' ', 'label' => ctrans('texts.partial_due')];
|
||||
$data['$total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.total')];
|
||||
$data['$amount'] = &$data['$total'];
|
||||
$data['$amount_due'] = ['value' => &$data['$total']['value'], 'label' => ctrans('texts.amount_due')];
|
||||
$data['$quote.total'] = &$data['$total'];
|
||||
$data['$invoice.total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.invoice_total')];
|
||||
$data['$invoice.amount'] = &$data['$total'];
|
||||
@ -275,10 +277,10 @@ class HtmlEngine
|
||||
$data['$company3'] = ['value' => $this->settings->custom_value3 ?: ' ', 'label' => $this->makeCustomField('company3')];
|
||||
$data['$company4'] = ['value' => $this->settings->custom_value4 ?: ' ', 'label' => $this->makeCustomField('company4')];
|
||||
|
||||
$data['$custom_surcharge1'] = ['value' => $this->entity->custom_surcharge1, 'label' => $this->makeCustomField('custom_surcharge1')];
|
||||
$data['$custom_surcharge2'] = ['value' => $this->entity->custom_surcharge2, 'label' => $this->makeCustomField('custom_surcharge2')];
|
||||
$data['$custom_surcharge3'] = ['value' => $this->entity->custom_surcharge3, 'label' => $this->makeCustomField('custom_surcharge3')];
|
||||
$data['$custom_surcharge4'] = ['value' => $this->entity->custom_surcharge4, 'label' => $this->makeCustomField('custom_surcharge4')];
|
||||
$data['$custom_surcharge1'] = ['value' => $this->entity->custom_surcharge1 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge1')];
|
||||
$data['$custom_surcharge2'] = ['value' => $this->entity->custom_surcharge2 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge2')];
|
||||
$data['$custom_surcharge3'] = ['value' => $this->entity->custom_surcharge3 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge3')];
|
||||
$data['$custom_surcharge4'] = ['value' => $this->entity->custom_surcharge4 ?: ' ', 'label' => $this->makeCustomField('custom_surcharge4')];
|
||||
|
||||
$data['$product.date'] = ['value' => '', 'label' => ctrans('texts.date')];
|
||||
$data['$product.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
|
||||
|
@ -3266,4 +3266,6 @@ return [
|
||||
'add_payment_method_first' => 'add payment method',
|
||||
|
||||
'no_items_selected' => 'No items selected.',
|
||||
|
||||
'payment_due' => 'Payment due',
|
||||
];
|
||||
|
@ -185,8 +185,8 @@
|
||||
<span class="entity-property-value">$entity_number</span>
|
||||
</span>
|
||||
<span>
|
||||
<span class="entity-property-label">$entity_date_label:</span>
|
||||
<span class="entity-property-value">$entity_date</span>
|
||||
<span class="entity-property-label">$date_label:</span>
|
||||
<span class="entity-property-value">$date</span>
|
||||
</span>
|
||||
<span>
|
||||
<span class="entity-property-label">$payment_due_label:</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user