Bug 23228: Add option to automatically display payment receipt for printing after making a payment

Some libraries would like an auto-popup after making a payment so librarians don't have
to navigate to the accounts page, locate the new payment, then click the print button.

Test Plan:
1) Apply this patch
2) Run updatedatabase.pl
3) Make a payment, note no difference in behavior
4) Enable the new syspref FinePaymentAutoPopup
5) Make a payment, note the popup for the payment receipt

Signed-off-by: Lisette Scheer <lisettes@latahlibrary.org>
Rescued-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Kyle Hall 2019-06-27 12:12:46 -04:00 committed by Martin Renvoize
parent d952abd837
commit 1bc1642b94
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
9 changed files with 50 additions and 13 deletions

View file

@ -0,0 +1,10 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
$dbh->do({
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
('FinePaymentAutoPopup','0',NULL,'If enabled, automatically display a print dialog for a payment receipt when making a payment.','YesNo')
});
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 23228 - Add option to automatically display payment receipt for printing after making a payment)\n";
}

View file

@ -183,6 +183,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('FeeOnChangePatronCategory','1','','If set, when a patron changes to a category with enrolment fee, a fee is charged','YesNo'),
('FilterBeforeOverdueReport','0','','Do not run overdue report until filter selected','YesNo'),
('FineNotifyAtCheckin','0',NULL,'If ON notify librarians of overdue fines on the items they are checking in.','YesNo'),
('FinePaymentAutoPopup','0',NULL,'If enabled, automatically display a print dialog for a payment receipt when making a payment.','YesNo'),
('finesCalendar','noFinesWhenClosed','ignoreCalendar|noFinesWhenClosed','Specify whether to use the Calendar in calculating duedates and fines','Choice'),
('FinesIncludeGracePeriod','1',NULL,'If enabled, fines calculations will include the grace period.','YesNo'),
('FinesLog','1',NULL,'If ON, log fines','YesNo'),

View file

@ -889,6 +889,12 @@ Circulation:
- pref: ProcessingFeeNote
type: textarea
class: code
-
- pref: FinePaymentAutoPopup
choices:
yes: "Do"
no: "Don't"
- automatically display a print dialog for a payment receipt when making a payment..
Self check-in module:
-
- "Include the following HTML on the self check-in screen:"

View file

@ -120,6 +120,10 @@
[% Asset.js("js/members-menu.js") | $raw %]
<script>
$(document).ready(function() {
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id %]&borrowernumber=[% patron.borrowernumber %]', '_blank');
[% END %]
var txtActivefilter = _("Filter paid transactions");
var txtInactivefilter = _("Show all transactions");
var columns_settings = [% ColumnsSettings.GetColumns('members', 'fines', 'account-fines', 'json') | $raw %];

View file

@ -179,7 +179,11 @@
}
}
$(document).ready(function(){
$('#pay-fines-form').preventDoubleFormSubmit();
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id %]&borrowernumber=[% patron.borrowernumber %]', '_blank');
[% END %]
$('#pay-fines-form').preventDoubleFormSubmit();
$("#woall").click(function(event){
var msg = _("Are you sure you want to write off %s in outstanding fines? This cannot be undone!").format( "[% total | $Price %]" );
var answer = confirm(msg);

View file

@ -277,6 +277,10 @@
[% Asset.js("js/members-menu.js") | $raw %]
<script>
$(document).ready(function() {
[% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id %]&borrowernumber=[% patron.borrowernumber %]', '_blank');
[% END %]
var forms = $('#payindivfine, #payfine');
var change = $('#change')[0];

View file

@ -48,7 +48,8 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
);
my $borrowernumber = $input->param('borrowernumber');
my $action = $input->param('action') || '';
my $payment_id = $input->param('payment_id');
my $action = $input->param('action') || '';
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
my $patron = Koha::Patrons->find( $borrowernumber );
@ -84,6 +85,7 @@ $template->param(
total => sprintf("%.2f",$total),
totalcredit => $totalcredit,
accounts => \@accountlines,
payment_id => $payment_id,
);
output_html_with_http_headers $input, $cookie, $template->output;

View file

@ -63,6 +63,8 @@ if ( !$borrowernumber ) {
$borrowernumber = $input->param('borrowernumber0');
}
my $payment_id = $input->param('payment_id');
# get borrower details
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
our $patron = Koha::Patrons->find($borrowernumber);
@ -131,7 +133,8 @@ for (@names) {
}
$template->param(
finesview => 1,
finesview => 1,
payment_id => $payment_id,
);
add_accounts_to_template();

View file

@ -36,8 +36,9 @@ use Koha::Token;
my $input = CGI->new();
my $writeoff_individual = $input->param('writeoff_individual');
my $type = scalar $input->param('type') || 'payment';
my $payment_id = $input->param('payment_id');
my $writeoff_individual = $input->param('writeoff_individual');
my $type = scalar $input->param('type') || 'payment';
my $updatecharges_permissions = ($writeoff_individual || $type eq 'writeoff') ? 'writeoff' : 'remaining_permissions';
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@ -121,7 +122,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
if ($pay_individual) {
my $line = Koha::Account::Lines->find($accountlines_id);
$account->pay(
$payment_id = $account->pay(
{
lines => [$line],
amount => $total_paid,
@ -132,7 +133,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
}
);
print $input->redirect(
"/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber");
"/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id");
} else {
if ($select) {
if ( $select =~ /^([\d,]*).*/ ) {
@ -150,7 +151,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
{ order_by => 'date' }
);
$account->pay(
$payment_id = $account->pay(
{
type => $type,
amount => $total_paid,
@ -164,7 +165,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
}
else {
my $note = $input->param('selected_accts_notes');
$account->pay(
$payment_id = $account->pay(
{
amount => $total_paid,
library_id => $library_id,
@ -175,7 +176,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
);
}
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber&payment_id=$payment_id");
}
}
} else {
@ -189,12 +190,14 @@ if ( $input->param('error_over') ) {
}
$template->param(
payment_id => $payment_id,
type => $type,
borrowernumber => $borrowernumber, # some templates require global
patron => $patron,
total => $total_due,
patron => $patron,
total => $total_due,
csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
csrf_token => Koha::Token->new->generate_csrf( { session_id => scalar $input->cookie('CGISESSID') } ),
);
output_html_with_http_headers $input, $cookie, $template->output;