mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Remodelling data for templates
This commit is contained in:
parent
72e699a045
commit
c5d94a7c2e
File diff suppressed because one or more lines are too long
@ -111,7 +111,6 @@ class TemplateService
|
||||
$this->data = $tm->engines;
|
||||
$this->variables = $tm->variables[0];
|
||||
|
||||
nlog($this->data);
|
||||
|
||||
$this->parseNinjaBlocks()
|
||||
->parseVariables();
|
||||
@ -151,7 +150,8 @@ class TemplateService
|
||||
$template = $template->render($this->data);
|
||||
|
||||
$f = $this->document->createDocumentFragment();
|
||||
$f->appendXML($template);
|
||||
nlog($template);
|
||||
$f->appendXML(html_entity_decode($template));
|
||||
$replacements[] = $f;
|
||||
|
||||
}
|
||||
@ -219,7 +219,7 @@ class TemplateService
|
||||
$html .= $this->template->design->body;
|
||||
$html .= $this->template->design->footer;
|
||||
|
||||
@$this->document->loadHTML($html);
|
||||
@$this->document->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
||||
return $this;
|
||||
|
||||
@ -240,7 +240,7 @@ class TemplateService
|
||||
$html .= $partials['design']['body'];
|
||||
$html .= $partials['design']['footer'];
|
||||
|
||||
@$this->document->loadHTML($html);
|
||||
@$this->document->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
||||
return $this;
|
||||
|
||||
@ -400,7 +400,7 @@ class TemplateService
|
||||
return $invoices['data'];
|
||||
}
|
||||
|
||||
private function transformPayment(Payment $payment): array
|
||||
private function transformPayment(Payment $payment): array
|
||||
{
|
||||
|
||||
$data = [];
|
||||
@ -530,22 +530,29 @@ private function transformPayment(Payment $payment): array
|
||||
*/
|
||||
public function processPayments($payments): array
|
||||
{
|
||||
$it = new PaymentTransformer();
|
||||
$it->setDefaultIncludes(['client','invoices','paymentables']);
|
||||
$manager = new Manager();
|
||||
$manager->parseIncludes(['client','invoices','paymentables']);
|
||||
$resource = new \League\Fractal\Resource\Collection($payments, $it, null);
|
||||
$resources = $manager->createData($resource)->toArray();
|
||||
|
||||
foreach($resources['data'] as $key => $resource) {
|
||||
$payments = $payments->map(function ($payment) {
|
||||
// nlog(microtime(true));
|
||||
return $this->transformPayment($payment);
|
||||
})->toArray();
|
||||
|
||||
$resources['data'][$key]['client'] = $resource['client']['data'] ?? [];
|
||||
$resources['data'][$key]['client']['contacts'] = $resource['client']['data']['contacts']['data'] ?? [];
|
||||
$resources['data'][$key]['invoices'] = $invoice['invoices']['data'] ?? [];
|
||||
return $payments;
|
||||
// $it = new PaymentTransformer();
|
||||
// $it->setDefaultIncludes(['client','invoices','paymentables']);
|
||||
// $manager = new Manager();
|
||||
// $manager->parseIncludes(['client','invoices','paymentables']);
|
||||
// $resource = new \League\Fractal\Resource\Collection($payments, $it, null);
|
||||
// $resources = $manager->createData($resource)->toArray();
|
||||
|
||||
}
|
||||
// foreach($resources['data'] as $key => $resource) {
|
||||
|
||||
return $resources['data'];
|
||||
// $resources['data'][$key]['client'] = $resource['client']['data'] ?? [];
|
||||
// $resources['data'][$key]['client']['contacts'] = $resource['client']['data']['contacts']['data'] ?? [];
|
||||
// $resources['data'][$key]['invoices'] = $invoice['invoices']['data'] ?? [];
|
||||
|
||||
// }
|
||||
|
||||
// return $resources['data'];
|
||||
|
||||
}
|
||||
|
||||
|
@ -132,9 +132,9 @@ class TemplateTest extends TestCase
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ invoice.number }}</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ invoice.date }}</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ invoice.due_date }}</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ invoice.amount|format_currency("EUR") }}</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ invoice.amount }}</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium"></td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ invoice.balance|format_currency("EUR") }}</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ invoice.balance }}</td>
|
||||
</tr>
|
||||
|
||||
{% for payment in invoice.payments|filter(payment => payment.is_deleted == false) %}
|
||||
@ -146,10 +146,10 @@ class TemplateTest extends TestCase
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">{{ payment.date }}</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium"></td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium">
|
||||
{% if pivot.amount > 0 %}
|
||||
{{ pivot.amount|format_currency("EUR") }} - {{ payment.type.name }}
|
||||
{% if pivot.amount_raw > 0 %}
|
||||
{{ pivot.amount }} - {{ payment.type.name }}
|
||||
{% else %}
|
||||
({{ pivot.refunded|format_currency("EUR") }})
|
||||
({{ pivot.refunded }})
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-6 py-4 font-medium"></td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user