mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
initial template
This commit is contained in:
parent
69f474cc67
commit
e6ee4150c1
@ -5,7 +5,7 @@
|
|||||||
"jquery": "~1.11",
|
"jquery": "~1.11",
|
||||||
"bootstrap": "~3.*",
|
"bootstrap": "~3.*",
|
||||||
"jquery-ui": "~1.*",
|
"jquery-ui": "~1.*",
|
||||||
"datatables": "~1.*",
|
"datatables": "1.10.5",
|
||||||
"datatables-bootstrap3": "*",
|
"datatables-bootstrap3": "*",
|
||||||
"knockout.js": "~3.*",
|
"knockout.js": "~3.*",
|
||||||
"knockout-mapping": "*",
|
"knockout-mapping": "*",
|
||||||
|
31
public/css/built.css
vendored
31
public/css/built.css
vendored
@ -37,34 +37,26 @@ table.dataTable tfoot td {
|
|||||||
padding: 10px 18px 6px 18px;
|
padding: 10px 18px 6px 18px;
|
||||||
border-top: 1px solid #111111;
|
border-top: 1px solid #111111;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting,
|
|
||||||
table.dataTable thead .sorting_asc,
|
table.dataTable thead .sorting_asc,
|
||||||
table.dataTable thead .sorting_desc {
|
table.dataTable thead .sorting_desc,
|
||||||
|
table.dataTable thead .sorting {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
*cursor: hand;
|
*cursor: hand;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting,
|
|
||||||
table.dataTable thead .sorting_asc,
|
|
||||||
table.dataTable thead .sorting_desc,
|
|
||||||
table.dataTable thead .sorting_asc_disabled,
|
|
||||||
table.dataTable thead .sorting_desc_disabled {
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center right;
|
|
||||||
}
|
|
||||||
table.dataTable thead .sorting {
|
table.dataTable thead .sorting {
|
||||||
background-image: url("../images/sort_both.png");
|
background: url("../images/sort_both.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_asc {
|
table.dataTable thead .sorting_asc {
|
||||||
background-image: url("../images/sort_asc.png");
|
background: url("../images/sort_asc.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_desc {
|
table.dataTable thead .sorting_desc {
|
||||||
background-image: url("../images/sort_desc.png");
|
background: url("../images/sort_desc.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_asc_disabled {
|
table.dataTable thead .sorting_asc_disabled {
|
||||||
background-image: url("../images/sort_asc_disabled.png");
|
background: url("../images/sort_asc_disabled.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_desc_disabled {
|
table.dataTable thead .sorting_desc_disabled {
|
||||||
background-image: url("../images/sort_desc_disabled.png");
|
background: url("../images/sort_desc_disabled.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable tbody tr {
|
table.dataTable tbody tr {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
@ -216,15 +208,15 @@ table.dataTable.nowrap th, table.dataTable.nowrap td {
|
|||||||
}
|
}
|
||||||
table.dataTable.compact thead th,
|
table.dataTable.compact thead th,
|
||||||
table.dataTable.compact thead td {
|
table.dataTable.compact thead td {
|
||||||
padding: 4px 17px 4px 4px;
|
padding: 5px 9px;
|
||||||
}
|
}
|
||||||
table.dataTable.compact tfoot th,
|
table.dataTable.compact tfoot th,
|
||||||
table.dataTable.compact tfoot td {
|
table.dataTable.compact tfoot td {
|
||||||
padding: 4px;
|
padding: 5px 9px 3px 9px;
|
||||||
}
|
}
|
||||||
table.dataTable.compact tbody th,
|
table.dataTable.compact tbody th,
|
||||||
table.dataTable.compact tbody td {
|
table.dataTable.compact tbody td {
|
||||||
padding: 4px;
|
padding: 4px 5px;
|
||||||
}
|
}
|
||||||
table.dataTable th.dt-left,
|
table.dataTable th.dt-left,
|
||||||
table.dataTable td.dt-left {
|
table.dataTable td.dt-left {
|
||||||
@ -406,9 +398,6 @@ table.dataTable td {
|
|||||||
/* W3C */
|
/* W3C */
|
||||||
box-shadow: inset 0 0 3px #111;
|
box-shadow: inset 0 0 3px #111;
|
||||||
}
|
}
|
||||||
.dataTables_wrapper .dataTables_paginate .ellipsis {
|
|
||||||
padding: 0 1em;
|
|
||||||
}
|
|
||||||
.dataTables_wrapper .dataTables_processing {
|
.dataTables_wrapper .dataTables_processing {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
31
public/css/built.public.css
vendored
31
public/css/built.public.css
vendored
@ -37,34 +37,26 @@ table.dataTable tfoot td {
|
|||||||
padding: 10px 18px 6px 18px;
|
padding: 10px 18px 6px 18px;
|
||||||
border-top: 1px solid #111111;
|
border-top: 1px solid #111111;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting,
|
|
||||||
table.dataTable thead .sorting_asc,
|
table.dataTable thead .sorting_asc,
|
||||||
table.dataTable thead .sorting_desc {
|
table.dataTable thead .sorting_desc,
|
||||||
|
table.dataTable thead .sorting {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
*cursor: hand;
|
*cursor: hand;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting,
|
|
||||||
table.dataTable thead .sorting_asc,
|
|
||||||
table.dataTable thead .sorting_desc,
|
|
||||||
table.dataTable thead .sorting_asc_disabled,
|
|
||||||
table.dataTable thead .sorting_desc_disabled {
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center right;
|
|
||||||
}
|
|
||||||
table.dataTable thead .sorting {
|
table.dataTable thead .sorting {
|
||||||
background-image: url("../images/sort_both.png");
|
background: url("../images/sort_both.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_asc {
|
table.dataTable thead .sorting_asc {
|
||||||
background-image: url("../images/sort_asc.png");
|
background: url("../images/sort_asc.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_desc {
|
table.dataTable thead .sorting_desc {
|
||||||
background-image: url("../images/sort_desc.png");
|
background: url("../images/sort_desc.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_asc_disabled {
|
table.dataTable thead .sorting_asc_disabled {
|
||||||
background-image: url("../images/sort_asc_disabled.png");
|
background: url("../images/sort_asc_disabled.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable thead .sorting_desc_disabled {
|
table.dataTable thead .sorting_desc_disabled {
|
||||||
background-image: url("../images/sort_desc_disabled.png");
|
background: url("../images/sort_desc_disabled.png") no-repeat center right;
|
||||||
}
|
}
|
||||||
table.dataTable tbody tr {
|
table.dataTable tbody tr {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
@ -216,15 +208,15 @@ table.dataTable.nowrap th, table.dataTable.nowrap td {
|
|||||||
}
|
}
|
||||||
table.dataTable.compact thead th,
|
table.dataTable.compact thead th,
|
||||||
table.dataTable.compact thead td {
|
table.dataTable.compact thead td {
|
||||||
padding: 4px 17px 4px 4px;
|
padding: 5px 9px;
|
||||||
}
|
}
|
||||||
table.dataTable.compact tfoot th,
|
table.dataTable.compact tfoot th,
|
||||||
table.dataTable.compact tfoot td {
|
table.dataTable.compact tfoot td {
|
||||||
padding: 4px;
|
padding: 5px 9px 3px 9px;
|
||||||
}
|
}
|
||||||
table.dataTable.compact tbody th,
|
table.dataTable.compact tbody th,
|
||||||
table.dataTable.compact tbody td {
|
table.dataTable.compact tbody td {
|
||||||
padding: 4px;
|
padding: 4px 5px;
|
||||||
}
|
}
|
||||||
table.dataTable th.dt-left,
|
table.dataTable th.dt-left,
|
||||||
table.dataTable td.dt-left {
|
table.dataTable td.dt-left {
|
||||||
@ -406,9 +398,6 @@ table.dataTable td {
|
|||||||
/* W3C */
|
/* W3C */
|
||||||
box-shadow: inset 0 0 3px #111;
|
box-shadow: inset 0 0 3px #111;
|
||||||
}
|
}
|
||||||
.dataTables_wrapper .dataTables_paginate .ellipsis {
|
|
||||||
padding: 0 1em;
|
|
||||||
}
|
|
||||||
.dataTables_wrapper .dataTables_processing {
|
.dataTables_wrapper .dataTables_processing {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,108 @@
|
|||||||
|
function GetPdfMake(invoice, javascript, callback) {
|
||||||
|
//var docDefinition = { content: 'This is an sample PDF printed wwęęwith pdfMake ĄČĘĖĮŠŲŪŽąčęėįšųž€' };
|
||||||
|
//eval(javascript);
|
||||||
|
|
||||||
|
//pdfmake
|
||||||
|
var cb = callback;
|
||||||
|
var account = invoice.account;
|
||||||
|
$.get( "../js/templates/clean.js", null, null, 'text')
|
||||||
|
.done(function( data ) {
|
||||||
|
//var account = invoice.account;
|
||||||
|
eval(data);
|
||||||
|
//var dd = {};
|
||||||
|
doc = pdfMake.createPdf(dd);
|
||||||
|
doc.getDataUrl(cb);
|
||||||
|
}).fail(function(xhr, status, error) {
|
||||||
|
console.log(error);
|
||||||
|
var err = eval("(" + xhr.responseText + ")");
|
||||||
|
alert(err.Message);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
var dd = {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
text: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: [account.name, account.id_number, account.vat_number, account.work_email, account.work_phone].join('\n')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: [
|
||||||
|
concatStrings(account.address1, account.address2) + "\n",
|
||||||
|
concatStrings(account.city, account.state, account.postal_code)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'INVOICE',
|
||||||
|
"-",
|
||||||
|
{
|
||||||
|
style: 'tableExample',
|
||||||
|
table: {
|
||||||
|
headerRows: 1,
|
||||||
|
body: [
|
||||||
|
['Sample value 1 \n x',
|
||||||
|
'Sample value 2 \n x',
|
||||||
|
'Sample value 3 \n x'
|
||||||
|
],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
layout: 'noBorders'
|
||||||
|
},
|
||||||
|
"-",
|
||||||
|
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
|
||||||
|
{
|
||||||
|
style: 'tableExample',
|
||||||
|
table: {
|
||||||
|
headerRows: 1,
|
||||||
|
widths: ['auto', '*', 'auto', 'auto', 'auto'],
|
||||||
|
body: [
|
||||||
|
[{text: 'Header 1', style: 'tableHeader'}, {text: 'Header 2', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
layout: 'lightHorizontalLines'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
var doc = new jsPDF('portrait', 'pt', 'a4');
|
||||||
|
|
||||||
|
//doc.getStringUnitWidth = function(param) { console.log('getStringUnitWidth: %s', param); return 0};
|
||||||
|
|
||||||
|
//Set PDF properities
|
||||||
|
doc.setProperties({
|
||||||
|
title: 'Invoice ' + invoice.invoice_number,
|
||||||
|
subject: '',
|
||||||
|
author: 'InvoiceNinja.com',
|
||||||
|
keywords: 'pdf, invoice',
|
||||||
|
creator: 'InvoiceNinja.com'
|
||||||
|
});
|
||||||
|
|
||||||
|
//set default style for report
|
||||||
|
doc.setFont('Helvetica','');
|
||||||
|
|
||||||
|
eval(javascript);
|
||||||
|
|
||||||
|
// add footer
|
||||||
|
if (invoice.invoice_footer) {
|
||||||
|
doc.setFontType('normal');
|
||||||
|
doc.setFontSize('8');
|
||||||
|
SetPdfColor(invoice.invoice_design_id == 2 || invoice.invoice_design_id == 3 ? 'White' : 'Black',doc);
|
||||||
|
var top = doc.internal.pageSize.height - layout.marginLeft;
|
||||||
|
var numLines = invoice.invoice_footer.split("\n").length - 1;
|
||||||
|
doc.text(layout.marginLeft, top - (numLines * 8), invoice.invoice_footer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
@ -8,17 +8,23 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
|
|||||||
|
|
||||||
|
|
||||||
var invoiceOld;
|
var invoiceOld;
|
||||||
function generatePDF(invoice, javascript, force) {
|
function generatePDF(invoice, javascript, force, cb) {
|
||||||
invoice = calculateAmounts(invoice);
|
invoice = calculateAmounts(invoice);
|
||||||
var a = copyInvoice(invoice);
|
var a = copyInvoice(invoice);
|
||||||
var b = copyInvoice(invoiceOld);
|
var b = copyInvoice(invoiceOld);
|
||||||
if (!force && _.isEqual(a, b)) {
|
if (!force && _.isEqual(a, b)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
pdfmakeMarker = "//pdfmake";
|
||||||
invoiceOld = invoice;
|
invoiceOld = invoice;
|
||||||
report_id = invoice.invoice_design_id;
|
report_id = invoice.invoice_design_id;
|
||||||
|
if(true || javascript.slice(0, pdfmakeMarker.length) === pdfmakeMarker) {
|
||||||
|
GetPdfMake(invoice, javascript, cb);
|
||||||
|
//doc.getDataUrl(cb);
|
||||||
|
} else {
|
||||||
doc = GetPdf(invoice, javascript);
|
doc = GetPdf(invoice, javascript);
|
||||||
return doc;
|
cb( doc.output("datauristring"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyInvoice(orig) {
|
function copyInvoice(orig) {
|
||||||
@ -797,7 +803,7 @@ function concatStrings() {
|
|||||||
concatStr += ' ';
|
concatStr += ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data.length ? concatStr : false;
|
return data.length ? concatStr : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayGrid(doc, invoice, data, x, y, layout, options) {
|
function displayGrid(doc, invoice, data, x, y, layout, options) {
|
||||||
|
73
public/js/templates/clean.js
Normal file
73
public/js/templates/clean.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
dd = {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
text: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: [account.name, account.id_number, account.vat_number, account.work_email, account.work_phone].join('\n')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: [
|
||||||
|
concatStrings(account.address1, account.address2) + "\n",
|
||||||
|
concatStrings(account.city, account.state, account.postal_code)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'INVOICE',
|
||||||
|
{
|
||||||
|
style: 'tableExample',
|
||||||
|
table: {
|
||||||
|
headerRows: 1,
|
||||||
|
widths: ['auto', 'auto', '*'],
|
||||||
|
body: [
|
||||||
|
['Invoice Number', {style: 'bold', text: invoice.invoice_number}, ""],
|
||||||
|
['Invoice Date', invoice.invoice_date, ""],
|
||||||
|
['Balance Due', formatMoney(invoice.balance_amount, invoice.client.currency_id), ""],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
hLineWidth: function (i, node) {
|
||||||
|
return (i === 0 || i === node.table.body.length) ? 1 : 0;
|
||||||
|
},
|
||||||
|
vLineWidth: function (i, node) {
|
||||||
|
return 0;//(i === 0 || i === node.table.widths.length) ? 2 : 1;
|
||||||
|
},
|
||||||
|
hLineColor: function (i, node) {
|
||||||
|
return 'gray';//(i === 0 || i === node.table.body.length) ? 'black' : 'gray';
|
||||||
|
},
|
||||||
|
/*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; }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'\n',
|
||||||
|
{
|
||||||
|
style: 'tableExample',
|
||||||
|
table: {
|
||||||
|
headerRows: 1,
|
||||||
|
widths: ['auto', '*', 'auto', 'auto', 'auto'],
|
||||||
|
body: [
|
||||||
|
[{text: 'Item', style: 'tableHeader'}, {text: 'Description', style: 'tableHeader'}, {text: 'Unit Cost', style: 'tableHeader'}, {text: 'Quantity', style: 'tableHeader'}, {text: 'Line Total', style: 'tableHeader'}],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'],
|
||||||
|
['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3']
|
||||||
|
]
|
||||||
|
},
|
||||||
|
layout: 'lightHorizontalLines'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
styles: {
|
||||||
|
bold: {
|
||||||
|
bold: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -688,13 +688,11 @@
|
|||||||
return invoice;
|
return invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPDFString() {
|
function getPDFString(cb) {
|
||||||
var invoice = createInvoiceModel();
|
var invoice = createInvoiceModel();
|
||||||
var design = getDesignJavascript();
|
var design = getDesignJavascript();
|
||||||
if (!design) return;
|
if (!design) return;
|
||||||
var doc = generatePDF(invoice, design);
|
generatePDF(invoice, design, false, cb);
|
||||||
if (!doc) return;
|
|
||||||
return doc.output('datauristring');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDesignJavascript() {
|
function getDesignJavascript() {
|
||||||
|
@ -81,18 +81,19 @@
|
|||||||
var needsRefresh = false;
|
var needsRefresh = false;
|
||||||
|
|
||||||
function refreshPDF() {
|
function refreshPDF() {
|
||||||
|
getPDFString(refreshPDFCB);
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshPDFCB(string) {
|
||||||
|
if (!string) return;
|
||||||
PDFJS.workerSrc = '{{ asset('js/pdf_viewer.worker.js') }}';
|
PDFJS.workerSrc = '{{ asset('js/pdf_viewer.worker.js') }}';
|
||||||
if ({{ Auth::check() && Auth::user()->force_pdfjs ? 'false' : 'true' }} && (isFirefox || (isChrome && !isChromium))) {
|
if ({{ Auth::check() && Auth::user()->force_pdfjs ? 'false' : 'true' }} && (isFirefox || (isChrome && !isChromium))) {
|
||||||
var string = getPDFString();
|
|
||||||
if (!string) return;
|
|
||||||
$('#theFrame').attr('src', string).show();
|
$('#theFrame').attr('src', string).show();
|
||||||
} else {
|
} else {
|
||||||
if (isRefreshing) {
|
if (isRefreshing) {
|
||||||
needsRefresh = true;
|
needsRefresh = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var string = getPDFString();
|
|
||||||
if (!string) return;
|
|
||||||
isRefreshing = true;
|
isRefreshing = true;
|
||||||
var pdfAsArray = convertDataURIToBinary(string);
|
var pdfAsArray = convertDataURIToBinary(string);
|
||||||
PDFJS.getDocument(pdfAsArray).then(function getPdfHelloWorld(pdf) {
|
PDFJS.getDocument(pdfAsArray).then(function getPdfHelloWorld(pdf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user