mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve signature on PDF
This commit is contained in:
parent
426c491fc2
commit
45ab98c62e
@ -113,6 +113,7 @@ class ClientPortalController extends BaseController
|
|||||||
'custom_value1',
|
'custom_value1',
|
||||||
'custom_value2',
|
'custom_value2',
|
||||||
]);
|
]);
|
||||||
|
$account->load(['date_format', 'datetime_format']);
|
||||||
|
|
||||||
// translate the country names
|
// translate the country names
|
||||||
if ($invoice->client->country) {
|
if ($invoice->client->country) {
|
||||||
|
@ -336,6 +336,7 @@ trait PresentsInvoice
|
|||||||
'custom_value1',
|
'custom_value1',
|
||||||
'custom_value2',
|
'custom_value2',
|
||||||
'delivery_note',
|
'delivery_note',
|
||||||
|
'date',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
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
@ -257,6 +257,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
|||||||
'fontSizeSmaller': NINJA.fontSize - 1,
|
'fontSizeSmaller': NINJA.fontSize - 1,
|
||||||
'bodyFont': NINJA.bodyFont,
|
'bodyFont': NINJA.bodyFont,
|
||||||
'headerFont': NINJA.headerFont,
|
'headerFont': NINJA.headerFont,
|
||||||
|
'signature': NINJA.signature(invoice),
|
||||||
'signatureBase64': NINJA.signatureImage(invoice),
|
'signatureBase64': NINJA.signatureImage(invoice),
|
||||||
'signatureDate': NINJA.signatureDate(invoice),
|
'signatureDate': NINJA.signatureDate(invoice),
|
||||||
}
|
}
|
||||||
@ -380,53 +381,65 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
|||||||
return 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) {
|
NINJA.signatureImage = function(invoice) {
|
||||||
var blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=';
|
var blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=';
|
||||||
|
var invitation = NINJA.getSignatureInvitation(invoice);
|
||||||
if (! invoice.invitations || ! invoice.invitations.length) {
|
return invitation ? invitation.signature_base64 : blankImage;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NINJA.signatureDate = function(invoice) {
|
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) {
|
if (! invoice.invitations || ! invoice.invitations.length) {
|
||||||
return '';
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! parseInt(invoice.account.signature_on_pdf)) {
|
if (! parseInt(invoice.account.signature_on_pdf)) {
|
||||||
return '';
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i=0; i<invoice.invitations.length; i++) {
|
for (var i=0; i<invoice.invitations.length; i++) {
|
||||||
var invitation = invoice.invitations[i];
|
var invitation = invoice.invitations[i];
|
||||||
if (invitation.signature_base64) {
|
if (invitation.signature_base64) {
|
||||||
break;
|
return invitation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! invitation.signature_base64) {
|
return false;
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
var date = invitation.signature_date;
|
|
||||||
return NINJA.formatDateTime(date, invoice.account);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NINJA.formatDateTime = function(date, account) {
|
NINJA.formatDateTime = function(date, account) {
|
||||||
|
@ -235,25 +235,6 @@
|
|||||||
]) !!}<br/>
|
]) !!}<br/>
|
||||||
|
|
||||||
@include('partials/variables_help', ['entityType' => ENTITY_INVOICE, 'account' => $account])
|
@include('partials/variables_help', ['entityType' => ENTITY_INVOICE, 'account' => $account])
|
||||||
|
|
||||||
@if ($account->require_invoice_signature || $account->require_invoice_signature)
|
|
||||||
<p> </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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user