1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00

Working on product fields

This commit is contained in:
Hillel Coren 2017-10-29 21:14:05 +02:00
parent 423b424acf
commit 6f2b842046
8 changed files with 57 additions and 61 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -15,22 +15,28 @@ NINJA.TEMPLATES = {
function GetPdfMake(invoice, javascript, callback) {
// check if we need to add a second table for tasks
var itemsTable = false;
if (invoice.hasSecondTable) {
var json = JSON.parse(javascript);
for (var i=0; i<json.content.length; i++) {
var item = json.content[i];
if (item.table && item.table.body == '$invoiceLineItems') {
itemsTable = JSON.stringify(item);
itemsTable = itemsTable.replace('$invoiceLineItems', '$taskLineItems');
itemsTable = itemsTable.replace('$invoiceLineItemColumns', '$taskLineItemColumns');
break;
if (invoice.hasTasks) {
// check if we need to add a second table for tasks
if (invoice.hasSecondTable) {
var json = JSON.parse(javascript);
for (var i=0; i<json.content.length; i++) {
var item = json.content[i];
if (item.table && item.table.body == '$invoiceLineItems') {
itemsTable = JSON.stringify(item);
itemsTable = itemsTable.replace('$invoiceLineItems', '$taskLineItems');
itemsTable = itemsTable.replace('$invoiceLineItemColumns', '$taskLineItemColumns');
break;
}
}
itemsTable = JSON.parse(itemsTable);
json.content.splice(i+1, 0, itemsTable);
javascript = JSON.stringify(json);
// use the single product table for tasks
} else {
javascript = javascript.replace('$invoiceLineItems', '$taskLineItems');
javascript = javascript.replace('$invoiceLineItemColumns', '$taskLineItemColumns');
}
itemsTable = JSON.parse(itemsTable);
json.content.splice(i+1, 0, itemsTable);
javascript = JSON.stringify(json);
}
javascript = NINJA.decodeJavascript(invoice, javascript);
@ -220,8 +226,8 @@ NINJA.decodeJavascript = function(invoice, javascript)
'accountAddress': NINJA.accountAddress(invoice),
'invoiceDetails': NINJA.invoiceDetails(invoice),
'invoiceDetailsHeight': (NINJA.invoiceDetails(invoice).length * 16) + 16,
'invoiceLineItems': invoice.is_statement ? NINJA.statementLines(invoice) : NINJA.invoiceLines(invoice, ! invoice.hasSecondTable),
'invoiceLineItemColumns': invoice.is_statement ? NINJA.statementColumns(invoice) : NINJA.invoiceColumns(invoice, javascript, ! invoice.hasSecondTable),
'invoiceLineItems': invoice.is_statement ? NINJA.statementLines(invoice) : NINJA.invoiceLines(invoice),
'invoiceLineItemColumns': invoice.is_statement ? NINJA.statementColumns(invoice) : NINJA.invoiceColumns(invoice, javascript),
'taskLineItems': NINJA.invoiceLines(invoice, true),
'taskLineItemColumns': NINJA.invoiceColumns(invoice, javascript, true),
'invoiceDocuments' : NINJA.invoiceDocuments(invoice),
@ -476,12 +482,14 @@ NINJA.invoiceFooter = function(invoice)
NINJA.quantityWidth = function(invoice)
{
return invoice.account.hide_quantity == '1' ? '' : '"14%", ';
var fields = NINJA.productFields(invoice);
return fields.indexOf('product.quantity') >= 0 ? '"14%", ' : '';
}
NINJA.taxWidth = function(invoice)
{
return invoice.account.show_item_taxes == '1' ? '"14%", ' : '';
var fields = NINJA.productFields(invoice);
return fields.indexOf('product.tax') >= 0 ? '"14%", ' : '';
}
NINJA.productFields = function(invoice, isTasks) {
@ -555,6 +563,12 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
headerStyles.push('cost');
}
if (i == 0) {
headerStyles.push('firstColumn');
} else if (i == fields.length - 1) {
headerStyles.push('lastColumn');
}
grid[0].push({text: value, style: headerStyles});
}

View File

@ -347,8 +347,6 @@ $LANG = array(
'session_expired' => 'Your session has expired.',
'invoice_fields' => 'Invoice Fields',
'invoice_options' => 'Invoice Options',
'hide_quantity' => 'Hide Quantity',
'hide_quantity_help' => 'Disable the quantities column, then you can declutter invoices by no longer displaying this field.',
'hide_paid_to_date' => 'Hide Paid to Date',
'hide_paid_to_date_help' => 'Only display the "Paid to Date" area on your invoices once a payment has been received.',
'charge_taxes' => 'Charge taxes',

View File

@ -61,7 +61,6 @@
remove_created_by:{{ Auth::user()->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
invoice_settings:{{ Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
};
invoice.account.hide_quantity = $('#hide_quantity').is(":checked");
invoice.account.invoice_embed_documents = $('#invoice_embed_documents').is(":checked");
invoice.account.hide_paid_to_date = $('#hide_paid_to_date').is(":checked");
invoice.invoice_design_id = $('#invoice_design_id').val();
@ -140,7 +139,6 @@
{!! Former::populateField('invoice_embed_documents', intval($account->invoice_embed_documents)) !!}
{!! Former::populateField('primary_color', $account->primary_color) !!}
{!! Former::populateField('secondary_color', $account->secondary_color) !!}
{!! Former::populateField('hide_quantity', intval($account->hide_quantity)) !!}
{!! Former::populateField('hide_paid_to_date', intval($account->hide_paid_to_date)) !!}
{!! Former::populateField('all_pages_header', intval($account->all_pages_header)) !!}
{!! Former::populateField('all_pages_footer', intval($account->all_pages_footer)) !!}
@ -282,7 +280,6 @@
<div role="tabpanel" class="tab-pane" id="invoice_options">
<div class="panel-body">
{!! 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('invoice_embed_documents')->text(trans('texts.invoice_embed_documents_help'))->value(1) !!}

View File

@ -9,7 +9,6 @@
{{ Former::populate($account) }}
{{ Former::populateField('invoice_taxes', intval($account->invoice_taxes)) }}
{{ Former::populateField('invoice_item_taxes', intval($account->invoice_item_taxes)) }}
{{ Former::populateField('show_item_taxes', intval($account->show_item_taxes)) }}
{{ Former::populateField('enable_second_tax_rate', intval($account->enable_second_tax_rate)) }}
{{ Former::populateField('include_item_taxes_inline', intval($account->include_item_taxes_inline)) }}
@ -30,11 +29,6 @@
->label('&nbsp;')
->value(1) !!}
{!! Former::checkbox('show_item_taxes')
->text(trans('texts.show_line_item_tax'))
->label('&nbsp;')
->value(1) !!}
{!! Former::checkbox('include_item_taxes_inline')
->text(trans('texts.include_item_taxes_inline'))
->label('&nbsp;')

View File

@ -51,7 +51,6 @@ function ViewModel(data) {
self.invoice_taxes = ko.observable({{ Auth::user()->account->invoice_taxes ? 'true' : 'false' }});
self.invoice_item_taxes = ko.observable({{ Auth::user()->account->invoice_item_taxes ? 'true' : 'false' }});
self.show_item_taxes = ko.observable({{ Auth::user()->account->show_item_taxes ? 'true' : 'false' }});
self.mapping = {
'invoice': {

View File

@ -182,12 +182,6 @@
"invoiceNumber": {
"bold": true
},
"itemTableHeader": {
"margin": [40,0,0,0]
},
"totalTableHeader": {
"margin": [0,0,40,0]
},
"tableHeader": {
"fontSize": 12,
"bold": true