1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Improvements to invoice labels customization

This commit is contained in:
Hillel Coren 2017-06-21 13:35:55 +03:00
parent 1c3b8e9cd7
commit c239146559
10 changed files with 57 additions and 59 deletions

View File

@ -220,20 +220,23 @@ class Account extends Eloquent
];
public static $customLabels = [
'item',
'description',
'unit_cost',
'quantity',
'line_total',
'terms',
'balance_due',
'partial_due',
'subtotal',
'paid_to_date',
'description',
'discount',
'tax',
'po_number',
'due_date',
'hours',
'item',
'line_total',
'paid_to_date',
'partial_due',
'po_number',
'quantity',
'rate',
'service',
'subtotal',
'tax',
'terms',
'unit_cost',
];
/**

View File

@ -263,13 +263,16 @@ trait PresentsInvoice
'outstanding',
'invoice_due_date',
'quote_due_date',
'service',
];
foreach ($fields as $field) {
$translated = $this->isEnglish() ? uctrans("texts.$field") : trans("texts.$field");
if (isset($custom[$field]) && $custom[$field]) {
$data[$field] = $custom[$field];
$data[$field . '_orig'] = $translated;
} else {
$data[$field] = $this->isEnglish() ? uctrans("texts.$field") : trans("texts.$field");
$data[$field] = $translated;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -468,7 +468,7 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
}
if (invoice.has_product_key) {
grid[0].push({text: invoiceLabels.item, style: styles.concat('itemTableHeader')});
grid[0].push({text: isTasks ? invoiceLabels.service : invoiceLabels.item, style: styles.concat('itemTableHeader')});
}
grid[0].push({text: invoiceLabels.description, style: styles.concat('descriptionTableHeader')});

View File

@ -556,12 +556,12 @@ $LANG = array(
'timer' => 'Timer',
'manual' => 'Manual',
'date_and_time' => 'Date & Time',
'second' => 'second',
'seconds' => 'seconds',
'minute' => 'minute',
'minutes' => 'minutes',
'hour' => 'hour',
'hours' => 'hours',
'second' => 'Second',
'seconds' => 'Seconds',
'minute' => 'Minute',
'minutes' => 'Minutes',
'hour' => 'Hour',
'hours' => 'Hours',
'task_details' => 'Task Details',
'duration' => 'Duration',
'end_time' => 'End Time',
@ -2266,8 +2266,9 @@ $LANG = array(
'mailgun_domain' => 'Mailgun Domain',
'mailgun_private_key' => 'Mailgun Private Key',
'send_test_email' => 'Send test email',
'select_field' => 'Select field',
'field' => 'Field',
'select_label' => 'Select label',
'label' => 'Label',
'service' => 'Service',
);

View File

@ -99,7 +99,7 @@
{
var $select = $('#invoice_design_id');
var id = $select.val();
$select.val(null);
$select.val(null).blur();
if (parseInt(id)) {
var design = _.find(invoiceDesigns, function(design){ return design.id == id});

View File

@ -74,26 +74,14 @@
NINJA.headerFont = $('#header_font_id option:selected').text();
NINJA.bodyFont = $('#body_font_id option:selected').text();
var fields = [
'item',
'description',
'unit_cost',
'quantity',
'line_total',
'terms',
'balance_due',
'partial_due'
];
invoiceLabels.old = {};
var fields = {!! json_encode(App\Models\Account::$customLabels) !!};
for (var i=0; i<fields.length; i++) {
var field = fields[i];
var val = $('#labels_' + field).val();
if (invoiceLabels.old.hasOwnProperty(field)) {
invoiceLabels.old[field] = invoiceLabels[field];
}
if (val) {
invoiceLabels[field] = val;
if ( ! invoiceLabels[field + '_orig']) {
invoiceLabels[field + '_orig'] = invoiceLabels[field];
}
invoiceLabels[field] = val || invoiceLabels[field + '_orig'];
}
generatePDF(invoice, getDesignJavascript(), true, cb);
@ -112,7 +100,7 @@
function onFieldChange() {
var $select = $('#label_field');
var id = $select.val();
$select.val(null);
$select.val(null).blur();
$('.' + id + '-label-group').fadeIn();
console.log(id);
}
@ -236,26 +224,29 @@
<div class="row">
<div class="col-md-6">
{!! Former::select('label_field')
->placeholder('select_field')
->label('field')
->placeholder('select_label')
->label('label')
->onchange('onFieldChange()')
->options(array_combine(App\Models\Account::$customLabels, Utils::trans(App\Models\Account::$customLabels))) !!}
</div>
<div class="col-md-6">
{!! Former::text('labels_item')->label('item')->addGroupClass('item-label-group label-group') !!}
{!! Former::text('labels_description')->label('description')->addGroupClass('description-label-group label-group') !!}
{!! Former::text('labels_unit_cost')->label('unit_cost')->addGroupClass('unit_cost-label-group label-group') !!}
{!! Former::text('labels_quantity')->label('quantity')->addGroupClass('quantity-label-group label-group') !!}
{!! Former::text('labels_line_total')->label('line_total')->addGroupClass('line_total-label-group label-group') !!}
{!! Former::text('labels_terms')->label('terms')->addGroupClass('terms-label-group label-group') !!}
{!! Former::text('labels_subtotal')->label('subtotal')->addGroupClass('subtotal-label-group label-group') !!}
{!! Former::text('labels_discount')->label('discount')->addGroupClass('discount-label-group label-group') !!}
{!! Former::text('labels_paid_to_date')->label('paid_to_date')->addGroupClass('paid_to_date-label-group label-group') !!}
{!! Former::text('labels_balance_due')->label('balance_due')->addGroupClass('balance_due-label-group label-group') !!}
{!! Former::text('labels_partial_due')->label('partial_due')->addGroupClass('partial_due-label-group label-group') !!}
{!! Former::text('labels_tax')->label('tax')->addGroupClass('tax-label-group label-group') !!}
{!! Former::text('labels_po_number')->label('po_number')->addGroupClass('po_number-label-group label-group') !!}
{!! Former::text('labels_description')->label('description')->addGroupClass('description-label-group label-group') !!}
{!! Former::text('labels_discount')->label('discount')->addGroupClass('discount-label-group label-group') !!}
{!! Former::text('labels_due_date')->label('due_date')->addGroupClass('due_date-label-group label-group') !!}
{!! Former::text('labels_hours')->label('hours')->addGroupClass('hours-label-group label-group') !!}
{!! Former::text('labels_item')->label('item')->addGroupClass('item-label-group label-group') !!}
{!! Former::text('labels_line_total')->label('line_total')->addGroupClass('line_total-label-group label-group') !!}
{!! Former::text('labels_paid_to_date')->label('paid_to_date')->addGroupClass('paid_to_date-label-group label-group') !!}
{!! Former::text('labels_partial_due')->label('partial_due')->addGroupClass('partial_due-label-group label-group') !!}
{!! Former::text('labels_po_number')->label('po_number')->addGroupClass('po_number-label-group label-group') !!}
{!! Former::text('labels_quantity')->label('quantity')->addGroupClass('quantity-label-group label-group') !!}
{!! Former::text('labels_rate')->label('rate')->addGroupClass('rate-label-group label-group') !!}
{!! Former::text('labels_service')->label('service')->addGroupClass('service-label-group label-group') !!}
{!! Former::text('labels_subtotal')->label('subtotal')->addGroupClass('subtotal-label-group label-group') !!}
{!! Former::text('labels_tax')->label('tax')->addGroupClass('tax-label-group label-group') !!}
{!! Former::text('labels_terms')->label('terms')->addGroupClass('terms-label-group label-group') !!}
{!! Former::text('labels_unit_cost')->label('unit_cost')->addGroupClass('unit_cost-label-group label-group') !!}
</div>
</div>

View File

@ -4,7 +4,7 @@
@endif
<tr>
<th style="min-width:32px;" class="hide-border"></th>
<th style="min-width:120px;width:25%">{{ $invoiceLabels['item'] }}</th>
<th style="min-width:120px;width:25%">{{ $invoiceLabels[$isTasks ? 'service' : 'item'] }}</th>
<th style="width:100%">{{ $invoiceLabels['description'] }}</th>
@if ($account->showCustomField('custom_invoice_item_label1'))
<th style="min-width:120px">{{ $account->custom_invoice_item_label1 }}</th>

View File

@ -237,8 +237,8 @@
var timeLabels = {};
@foreach (['hour', 'minute', 'second'] as $period)
timeLabels['{{ $period }}'] = '{{ trans("texts.{$period}") }}';
timeLabels['{{ $period }}s'] = '{{ trans("texts.{$period}s") }}';
timeLabels['{{ $period }}'] = '{{ strtolower(trans("texts.{$period}")) }}';
timeLabels['{{ $period }}s'] = '{{ strtolower(trans("texts.{$period}s")) }}';
@endforeach
function onFormSubmit(event) {