mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Working on invoice customizations
This commit is contained in:
parent
67a6d66bd0
commit
912fe5b7a3
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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(),
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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()
|
||||
|
@ -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<matches.length; i++) {
|
||||
var match = matches[i];
|
||||
field = match.substring(2, match.indexOf('Label'));
|
||||
field = toSnakeCase(field);
|
||||
var label = invoiceLabels[field];
|
||||
if (match.indexOf('UC') >= 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<matches.length; i++) {
|
||||
var match = matches[i];
|
||||
field = match.substring(2, match.indexOf('Value'));
|
||||
field = toSnakeCase(field);
|
||||
var value = getDescendantProp(invoice, field) || ' ';
|
||||
if (field.indexOf('date') >= 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']}
|
||||
])
|
||||
|
||||
|
@ -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<matches.length; i++) {
|
||||
var match = matches[i];
|
||||
field = match.substring(2, match.indexOf('Label'));
|
||||
field = toSnakeCase(field);
|
||||
var label = invoiceLabels[field];
|
||||
if (match.indexOf('UC') >= 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<matches.length; i++) {
|
||||
var match = matches[i];
|
||||
field = match.substring(2, match.indexOf('Value'));
|
||||
field = toSnakeCase(field);
|
||||
var value = getDescendantProp(invoice, field) || ' ';
|
||||
if (field.indexOf('date') >= 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']}
|
||||
])
|
||||
|
||||
|
@ -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;
|
||||
}
|
@ -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]
|
||||
|
@ -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]
|
||||
}
|
@ -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
|
||||
|
@ -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]
|
||||
}
|
@ -736,7 +736,8 @@ return array(
|
||||
'header' => 'Header',
|
||||
'footer' => 'Footer',
|
||||
'custom' => 'Custom',
|
||||
|
||||
'invoice_to' => 'Invoice to',
|
||||
'invoice_no' => 'Invoice No.',
|
||||
|
||||
);
|
||||
|
||||
|
@ -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 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
{!! Former::open()->addClass('warn-on-exit')->onchange('refreshPDF()') !!}
|
||||
{!! Former::open()->addClass('warn-on-exit') !!}
|
||||
{!! Former::populateField('invoice_design_id', $account->invoice_design_id) !!}
|
||||
|
||||
<div style="display:none">
|
||||
@ -146,13 +143,16 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div id="jsoneditor" style="width: 550px; height: 743px;"></div>
|
||||
|
||||
<p> </p>
|
||||
|
||||
{!! 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'))
|
||||
) !!}
|
||||
<div>
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id')->onchange('onSelectChange()')->raw() !!}
|
||||
<div class="pull-right">
|
||||
{!! 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')) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (!Auth::user()->isPro())
|
||||
<script>
|
||||
|
@ -96,7 +96,7 @@
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
@if (!Utils::isPro() || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS)
|
||||
@if (!Utils::isPro() || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST)
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id')->addOption(trans('texts.more_designs') . '...', '-1') !!}
|
||||
@else
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id') !!}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
<div class="pull-right">
|
||||
{!! Button::normal(trans('texts.documentation'))->asLinkTo(NINJA_WEB_URL.'/knowledgebase/api-documentation/')->withAttributes(['target' => '_blank']) !!}
|
||||
{!! Button::normal(trans('texts.documentation'))->asLinkTo(NINJA_WEB_URL.'/knowledgebase/api-documentation/')->withAttributes(['target' => '_blank'])->appendIcon(Icon::create('info-sign')) !!}
|
||||
@if (Utils::isNinja())
|
||||
{!! Button::normal(trans('texts.zapier'))->asLinkTo(ZAPIER_URL)->withAttributes(['target' => '_blank']) !!}
|
||||
@endif
|
||||
|
@ -132,7 +132,6 @@
|
||||
Former::select('is_amount_discount')->addOption(trans('texts.discount_percent'), '0')
|
||||
->addOption(trans('texts.discount_amount'), '1')->data_bind("value: is_amount_discount")->raw()
|
||||
) !!}
|
||||
{{-- Former::select('currency_id')->addOption('', '')->fromQuery($currencies, 'name', 'id')->data_bind("value: currency_id") --}}
|
||||
|
||||
<div class="form-group" style="margin-bottom: 8px">
|
||||
<label for="taxes" class="control-label col-lg-4 col-sm-4">{{ trans('texts.taxes') }}</label>
|
||||
@ -324,7 +323,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
@if (!Utils::isPro() || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS)
|
||||
@if (!Utils::isPro() || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST)
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id")->addOption(trans('texts.more_designs') . '...', '-1') !!}
|
||||
@else
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") !!}
|
||||
@ -588,7 +587,7 @@
|
||||
} else {
|
||||
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
|
||||
model.invoice().client().country = false;
|
||||
}
|
||||
}
|
||||
refreshPDF(true);
|
||||
});
|
||||
|
||||
@ -600,7 +599,7 @@
|
||||
}
|
||||
|
||||
$('#invoice_footer, #terms, #public_notes, #invoice_number, #invoice_date, #due_date, #po_number, #discount, #currency_id, #invoice_design_id, #recurring, #is_amount_discount, #partial').change(function() {
|
||||
setTimeout(function() {
|
||||
setTimeout(function() {
|
||||
refreshPDF(true);
|
||||
}, 1);
|
||||
});
|
||||
@ -712,7 +711,7 @@
|
||||
}
|
||||
|
||||
function getPDFString(cb, force) {
|
||||
var invoice = createInvoiceModel();
|
||||
var invoice = createInvoiceModel();
|
||||
var design = getDesignJavascript();
|
||||
if (!design) return;
|
||||
generatePDF(invoice, design, force, cb);
|
||||
@ -918,7 +917,6 @@
|
||||
var paymentTerms = parseInt(self.invoice().client().payment_terms());
|
||||
if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date())
|
||||
{
|
||||
console.log("here");
|
||||
if (paymentTerms == -1) paymentTerms = 0;
|
||||
var dueDate = $('#invoice_date').datepicker('getDate');
|
||||
dueDate.setDate(dueDate.getDate() + paymentTerms);
|
||||
@ -1763,7 +1761,7 @@
|
||||
// move the blank invoice line item to the end
|
||||
var blank = model.invoice().invoice_items.pop();
|
||||
var tasks = {!! $tasks !!};
|
||||
console.log(tasks);
|
||||
|
||||
for (var i=0; i<tasks.length; i++) {
|
||||
var task = tasks[i];
|
||||
var item = model.invoice().addItem();
|
||||
|
@ -97,7 +97,7 @@
|
||||
$('#theFrame').attr('src', string).show();
|
||||
} else {
|
||||
if (isRefreshing) {
|
||||
needsRefresh = true;
|
||||
//needsRefresh = true;
|
||||
return;
|
||||
}
|
||||
isRefreshing = true;
|
||||
|
Loading…
Reference in New Issue
Block a user