mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 05:32:39 +01:00
ac5525c9ac
* Client login, reset and update password page * Client dashboard, sidebar, PortalComposer.php * wip * Personal page & update for details * Invoices, paying & pagination.blade.php * Invoices, recurring invoice & buttons * Payments, link component * Payment methods * Breadcrums, clean up & wrap up * Remove format_date() method to formatDate on object * Payments - $this->render is now proxy for render() - Removed logic from Controller.php to ClientPortal.php - Added MakesDates to ClientGatewayToken.php - StripePaymentDriver.php now returns correct views - Refactor of adding new payment method - Ignoring all local builds for public/js/clients/* * Signature, wip * Fix "Pay now" on single invoice * Payments: - Added ProcessInvoicesInBulk request class - Refactor InvoiceController::bulk() - Displaying terms & payments - New signature.blade.php - Removed comment from webpack.mix.js * Quotes: - Refactor ProcessInvoicesInBulk.php to ProcessInvoicesInBulkRequest.php - Add new 'Quotes' field inside of PortalComposer.php - Added MakesDates to Quote.php - Added Quote::badgeForStatus() - Cleanup payment.blade.php - Quote showing and approving - New resource 'quotes' in client.php - New image for quotes, align-left.svg * Credits: - New 'credits' resource in client.php - Fixes for client.php typo * Breadcrumbs: - Quotes - Credits * Placeholder for translations. * Restore whereIn & client scope Co-authored-by: David Bomba <turbo124@gmail.com>
92 lines
2.7 KiB
JavaScript
Vendored
92 lines
2.7 KiB
JavaScript
Vendored
/**
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://opensource.org/licenses/AAL
|
|
*/
|
|
|
|
class Payment {
|
|
constructor(displayTerms, displaySignature) {
|
|
this.shouldDisplayTerms = displayTerms;
|
|
this.shouldDisplaySignature = displaySignature;
|
|
this.termsAccepted = false;
|
|
}
|
|
|
|
handleMethodSelect(element) {
|
|
|
|
if (this.shouldDisplaySignature && !this.shouldDisplayTerms) {
|
|
this.displayTerms();
|
|
|
|
document.getElementById('accept-terms-button').addEventListener('click', () => {
|
|
this.termsAccepted = true;
|
|
this.submitForm();
|
|
});
|
|
}
|
|
|
|
if (!this.shouldDisplaySignature && this.shouldDisplayTerms) {
|
|
this.displaySignature();
|
|
|
|
document.getElementById('signature-next-step').addEventListener('click', () => {
|
|
this.submitForm();
|
|
});
|
|
}
|
|
|
|
if (this.shouldDisplaySignature && this.shouldDisplayTerms) {
|
|
this.displaySignature();
|
|
|
|
document.getElementById('signature-next-step').addEventListener('click', () => {
|
|
this.displayTerms();
|
|
|
|
document.getElementById('accept-terms-button').addEventListener('click', () => {
|
|
this.termsAccepted = true;
|
|
this.submitForm();
|
|
});
|
|
});
|
|
}
|
|
|
|
if (!this.shouldDisplaySignature && !this.shouldDisplayTerms) {
|
|
this.submitForm();
|
|
}
|
|
}
|
|
|
|
submitForm() {
|
|
document.getElementById('payment-form').submit();
|
|
}
|
|
|
|
displayTerms() {
|
|
let displayTermsModal = document.getElementById('displayTermsModal');
|
|
displayTermsModal.removeAttribute('style');
|
|
}
|
|
|
|
displaySignature() {
|
|
let displaySignatureModal = document.getElementById('displaySignatureModal');
|
|
displaySignatureModal.removeAttribute('style');
|
|
|
|
const signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
|
|
backgroundColor: 'rgb(240,240,240)',
|
|
penColor: 'rgb(0, 0, 0)'
|
|
});
|
|
}
|
|
|
|
handle() {
|
|
document.querySelectorAll('.dropdown-gateway-button').forEach((element) => {
|
|
element.addEventListener('click', () => this.handleMethodSelect(element));
|
|
});
|
|
}
|
|
}
|
|
|
|
const signature = document.querySelector(
|
|
'meta[name="require-invoice-signature"]'
|
|
).content;
|
|
|
|
const terms = document.querySelector(
|
|
'meta[name="show-invoice-terms"]'
|
|
).content;
|
|
|
|
new Payment(Boolean(+signature), Boolean(+terms)).handle();
|
|
|
|
|