From 736cb171f9f24e7fd2210a2db235fccb6578e56f Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Mon, 17 Oct 2016 08:00:32 +0000 Subject: [PATCH] Bug 17449 - Let users choose action in self checkout Currently if you have a stack of 15 books that you want to renew through the self checkout, you need to read the barcode of each item and then click "renew" for each of them. Same for returning books. One of my customers wants to change the SCO screen so that users can choose the action they want to take up front, then let them do the 15 renewals by just scanning the barcodes. This patch uses "Bootstrap tabs". I tried using "jQuery tabs", in a similar way to how it is done in e.g. record detail display in the OPAC. This resulted in weird conflicts between jQuery and Bootstrap, hence the use of Bootstrap for the final patch. To test: - Apply this patch - Make sure self check is enabled - Log in to self check - Process some barcodes, first by borrowing, then renewing, then returning. Verify that the selected tab is still active and has focus after each barcode has been processed. - Now try "illegal" actions and check that you get appropriate responses: - Try to borrow a barcode you have already borrowed. - Try to return a barcode that you have not already borrowed. - Etc. - Try this with and without AllowSelfCheckReturns 2018-04-24: Fixed conflicts and problems with renew and return. Sponsored-by: Hylte Public Library --- koha-tmpl/opac-tmpl/bootstrap/css/sco.css | 8 +- .../opac-tmpl/bootstrap/en/modules/sco/sco-main.tt | 114 +++++++++++++++++---- opac/sco/sco-main.pl | 19 ++++ 3 files changed, 117 insertions(+), 24 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/sco.css b/koha-tmpl/opac-tmpl/bootstrap/css/sco.css index 38fe877..3045e24 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/sco.css +++ b/koha-tmpl/opac-tmpl/bootstrap/css/sco.css @@ -170,6 +170,9 @@ i.cancel { i.finish { background : transparent url("../lib/famfamfam/silk/stop.png") no-repeat 0 0; } +.finish-button { + padding-top: 20px; +} i.help { background : transparent url("../lib/famfamfam/silk/help.png") no-repeat 0 0; @@ -194,15 +197,12 @@ i.help { padding-right: 19px; background: #EEEEEE none; } - #sci_logout { color: #E8583C; } - #sci_checkin_button, #sci_refresh_button, #sci_append_button { margin-bottom: 10px; } - #sci_refresh_button { color: rgb(51, 51, 51); -} \ No newline at end of file +} diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 8cadb17..6a56b24 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -182,26 +182,94 @@ [% END # / IF patronid %] [% IF ( validuser ) %] -
-
+ + + + + +
+ [% IF ( op_sanitized == 'checkout' ) %] +
+ [% ELSE %] +
+ [% END %] +
- Check out[% IF ( Koha.Preference('AllowSelfCheckReturns') ) %], return[% END %] or renew an item: -
- - - -
- - -
+
+ + + + + +
+ + + +
-
-
- -
-
-
+ [% IF ( op_sanitized == 'renew' ) %] +
+ [% ELSE %] +
+ [% END %] +
+
+
+ + + +
+ + +
+
+
+ + [% IF ( Koha.Preference('AllowSelfCheckReturns') ) %] + [% IF ( op_sanitized == 'return' ) %] +
+ [% ELSE %] +
+ [% END %] +
+
+
+ + + +
+ + +
+
+
+ [% END %] +
+ +
+
+ +
+
[% IF ( display_patron_image ) %]
@@ -327,7 +395,6 @@
- [% INCLUDE 'opac-bottom.inc' %] [% BLOCK jsinclude %] @@ -356,8 +423,8 @@ return false; } - function checkout_confirm(patronid) { - var barcode = $("#barcode").val(); + function checkout_confirm(target, patronid) { + var barcode = $("#" + target + "-barcode").val(); // alert("checkout_confirm('" + patronid + "') called for barcode '" + barcode + "'"); if (! barcode) { dofocus(); return false; } // no barcode if (barcode == "__KOHA_NEW_CIRC__") { // magic barcode @@ -415,6 +482,13 @@ return true; }); + + // Make sure the barcode box on the selected tab is given focus + $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { + var target = $(e.target).attr("href"); + $(target + '-barcode').focus(); + }); + }); //]]> diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 9fcf729..621f59a 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -128,6 +128,9 @@ if ($op eq "logout") { elsif ( $op eq "returnbook" && $allowselfcheckreturns ) { my ($doreturn) = AddReturn( $barcode, $branch ); } +elsif ( $op eq "renew" ) { + AddRenewal( $borrower->{borrowernumber}, $item->{itemnumber} ); +} elsif ( $patron and $op eq "checkout" ) { my $impossible = {}; my $needconfirm = {}; @@ -306,4 +309,20 @@ if ($borrower) { ); } +# Send a sanitized value for op to the template, to determine active tab +my $op_sanitized; +if ( $op eq 'returnbook' ) { + $op_sanitized = 'return'; +} elsif ( $op eq 'renew' ) { + $op_sanitized = 'renew'; +} else { + $op_sanitized = 'checkout'; +} + +$template->param( + SCOUserJS => C4::Context->preference('SCOUserJS'), + SCOUserCSS => C4::Context->preference('SCOUserCSS'), + op_sanitized => $op_sanitized, +); + output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.7.4