mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Working on product fields
This commit is contained in:
parent
22ac0c05a4
commit
e8888e38d0
@ -556,6 +556,8 @@ if (! defined('APP_NAME')) {
|
|||||||
define('INVOICE_FIELDS_CLIENT', 'client_fields');
|
define('INVOICE_FIELDS_CLIENT', 'client_fields');
|
||||||
define('INVOICE_FIELDS_INVOICE', 'invoice_fields');
|
define('INVOICE_FIELDS_INVOICE', 'invoice_fields');
|
||||||
define('INVOICE_FIELDS_ACCOUNT', 'account_fields');
|
define('INVOICE_FIELDS_ACCOUNT', 'account_fields');
|
||||||
|
define('INVOICE_FIELDS_PRODUCT', 'product_fields');
|
||||||
|
define('INVOICE_FIELDS_TASK', 'task_fields');
|
||||||
|
|
||||||
$creditCards = [
|
$creditCards = [
|
||||||
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
|
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
|
||||||
|
@ -12,6 +12,29 @@ trait PresentsInvoice
|
|||||||
if ($this->invoice_fields) {
|
if ($this->invoice_fields) {
|
||||||
$fields = json_decode($this->invoice_fields, true);
|
$fields = json_decode($this->invoice_fields, true);
|
||||||
|
|
||||||
|
if (! isset($fields['product_fields'])) {
|
||||||
|
$fields['product_fields'] = [
|
||||||
|
'product.item',
|
||||||
|
'product.description',
|
||||||
|
'product.custom_value1',
|
||||||
|
'product.custom_value2',
|
||||||
|
'product.unit_cost',
|
||||||
|
'product.quantity',
|
||||||
|
'product.tax',
|
||||||
|
'product.line_total',
|
||||||
|
];
|
||||||
|
$fields['task_fields'] = [
|
||||||
|
'product.service',
|
||||||
|
'product.description',
|
||||||
|
'product.custom_value1',
|
||||||
|
'product.custom_value2',
|
||||||
|
'product.rate',
|
||||||
|
'product.hours',
|
||||||
|
'product.tax',
|
||||||
|
'product.line_total',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $this->applyLabels($fields);
|
return $this->applyLabels($fields);
|
||||||
} else {
|
} else {
|
||||||
return $this->getDefaultInvoiceFields();
|
return $this->getDefaultInvoiceFields();
|
||||||
@ -54,6 +77,26 @@ trait PresentsInvoice
|
|||||||
'account.city_state_postal',
|
'account.city_state_postal',
|
||||||
'account.country',
|
'account.country',
|
||||||
],
|
],
|
||||||
|
'product_fields' => [
|
||||||
|
'product.item',
|
||||||
|
'product.description',
|
||||||
|
'product.custom_value1',
|
||||||
|
'product.custom_value2',
|
||||||
|
'product.unit_cost',
|
||||||
|
'product.quantity',
|
||||||
|
'product.tax',
|
||||||
|
'product.line_total',
|
||||||
|
],
|
||||||
|
'task_fields' => [
|
||||||
|
'product.service',
|
||||||
|
'product.description',
|
||||||
|
'product.custom_value1',
|
||||||
|
'product.custom_value2',
|
||||||
|
'product.rate',
|
||||||
|
'product.hours',
|
||||||
|
'product.tax',
|
||||||
|
'product.line_total',
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->custom_invoice_text_label1) {
|
if ($this->custom_invoice_text_label1) {
|
||||||
@ -136,6 +179,26 @@ trait PresentsInvoice
|
|||||||
'account.custom_value2',
|
'account.custom_value2',
|
||||||
'.blank',
|
'.blank',
|
||||||
],
|
],
|
||||||
|
INVOICE_FIELDS_PRODUCT => [
|
||||||
|
'product.item',
|
||||||
|
'product.description',
|
||||||
|
'product.custom_value1',
|
||||||
|
'product.custom_value2',
|
||||||
|
'product.unit_cost',
|
||||||
|
'product.quantity',
|
||||||
|
'product.tax',
|
||||||
|
'product.line_total',
|
||||||
|
],
|
||||||
|
INVOICE_FIELDS_TASK => [
|
||||||
|
'product.service',
|
||||||
|
'product.description',
|
||||||
|
'product.custom_value1',
|
||||||
|
'product.custom_value2',
|
||||||
|
'product.rate',
|
||||||
|
'product.hours',
|
||||||
|
'product.tax',
|
||||||
|
'product.line_total',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->applyLabels($fields);
|
return $this->applyLabels($fields);
|
||||||
@ -264,6 +327,10 @@ trait PresentsInvoice
|
|||||||
'invoice_due_date',
|
'invoice_due_date',
|
||||||
'quote_due_date',
|
'quote_due_date',
|
||||||
'service',
|
'service',
|
||||||
|
'product_key',
|
||||||
|
'unit_cost',
|
||||||
|
'tax1',
|
||||||
|
'tax2',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
@ -289,6 +356,8 @@ trait PresentsInvoice
|
|||||||
'client.custom_value2' => 'custom_client_label2',
|
'client.custom_value2' => 'custom_client_label2',
|
||||||
'contact.custom_value1' => 'custom_contact_label1',
|
'contact.custom_value1' => 'custom_contact_label1',
|
||||||
'contact.custom_value2' => 'custom_contact_label2',
|
'contact.custom_value2' => 'custom_contact_label2',
|
||||||
|
'product.custom_value1' => 'custom_invoice_item_label1',
|
||||||
|
'product.custom_value2' => 'custom_invoice_item_label2',
|
||||||
] as $field => $property) {
|
] as $field => $property) {
|
||||||
$data[$field] = e($this->$property) ?: trans('texts.custom_field');
|
$data[$field] = e($this->$property) ?: trans('texts.custom_field');
|
||||||
}
|
}
|
||||||
|
@ -2508,6 +2508,8 @@ $LANG = array(
|
|||||||
'return_to_invoice' => 'Return to Invoice',
|
'return_to_invoice' => 'Return to Invoice',
|
||||||
'gateway_help_13' => 'To use ITN leave the PDT Key field blank.',
|
'gateway_help_13' => 'To use ITN leave the PDT Key field blank.',
|
||||||
'partial_due_date' => 'Partial Due Date',
|
'partial_due_date' => 'Partial Due Date',
|
||||||
|
'task_fields' => 'Task Fields',
|
||||||
|
'product_fields_help' => 'Drag and drop fields to change their order',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -102,7 +102,6 @@
|
|||||||
var id = $select.val();
|
var id = $select.val();
|
||||||
$select.val(null).blur();
|
$select.val(null).blur();
|
||||||
$('.' + id + '-label-group').fadeIn();
|
$('.' + id + '-label-group').fadeIn();
|
||||||
console.log(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
@ -166,8 +165,8 @@
|
|||||||
<li role="presentation" class="active"><a href="#general_settings" aria-controls="general_settings" role="tab" data-toggle="tab">{{ trans('texts.general_settings') }}</a></li>
|
<li role="presentation" class="active"><a href="#general_settings" aria-controls="general_settings" role="tab" data-toggle="tab">{{ trans('texts.general_settings') }}</a></li>
|
||||||
<li role="presentation"><a href="#invoice_labels" aria-controls="invoice_labels" role="tab" data-toggle="tab">{{ trans('texts.invoice_labels') }}</a></li>
|
<li role="presentation"><a href="#invoice_labels" aria-controls="invoice_labels" role="tab" data-toggle="tab">{{ trans('texts.invoice_labels') }}</a></li>
|
||||||
<li role="presentation"><a href="#invoice_fields" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.invoice_fields') }}</a></li>
|
<li role="presentation"><a href="#invoice_fields" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.invoice_fields') }}</a></li>
|
||||||
|
<li role="presentation"><a href="#product_fields" aria-controls="product_fields" role="tab" data-toggle="tab">{{ trans('texts.product_fields') }}</a></li>
|
||||||
<li role="presentation"><a href="#invoice_options" aria-controls="invoice_options" role="tab" data-toggle="tab">{{ trans('texts.invoice_options') }}</a></li>
|
<li role="presentation"><a href="#invoice_options" aria-controls="invoice_options" role="tab" data-toggle="tab">{{ trans('texts.invoice_options') }}</a></li>
|
||||||
<li role="presentation"><a href="#header_footer" aria-controls="header_footer" role="tab" data-toggle="tab">{{ trans('texts.header_footer') }}</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
@ -242,7 +241,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="invoice_fields">
|
<div role="tabpanel" class="tab-pane" id="invoice_fields">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row" id="invoiceFields">
|
||||||
@include('accounts.partials.invoice_fields_selector', ['section' => 'invoice_fields', 'fields' => INVOICE_FIELDS_INVOICE])
|
@include('accounts.partials.invoice_fields_selector', ['section' => 'invoice_fields', 'fields' => INVOICE_FIELDS_INVOICE])
|
||||||
@include('accounts.partials.invoice_fields_selector', ['section' => 'client_fields', 'fields' => INVOICE_FIELDS_CLIENT])
|
@include('accounts.partials.invoice_fields_selector', ['section' => 'client_fields', 'fields' => INVOICE_FIELDS_CLIENT])
|
||||||
@include('accounts.partials.invoice_fields_selector', ['section' => 'account_fields1', 'fields' => INVOICE_FIELDS_ACCOUNT])
|
@include('accounts.partials.invoice_fields_selector', ['section' => 'account_fields1', 'fields' => INVOICE_FIELDS_ACCOUNT])
|
||||||
@ -253,11 +252,29 @@
|
|||||||
{{ trans('texts.invoice_fields_help') }}
|
{{ trans('texts.invoice_fields_help') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right" style="padding-right:14px">
|
<div class="pull-right" style="padding-right:14px">
|
||||||
{!! Button::normal(trans('texts.reset'))
|
{!! Button::normal(trans('texts.reset'))->small()
|
||||||
->withAttributes(['onclick' => 'sweetConfirm(function() {
|
->withAttributes(['onclick' => 'sweetConfirm(function() {
|
||||||
resetFields();
|
resetFields();
|
||||||
})'])
|
})']) !!}
|
||||||
->small() !!}
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="product_fields">
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="row" id="productFields">
|
||||||
|
@include('accounts.partials.invoice_fields_selector', ['section' => 'product_fields', 'fields' => INVOICE_FIELDS_PRODUCT, 'colWidth' => 6])
|
||||||
|
@include('accounts.partials.invoice_fields_selector', ['section' => 'task_fields', 'fields' => INVOICE_FIELDS_TASK, 'colWidth' => 6])
|
||||||
|
</div>
|
||||||
|
<div class="row" style="padding-top:30px">
|
||||||
|
<div class="pull-left help-block">
|
||||||
|
{{ trans('texts.product_fields_help') }}
|
||||||
|
</div>
|
||||||
|
<div class="pull-right" style="padding-right:14px">
|
||||||
|
{!! Button::normal(trans('texts.reset'))->small()
|
||||||
|
->withAttributes(['onclick' => 'sweetConfirm(function() {
|
||||||
|
resetFields();
|
||||||
|
})']) !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -265,14 +282,14 @@
|
|||||||
<div role="tabpanel" class="tab-pane" id="invoice_options">
|
<div role="tabpanel" class="tab-pane" id="invoice_options">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<!--
|
||||||
{!! Former::checkbox('hide_quantity')->text(trans('texts.hide_quantity_help'))->value(1) !!}
|
{!! Former::checkbox('hide_quantity')->text(trans('texts.hide_quantity_help'))->value(1) !!}
|
||||||
|
-->
|
||||||
|
|
||||||
{!! Former::checkbox('hide_paid_to_date')->text(trans('texts.hide_paid_to_date_help'))->value(1) !!}
|
{!! Former::checkbox('hide_paid_to_date')->text(trans('texts.hide_paid_to_date_help'))->value(1) !!}
|
||||||
{!! Former::checkbox('invoice_embed_documents')->text(trans('texts.invoice_embed_documents_help'))->value(1) !!}
|
{!! Former::checkbox('invoice_embed_documents')->text(trans('texts.invoice_embed_documents_help'))->value(1) !!}
|
||||||
|
|
||||||
</div>
|
<br/>
|
||||||
</div>
|
|
||||||
<div role="tabpanel" class="tab-pane" id="header_footer">
|
|
||||||
<div class="panel-body">
|
|
||||||
|
|
||||||
{!! Former::inline_radios('all_pages_header')
|
{!! Former::inline_radios('all_pages_header')
|
||||||
->label(trans('texts.all_pages_header'))
|
->label(trans('texts.all_pages_header'))
|
||||||
|
@ -7,6 +7,8 @@ function ViewModel(data) {
|
|||||||
self.client_fields = ko.observableArray();
|
self.client_fields = ko.observableArray();
|
||||||
self.account_fields1 = ko.observableArray();
|
self.account_fields1 = ko.observableArray();
|
||||||
self.account_fields2 = ko.observableArray();
|
self.account_fields2 = ko.observableArray();
|
||||||
|
self.product_fields = ko.observableArray();
|
||||||
|
self.task_fields = ko.observableArray();
|
||||||
window.field_map = [];
|
window.field_map = [];
|
||||||
|
|
||||||
self.addField = function(section, field, label) {
|
self.addField = function(section, field, label) {
|
||||||
@ -20,6 +22,8 @@ function ViewModel(data) {
|
|||||||
self.client_fields.removeAll();
|
self.client_fields.removeAll();
|
||||||
self.account_fields1.removeAll();
|
self.account_fields1.removeAll();
|
||||||
self.account_fields2.removeAll();
|
self.account_fields2.removeAll();
|
||||||
|
self.product_fields.removeAll();
|
||||||
|
self.task_fields.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.onChange = function() {
|
self.onChange = function() {
|
||||||
@ -29,17 +33,28 @@ function ViewModel(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.updateSelects = function() {
|
self.updateSelects = function() {
|
||||||
var usedFields = [].concat(self.invoice_fields(), self.client_fields(), self.account_fields1(), self.account_fields2());
|
var usedFields = [].concat(
|
||||||
|
self.invoice_fields(),
|
||||||
|
self.client_fields(),
|
||||||
|
self.account_fields1(),
|
||||||
|
self.account_fields2());
|
||||||
var selects = [
|
var selects = [
|
||||||
'invoice_fields',
|
'invoice_fields',
|
||||||
'client_fields',
|
'client_fields',
|
||||||
'account_fields1',
|
'account_fields1',
|
||||||
'account_fields2',
|
'account_fields2',
|
||||||
|
'product_fields',
|
||||||
|
'task_fields',
|
||||||
];
|
];
|
||||||
|
|
||||||
for (var i=0; i<selects.length; i++) {
|
for (var i=0; i<selects.length; i++) {
|
||||||
var select = selects[i];
|
var select = selects[i];
|
||||||
$('#' + select + '_select > option').each(function() {
|
$('#' + select + '_select > option').each(function() {
|
||||||
|
if (select == 'product_fields') {
|
||||||
|
usedFields = self.product_fields();
|
||||||
|
} else if (select == 'task_fields') {
|
||||||
|
usedFields = self.task_fields();
|
||||||
|
}
|
||||||
var isUsed = usedFields.indexOf(this.value) >= 0;
|
var isUsed = usedFields.indexOf(this.value) >= 0;
|
||||||
$(this).css('color', isUsed ? '#888' : 'black');
|
$(this).css('color', isUsed ? '#888' : 'black');
|
||||||
});
|
});
|
||||||
@ -66,6 +81,14 @@ function ViewModel(data) {
|
|||||||
self.account_fields2.remove(item);
|
self.account_fields2.remove(item);
|
||||||
self.onChange();
|
self.onChange();
|
||||||
}
|
}
|
||||||
|
self.removeProductFields = function(item) {
|
||||||
|
self.product_fields.remove(item);
|
||||||
|
self.onChange();
|
||||||
|
}
|
||||||
|
self.removeTaskFields = function(item) {
|
||||||
|
self.task_fields.remove(item);
|
||||||
|
self.onChange();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addField(section) {
|
function addField(section) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="col-lg-3 col-md-6">
|
<div class="col-lg-{{ isset($colWidth) ? $colWidth : 3 }} col-md-6">
|
||||||
|
|
||||||
{!! Former::select("{$section}_select")
|
{!! Former::select("{$section}_select")
|
||||||
->placeholder(trans("texts.{$fields}"))
|
->placeholder(trans("texts.{$fields}"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user