mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support relabeling po number and due date
This commit is contained in:
parent
4abefb86fc
commit
a6c100eb47
@ -956,7 +956,22 @@ class AccountController extends BaseController
|
||||
$account->page_size = Input::get('page_size');
|
||||
|
||||
$labels = [];
|
||||
foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms', 'balance_due', 'partial_due', 'subtotal', 'paid_to_date', 'discount', 'tax'] as $field) {
|
||||
foreach ([
|
||||
'item',
|
||||
'description',
|
||||
'unit_cost',
|
||||
'quantity',
|
||||
'line_total',
|
||||
'terms',
|
||||
'balance_due',
|
||||
'partial_due',
|
||||
'subtotal',
|
||||
'paid_to_date',
|
||||
'discount',
|
||||
'tax',
|
||||
'po_number',
|
||||
'due_date',
|
||||
] as $field) {
|
||||
$labels[$field] = Input::get("labels_{$field}");
|
||||
}
|
||||
$account->invoice_labels = json_encode($labels);
|
||||
|
@ -1504,6 +1504,11 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getDueDateLabel()
|
||||
{
|
||||
return $this->isQuote() ? 'valid_until' : 'due_date';
|
||||
}
|
||||
}
|
||||
|
||||
Invoice::creating(function ($invoice) {
|
||||
|
@ -162,6 +162,28 @@ trait PresentsInvoice
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function hasCustomLabel($field)
|
||||
{
|
||||
$custom = (array) json_decode($this->invoice_labels);
|
||||
|
||||
return isset($custom[$field]) && $custom[$field];
|
||||
}
|
||||
|
||||
public function getLabel($field, $override = false)
|
||||
{
|
||||
$custom = (array) json_decode($this->invoice_labels);
|
||||
|
||||
if (isset($custom[$field]) && $custom[$field]) {
|
||||
return $custom[$field];
|
||||
} else {
|
||||
if ($override) {
|
||||
$field = $override;
|
||||
}
|
||||
return $this->isEnglish() ? uctrans("texts.$field") : trans("texts.$field");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -239,6 +261,8 @@ trait PresentsInvoice
|
||||
'work_phone',
|
||||
'invoice_total',
|
||||
'outstanding',
|
||||
'invoice_due_date',
|
||||
'quote_due_date',
|
||||
];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
|
@ -215,14 +215,16 @@
|
||||
{!! Former::text('labels_quantity')->label('quantity') !!}
|
||||
{!! Former::text('labels_line_total')->label('line_total') !!}
|
||||
{!! Former::text('labels_terms')->label('terms') !!}
|
||||
{!! Former::text('labels_subtotal')->label('subtotal') !!}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('labels_subtotal')->label('subtotal') !!}
|
||||
{!! Former::text('labels_discount')->label('discount') !!}
|
||||
{!! Former::text('labels_paid_to_date')->label('paid_to_date') !!}
|
||||
{!! Former::text('labels_balance_due')->label('balance_due') !!}
|
||||
{!! Former::text('labels_partial_due')->label('partial_due') !!}
|
||||
{!! Former::text('labels_tax')->label('tax') !!}
|
||||
{!! Former::text('labels_po_number')->label('po_number') !!}
|
||||
{!! Former::text('labels_due_date')->label('due_date') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -25,7 +25,11 @@
|
||||
@if ($invoice->isQuote())
|
||||
{{ strtoupper(trans('texts.valid_until')) }} {{ $account->formatDate($invoice->due_date) }}
|
||||
@else
|
||||
{{ strtoupper(trans('texts.due_by', ['date' => $account->formatDate($invoice->due_date)])) }}
|
||||
@if ($account->hasCustomLabel('due_date'))
|
||||
{{ $account->getLabel('due_date') }} {{ $account->formatDate($invoice->due_date) }}
|
||||
@else
|
||||
{{ strtoupper(trans('texts.due_by', ['date' => $account->formatDate($invoice->due_date)])) }}
|
||||
@endif
|
||||
@endif
|
||||
</span><br />
|
||||
@endif
|
||||
|
@ -25,7 +25,11 @@
|
||||
@if ($invoice->isQuote())
|
||||
{{ strtoupper(trans('texts.valid_until')) }} {{ $account->formatDate($invoice->due_date) }}
|
||||
@else
|
||||
{{ strtoupper(trans('texts.due_by', ['date' => $account->formatDate($invoice->due_date)])) }}
|
||||
@if ($account->hasCustomLabel('due_date'))
|
||||
{{ $account->getLabel('due_date') }} {{ $account->formatDate($invoice->due_date) }}
|
||||
@else
|
||||
{{ strtoupper(trans('texts.due_by', ['date' => $account->formatDate($invoice->due_date)])) }}
|
||||
@endif
|
||||
@endif
|
||||
</span><br />
|
||||
@endif
|
||||
|
@ -153,7 +153,7 @@
|
||||
<div data-bind="visible: !is_recurring()">
|
||||
{!! Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->label(trans("texts.{$entityType}_date"))
|
||||
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('invoice_date') !!}
|
||||
{!! Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")->label(trans("texts.{$entityType}_due_date"))
|
||||
{!! Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")->label($account->getLabel($invoice->getDueDateLabel()))
|
||||
->placeholder($invoice->exists || $invoice->isQuote() ? ' ' : $account->present()->dueDatePlaceholder())
|
||||
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('due_date') !!}
|
||||
{!! Former::text('partial')->data_bind("value: partial, valueUpdate: 'afterkeydown'")->onkeyup('onPartialChange()')
|
||||
@ -209,7 +209,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
{!! Former::text('po_number')->label(trans('texts.po_number_short'))->data_bind("value: po_number, valueUpdate: 'afterkeydown'") !!}
|
||||
{!! Former::text('po_number')->label($account->getLabel('po_number', 'po_number_short'))->data_bind("value: po_number, valueUpdate: 'afterkeydown'") !!}
|
||||
{!! Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'")
|
||||
->addGroupClass('discount-group')->type('number')->min('0')->step('any')->append(
|
||||
Former::select('is_amount_discount')->addOption(trans('texts.discount_percent'), '0')
|
||||
|
Loading…
x
Reference in New Issue
Block a user