@@ -, +, @@ preferences. --- Koha/Accounts/CreditTypes.pm | 10 + .../prog/en/modules/admin/preferences/opac.pref | 30 ++ .../en/modules/opac-account-pay-return.tt | 392 +++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-account.tt | 161 ++++++--- .../opac-tmpl/prog/en/includes/browser-strings.inc | 1 + .../prog/en/modules/opac-account-pay-return.tt | 396 ++++++++++++++++++++ .../opac-tmpl/prog/en/modules/opac-account.tt | 179 +++++++--- opac/opac-account-pay-paypal-return.pl | 121 ++++++ opac/opac-account-pay.pl | 127 +++++++ opac/opac-account.pl | 1 - 10 files changed, 1325 insertions(+), 93 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-return.tt create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-account-pay-return.tt create mode 100755 opac/opac-account-pay-paypal-return.pl create mode 100755 opac/opac-account-pay.pl --- a/Koha/Accounts/CreditTypes.pm +++ a/Koha/Accounts/CreditTypes.pm @@ -58,6 +58,8 @@ sub IsValid { || $string eq Koha::Accounts::CreditTypes::Credit() || $string eq Koha::Accounts::CreditTypes::Forgiven() ); + $is_valid ||= $string eq Koha::Accounts::CreditTypes::PayPal(); + unless ($is_valid) { $is_valid = Koha::Database->new()->schema->resultset('AuthorisedValue') @@ -108,6 +110,14 @@ sub Forgiven { return 'FORGIVEN'; } +=head2 PayPal + +=cut + +sub PayPal { + return 'PAYPAL'; +} + 1; =head1 AUTHOR --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -619,3 +619,33 @@ OPAC: - pref: PatronSelfRegistrationAdditionalInstructions type: textarea class: html + Payments: + - + - pref: EnablePayPalOpacPayments + default: 1 + choices: + yes: Allow + no: "Don't allow" + - "patrons to make payments from the OPAC via PayPal in" + - pref: PayPalSandboxMode + default: 1 + choices: + yes: "Sandbox" + no: "Production" + - "mode." + - + - "The email address to recieve PayPal payments is " + - pref: PayPalUser + class: long + - + - "The password for the PayPal account to recieve payments is " + - pref: PayPalPwd + class: long + - + - "The signature for the PayPal account to recieve payments is " + - pref: PayPalSignature + class: long + - + - "The patron should see the charge description as " + - pref: PayPalChargeDescription + class: long --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-return.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-return.tt @@ -0,0 +1,392 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE Currency %] + +[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your fines and charges +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + + + + +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+
+ +
+
+
+ [% IF error %] +
+

Error: there was an problem processing your payment

+ + [% IF error == "PAYPAL_UNABLE_TO_CONNECT" %] +

Unable to connect to PayPal.

+

Please try again later.

+ [% ELSIF error == "PAYPAL_ERROR_PROCESSING" %] +

Unable to verify payment.

+

Please contact the library to verify your payment.

+ [% END %] +
+ [% ELSIF credit %] +
+

Payment applied: your payment of [% credit.amount_paid %] has been applied to your account

+
+ [% END %] + + Return to fine details +
+
+
+
+
+ +[% INCLUDE 'opac-bottom.inc' %] +[% INCLUDE 'datatables.inc' %] + + + +[% BLOCK jsinclude %][% END %] + +[% BLOCK format_data %] + [% FOREACH key IN data.result_source.columns %] + [% IF key.match('^amount') %] + "[% key %]": "[% data.$key FILTER $Currency %]", + "[% key %]_unformatted": "[% data.$key %]", + [% ELSIF key.match('_on$') %] + "[% key %]": "[% data.$key | $KohaDates %]", + "[% key %]_unformatted": "[% data.$key %]", + [% ELSE %] + "[% key %]": "[% data.$key %]", + [% END %] + [% END %] +[% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt @@ -34,51 +34,79 @@

Account balance: [% borrower.account_balance | $Currency %]

-
-
- View payments - - - - - - - - - - - - - - - - - -
Fees
IDDescriptionTypeAmountOutsandingCreated onUpdated on
+
+
+
+ View payments + + + + + + + + + + + + + + + + + + +
Fees
IDDescriptionTypeAmountOutsandingCreated onUpdated onPay
+
+ +
+ View fees + + + + + + + + + + + + + + + + + +
Payments
IDNotesTypeAmountRemainingCreated onUpdated on
+
+ + [% IF Koha.Preference('EnablePayPalOpacPayments') %] +
+ Pay online + +
+ Amount to pay: + [% Currency.symbol() %] +
+ +
+
Payment method:
+ + +
+ +
+ +
+ +
+
+ [% END %]
- -
- View fees - - - - - - - - - - - - - - - - - -
Payments
IDNotesTypeAmountRemainingCreated onUpdated on
-
-
+ [% ELSE %]

You have no fines or charges

[% END %] @@ -121,7 +149,24 @@ $(document).ready(function() { { "mDataProp": "amount_original" }, { "mDataProp": "amount_outstanding" }, { "mDataProp": "created_on" }, - { "mDataProp": "updated_on" } + { "mDataProp": "updated_on" }, + { + /* Payment selection checkboxes */ + [% UNLESS Koha.Preference('EnablePayPalOpacPayments') %] + "bVisible": false, + [% END %] + "mDataProp": null, + "sDefaultContent": "", + "fnRender": function ( o, val ) { + return val; + }, + "mRender": function ( data, type, full ) { + if ( full.amount_outstanding_unformatted > 0 ) { + return "" + + ""; + } + } + }, ], "aaData": [ [% FOREACH d IN debits %] @@ -242,6 +287,28 @@ $(document).ready(function() { } } ); + // Allow only numbers in ammount to pay + $('#amount_to_pay').keypress(function(event) { + end = $(this).val().split('.')[1]; + if (typeof end === 'undefined') { + end = ''; + } + + if ( ( ( event.which != 46 || $(this).val().indexOf('.') != -1 ) && ( event.which < 48 || event.which > 57 ) ) || ( end.length > 1 ) ) { + event.preventDefault(); + } + }); + + // Update the "amount to pay" field whenever a fee checkbox is changed + // Note, this is just a payment suggestion and can be changed to any amount + $(".pay-checkbox" ).change(function() { + var sum = 0; + $("input[name='debit_id']:checked" ).each(function(i,n){ + sum += parseFloat( $( "#amount_outstanding_" + $(this).val() ).val() ); + }); + $('#amount_to_pay').val( sum.toFixed(2) ); + }); + } ); function fnFormatDebitDetails( debitsTable, nTr ) { @@ -321,7 +388,7 @@ function fnFormatDebitDetails( debitsTable, nTr ) { function fnFormatCreditDetails( creditsTable, nTr ) { var oData = creditsTable.fnGetData( nTr ); - var sOut = "