1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 06:32:40 +01:00

change entity details from table to div

This commit is contained in:
David Bomba 2023-01-30 11:07:55 +11:00
parent a4467149f9
commit 813fc7bd5e
3 changed files with 94 additions and 10 deletions

View File

@ -310,6 +310,79 @@ class Design extends BaseDesign
{ {
if ($this->type === 'statement') {
$s_date = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale()) . " - " . $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale());
return [
['element' => 'p', 'content' => "<h2>".ctrans('texts.statement')."</h2>", 'properties' => ['data-ref' => 'statement-label']],
['element' => 'p', 'content' => ctrans('texts.statement_date'), 'properties' => ['data-ref' => 'statement-label'],'elements' =>
['element' => 'span', 'content' => "{$s_date} "]
],
['element' => 'p', 'content' => '$balance_due_label', 'properties' => ['data-ref' => 'statement-label'],'elements' =>
['element' => 'span', 'content' => Number::formatMoney($this->invoices->sum('balance'), $this->client)]
],
];
}
$variables = $this->context['pdf_variables']['invoice_details'];
if ($this->entity instanceof Quote) {
$variables = $this->context['pdf_variables']['quote_details'];
if ($this->entity->partial > 0) {
$variables[] = '$quote.balance_due';
}
}
if ($this->entity instanceof Credit) {
$variables = $this->context['pdf_variables']['credit_details'];
}
if($this->vendor){
$variables = $this->context['pdf_variables']['purchase_order_details'];
}
$elements = [];
// We don't want to show account balance or invoice total on PDF.. or any amount with currency.
if ($this->type == self::DELIVERY_NOTE) {
$variables = array_filter($variables, function ($m) {
return !in_array($m, ['$invoice.balance_due', '$invoice.total']);
});
}
foreach ($variables as $variable) {
$_variable = explode('.', $variable)[1];
$_customs = ['custom1', 'custom2', 'custom3', 'custom4'];
/* 2/7/2022 don't show custom values if they are empty */
$var = str_replace("custom", "custom_value", $_variable);
if (in_array($_variable, $_customs) && !empty($this->entity->{$var})) {
$elements[] = ['element' => 'div', 'properties' => ['style' => "display: table-row; visibility: {$this->entityVariableCheck($_variable)};"],'elements' => [
['element' => 'div', 'content' => $variable . '_label', 'properties' => ['style' => 'display: table-cell;', 'data-ref' => 'entity_details-' . substr($variable, 1) . '_label']],
['element' => 'div', 'content' => $variable, 'properties' => ['style' => 'display: table-cell;', 'data-ref' => 'entity_details-' . substr($variable, 1)]],
]];
} else {
$elements[] = ['element' => 'div', 'properties' => ['style' => "display: table-row; visibility: {$this->entityVariableCheck($variable)};"], 'elements' => [
['element' => 'span', 'content' => $variable . '_label', 'properties' => ['style' => 'display: table-cell;','data-ref' => 'entity_details-' . substr($variable, 1) . '_label']],
['element' => 'span', 'content' => $variable, 'properties' => ['style' => 'display: table-cell;','data-ref' => 'entity_details-' . substr($variable, 1)]],
]];
}
}
return $elements;
}
public function entityDetailsx(): array
{
if ($this->type === 'statement') { if ($this->type === 'statement') {
// $s_date = $this->translateDate(now(), $this->client->date_format(), $this->client->locale()); // $s_date = $this->translateDate(now(), $this->client->date_format(), $this->client->locale());

View File

@ -246,14 +246,14 @@ trait DesignHelpers
]]; ]];
} }
public function entityVariableCheck(string $variable): bool public function entityVariableCheck(string $variable): string
{ {
// Extract $invoice.date => date // Extract $invoice.date => date
// so we can append date as $entity->date and not $entity->$invoice.date; // so we can append date as $entity->date and not $entity->$invoice.date;
// When it comes to invoice balance, we'll always show it. // When it comes to invoice balance, we'll always show it.
if ($variable == '$invoice.total') { if ($variable == '$invoice.total') {
return false; return 'visible';
} }
// Some variables don't map 1:1 to table columns. This gives us support for such cases. // Some variables don't map 1:1 to table columns. This gives us support for such cases.
@ -272,14 +272,14 @@ trait DesignHelpers
} }
if (is_null($this->entity->{$_variable})) { if (is_null($this->entity->{$_variable})) {
return true; return 'collapse';
} }
if (empty($this->entity->{$_variable})) { if (empty($this->entity->{$_variable})) {
return true; return 'collapse';
} }
return false; return 'visible';
} }
public function composeFromPartials(array $partials) public function composeFromPartials(array $partials)

View File

@ -34,6 +34,11 @@
padding: 0; padding: 0;
} }
span {
margin-left:2px;
margin-right:2px;
}
#qr-bill { #qr-bill {
width:100% !important; width:100% !important;
box-sizing: border-box; box-sizing: border-box;
@ -83,14 +88,18 @@
.client-and-entity-wrapper { .client-and-entity-wrapper {
display: flex; display: flex;
padding: 1rem; padding: 0.2rem;
border-top: 1px solid #d8d8d8; border-top: 1px solid #d8d8d8;
border-bottom: 1px solid #d8d8d8; border-bottom: 1px solid #d8d8d8;
} }
#entity-details { #entity-details {
text-align: left; display: flex;
margin-right: 20px; flex-direction: column;
line-height: var(--line-height);
padding-right: 5px;
white-space: nowrap;
margin-right: auto;
} }
#entity-details > tr, #entity-details > tr,
@ -105,12 +114,15 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
line-height: var(--line-height); line-height: var(--line-height);
margin-right: auto;
} }
#shipping-details { #shipping-details {
display: flex; display: flex;
float:right;
flex-direction: column; flex-direction: column;
line-height: var(--line-height); line-height: var(--line-height);
margin-right: auto;
} }
#client-details > :first-child { #client-details > :first-child {
@ -360,8 +372,7 @@
</div> </div>
<p class="entity-label">$entity_label</p> <p class="entity-label">$entity_label</p>
<div class="client-and-entity-wrapper"> <div class="client-and-entity-wrapper">
<div> <div id="entity-details" style="display: table;">
<table id="entity-details" cellspacing="0" dir="$dir"></table>
</div> </div>
<div id="client-details"></div> <div id="client-details"></div>
<div id="shipping-details"></div> <div id="shipping-details"></div>