diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 05b418d548ef..67c185d0bd42 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -188,7 +188,7 @@ class AccountController extends BaseController } elseif ($section == ACCOUNT_IMPORT_EXPORT) { return View::make('accounts.import_export', ['title' => trans('texts.import_export')]); } elseif ($section == ACCOUNT_ADVANCED_SETTINGS) { - $account = Auth::user()->account; + $account = Auth::user()->account->load('country'); $data = [ 'account' => $account, 'feature' => $subSection, @@ -215,8 +215,8 @@ class AccountController extends BaseController $invoice->account = json_decode($account->toJson()); $invoice->amount = $invoice->balance = 100; - $invoice->terms = $account->invoice_terms; - $invoice->invoice_footer = $account->invoice_footer; + $invoice->terms = trim($account->invoice_terms); + $invoice->invoice_footer = trim($account->invoice_footer); $contact->email = 'contact@gmail.com'; $client->contacts = [$contact]; @@ -244,7 +244,7 @@ class AccountController extends BaseController } if ($subSection == ACCOUNT_CUSTOMIZE_DESIGN) { - $data['customDesign'] = $account->custom_design ?: $design; + $data['customDesign'] = $account->custom_design && !$design ? $account->custom_design : $design; } } else if ($subSection == ACCOUNT_EMAIL_TEMPLATES) { $data['invoiceEmail'] = $account->getEmailTemplate(ENTITY_INVOICE); @@ -701,14 +701,22 @@ class AccountController extends BaseController $image = Image::make($path); $mimeType = $file->getMimeType(); - - if ($image->width() == 200 && $mimeType == 'image/jpeg') { + + if ($mimeType == 'image/jpeg') { $file->move('logo/', $account->account_key . '.jpg'); + } else if ($mimeType == 'image/png') { + $file->move('logo/', $account->account_key . '.png'); + + if (!$account->utf8_invoices) { + $account->utf8_invoices = true; + $account->save(); + } } else { $image->resize(200, 120, function ($constraint) { $constraint->aspectRatio(); }); - Image::canvas($image->width(), $image->height(), '#FFFFFF')->insert($image)->save($account->getLogoPath()); + Image::canvas($image->width(), $image->height(), '#FFFFFF') + ->insert($image)->save('logo/'.$this->account_key.'.jpg'); } } diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 9defb3e9af9c..e286b885cbf6 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -44,6 +44,8 @@ class DashboardController extends BaseController ->where('accounts.id', '=', Auth::user()->account_id) ->where('clients.is_deleted', '=', false) ->where('invoices.is_deleted', '=', false) + ->where('invoices.is_quote', '=', false) + ->where('invoices.is_recurring', '=', false) ->groupBy('accounts.id') ->groupBy(DB::raw('CASE WHEN clients.currency_id IS NULL THEN CASE WHEN accounts.currency_id IS NULL THEN 1 ELSE accounts.currency_id END ELSE clients.currency_id END')) ->get(); diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index c8aa8146eb13..e477944ad11b 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -329,7 +329,6 @@ class InvoiceController extends BaseController $data = array( 'entityType' => $entityType, 'showBreadcrumbs' => $clone, - 'account' => $invoice->account, 'invoice' => $invoice, 'data' => false, 'method' => $method, @@ -364,7 +363,6 @@ class InvoiceController extends BaseController { $client = null; $invoiceNumber = Auth::user()->account->getNextInvoiceNumber(); - $account = Account::with('country')->findOrFail(Auth::user()->account_id); if ($clientPublicId) { $client = Client::scope($clientPublicId)->firstOrFail(); @@ -372,7 +370,6 @@ class InvoiceController extends BaseController $data = array( 'entityType' => ENTITY_INVOICE, - 'account' => $account, 'invoice' => null, 'data' => Input::old('data'), 'invoiceNumber' => $invoiceNumber, @@ -399,7 +396,7 @@ class InvoiceController extends BaseController } return [ - 'account' => Auth::user()->account, + 'account' => Auth::user()->account->load('country'), 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Cache::get('countries'), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), diff --git a/app/Http/routes.php b/app/Http/routes.php index 967015acfed6..7725b1043154 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -365,12 +365,15 @@ define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com'); define('NINJA_VERSION', '2.2.2'); define('NINJA_DATE', '2000-01-01'); + define('NINJA_FROM_EMAIL', 'maildelivery@invoiceninja.com'); define('RELEASES_URL', 'https://github.com/hillelcoren/invoice-ninja/releases/'); define('ZAPIER_URL', 'https://zapier.com/developer/invite/11276/85cf0ee4beae8e802c6c579eb4e351f1/'); define('OUTDATE_BROWSER_URL', 'http://browsehappy.com/'); +define('PDFMAKE_DOCS', 'http://pdfmake.org/playground.html'); define('COUNT_FREE_DESIGNS', 4); +define('COUNT_FREE_DESIGNS_SELF_HOST', 5); // include the custom design define('PRODUCT_ONE_CLICK_INSTALL', 1); define('PRODUCT_INVOICE_DESIGNS', 2); define('PRODUCT_WHITE_LABEL', 3); @@ -436,7 +439,6 @@ function otrans($text) } } -/* // Log all SQL queries to laravel.log Event::listen('illuminate.query', function($query, $bindings, $time, $name) { @@ -461,7 +463,6 @@ Event::listen('illuminate.query', function($query, $bindings, $time, $name) Log::info($query, $data); }); -*/ /* if (Auth::check() && Auth::user()->id === 1) diff --git a/app/Models/Account.php b/app/Models/Account.php index 7aadf6368389..10ba19d99ecd 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -146,7 +146,8 @@ class Account extends Eloquent public function getLogoPath() { - return 'logo/'.$this->account_key.'.jpg'; + $fileName = 'logo/' . $this->account_key; + return file_exists($fileName.'.png') ? $fileName.'.png' : $fileName.'.jpg'; } public function getLogoWidth() @@ -267,6 +268,9 @@ class Account extends Eloquent 'balance', 'from', 'to', + 'invoice_to', + 'details', + 'invoice_no', ]; foreach ($fields as $field) { @@ -418,7 +422,7 @@ class Account extends Eloquent Account::updating(function ($account) { // Lithuanian requires UTF8 support - if (!Utils::isPro()) { - $account->utf8_invoices = ($account->language_id == 13) ? 1 : 0; + if (!Utils::isPro() && $account->language_id == 13) { + $account->utf8_invoices = true; } }); diff --git a/app/Models/User.php b/app/Models/User.php index 3ffed163543d..9343c686f666 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -100,7 +100,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon public function maxInvoiceDesignId() { - return $this->isPro() ? 11 : COUNT_FREE_DESIGNS; + return $this->isPro() ? 11 : (Utils::isNinja() ? COUNT_FREE_DESIGNS : COUNT_FREE_DESIGNS_SELF_HOST); } public function getDisplayName() diff --git a/public/js/built.js b/public/js/built.js index b2ff6db5633d..4a6291fc333d 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -33229,6 +33229,17 @@ function twoDigits(value) { } return value; } + +function toSnakeCase(str) { + if (!str) return ''; + return str.replace(/([A-Z])/g, function($1){return "_"+$1.toLowerCase();}); +} + +function getDescendantProp(obj, desc) { + var arr = desc.split("."); + while(arr.length && (obj = obj[arr.shift()])); + return obj; +} var NINJA = NINJA || {}; NINJA.TEMPLATES = { @@ -33245,8 +33256,6 @@ NINJA.TEMPLATES = { }; function GetPdfMake(invoice, javascript, callback) { - //console.log("== GetPdfMake.. "); - //console.log(javascript); javascript = NINJA.decodeJavascript(invoice, javascript); @@ -33265,6 +33274,11 @@ function GetPdfMake(invoice, javascript, callback) { return function (i, node) { return i === 0 ? 0 : parseFloat(parts[1]); }; + } else if ((val+'').indexOf('$border') === 0) { + var parts = val.split(':'); + return function (i, node) { + return parseFloat(parts[1]); + }; } else if ((val+'').indexOf('$padding') === 0) { var parts = val.split(':'); return function (i, node) { @@ -33284,6 +33298,11 @@ function GetPdfMake(invoice, javascript, callback) { //console.log(javascript); var dd = JSON.parse(javascript, jsonCallBack); + + if (!invoice.is_pro && dd.footer.hasOwnProperty('columns')) { + dd.footer.columns.push({image: logoImages.imageLogo1, alignment: 'right', width: 130}) + } + //console.log(JSON.stringify(dd)); /* @@ -33309,6 +33328,7 @@ NINJA.decodeJavascript = function(invoice, javascript) var account = invoice.account; var blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII='; + // search/replace variables var json = { 'accountName': account.name || ' ', 'accountLogo': window.accountLogo || blankImage, @@ -33326,14 +33346,19 @@ NINJA.decodeJavascript = function(invoice, javascript) 'balanceDue': formatMoney(invoice.balance_amount, invoice.client.currency_id), 'balanceDueLabel': invoiceLabels.balance_due, 'invoiceFooter': account.invoice_footer || ' ', + 'invoiceNumber': invoice.invoice_number || ' ', 'entityType': invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice, 'entityTypeUpper': (invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice).toUpperCase(), 'yourInvoice': invoiceLabels.your_invoice, 'yourInvoiceUpper': invoiceLabels.your_invoice.toUpperCase(), 'invoiceIssuedTo': invoiceLabels.invoice_issued_to + ':', + 'invoiceTo': invoiceLabels.invoice_to + ':', + 'details': invoiceLabels.details + ':', + 'fromUpper': invoiceLabels.from.toUpperCase() + ':', + 'toUpper': invoiceLabels.to.toUpperCase() + ':', 'fontSize': NINJA.fontSize, 'fontSizeLarger': NINJA.fontSize + 1, - 'fontSizeLargest': NINJA.fontSize + 2, + 'fontSizeLargest': NINJA.fontSize + 2, } for (var key in json) { @@ -33342,6 +33367,41 @@ NINJA.decodeJavascript = function(invoice, javascript) javascript = javascript.replace(regExp, val); } + // search/replace labels + var regExp = new RegExp('"\\$\\\w*?Label(UC)?"', 'g'); + var matches = javascript.match(regExp); + + if (matches) { + for (var i=0; i= 0) { + if (!label) console.log('match: ' + field); + label = label.toUpperCase(); + } + javascript = javascript.replace(match, '"'+label+'"'); + } + } + + // search/replace values + var regExp = new RegExp('"\\$\\\w*?Value"', 'g'); + var matches = javascript.match(regExp); + + if (matches) { + for (var i=0; i= 0) { + value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); + } + javascript = javascript.replace(match, '"'+value+'"'); + } + } + return javascript; } @@ -33355,7 +33415,7 @@ NINJA.notesAndTerms = function(invoice) } if (invoice.terms) { - data.push({text:invoiceLabels.terms, style: ['bold']}); + data.push({text:invoiceLabels.terms, style: ['termsLabel']}); data.push({text:invoice.terms, style: ['terms']}); } @@ -33405,8 +33465,7 @@ NINJA.invoiceLines = function(invoice) { } // show at most one blank line - //if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) { - if ((!cost || cost == '0.00') && !notes && !productKey) { + if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) { continue; } @@ -33490,7 +33549,6 @@ NINJA.subtotals = function(invoice, removeBalance) ]); } - //return data; return NINJA.prepareDataPairs(data, 'subtotals'); } @@ -33559,7 +33617,7 @@ NINJA.invoiceDetails = function(invoice) { } data.push([ - {text: invoiceLabels.balance_due}, + {text: invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, {text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style: ['invoiceDetailBalanceDue']} ]) diff --git a/public/js/pdf.pdfmake.js b/public/js/pdf.pdfmake.js index 93c9c0e556a6..a968376abb78 100644 --- a/public/js/pdf.pdfmake.js +++ b/public/js/pdf.pdfmake.js @@ -14,8 +14,6 @@ NINJA.TEMPLATES = { }; function GetPdfMake(invoice, javascript, callback) { - //console.log("== GetPdfMake.. "); - //console.log(javascript); javascript = NINJA.decodeJavascript(invoice, javascript); @@ -34,6 +32,11 @@ function GetPdfMake(invoice, javascript, callback) { return function (i, node) { return i === 0 ? 0 : parseFloat(parts[1]); }; + } else if ((val+'').indexOf('$border') === 0) { + var parts = val.split(':'); + return function (i, node) { + return parseFloat(parts[1]); + }; } else if ((val+'').indexOf('$padding') === 0) { var parts = val.split(':'); return function (i, node) { @@ -53,6 +56,11 @@ function GetPdfMake(invoice, javascript, callback) { //console.log(javascript); var dd = JSON.parse(javascript, jsonCallBack); + + if (!invoice.is_pro && dd.footer.hasOwnProperty('columns')) { + dd.footer.columns.push({image: logoImages.imageLogo1, alignment: 'right', width: 130}) + } + //console.log(JSON.stringify(dd)); /* @@ -78,6 +86,7 @@ NINJA.decodeJavascript = function(invoice, javascript) var account = invoice.account; var blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII='; + // search/replace variables var json = { 'accountName': account.name || ' ', 'accountLogo': window.accountLogo || blankImage, @@ -95,14 +104,19 @@ NINJA.decodeJavascript = function(invoice, javascript) 'balanceDue': formatMoney(invoice.balance_amount, invoice.client.currency_id), 'balanceDueLabel': invoiceLabels.balance_due, 'invoiceFooter': account.invoice_footer || ' ', + 'invoiceNumber': invoice.invoice_number || ' ', 'entityType': invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice, 'entityTypeUpper': (invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice).toUpperCase(), 'yourInvoice': invoiceLabels.your_invoice, 'yourInvoiceUpper': invoiceLabels.your_invoice.toUpperCase(), 'invoiceIssuedTo': invoiceLabels.invoice_issued_to + ':', + 'invoiceTo': invoiceLabels.invoice_to + ':', + 'details': invoiceLabels.details + ':', + 'fromUpper': invoiceLabels.from.toUpperCase() + ':', + 'toUpper': invoiceLabels.to.toUpperCase() + ':', 'fontSize': NINJA.fontSize, 'fontSizeLarger': NINJA.fontSize + 1, - 'fontSizeLargest': NINJA.fontSize + 2, + 'fontSizeLargest': NINJA.fontSize + 2, } for (var key in json) { @@ -111,6 +125,41 @@ NINJA.decodeJavascript = function(invoice, javascript) javascript = javascript.replace(regExp, val); } + // search/replace labels + var regExp = new RegExp('"\\$\\\w*?Label(UC)?"', 'g'); + var matches = javascript.match(regExp); + + if (matches) { + for (var i=0; i= 0) { + if (!label) console.log('match: ' + field); + label = label.toUpperCase(); + } + javascript = javascript.replace(match, '"'+label+'"'); + } + } + + // search/replace values + var regExp = new RegExp('"\\$\\\w*?Value"', 'g'); + var matches = javascript.match(regExp); + + if (matches) { + for (var i=0; i= 0) { + value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); + } + javascript = javascript.replace(match, '"'+value+'"'); + } + } + return javascript; } @@ -124,7 +173,7 @@ NINJA.notesAndTerms = function(invoice) } if (invoice.terms) { - data.push({text:invoiceLabels.terms, style: ['bold']}); + data.push({text:invoiceLabels.terms, style: ['termsLabel']}); data.push({text:invoice.terms, style: ['terms']}); } @@ -174,8 +223,7 @@ NINJA.invoiceLines = function(invoice) { } // show at most one blank line - //if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) { - if ((!cost || cost == '0.00') && !notes && !productKey) { + if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) { continue; } @@ -259,7 +307,6 @@ NINJA.subtotals = function(invoice, removeBalance) ]); } - //return data; return NINJA.prepareDataPairs(data, 'subtotals'); } @@ -328,7 +375,7 @@ NINJA.invoiceDetails = function(invoice) { } data.push([ - {text: invoiceLabels.balance_due}, + {text: invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, {text: formatMoney(invoice.balance_amount, invoice.client.currency_id), style: ['invoiceDetailBalanceDue']} ]) diff --git a/public/js/script.js b/public/js/script.js index 6ef77056662b..dded462d101a 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1592,4 +1592,15 @@ function twoDigits(value) { return '0' + value; } return value; +} + +function toSnakeCase(str) { + if (!str) return ''; + return str.replace(/([A-Z])/g, function($1){return "_"+$1.toLowerCase();}); +} + +function getDescendantProp(obj, desc) { + var arr = desc.split("."); + while(arr.length && (obj = obj[arr.shift()])); + return obj; } \ No newline at end of file diff --git a/public/js/templates/bold.js b/public/js/templates/bold.js index 2ab1d506fa5f..529c397b918f 100644 --- a/public/js/templates/bold.js +++ b/public/js/templates/bold.js @@ -13,7 +13,7 @@ {"text":"$yourInvoiceUpper", "style": "yourInvoice"}, "$clientDetails" ], - "margin": [-32, 150, 0, 0] + "margin": [-32, 120, 0, 0] }, { "canvas": [ @@ -22,21 +22,21 @@ "x": 0, "y": 0, "w": 225, - "h": 80, + "h": "$invoiceDetailsHeight", "r":0, "lineWidth": 1, - "color": "#36a399" + "color": "$primaryColor:#36a498" } ], "width":10, - "margin":[-10,150,0,0] + "margin":[-10,120,0,0] }, { "table": { "body": "$invoiceDetails" }, "layout": "noBorders", - "margin": [0, 160, 0, 0] + "margin": [0, 130, 0, 0] } ] }, @@ -93,8 +93,21 @@ {"canvas": [{ "type": "line", "x1": 0, "y1": 0, "x2": 150, "y2":0,"lineWidth": 60,"lineColor":"#2e2b2b"}],"width":100,"margin":[0,0,0,0]}, {"canvas": [{ "type": "line", "x1": 149, "y1": 0, "x2": 600, "y2":0,"lineWidth": 200,"lineColor":"#2e2b2b"}],"width":10,"margin":[0,0,0,0]}, { - "stack": "$accountDetails", - "margin": [380, 16, 0, 0] + "columns": [ + { + "text": " ", + "width": 260 + }, + { + "stack": "$accountDetails", + "margin": [0, 16, 0, 0], + "width": 140 + }, + { + "stack": "$accountAddress", + "margin": [20, 16, 0, 0] + } + ] } ], "defaultStyle": { @@ -103,22 +116,27 @@ }, "styles": { "primaryColor":{ - "color": "$primaryColor:#299CC2" + "color": "$primaryColor:#36a498" }, "accountName": { + "bold": true, "margin": [4, 2, 4, 2], - "color": "$primaryColor:#299CC2" + "color": "$primaryColor:#36a498" }, "accountDetails": { "margin": [4, 2, 4, 2], "color": "#AAA9A9" }, + "accountAddress": { + "margin": [4, 2, 4, 2], + "color": "#AAA9A9" + }, "odd": { "fillColor": "#ebebeb", "margin": [0,0,0,0] }, "productKey": { - "color": "$primaryColor:#299CC2" + "color": "$primaryColor:#36a498" }, "balanceDueLabel": { "fontSize": "$fontSizeLargest", @@ -126,7 +144,7 @@ }, "balanceDue": { "fontSize": "$fontSizeLargest", - "color": "$primaryColor:#299CC2", + "color": "$primaryColor:#36a498", "bold": true }, "invoiceDetails": { @@ -146,18 +164,18 @@ "bold": true }, "productKey": { - "color": "$primaryColor:#299CC2", + "color": "$primaryColor:#36a498", "margin": [40,0,0,0], "bold": true }, "yourInvoice": { "bold": true, "fontSize": 14, - "color": "#36a399", + "color": "$primaryColor:#36a498", "margin": [0,0,0,8] }, "invoiceLineItemsTable": { - "margin": [0, 16, 0, 16] + "margin": [0, 26, 0, 16] }, "clientName": { "bold": true @@ -181,7 +199,7 @@ }, "termsLabel": { "bold": true, - "margin": [0, 10, 0, 4] + "margin": [0, 0, 0, 4] } }, "pageMargins": [0, 80, 0, 40] diff --git a/public/js/templates/clean.js b/public/js/templates/clean.js index 5bb7dc32a667..17301faa895c 100644 --- a/public/js/templates/clean.js +++ b/public/js/templates/clean.js @@ -94,20 +94,26 @@ "margin": [8, 4, 8, 4] }, "footer": { - "text": "$invoiceFooter", - "margin": [40, -20, 40, 0], - "alignment": "left" + "columns": [ + { + "text": "$invoiceFooter", + "alignment": "left", + "margin": [0, 0, 0, 12] + + } + ], + "margin": [40, -20, 40, 40] }, "styles": { "entityTypeLabel": { "fontSize": "$fontSizeLargest", - "color": "$primaryColor:#299CC2" + "color": "$primaryColor:#37a3c6" }, "primaryColor":{ - "color": "$primaryColor:#299CC2" + "color": "$primaryColor:#37a3c6" }, "accountName": { - "color": "$primaryColor:#299CC2", + "color": "$primaryColor:#37a3c6", "bold": true }, "accountDetails": { @@ -126,7 +132,7 @@ "fillColor": "#fbfbfb" }, "productKey": { - "color": "$primaryColor:#299CC2", + "color": "$primaryColor:#37a3c6", "bold": true }, "balanceDueLabel": { @@ -134,7 +140,7 @@ }, "balanceDue": { "fontSize": "$fontSizeLargest", - "color": "$primaryColor:#299CC2" + "color": "$primaryColor:#37a3c6" }, "invoiceNumber": { "bold": true @@ -166,8 +172,8 @@ }, "termsLabel": { "bold": true, - "margin": [0, 10, 0, 4] + "margin": [0, 0, 0, 4] } }, - "pageMargins": [40, 40, 40, 40] + "pageMargins": [40, 40, 40, 60] } \ No newline at end of file diff --git a/public/js/templates/modern.js b/public/js/templates/modern.js index 24b53bdd4dd6..21eee276c5dc 100644 --- a/public/js/templates/modern.js +++ b/public/js/templates/modern.js @@ -91,7 +91,7 @@ { "canvas": [ { - "type": "line", "x1": 0, "y1": 0, "x2": 600, "y2": 0,"lineWidth": 100,"lineColor":"#f26621" + "type": "line", "x1": 0, "y1": 0, "x2": 600, "y2": 0,"lineWidth": 100,"lineColor":"$primaryColor:#f26621" }] ,"width":10 }, @@ -119,7 +119,7 @@ ], "header": [ { - "canvas": [{ "type": "line", "x1": 0, "y1": 0, "x2": 600, "y2": 0,"lineWidth": 200,"lineColor":"#f26621"}],"width":10 + "canvas": [{ "type": "line", "x1": 0, "y1": 0, "x2": 600, "y2": 0,"lineWidth": 200,"lineColor":"$primaryColor:#f26621"}],"width":10 }, { "columns": [ @@ -206,7 +206,7 @@ }, "termsLabel": { "bold": true, - "margin": [0, 10, 0, 4] + "margin": [0, 0, 0, 4] }, "invoiceNumberLabel": { "bold": true diff --git a/public/js/templates/plain.js b/public/js/templates/plain.js index 9a51d9f60bfd..b908c35eace0 100644 --- a/public/js/templates/plain.js +++ b/public/js/templates/plain.js @@ -82,10 +82,16 @@ } ], "footer": { - "text": "$invoiceFooter", - "margin": [40, -40, 40, 0], - "alignment": "left" - }, + "columns": [ + { + "text": "$invoiceFooter", + "alignment": "left", + "margin": [0, 0, 0, 12] + + } + ], + "margin": [40, -20, 40, 40] + }, "defaultStyle": { "fontSize": "$fontSize", "margin": [8, 4, 8, 4] @@ -126,8 +132,8 @@ }, "termsLabel": { "bold": true, - "margin": [0, 10, 0, 4] + "margin": [0, 0, 0, 4] } }, - "pageMargins": [40, 40, 40, 40] + "pageMargins": [40, 40, 40, 60] } \ No newline at end of file diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index daee646f187b..8b590d85ae12 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -736,7 +736,8 @@ return array( 'header' => 'Header', 'footer' => 'Footer', 'custom' => 'Custom', - + 'invoice_to' => 'Invoice to', + 'invoice_no' => 'Invoice No.', ); diff --git a/resources/views/accounts/customize_design.blade.php b/resources/views/accounts/customize_design.blade.php index cd4a1792d31d..a48414cd5db1 100644 --- a/resources/views/accounts/customize_design.blade.php +++ b/resources/views/accounts/customize_design.blade.php @@ -79,16 +79,16 @@ function onSelectChange() { - var id = $('#invoice_design_id').val(); - + var id = $('#invoice_design_id').val(); if (parseInt(id)) { - customDesign = JSON.parse(invoiceDesigns[id-1].javascript); + var design = _.find(invoiceDesigns, function(design){ return design.id == id}); + customDesign = JSON.parse(design.javascript); } else { customDesign = origCustomDesign; } loadEditor(editorSection); - refreshPDF(true); + refreshPDF(true); } function submitForm() @@ -104,9 +104,6 @@ var options = { mode: 'form', modes: ['form', 'code'], - error: function (err) { - console.error(err.toString()); - }, change: function() { saveEditor(); } @@ -127,7 +124,7 @@
- {!! Former::open()->addClass('warn-on-exit')->onchange('refreshPDF()') !!} + {!! Former::open()->addClass('warn-on-exit') !!} {!! Former::populateField('invoice_design_id', $account->invoice_design_id) !!}
@@ -146,13 +143,16 @@
-

 

- {!! Former::actions( - Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id')->onchange('onSelectChange()')->raw(), - Button::success(trans('texts.save'))->withAttributes(['onclick' => 'submitForm()'])->large()->appendIcon(Icon::create('floppy-disk')) - ) !!} +
+ {!! Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id')->onchange('onSelectChange()')->raw() !!} +
+ {!! Button::normal(trans('texts.documentation'))->asLinkTo(PDFMAKE_DOCS)->withAttributes(['target' => '_blank'])->appendIcon(Icon::create('info-sign')) !!} + {!! Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/company/advanced_settings/invoice_design'))->appendIcon(Icon::create('remove-circle')) !!} + {!! Button::success(trans('texts.save'))->withAttributes(['onclick' => 'submitForm()'])->appendIcon(Icon::create('floppy-disk')) !!} +
+
@if (!Auth::user()->isPro())