mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Complete Plain.php
This commit is contained in:
parent
e5defd870b
commit
ad2ff79336
@ -58,37 +58,85 @@ class Plain implements DesignInterface
|
||||
return [
|
||||
'company-address' => [
|
||||
'id' => 'company-address',
|
||||
'elements' => [
|
||||
['element' => 'p', 'content' => '$company.address1'],
|
||||
],
|
||||
'elements' => $this->companyAddress(),
|
||||
],
|
||||
'entity-details' => [
|
||||
'id' => 'entity-details',
|
||||
'elements' => $this->entityDetails(),
|
||||
],
|
||||
'client-details' => [
|
||||
'id' => 'client-details',
|
||||
'elements' => $this->clientDetails(),
|
||||
],
|
||||
'product-table' => [
|
||||
'id' => 'product-table',
|
||||
'elements' => $this->productTable(),
|
||||
],
|
||||
$this->productTable(),
|
||||
];
|
||||
}
|
||||
|
||||
public function companyAddress(): array
|
||||
{
|
||||
$variables = $this->invoice->company->settings->pdf_variables->company_address;
|
||||
|
||||
$elements = [];
|
||||
|
||||
foreach ($variables as $variable) {
|
||||
$elements[] = ['element' => 'p', 'content' => $variable];
|
||||
}
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
public function entityDetails(): array
|
||||
{
|
||||
$variables = $this->invoice->company->settings->pdf_variables->invoice_details;
|
||||
|
||||
$elements = [];
|
||||
|
||||
foreach ($variables as $variable) {
|
||||
$elements[] = ['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-medium']],
|
||||
]];
|
||||
}
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
public function clientDetails(): array
|
||||
{
|
||||
$variables = $this->invoice->company->settings->pdf_variables->client_details;
|
||||
|
||||
$elements = [];
|
||||
|
||||
foreach ($variables as $variable) {
|
||||
$elements[] = ['element' => 'p', 'content' => $variable];
|
||||
}
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
public function productTable(): array
|
||||
{
|
||||
return [
|
||||
'id' => 'product-table',
|
||||
'elements' => [
|
||||
['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left bg-gray-200'], 'elements' => $this->buildTableHeader()],
|
||||
['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()],
|
||||
['element' => 'tfoot', 'content' => '', 'elements' => [
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 py-4', 'colspan' => '2']],
|
||||
['element' => 'td', 'content' => '$subtotal_label', 'properties' => ['class' => 'px-4 py-4 text-right', 'colspan' => '2']],
|
||||
['element' => 'td', 'content' => '$subtotal', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => '$discount_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '4']],
|
||||
['element' => 'td', 'content' => '$discount', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'properties' => ['class' => 'mt-8 px-4 py-2 bg-gray-300'], 'elements' => [
|
||||
['element' => 'td', 'content' => '$balance_due_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '4']],
|
||||
['element' => 'td', 'content' => '$balance_due', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left bg-gray-200'], 'elements' => $this->buildTableHeader()],
|
||||
['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()],
|
||||
['element' => 'tfoot', 'content' => '', 'elements' => [
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 py-4', 'colspan' => '4']],
|
||||
['element' => 'td', 'content' => '$subtotal_label', 'properties' => ['class' => 'px-4 py-4 text-right', 'colspan' => '2']],
|
||||
['element' => 'td', 'content' => '$subtotal', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => '$discount_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '6']],
|
||||
['element' => 'td', 'content' => '$discount', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'properties' => ['class' => 'mt-8 px-4 py-2 bg-gray-300'], 'elements' => [
|
||||
['element' => 'td', 'content' => '$balance_due_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '6']],
|
||||
['element' => 'td', 'content' => '$balance_due', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
]],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -28,13 +28,13 @@
|
||||
|
||||
<!-- Entity details -->
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-6 col-start-8 mt-10">
|
||||
<div class="col-span-6 col-start-6 mt-12">
|
||||
<table class="flex justify-between" id="entity-details"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Client details -->
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="grid grid-cols-12 mt-12">
|
||||
<div class="col-span-6" id="client-details"></div>
|
||||
</div>
|
||||
|
||||
|
@ -23,7 +23,8 @@ class ExampleIntegrationTest extends TestCase
|
||||
$design = new Plain();
|
||||
|
||||
$product_table_columns = json_decode(
|
||||
json_encode($invoice->company->settings->pdf_variables), 1
|
||||
json_encode($invoice->company->settings->pdf_variables),
|
||||
1
|
||||
)['product_columns'];
|
||||
|
||||
$state = [
|
||||
@ -41,6 +42,10 @@ class ExampleIntegrationTest extends TestCase
|
||||
->design(Plain::class)
|
||||
->build();
|
||||
|
||||
info($maker->getCompiledHTML());
|
||||
exec('echo "" > storage/logs/laravel.log');
|
||||
|
||||
info($maker->getCompiledHTML(true));
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user