diff --git a/Gruntfile.js b/Gruntfile.js
index 43dc8abe82..b8ef2ea6aa 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -6,36 +6,34 @@ module.exports = function(grunt) {
options: {
process: function(src, filepath) {
var basepath = filepath.substring(7, filepath.lastIndexOf('/') + 1);
-
- console.log(filepath);
// Fix relative paths for css files
if(filepath.indexOf('.css', filepath.length - 4) !== -1) {
return src.replace(/(url\s*[\("']+)\s*([^'"\)]+)(['"\)]+;?)/gi, function(match, start, url, end, offset, string) {
if(url.indexOf('data:') === 0) {
// Skip data urls
return match;
-
+
} else if(url.indexOf('/') === 0) {
// Skip absolute urls
return match;
-
+
} else {
return start + basepath + url + end;
}
});
-
+
// Fix source maps locations
} else if(filepath.indexOf('.js', filepath.length - 4) !== -1) {
return src.replace(/(\/[*\/][#@]\s*sourceMappingURL=)([^\s]+)/gi, function(match, start, url, offset, string) {
if(url.indexOf('/') === 0) {
// Skip absolute urls
return match;
-
+
} else {
return start + basepath + url;
}
});
-
+
// Don't do anything for unknown file types
} else {
return src;
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 124b9f29f6..61ab883995 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -818,7 +818,8 @@ class AccountController extends \BaseController {
{
$account = Auth::user()->account;
$account->name = trim(Input::get('name'));
- $account->vat_number = trim(Input::get('vat_number'));
+ $account->id_number = trim(Input::get('id_number'));
+ $account->vat_number = trim(Input::get('vat_number'));
$account->work_email = trim(Input::get('work_email'));
$account->work_phone = trim(Input::get('work_phone'));
$account->address1 = trim(Input::get('address1'));
diff --git a/app/controllers/ClientController.php b/app/controllers/ClientController.php
index af6edefd1f..74494441dc 100755
--- a/app/controllers/ClientController.php
+++ b/app/controllers/ClientController.php
@@ -199,7 +199,8 @@ class ClientController extends \BaseController {
}
$client->name = trim(Input::get('name'));
- $client->vat_number = trim(Input::get('vat_number'));
+ $client->id_number = trim(Input::get('id_number'));
+ $client->vat_number = trim(Input::get('vat_number'));
$client->work_phone = trim(Input::get('work_phone'));
$client->custom_value1 = trim(Input::get('custom_value1'));
$client->custom_value2 = trim(Input::get('custom_value2'));
diff --git a/app/database/migrations/2014_10_01_141248_add_company_vat_number.php b/app/database/migrations/2014_10_01_141248_add_company_vat_number.php
index 9a1a79f98e..b93a217712 100644
--- a/app/database/migrations/2014_10_01_141248_add_company_vat_number.php
+++ b/app/database/migrations/2014_10_01_141248_add_company_vat_number.php
@@ -17,7 +17,7 @@ class AddCompanyVatNumber extends Migration {
$table->string('vat_number')->nullable();
});
- Schema::table('clients', function($table)
+ Schema::table('clients', function($table)
{
$table->string('vat_number')->nullable();
});
@@ -34,7 +34,7 @@ class AddCompanyVatNumber extends Migration {
{
$table->dropColumn('vat_number');
});
- Schema::table('clients', function($table)
+ Schema::table('clients', function($table)
{
$table->dropColumn('vat_number');
});
diff --git a/app/database/migrations/2014_10_30_184126_add_company_id_number.php b/app/database/migrations/2014_10_30_184126_add_company_id_number.php
new file mode 100644
index 0000000000..9e0fcb75b4
--- /dev/null
+++ b/app/database/migrations/2014_10_30_184126_add_company_id_number.php
@@ -0,0 +1,43 @@
+string('id_number')->nullable();
+ });
+
+ Schema::table('clients', function($table)
+ {
+ $table->string('id_number')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('accounts', function($table)
+ {
+ $table->dropColumn('id_number');
+ });
+ Schema::table('clients', function($table)
+ {
+ $table->dropColumn('id_number');
+ });
+ }
+
+}
diff --git a/app/lang/da/texts.php b/app/lang/da/texts.php
index 4de35379fe..435b106ca8 100644
--- a/app/lang/da/texts.php
+++ b/app/lang/da/texts.php
@@ -5,7 +5,8 @@ return array(
// client
'organization' => 'Organisation',
'name' => 'Navn',
- 'vat_number' => 'CVR nummer',
+ 'id_number' => 'SE/CVR nummer',
+ 'vat_number' => 'SE/CVR nummer',
'website' => 'Webside',
'work_phone' => 'Telefon',
'address' => 'Adresse',
diff --git a/app/lang/en/texts.php b/app/lang/en/texts.php
index 4eb1ccbf73..775414d063 100644
--- a/app/lang/en/texts.php
+++ b/app/lang/en/texts.php
@@ -457,8 +457,11 @@ return array(
'more_designs_self_host_text' => '',
'buy' => 'Buy',
'bought_designs' => 'Successfully added additional invoice designs',
-
'sent' => 'sent',
+
+ 'id_number' => 'ID Number',
+ 'vat_number' => 'VAT Number',
+
'timesheets' => 'Timesheets',
'payment_title' => 'Enter Your Billing Address and Credit Card information',
diff --git a/app/models/Client.php b/app/models/Client.php
index f87e9aeda6..e40f50e8cc 100755
--- a/app/models/Client.php
+++ b/app/models/Client.php
@@ -131,11 +131,23 @@ class Client extends EntityModel
return $str;
}
- public function getVatNumber()
+ public function getIdNumber()
{
$str = '';
- if ($this->work_phone)
+ if ($this->id_number)
+ {
+ $str .= '' . $this->vat_number;
+ }
+
+ return $str;
+ }
+
+ public function getVatNumber()
+ {
+ $str = '';
+
+ if ($this->vat_number)
{
$str .= '' . $this->vat_number;
}
diff --git a/app/models/Invoice.php b/app/models/Invoice.php
index b4100f1dc8..705a1379b4 100755
--- a/app/models/Invoice.php
+++ b/app/models/Invoice.php
@@ -95,7 +95,8 @@ class Invoice extends EntityModel
$this->client->setVisible([
'name',
- 'vat_number',
+ 'id_number',
+ 'vat_number',
'address1',
'address2',
'city',
@@ -111,7 +112,8 @@ class Invoice extends EntityModel
$this->account->setVisible([
'name',
- 'vat_number',
+ 'id_number',
+ 'vat_number',
'address1',
'address2',
'city',
diff --git a/app/ninja/repositories/AccountRepository.php b/app/ninja/repositories/AccountRepository.php
index c4bc0e8b2c..d8f992a00e 100755
--- a/app/ninja/repositories/AccountRepository.php
+++ b/app/ninja/repositories/AccountRepository.php
@@ -45,7 +45,7 @@ class AccountRepository
public function getSearchData()
{
- $clients = \DB::table('clients')
+ $clients = \DB::table('clients')
->where('clients.deleted_at', '=', null)
->where('clients.account_id', '=', \Auth::user()->account_id)
->whereRaw("clients.name <> ''")
diff --git a/app/ninja/repositories/ClientRepository.php b/app/ninja/repositories/ClientRepository.php
index 1b278570bc..103acb0e0e 100755
--- a/app/ninja/repositories/ClientRepository.php
+++ b/app/ninja/repositories/ClientRepository.php
@@ -62,7 +62,10 @@ class ClientRepository
if (isset($data['name'])) {
$client->name = trim($data['name']);
}
- if (isset($data['vat_number'])) {
+ if (isset($data['id_number'])) {
+ $client->id_number = trim($data['id_number']);
+ }
+ if (isset($data['vat_number'])) {
$client->vat_number = trim($data['vat_number']);
}
if (isset($data['work_phone'])) {
diff --git a/app/views/accounts/details.blade.php b/app/views/accounts/details.blade.php
index 7a12092a06..c92a41cea0 100755
--- a/app/views/accounts/details.blade.php
+++ b/app/views/accounts/details.blade.php
@@ -29,7 +29,8 @@
{{ Former::legend('details') }}
{{ Former::text('name') }}
- {{ Former::text('vat_number') }}
+ {{ Former::text('id_number') }}
+ {{ Former::text('vat_number') }}
{{ Former::text('work_email') }}
{{ Former::text('work_phone') }}
{{ Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) }}
diff --git a/app/views/client.blade.php b/app/views/client.blade.php
index a1912b0709..ef22259a06 100755
--- a/app/views/client.blade.php
+++ b/app/views/client.blade.php
@@ -4,7 +4,8 @@
{{ Former::legend('Organization') }}
{{ Former::text('name') }}
- {{ Former::text('vat_number') }}
+ {{ Former::text('id_number') }}
+ {{ Former::text('vat_number') }}
{{ Former::text('work_phone')->label('Phone') }}
{{ Former::textarea('notes') }}
diff --git a/app/views/clients/edit.blade.php b/app/views/clients/edit.blade.php
index 87f43c9abf..6d9eac7c76 100755
--- a/app/views/clients/edit.blade.php
+++ b/app/views/clients/edit.blade.php
@@ -23,8 +23,9 @@
{{ Former::legend('organization') }}
{{ Former::text('name')->data_bind("attr { placeholder: placeholderName }") }}
- {{ Former::text('vat_number') }}
- {{ Former::text('website') }}
+ {{ Former::text('id_number') }}
+ {{ Former::text('vat_number') }}
+ {{ Former::text('website') }}
{{ Former::text('work_phone') }}
@if (Auth::user()->isPro())
diff --git a/app/views/clients/show.blade.php b/app/views/clients/show.blade.php
index 39eb1b42dd..6fc755fd8b 100755
--- a/app/views/clients/show.blade.php
+++ b/app/views/clients/show.blade.php
@@ -39,8 +39,9 @@
{{ trans('texts.details') }}
+
{{ $client->getIdNumber() }}
{{ $client->getVatNumber() }}
-
{{ $client->getAddress() }}
+
{{ $client->getAddress() }}
{{ $client->getCustomFields() }}
{{ $client->getPhone() }}
{{ $client->getNotes() }}
diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php
index 662becf12f..359b1746af 100755
--- a/app/views/invoices/edit.blade.php
+++ b/app/views/invoices/edit.blade.php
@@ -341,7 +341,8 @@
{{ Former::legend('organization') }}
{{ Former::text('name')->data_bind("value: name, valueUpdate: 'afterkeydown', attr { placeholder: name.placeholder }") }}
- {{ Former::text('vat_number')->data_bind("value: vat_number, valueUpdate: 'afterkeydown'") }}
+ {{ Former::text('id_number')->data_bind("value: id_number, valueUpdate: 'afterkeydown'") }}
+ {{ Former::text('vat_number')->data_bind("value: vat_number, valueUpdate: 'afterkeydown'") }}
{{ Former::text('website')->data_bind("value: website, valueUpdate: 'afterkeydown'") }}
{{ Former::text('work_phone')->data_bind("value: work_phone, valueUpdate: 'afterkeydown'") }}
@@ -1222,7 +1223,8 @@
var self = this;
self.public_id = ko.observable(0);
self.name = ko.observable('');
- self.vat_number = ko.observable('');
+ self.id_number = ko.observable('');
+ self.vat_number = ko.observable('');
self.work_phone = ko.observable('');
self.custom_value1 = ko.observable('');
self.custom_value2 = ko.observable('');
diff --git a/public/built.js b/public/built.js
index e9a7f5ada7..9b2891c94e 100644
--- a/public/built.js
+++ b/public/built.js
@@ -30966,7 +30966,7 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
var invoiceOld;
function generatePDF(invoice, javascript, force) {
- invoice = calculateAmounts(invoice);
+ invoice = calculateAmounts(invoice);
var a = copyInvoice(invoice);
var b = copyInvoice(invoiceOld);
if (!force && _.isEqual(a, b)) {
@@ -31011,7 +31011,7 @@ function GetPdf(invoice, javascript){
layout.descriptionLeft -= 20;
layout.unitCostRight -= 40;
layout.qtyRight -= 40;
- }
+ }
/*
@param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
@@ -31099,24 +31099,24 @@ function processVariables(str) {
if (!str) return '';
var variables = ['MONTH','QUARTER','YEAR'];
for (var i=0; i
1) {
offset = match.split('+')[1];
} else if (match.split('-').length > 1) {
offset = parseInt(match.split('-')[1]) * -1;
}
- str = str.replace(match, getDatePart(variable, offset));
+ str = str.replace(match, getDatePart(variable, offset));
}
- }
-
+ }
+
return str;
}
@@ -31139,7 +31139,7 @@ function getMonth(offset) {
var months = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
var month = today.getMonth();
- month = parseInt(month) + offset;
+ month = parseInt(month) + offset;
month = month % 12;
if (month < 0) {
month += 12;
@@ -31159,7 +31159,7 @@ function getQuarter(offset) {
quarter += offset;
quarter = quarter % 4;
if (quarter == 0) {
- quarter = 4;
+ quarter = 4;
}
return 'Q' + quarter;
}
@@ -31348,7 +31348,7 @@ function enableHoverClick($combobox, $entityId, url) {
setAsLink($combobox, false);
}).on('click', function() {
var clientId = $entityId.val();
- if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
+ if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
if (parseInt(clientId) > 0) {
window.open(url + '/' + clientId, '_blank');
} else {
@@ -31362,10 +31362,10 @@ function enableHoverClick($combobox, $entityId, url) {
function setAsLink($input, enable) {
if (enable) {
$input.css('text-decoration','underline');
- $input.css('cursor','pointer');
+ $input.css('cursor','pointer');
} else {
$input.css('text-decoration','none');
- $input.css('cursor','text');
+ $input.css('cursor','text');
}
}
@@ -31396,45 +31396,45 @@ if (window.ko) {
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
if (id) $(element).val(id);
//console.log("combo-init: %s", id);
- $(element).combobox(options);
+ $(element).combobox(options);
/*
ko.utils.registerEventHandler(element, "change", function () {
- console.log("change: %s", $(element).val());
- //var
+ console.log("change: %s", $(element).val());
+ //var
valueAccessor($(element).val());
//$(element).combobox('refresh');
});
*/
},
- update: function (element, valueAccessor) {
+ update: function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
//console.log("combo-update: %s", id);
- if (id) {
- $(element).val(id);
+ if (id) {
+ $(element).val(id);
$(element).combobox('refresh');
} else {
- $(element).combobox('clearTarget');
- $(element).combobox('clearElement');
- }
- }
+ $(element).combobox('clearTarget');
+ $(element).combobox('clearElement');
+ }
+ }
};
ko.bindingHandlers.datePicker = {
init: function (element, valueAccessor, allBindingsAccessor) {
- var value = ko.utils.unwrapObservable(valueAccessor());
+ var value = ko.utils.unwrapObservable(valueAccessor());
if (value) $(element).datepicker('update', value);
- $(element).change(function() {
+ $(element).change(function() {
var value = valueAccessor();
value($(element).val());
})
},
- update: function (element, valueAccessor) {
+ update: function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
if (value) $(element).datepicker('update', value);
- }
+ }
};
}
@@ -31452,11 +31452,11 @@ function wordWrapText(value, width)
while (j++ < lines[i].length) {
if (lines[i].charAt(j) === ' ') space = j;
}
- if (space == lines[i].length) space = width/6;
+ if (space == lines[i].length) space = width/6;
lines[i + 1] = lines[i].substring(space + 1) + ' ' + (lines[i + 1] || '');
lines[i] = lines[i].substring(0, space);
}
-
+
var newValue = (lines.join("\n")).trim();
if (value == newValue) {
@@ -31485,14 +31485,14 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
var clientMap = {};
var invoiceMap = {};
var invoicesForClientMap = {};
- var $clientSelect = $('select#client');
-
+ var $clientSelect = $('select#client');
+
for (var i=0; i 0 ? formatMoney(invoice.discount_amount, invoice.client.currency_id) : false}
];
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
- data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
+ data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
}
data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false});
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
- data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
+ data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
}
var paid = invoice.amount - invoice.balance;
@@ -31722,7 +31724,7 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX)
var options = {
hasheader: true,
rightAlignX: 550,
- rightAlignTitleX: rightAlignTitleX
+ rightAlignTitleX: rightAlignTitleX
};
return displayGrid(doc, invoice, data, 300, y, layout, options) + 10;
@@ -31753,7 +31755,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
var origY = y;
for (var i=0; i 0 && origY === layout.accountTop) {
SetPdfColor('GrayText',doc);
}
@@ -31767,7 +31769,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
doc.setFontType('bold');
}
- if (typeof row === 'object') {
+ if (typeof row === 'object') {
for (var key in row) {
if (row.hasOwnProperty(key)) {
var value = row[key] ? row[key] + '' : false;
@@ -31775,16 +31777,16 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
}
if (!value) {
continue;
- }
+ }
var marginLeft;
if (options.rightAlignX) {
- marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
+ marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
} else {
marginLeft = x + 80;
}
- doc.text(marginLeft, y, value);
-
+ doc.text(marginLeft, y, value);
+
doc.setFontType('normal');
if (invoice.is_quote) {
if (key == 'invoice_number') {
@@ -31810,7 +31812,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
marginLeft = x;
}
- doc.text(marginLeft, y, key);
+ doc.text(marginLeft, y, key);
} else {
doc.text(x, y, row);
}
@@ -31829,16 +31831,16 @@ function displayNotesAndTerms(doc, layout, invoice, y)
if (invoice.public_notes) {
doc.text(layout.marginLeft, y, invoice.public_notes);
- y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
+ y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
}
-
+
if (invoice.terms) {
doc.setFontType("bold");
doc.text(layout.marginLeft, y, invoiceLabels.terms);
y += 16;
doc.setFontType("normal");
doc.text(layout.marginLeft, y, invoice.terms);
- y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
+ y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
}
return y - origY;
@@ -31855,7 +31857,7 @@ function calculateAmounts(invoice) {
tax = parseFloat(item.tax.rate);
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
tax = parseFloat(item.tax_rate);
- }
+ }
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
if (tax) {
@@ -31878,11 +31880,11 @@ function calculateAmounts(invoice) {
}
// custom fields with taxes
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
- total += roundToTwo(invoice.custom_value1);
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
+ total += roundToTwo(invoice.custom_value1);
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
- total += roundToTwo(invoice.custom_value2);
+ total += roundToTwo(invoice.custom_value2);
}
var tax = 0;
@@ -31898,11 +31900,11 @@ function calculateAmounts(invoice) {
}
// custom fields w/o with taxes
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
- total += roundToTwo(invoice.custom_value1);
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
+ total += roundToTwo(invoice.custom_value1);
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
- total += roundToTwo(invoice.custom_value2);
+ total += roundToTwo(invoice.custom_value2);
}
invoice.balance_amount = roundToTwo(total) - (roundToTwo(invoice.amount) - roundToTwo(invoice.balance));
@@ -31919,7 +31921,7 @@ function getInvoiceTaxRate(invoice) {
tax = parseFloat(invoice.tax.rate);
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
tax = parseFloat(invoice.tax_rate);
- }
+ }
return tax;
}
@@ -31960,9 +31962,9 @@ function displayInvoiceItems(doc, invoice, layout) {
var line = 1;
var total = 0;
var shownItem = false;
- var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
+ var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
var tableTop = layout.tableTop;
- var hideQuantity = invoice.account.hide_quantity == '1';
+ var hideQuantity = invoice.account.hide_quantity == '1';
doc.setFontSize(8);
for (var i=0; i length) ? (str.substr(0, length-1) + '...') : str;
}
diff --git a/public/js/script.js b/public/js/script.js
index d53189433d..05fb3c4c41 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -9,7 +9,7 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
var invoiceOld;
function generatePDF(invoice, javascript, force) {
- invoice = calculateAmounts(invoice);
+ invoice = calculateAmounts(invoice);
var a = copyInvoice(invoice);
var b = copyInvoice(invoiceOld);
if (!force && _.isEqual(a, b)) {
@@ -54,7 +54,7 @@ function GetPdf(invoice, javascript){
layout.descriptionLeft -= 20;
layout.unitCostRight -= 40;
layout.qtyRight -= 40;
- }
+ }
/*
@param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
@@ -142,24 +142,24 @@ function processVariables(str) {
if (!str) return '';
var variables = ['MONTH','QUARTER','YEAR'];
for (var i=0; i 1) {
offset = match.split('+')[1];
} else if (match.split('-').length > 1) {
offset = parseInt(match.split('-')[1]) * -1;
}
- str = str.replace(match, getDatePart(variable, offset));
+ str = str.replace(match, getDatePart(variable, offset));
}
- }
-
+ }
+
return str;
}
@@ -182,7 +182,7 @@ function getMonth(offset) {
var months = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
var month = today.getMonth();
- month = parseInt(month) + offset;
+ month = parseInt(month) + offset;
month = month % 12;
if (month < 0) {
month += 12;
@@ -202,7 +202,7 @@ function getQuarter(offset) {
quarter += offset;
quarter = quarter % 4;
if (quarter == 0) {
- quarter = 4;
+ quarter = 4;
}
return 'Q' + quarter;
}
@@ -391,7 +391,7 @@ function enableHoverClick($combobox, $entityId, url) {
setAsLink($combobox, false);
}).on('click', function() {
var clientId = $entityId.val();
- if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
+ if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
if (parseInt(clientId) > 0) {
window.open(url + '/' + clientId, '_blank');
} else {
@@ -405,10 +405,10 @@ function enableHoverClick($combobox, $entityId, url) {
function setAsLink($input, enable) {
if (enable) {
$input.css('text-decoration','underline');
- $input.css('cursor','pointer');
+ $input.css('cursor','pointer');
} else {
$input.css('text-decoration','none');
- $input.css('cursor','text');
+ $input.css('cursor','text');
}
}
@@ -439,45 +439,45 @@ if (window.ko) {
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
if (id) $(element).val(id);
//console.log("combo-init: %s", id);
- $(element).combobox(options);
+ $(element).combobox(options);
/*
ko.utils.registerEventHandler(element, "change", function () {
- console.log("change: %s", $(element).val());
- //var
+ console.log("change: %s", $(element).val());
+ //var
valueAccessor($(element).val());
//$(element).combobox('refresh');
});
*/
},
- update: function (element, valueAccessor) {
+ update: function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
//console.log("combo-update: %s", id);
- if (id) {
- $(element).val(id);
+ if (id) {
+ $(element).val(id);
$(element).combobox('refresh');
} else {
- $(element).combobox('clearTarget');
- $(element).combobox('clearElement');
- }
- }
+ $(element).combobox('clearTarget');
+ $(element).combobox('clearElement');
+ }
+ }
};
ko.bindingHandlers.datePicker = {
init: function (element, valueAccessor, allBindingsAccessor) {
- var value = ko.utils.unwrapObservable(valueAccessor());
+ var value = ko.utils.unwrapObservable(valueAccessor());
if (value) $(element).datepicker('update', value);
- $(element).change(function() {
+ $(element).change(function() {
var value = valueAccessor();
value($(element).val());
})
},
- update: function (element, valueAccessor) {
+ update: function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
if (value) $(element).datepicker('update', value);
- }
+ }
};
}
@@ -495,11 +495,11 @@ function wordWrapText(value, width)
while (j++ < lines[i].length) {
if (lines[i].charAt(j) === ' ') space = j;
}
- if (space == lines[i].length) space = width/6;
+ if (space == lines[i].length) space = width/6;
lines[i + 1] = lines[i].substring(space + 1) + ' ' + (lines[i + 1] || '');
lines[i] = lines[i].substring(0, space);
}
-
+
var newValue = (lines.join("\n")).trim();
if (value == newValue) {
@@ -528,14 +528,14 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
var clientMap = {};
var invoiceMap = {};
var invoicesForClientMap = {};
- var $clientSelect = $('select#client');
-
+ var $clientSelect = $('select#client');
+
for (var i=0; i 0 ? formatMoney(invoice.discount_amount, invoice.client.currency_id) : false}
];
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
- data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
+ data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
}
data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false});
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
- data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
+ data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
}
var paid = invoice.amount - invoice.balance;
@@ -765,7 +767,7 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX)
var options = {
hasheader: true,
rightAlignX: 550,
- rightAlignTitleX: rightAlignTitleX
+ rightAlignTitleX: rightAlignTitleX
};
return displayGrid(doc, invoice, data, 300, y, layout, options) + 10;
@@ -796,7 +798,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
var origY = y;
for (var i=0; i 0 && origY === layout.accountTop) {
SetPdfColor('GrayText',doc);
}
@@ -810,7 +812,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
doc.setFontType('bold');
}
- if (typeof row === 'object') {
+ if (typeof row === 'object') {
for (var key in row) {
if (row.hasOwnProperty(key)) {
var value = row[key] ? row[key] + '' : false;
@@ -818,16 +820,16 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
}
if (!value) {
continue;
- }
+ }
var marginLeft;
if (options.rightAlignX) {
- marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
+ marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
} else {
marginLeft = x + 80;
}
- doc.text(marginLeft, y, value);
-
+ doc.text(marginLeft, y, value);
+
doc.setFontType('normal');
if (invoice.is_quote) {
if (key == 'invoice_number') {
@@ -853,7 +855,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
marginLeft = x;
}
- doc.text(marginLeft, y, key);
+ doc.text(marginLeft, y, key);
} else {
doc.text(x, y, row);
}
@@ -872,16 +874,16 @@ function displayNotesAndTerms(doc, layout, invoice, y)
if (invoice.public_notes) {
doc.text(layout.marginLeft, y, invoice.public_notes);
- y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
+ y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
}
-
+
if (invoice.terms) {
doc.setFontType("bold");
doc.text(layout.marginLeft, y, invoiceLabels.terms);
y += 16;
doc.setFontType("normal");
doc.text(layout.marginLeft, y, invoice.terms);
- y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
+ y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
}
return y - origY;
@@ -898,7 +900,7 @@ function calculateAmounts(invoice) {
tax = parseFloat(item.tax.rate);
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
tax = parseFloat(item.tax_rate);
- }
+ }
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
if (tax) {
@@ -921,11 +923,11 @@ function calculateAmounts(invoice) {
}
// custom fields with taxes
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
- total += roundToTwo(invoice.custom_value1);
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
+ total += roundToTwo(invoice.custom_value1);
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
- total += roundToTwo(invoice.custom_value2);
+ total += roundToTwo(invoice.custom_value2);
}
var tax = 0;
@@ -941,11 +943,11 @@ function calculateAmounts(invoice) {
}
// custom fields w/o with taxes
- if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
- total += roundToTwo(invoice.custom_value1);
+ if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
+ total += roundToTwo(invoice.custom_value1);
}
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
- total += roundToTwo(invoice.custom_value2);
+ total += roundToTwo(invoice.custom_value2);
}
invoice.balance_amount = roundToTwo(total) - (roundToTwo(invoice.amount) - roundToTwo(invoice.balance));
@@ -962,7 +964,7 @@ function getInvoiceTaxRate(invoice) {
tax = parseFloat(invoice.tax.rate);
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
tax = parseFloat(invoice.tax_rate);
- }
+ }
return tax;
}
@@ -1003,9 +1005,9 @@ function displayInvoiceItems(doc, invoice, layout) {
var line = 1;
var total = 0;
var shownItem = false;
- var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
+ var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
var tableTop = layout.tableTop;
- var hideQuantity = invoice.account.hide_quantity == '1';
+ var hideQuantity = invoice.account.hide_quantity == '1';
doc.setFontSize(8);
for (var i=0; i length) ? (str.substr(0, length-1) + '...') : str;
}