mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
use invoice colors
This commit is contained in:
parent
d2e22167da
commit
c36e47a07c
@ -58,8 +58,8 @@ module.exports = function(grunt) {
|
||||
'public/vendor/jspdf/dist/jspdf.min.js',
|
||||
//'public/vendor/handsontable/dist/jquery.handsontable.full.min.js',
|
||||
'public/vendor/pdfmake/build/pdfmake.min.js',
|
||||
//'public/vendor/pdfmake/build/vfs_fonts.js',
|
||||
'public/js/vfs_fonts.js',
|
||||
'public/vendor/pdfmake/build/vfs_fonts.js',
|
||||
//'public/js/vfs_fonts.js',
|
||||
'public/js/lightbox.min.js',
|
||||
'public/js/bootstrap-combobox.js',
|
||||
'public/js/script.js',
|
||||
|
File diff suppressed because one or more lines are too long
@ -83,3 +83,68 @@ function invoiceLines(invoice) {
|
||||
return grid;
|
||||
}
|
||||
|
||||
function subtotals(invoice)
|
||||
{
|
||||
if (!invoice) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = [
|
||||
[invoiceLabels.subtotal, formatMoney(invoice.subtotal_amount, invoice.client.currency_id)],
|
||||
];
|
||||
if(invoice.discount_amount != 0) {
|
||||
data.push([invoiceLabels.discount, formatMoney(invoice.discount_amount, invoice.client.currency_id)]);
|
||||
}
|
||||
|
||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
||||
data.push([invoiceLabels.custom_invoice_label1, formatMoney(invoice.custom_value1, invoice.client.currency_id)]);
|
||||
}
|
||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
||||
data.push([invoiceLabels.custom_invoice_label2, formatMoney(invoice.custom_value2, invoice.client.currency_id)]);
|
||||
}
|
||||
|
||||
if(invoice.tax && invoice.tax.name || invoice.tax_name) {
|
||||
data.push([invoiceLabels.tax, formatMoney(invoice.tax_amount, invoice.client.currency_id)]);
|
||||
}
|
||||
|
||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
||||
data.push([invoiceLabels.custom_invoice_label1, formatMoney(invoice.custom_value1, invoice.client.currency_id)]);
|
||||
}
|
||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
||||
data.push([invoiceLabels.custom_invoice_label2, formatMoney(invoice.custom_value2, invoice.client.currency_id)]);
|
||||
}
|
||||
|
||||
var paid = invoice.amount - invoice.balance;
|
||||
if (invoice.account.hide_paid_to_date != '1' || paid) {
|
||||
data.push([invoiceLabels.paid_to_date, formatMoney(paid, invoice.client.currency_id)]);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function accountDetails(account) {
|
||||
var data = [];
|
||||
if(account.name) data.push({text:account.name, style:'accountDetails'});
|
||||
if(account.id_number) data.push({text:account.id_number, style:'accountDetails'});
|
||||
if(account.vat_number) data.push({text:account.vat_number, style:'accountDetails'});
|
||||
if(account.work_email) data.push({text:account.work_email, style:'accountDetails'});
|
||||
if(account.work_phone) data.push({text:account.work_phone, style:'accountDetails'});
|
||||
return data;
|
||||
}
|
||||
|
||||
function accountAddress(account) {
|
||||
var data = [];
|
||||
if(account.address1) data.push({text:account.address1, style:'accountDetails'});
|
||||
if(account.address2) data.push({text:account.address2, style:'accountDetails'});
|
||||
if(account.city) data.push({text:account.city, style:'accountDetails'});
|
||||
if(account.state) data.push({text:account.state, style:'accountDetails'});
|
||||
if(account.postal_code) data.push({text:account.postal_code, style:'accountDetails'});
|
||||
return data;
|
||||
}
|
||||
|
||||
function primaryColor( defaultColor) {
|
||||
return NINJA.primaryColor?NINJA.primaryColor:defaultColor;
|
||||
}
|
||||
|
||||
function secondaryColor( defaultColor) {
|
||||
return NINJA.primaryColor?NINJA.secondaryColor:defaultColor;
|
||||
}
|
@ -7,7 +7,7 @@ var templateFonts = {
|
||||
bolditalics: 'FreeSansBoldOblique.ttf'
|
||||
}
|
||||
};
|
||||
window.pdfMake.fonts = templateFonts;
|
||||
//window.pdfMake.fonts = templateFonts;
|
||||
var dd = {
|
||||
content: [
|
||||
{
|
||||
@ -20,17 +20,18 @@ var dd = {
|
||||
}:""
|
||||
],
|
||||
{
|
||||
text: [account.name, account.id_number, account.vat_number, account.work_email, account.work_phone].join('\n')
|
||||
stack: accountDetails(account)
|
||||
},
|
||||
{
|
||||
text: [
|
||||
concatStrings(account.address1, account.address2) + "\n",
|
||||
concatStrings(account.city, account.state, account.postal_code)
|
||||
]
|
||||
stack: accountAddress(account)
|
||||
}
|
||||
]
|
||||
},
|
||||
(invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice).toUpperCase(),
|
||||
{
|
||||
text:(invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice).toUpperCase(),
|
||||
margin: [8, 16, 8, 16],
|
||||
style: 'primaryColor'
|
||||
},
|
||||
{
|
||||
style: 'tableExample',
|
||||
table: {
|
||||
@ -55,32 +56,18 @@ var dd = {
|
||||
/*vLineColor: function (i, node) {
|
||||
return (i === 0 || i === node.table.widths.length) ? 'black' : 'gray';
|
||||
},*/
|
||||
// paddingLeft: function(i, node) { return 4; },
|
||||
// paddingRight: function(i, node) { return 4; },
|
||||
// paddingTop: function(i, node) { return 2; },
|
||||
// paddingBottom: function(i, node) { return 2; }
|
||||
paddingLeft: function(i, node) { return 8; },
|
||||
paddingRight: function(i, node) { return 8; },
|
||||
paddingTop: function(i, node) { return 4; },
|
||||
paddingBottom: function(i, node) { return 4; }
|
||||
}
|
||||
},
|
||||
'\n',
|
||||
{
|
||||
style: 'tableExample',
|
||||
table: {
|
||||
headerRows: 1,
|
||||
widths: ['auto', '*', 'auto', 'auto', 'auto', 'auto'],
|
||||
body:invoiceLines(invoice),
|
||||
/*body: [
|
||||
[{text: 'Item', style: 'tableHeader'},
|
||||
{text: 'Description', style: 'tableHeader'},
|
||||
{text: 'Unit Cost', style: 'tableHeader'},
|
||||
{text: 'Quantity', style: 'tableHeader'},
|
||||
{text: invoice.has_taxes?'Tax':'', style: 'tableHeader'},
|
||||
{text: 'Line Total', style: 'tableHeader'}]
|
||||
/*['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', invoice.has_taxes?'Sample value 2':'','Sample value 3'],
|
||||
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', invoice.has_taxes?'Sample value 2':'','Sample value 3'],
|
||||
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', invoice.has_taxes?'Sample value 2':'','Sample value 3'],
|
||||
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', invoice.has_taxes?'Sample value 2':'','Sample value 3'],
|
||||
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', invoice.has_taxes?'Sample value 2':'','Sample value 3']*
|
||||
].push(invoiceLines(invoice))*/
|
||||
},
|
||||
layout: {
|
||||
hLineWidth: function (i, node) {
|
||||
@ -91,14 +78,34 @@ var dd = {
|
||||
},
|
||||
hLineColor: function (i, node) {
|
||||
return '#D8D8D8';
|
||||
}
|
||||
},
|
||||
paddingLeft: function(i, node) { return 8; },
|
||||
paddingRight: function(i, node) { return 8; },
|
||||
paddingTop: function(i, node) { return 8; },
|
||||
paddingBottom: function(i, node) { return 8; }
|
||||
},
|
||||
},
|
||||
{
|
||||
columns: [
|
||||
notesAndTerms(invoice),
|
||||
{
|
||||
text: ""
|
||||
style: 'subtotals',
|
||||
table: {
|
||||
widths: ['*', '*'],
|
||||
body: subtotals(invoice),
|
||||
},
|
||||
layout: {
|
||||
hLineWidth: function (i, node) {
|
||||
return 0;
|
||||
},
|
||||
vLineWidth: function (i, node) {
|
||||
return 0;
|
||||
},
|
||||
paddingLeft: function(i, node) { return 8; },
|
||||
paddingRight: function(i, node) { return 8; },
|
||||
paddingTop: function(i, node) { return 4; },
|
||||
paddingBottom: function(i, node) { return 4; }
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -117,9 +124,18 @@ var dd = {
|
||||
},
|
||||
|
||||
defaultStyle: {
|
||||
font: 'sans'
|
||||
//font: 'sans'
|
||||
fontSize: 9,
|
||||
margin: [8, 4, 8, 4]
|
||||
},
|
||||
styles: {
|
||||
primaryColor:{
|
||||
color: primaryColor('#299CC2')
|
||||
},
|
||||
accountDetails: {
|
||||
margin: [4, 2, 4, 2],
|
||||
color: '#AAA9A9'
|
||||
},
|
||||
bold: {
|
||||
bold: true
|
||||
},
|
||||
@ -128,6 +144,9 @@ var dd = {
|
||||
odd: {
|
||||
fillColor:'#F4F4F4'
|
||||
},
|
||||
productKey: {
|
||||
color:primaryColor('#299CC2')
|
||||
},
|
||||
cost: {
|
||||
alignment: 'right'
|
||||
},
|
||||
@ -139,6 +158,15 @@ var dd = {
|
||||
},
|
||||
lineTotal: {
|
||||
alignment: 'right'
|
||||
},
|
||||
right: {
|
||||
alignment: 'right'
|
||||
},
|
||||
subtotals: {
|
||||
alignment: 'right'
|
||||
},
|
||||
tableHeader: {
|
||||
bold: true
|
||||
}
|
||||
},
|
||||
pageMargins: [72, 40, 40, 80]
|
||||
|
Loading…
Reference in New Issue
Block a user