diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 9aa821a2611d..065e3e073a33 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -306,7 +306,7 @@ class ClientController extends BaseController Session::flash('message', $message); if ($action == 'restore' && $count == 1) { - return Redirect::to('clients/'.$ids[0]); + return Redirect::to('clients/'.Utils::getFirst($ids)); } else { return Redirect::to('clients'); } diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 430280ddc849..c469bade2ee0 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -594,7 +594,7 @@ class InvoiceController extends BaseController } if ($action == 'restore' && $count == 1) { - return Redirect::to("{$entityType}s/".$ids[0]); + return Redirect::to("{$entityType}s/".Utils::getFirst($ids)); } else { return Redirect::to("{$entityType}s"); } diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 589841a314bf..d84ce2fece65 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -185,7 +185,11 @@ class QuoteController extends BaseController Session::flash('message', $message); } - return Redirect::to('quotes'); + if ($action == 'restore' && $count == 1) { + return Redirect::to("quotes/".Utils::getFirst($ids)); + } else { + return Redirect::to("quotes"); + } } public function approve($invitationKey) diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 1263b4ed6763..a5eb3b9a4a4c 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -735,4 +735,12 @@ class Utils return $val; } + + public static function getFirst($values) { + if (is_array($values)) { + return count($values) ? $values[0] : false; + } else { + return $values; + } + } } diff --git a/public/js/built.js b/public/js/built.js index 1d7f68550653..d489f0d94ef7 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -31511,6 +31511,11 @@ function getDescendantProp(obj, desc) { while(arr.length && (obj = obj[arr.shift()])); return obj; } + +function doubleDollarSign(str) { + if (!str) return ''; + return str.replace(/\$/g, '\$\$\$'); +} var NINJA = NINJA || {}; NINJA.TEMPLATES = { @@ -31622,6 +31627,7 @@ NINJA.decodeJavascript = function(invoice, javascript) for (var key in json) { var regExp = new RegExp('"\\$'+key+'"', 'g'); var val = JSON.stringify(json[key]); + val = doubleDollarSign(val); javascript = javascript.replace(regExp, val); } @@ -31664,7 +31670,8 @@ NINJA.decodeJavascript = function(invoice, javascript) field = match.substring(2, match.indexOf('Value')); field = toSnakeCase(field); var value = getDescendantProp(invoice, field) || ' '; - + value = doubleDollarSign(value); + if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') { value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); } @@ -31695,9 +31702,9 @@ NINJA.notesAndTerms = function(invoice) NINJA.invoiceColumns = function(invoice) { if (invoice.account.hide_quantity == '1') { - return ["15%", "*", "auto", "15%"]; + return ["15%", "*", "10%", "15%"]; } else { - return ["15%", "*", "auto", "auto", "15%"]; + return ["15%", "*", "10%", "auto", "15%"]; } } diff --git a/public/js/pdf.pdfmake.js b/public/js/pdf.pdfmake.js index ee0d4034e984..2938e044d275 100644 --- a/public/js/pdf.pdfmake.js +++ b/public/js/pdf.pdfmake.js @@ -109,6 +109,7 @@ NINJA.decodeJavascript = function(invoice, javascript) for (var key in json) { var regExp = new RegExp('"\\$'+key+'"', 'g'); var val = JSON.stringify(json[key]); + val = doubleDollarSign(val); javascript = javascript.replace(regExp, val); } @@ -151,7 +152,8 @@ NINJA.decodeJavascript = function(invoice, javascript) field = match.substring(2, match.indexOf('Value')); field = toSnakeCase(field); var value = getDescendantProp(invoice, field) || ' '; - + value = doubleDollarSign(value); + if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') { value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); } @@ -182,9 +184,9 @@ NINJA.notesAndTerms = function(invoice) NINJA.invoiceColumns = function(invoice) { if (invoice.account.hide_quantity == '1') { - return ["15%", "*", "auto", "15%"]; + return ["15%", "*", "10%", "15%"]; } else { - return ["15%", "*", "auto", "auto", "15%"]; + return ["15%", "*", "10%", "auto", "15%"]; } } diff --git a/public/js/script.js b/public/js/script.js index 61b564bdff2a..985fffcba127 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1639,4 +1639,9 @@ function getDescendantProp(obj, desc) { var arr = desc.split("."); while(arr.length && (obj = obj[arr.shift()])); return obj; +} + +function doubleDollarSign(str) { + if (!str) return ''; + return str.replace(/\$/g, '\$\$\$'); } \ No newline at end of file