1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Improve signature on PDF

This commit is contained in:
Hillel Coren 2018-03-12 22:02:48 +02:00
parent 426c491fc2
commit 45ab98c62e
6 changed files with 48 additions and 52 deletions

View File

@ -113,6 +113,7 @@ class ClientPortalController extends BaseController
'custom_value1',
'custom_value2',
]);
$account->load(['date_format', 'datetime_format']);
// translate the country names
if ($invoice->client->country) {

View File

@ -336,6 +336,7 @@ trait PresentsInvoice
'custom_value1',
'custom_value2',
'delivery_note',
'date',
];
foreach ($fields as $field) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -257,6 +257,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
'fontSizeSmaller': NINJA.fontSize - 1,
'bodyFont': NINJA.bodyFont,
'headerFont': NINJA.headerFont,
'signature': NINJA.signature(invoice),
'signatureBase64': NINJA.signatureImage(invoice),
'signatureDate': NINJA.signatureDate(invoice),
}
@ -380,53 +381,65 @@ NINJA.decodeJavascript = function(invoice, javascript)
return javascript;
}
NINJA.signature = function(invoice) {
var invitation = NINJA.getSignatureInvitation(invoice);
if (invitation) {
return {
"stack": [
{
"image": "$signatureBase64",
"margin": [200, 10, 0, 0]
},
{
"canvas": [{
"type": "line",
"x1": 200,
"y1": -65,
"x2": 504,
"y2": -65,
"lineWidth": 1,
"lineColor": "#888888"
}]
},
{
"text": [invoiceLabels.date, ": ", "$signatureDate"],
"margin": [200, -60, 0, 0]
}
]
};
} else {
return '';
}
}
NINJA.signatureImage = function(invoice) {
var blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=';
if (! invoice.invitations || ! invoice.invitations.length) {
return blankImage;
}
if (! parseInt(invoice.account.signature_on_pdf)) {
return blankImage;
}
for (var i=0; i<invoice.invitations.length; i++) {
var invitation = invoice.invitations[i];
if (invitation.signature_base64) {
break;
}
}
if (! invitation.signature_base64) {
return blankImage;
}
return invitation.signature_base64 || blankImage;
var invitation = NINJA.getSignatureInvitation(invoice);
return invitation ? invitation.signature_base64 : blankImage;
}
NINJA.signatureDate = function(invoice) {
var invitation = NINJA.getSignatureInvitation(invoice);
return invitation ? NINJA.formatDateTime(invitation.signature_date, invoice.account) : '';
}
NINJA.getSignatureInvitation = function(invoice) {
if (! invoice.invitations || ! invoice.invitations.length) {
return '';
return false;
}
if (! parseInt(invoice.account.signature_on_pdf)) {
return '';
return false;
}
for (var i=0; i<invoice.invitations.length; i++) {
var invitation = invoice.invitations[i];
if (invitation.signature_base64) {
break;
return invitation;
}
}
if (! invitation.signature_base64) {
return '';
}
var date = invitation.signature_date;
return NINJA.formatDateTime(date, invoice.account);
return false;
}
NINJA.formatDateTime = function(date, account) {

View File

@ -235,25 +235,6 @@
]) !!}<br/>
@include('partials/variables_help', ['entityType' => ENTITY_INVOICE, 'account' => $account])
@if ($account->require_invoice_signature || $account->require_invoice_signature)
<p>&nbsp;</p>
{{ trans('texts.signature_on_invoice_help') }}
<pre style="padding-top:16px;">
{
"stack": [
{
"image": "$signatureBase64",
"margin": [200, 10, 0, 0]
},
{
"text": ["{{ trans('texts.signed') }}: ", "$signatureDate"],
"margin": [200, -40, 0, 0]
}
]
},
</pre>
@endif
</div>
</div>
</div>