mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improvements for variable replacements
This commit is contained in:
parent
a9188bf6e8
commit
872ac11329
@ -1036,16 +1036,19 @@ class PdfBuilder
|
||||
*/
|
||||
public function getTableTotals() :array
|
||||
{
|
||||
|
||||
//need to see where we don't pass all these particular variables. try and refactor thisout
|
||||
$_variables = array_key_exists('variables', $this->service->options)
|
||||
? $this->service->options['variables']
|
||||
: ['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 = array_key_exists('variables', $this->service->options)
|
||||
// ? $this->service->options['variables']
|
||||
// : ['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->html_variables;
|
||||
|
||||
$variables = $this->service->config->pdf_variables['total_columns'];
|
||||
|
||||
$elements = [
|
||||
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
|
||||
['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' => 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' => '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']['$entity.terms']), $_variables['labels']), 'properties' => ['data-ref' => 'total_table-terms', 'style' => 'text-align: left;']],
|
||||
|
@ -266,12 +266,12 @@ class Helpers
|
||||
$_right = '';
|
||||
|
||||
// If right side doesn't have any calculations, replace with raw ranges keyword.
|
||||
if (! Str::contains($right, ['-', '+', '/', '*'])) {
|
||||
if (! Str::contains(str_replace("</", "", $right), ['-', '+', '/', '*'])) {
|
||||
$_right = Carbon::createFromDate($currentDateTime->year, $currentDateTime->month)->translatedFormat('F Y');
|
||||
}
|
||||
|
||||
// If right side contains one of math operations, calculate.
|
||||
if (Str::contains($right, ['+'])) {
|
||||
if (Str::contains(str_replace("</", "", $right), ['+'])) {
|
||||
$operation = preg_match_all('/(?!^-)[+*\/-](\s?-)?/', $right, $_matches);
|
||||
|
||||
$_operation = array_shift($_matches)[0]; // + -
|
||||
@ -306,7 +306,7 @@ class Helpers
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! Str::contains($match, ['-', '+', '/', '*'])) {
|
||||
if (! Str::contains(str_replace("</", "", $match), ['-', '+', '/', '*'])) {
|
||||
$value = preg_replace(
|
||||
sprintf('/%s/', $matches->keys()->first()),
|
||||
$replacements['literal'][$matches->keys()->first()],
|
||||
@ -315,7 +315,7 @@ class Helpers
|
||||
);
|
||||
}
|
||||
|
||||
if (Str::contains($match, ['-', '+', '/', '*'])) {
|
||||
if (Str::contains(str_replace("</", "", $match), ['-', '+', '/', '*'])) {
|
||||
$operation = preg_match_all('/(?!^-)[+*\/-](\s?-)?/', $match, $_matches);
|
||||
|
||||
$_operation = array_shift($_matches)[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user