mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-30 22:14:33 -04:00
Merge pull request #4136 from beganovich/v2-products-table-in-invoices
(v5) Support for custom products table columns
This commit is contained in:
commit
4bbdeef539
@ -113,6 +113,7 @@ class PreviewController extends BaseController
|
|||||||
'client' => $entity_obj->client,
|
'client' => $entity_obj->client,
|
||||||
'entity' => $entity_obj,
|
'entity' => $entity_obj,
|
||||||
'pdf_variables' => (array) $entity_obj->company->settings->pdf_variables,
|
'pdf_variables' => (array) $entity_obj->company->settings->pdf_variables,
|
||||||
|
'products' => request()->design['design']['product'],
|
||||||
]),
|
]),
|
||||||
'variables' => $html->generateLabelsAndValues(),
|
'variables' => $html->generateLabelsAndValues(),
|
||||||
];
|
];
|
||||||
@ -184,6 +185,7 @@ class PreviewController extends BaseController
|
|||||||
'client' => $invoice->client,
|
'client' => $invoice->client,
|
||||||
'entity' => $invoice,
|
'entity' => $invoice,
|
||||||
'pdf_variables' => (array) $invoice->company->settings->pdf_variables,
|
'pdf_variables' => (array) $invoice->company->settings->pdf_variables,
|
||||||
|
'products' => request()->design['design']['product'],
|
||||||
]),
|
]),
|
||||||
'variables' => $html->generateLabelsAndValues(),
|
'variables' => $html->generateLabelsAndValues(),
|
||||||
];
|
];
|
||||||
|
@ -94,6 +94,7 @@ class CreateInvoicePdf implements ShouldQueue
|
|||||||
'client' => $this->invoice->client,
|
'client' => $this->invoice->client,
|
||||||
'entity' => $this->invoice,
|
'entity' => $this->invoice,
|
||||||
'pdf_variables' => (array) $this->invoice->company->settings->pdf_variables,
|
'pdf_variables' => (array) $this->invoice->company->settings->pdf_variables,
|
||||||
|
'products' => $design->design->product,
|
||||||
]),
|
]),
|
||||||
'variables' => $html->generateLabelsAndValues(),
|
'variables' => $html->generateLabelsAndValues(),
|
||||||
'options' => [
|
'options' => [
|
||||||
|
@ -92,6 +92,7 @@ class CreateQuotePdf implements ShouldQueue
|
|||||||
'client' => $this->quote->client,
|
'client' => $this->quote->client,
|
||||||
'entity' => $this->quote,
|
'entity' => $this->quote,
|
||||||
'pdf_variables' => (array) $this->quote->company->settings->pdf_variables,
|
'pdf_variables' => (array) $this->quote->company->settings->pdf_variables,
|
||||||
|
'products' => $design->design->product,
|
||||||
]),
|
]),
|
||||||
'variables' => $html->generateLabelsAndValues(),
|
'variables' => $html->generateLabelsAndValues(),
|
||||||
'options' => [
|
'options' => [
|
||||||
|
@ -16,6 +16,7 @@ use App\Services\PdfMaker\Designs\Utilities\BaseDesign;
|
|||||||
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
|
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use App\Utils\Traits\MakesInvoiceValues;
|
use App\Utils\Traits\MakesInvoiceValues;
|
||||||
|
use DOMDocument;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Design extends BaseDesign
|
class Design extends BaseDesign
|
||||||
@ -210,8 +211,33 @@ class Design extends BaseDesign
|
|||||||
foreach ($items as $row) {
|
foreach ($items as $row) {
|
||||||
$element = ['element' => 'tr', 'elements' => []];
|
$element = ['element' => 'tr', 'elements' => []];
|
||||||
|
|
||||||
foreach ($this->context['pdf_variables']["{$this->type}_columns"] as $key => $cell) {
|
if (
|
||||||
$element['elements'][] = ['element' => 'td', 'content' => $row[$cell]];
|
isset($this->context['products']) &&
|
||||||
|
!empty($this->context['products']) &&
|
||||||
|
!is_null($this->context['products'])
|
||||||
|
) {
|
||||||
|
$document = new DOMDocument();
|
||||||
|
$document->loadHTML($this->context['products'], LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||||
|
|
||||||
|
$td = $document->getElementsByTagName('tr')->item(0);
|
||||||
|
|
||||||
|
if ($td) {
|
||||||
|
foreach ($td->childNodes as $child) {
|
||||||
|
if ($child->nodeType !== 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($child->tagName !== 'td') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element['elements'][] = ['element' => 'td', 'content' => strtr($child->nodeValue, $row)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($this->context['pdf_variables']["{$this->type}_columns"] as $key => $cell) {
|
||||||
|
$element['elements'][] = ['element' => 'td', 'content' => $row[$cell]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$elements[] = $element;
|
$elements[] = $element;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user