1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

wip with table body

This commit is contained in:
Benjamin Beganović 2020-08-03 13:29:57 +02:00
parent 184f60785f
commit efd698c9c5

View File

@ -89,6 +89,33 @@ class Plain
{
$elements = [];
if (isset($this->context['product-table-columns']['$product.tax'])) {
$line_items = collect($this->invoice->line_items);
$tax1 = $line_items->where('tax_name1', '<>', '')->where('type_id', 1)->count();
$tax2 = $line_items->where('tax_name2', '<>', '')->where('type_id', 1)->count();
$tax3 = $line_items->where('tax_name3', '<>', '')->where('type_id', 1)->count();
$taxes = [];
if ($tax1 > 0) {
array_push($taxes, '$product.tax_rate1');
}
if ($tax2 > 0) {
array_push($taxes, '$product.tax_rate2');
}
if ($tax3 > 0) {
array_push($taxes, '$product.tax_rate3');
}
$key = array_search('$product.tax', $this->context['product-table-columns'], true);
if ($key) {
array_splice($this->context['product-table-columns'], $key, 1, $taxes);
}
}
foreach ($this->context['product-table-columns'] as $column) {
$elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'px-4 py-2']];
}
@ -109,10 +136,14 @@ class Plain
foreach ($items as $row) {
$element = ['element' => 'tr', 'content' => '', 'elements' => []];
foreach ($row as $child) {
$element['elements'][] = ['element' => 'td', 'content' => $child, 'properties' => ['class' => 'border-t-2 border-b border-gray-200 px-4 py-4']];
foreach ($this->context['product-table-columns'] as $key => $cell) {
$element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'border-t-2 border-b border-gray-200 px-4 py-4']];
}
// foreach ($row as $child) {
// $element['elements'][] = ['element' => 'td', 'content' => $child, 'properties' => ['class' => 'border-t-2 border-b border-gray-200 px-4 py-4']];
// }
$elements[] = $element;
}