Skip to content

Commit

Permalink
Bug 34557: Add SCOLoadCheckoutsByDefault system preference
Browse files Browse the repository at this point in the history
This patch adds a enw system preference SCOLoadCheckoutsByDefault

When enabled, a patron's list o fcurrent checkouts will be loaded when the sign in to the SCO
module. If disabled, they will see link to load their checkouts. In either case, a new section
is added to the SCO to show a brief display of the last checked out it

To test:
1 - Enable WebBasedSelfCheck system preference
2 - Browse to:
    http://localhost:8080/cgi-bin/koha/sco/sco-main.pl
3 - Sign in the SCO user (or enable AutoSelfCheck)
4 - Sign in as a user with several items checked out
5 - Confirm you see a list of items checked out
6 - Apply patches, updatedatabase, restart_all
7 - 'Finish' and login patron to SCO again
8 - Confirm you still see the list
9 - 'Finish'
10 - Chenge the system preference
11 - Sign in to SCO, confirm checkouts do not load
12 - Confirm you see 'Load your checkouts' link
13 - Check an item out
14 - Confirm you see the last checkout, but not a list
15 - Attempt to checkout an item that cannot be checked out
16 - Confirm "Return to account summary" does not load checkouts
17 - Click "Load your checkouts"
18 - Confirm they load
19 - Check out another item, confrim they remain and are updated
20 - Checkout an item that cannot be issued
21 - Confirm 'Return to account summary' loads the checkouts again

Signed-off-by: Andrew Auld <[email protected]>
Signed-off-by: AndrewA <[email protected]>
Signed-off-by: Katrin Fischer <[email protected]>
Signed-off-by: Tomas Cohen Arazi <[email protected]>
  • Loading branch information
kidclamp authored and tomascohen committed Nov 8, 2023
1 parent 1f2bdac commit 8c801ea
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 18 deletions.
19 changes: 19 additions & 0 deletions installer/data/mysql/atomicupdate/bug_34557.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use Modern::Perl;

return {
bug_number => "34557",
description => "Add system preference SCOLoadCheckoutsByDefault",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};

$dbh->do(
q{
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
('SCOLoadCheckoutsByDefault','1','','If enabled, load the list of a patrons checkouts when they log in to the Self Checkout','YesNo')
}
);

say $out "Added new system preference 'SCOLoadCheckoutsByDefault'";
},
};
1 change: 1 addition & 0 deletions installer/data/mysql/mandatory/sysprefs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'),
('SavedSearchFilters', '0', NULL, 'Allow staff with permission to create/edit custom search filters', 'YesNo'),
('SCOAllowCheckin','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'),
('SCOLoadCheckoutsByDefault','1','','If enabled, load the list of a patrons checkouts when they log in to the Self Checkout','YesNo'),
('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea'),
('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded <style> tag.','free'),
('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,12 @@ Circulation:
type: textarea
syntax: css
class: code
-
- pref: SCOLoadCheckoutsByDefault
choices:
1: Show
0: "Don't show"
- "the patron's list of current checkouts by default when they log in to the self checkout module."
-
- pref: ShowPatronImageInWebBasedSelfCheck
choices:
Expand Down
27 changes: 27 additions & 0 deletions koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<input type="hidden" name="op" value="returnbook" />
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="barcode" value="[% barcode | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
<button type="submit" name="returnbook" class="btn btn-primary"><i class="fa fa-undo" aria-hidden="true"></i> Return this item</button>
</form>
Expand All @@ -116,6 +117,7 @@
<input type="hidden" name="op" value="" />
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="barcode" value="[% barcode | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
<input type="submit" name= "confirm" value="Return to account summary" class="btn btn-info back focus" />
</form>
Expand All @@ -135,6 +137,7 @@
<input type="hidden" name="op" value="returnbook" />
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="barcode" value="[% barcode | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="confirmed" value="" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
<button type="submit" name="returnbook" class="btn btn-primary"><i class="fa fa-undo" aria-hidden="true"></i> Return this item</button>
Expand All @@ -147,6 +150,7 @@
<input type="hidden" name="op" value="renew" />
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="barcode" value="[% barcode | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="confirmed" value="1" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
<button type="submit" name="confirm" class="btn btn-primary"><i class="fa-solid fa-rotate" aria-hidden="true"></i> Renew item</button>
Expand All @@ -157,6 +161,7 @@
<input type="hidden" name="op" value="renew" />
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="barcode" value="[% barcode | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="confirmed" value="1" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
<button type="submit" class="btn btn-primary"><i class="fa-solid fa-rotate" aria-hidden="true"></i> Renew item</button>
Expand All @@ -167,6 +172,7 @@
<legend class="sr-only">Cancel</legend>
<input type="hidden" name="op" value="" />
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
<button type="submit" class="btn btn-primary"><i class="fa fa-cancel" aria-hidden="true"></i> Cancel</button>
</form>
Expand Down Expand Up @@ -271,6 +277,7 @@
<button type="button" id="logout_form" class="btn btn-info"><i class="fa fa-check" aria-hidden="true"></i> Finish</button>
<input type="hidden" name="op" value="checkout" />
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
</div>
</div> <!-- /.row -->
Expand Down Expand Up @@ -307,7 +314,23 @@
<div class="tab-content">
<div id="checkouts-tab" class="tab-pane show active" aria-labelledby="checkouts">
<div id="borrowerdetails">
[% IF ( new_issue ) %]
<div class="lastchecked">
<p>
<strong>Checked out: </strong>
[% new_issue.item.biblio.title | html %] ([% new_issue.item.barcode | html %]).

[% IF new_issue.item.is_bundle %]
[% SET bundle_items_count = new_issue.item.bundle_items.count %]
[% tnx('Bundle of {count} item', 'Bundle of {count} items', bundle_items_count, { count = bundle_items_count }) | html %].
[% END %]

Due on [% new_issue.date_due | $KohaDates as_due_date => 1 %]
</p>
</div>
[% END %]
[% IF ( issues_count ) %]
[% IF ( Koha.Preference('SCOLoadCheckoutsByDefault') || load_checkouts ) %]
<table id="loanTable" class="table table-bordered table-striped">
<caption>Checkouts for [% borrowername | html %] <span class="count">([% issues_count | html %] total)</span></caption>
<!-- ISSUES TABLE ROWS -->
Expand Down Expand Up @@ -354,6 +377,7 @@
<form action="/cgi-bin/koha/sco/sco-main.pl" method="post">
<legend class="sr-only">Issue renews</legend>
<input type="hidden" name="patronid" value="[% patronid | html %]" />
<input type="hidden" name="load_checkouts" value="[% load_checkouts | html %]" />
<input type="hidden" name="barcode" value="[% ISSUE.barcode | html %]" />
<input type="hidden" name="newissues" value="[% newissues | html %]" />
[% IF ISSUE.can_be_renewed %]
Expand Down Expand Up @@ -397,6 +421,9 @@
[% END # / FOREACH ISSUE %]
</tbody>
</table>
[% ELSE %]
<a href="?load_checkouts=1">Load your checkouts</a>
[% END # / IF ( Koha.preference('SCOLoadCheckoutsByDefault') || load_checkouts ) %]
[% ELSE %]
<h3>You currently have nothing checked out.</h3>
[% END # / IF issues_count %]
Expand Down
40 changes: 22 additions & 18 deletions opac/sco/sco-main.pl
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@
}

my $issuerid = $loggedinuser;
my ($op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = (
$query->param("op") || '',
$query->param("patronlogin")|| '',
$query->param("patronpw") || '',
$query->param("barcode") || '',
$query->param("confirmed") || '',
$query->param("newissues") || '',
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts ) = (
$query->param("op") || '',
$query->param("patronlogin") || '',
$query->param("patronpw") || '',
$query->param("barcode") || '',
$query->param("confirmed") || '',
$query->param("newissues") || '',
$query->param("load_checkouts") || '',
);

my $jwt = $query->cookie('JWT');
Expand Down Expand Up @@ -245,8 +246,8 @@
)->count;
}

AddIssue( $patron, $barcode );
$template->param( issued => 1 );
my $new_issue = AddIssue( $patron, $barcode );
$template->param( issued => 1, new_issue => $new_issue );
push @newissueslist, $barcode;

if ( $hold_existed ) {
Expand Down Expand Up @@ -298,15 +299,17 @@

if ( $patron) {
my $borrowername = sprintf "%s %s", ($patron->firstname || ''), ($patron->surname || '');
my $pending_checkouts = $patron->pending_checkouts;
my @checkouts;
while ( my $c = $pending_checkouts->next ) {
my $checkout = $c->unblessed_all_relateds;
my ($can_be_renewed, $renew_error) = CanBookBeRenewed( $patron, $c );
$checkout->{can_be_renewed} = $can_be_renewed; # In the future this will be $checkout->can_be_renewed
$checkout->{renew_error} = $renew_error;
$checkout->{overdue} = $c->is_overdue;
push @checkouts, $checkout;
my $pending_checkouts = $patron->pending_checkouts;
if ( C4::Context->preference('SCOLoadCheckoutsByDefault') || $load_checkouts ) {
while ( my $c = $pending_checkouts->next ) {
my $checkout = $c->unblessed_all_relateds;
my ( $can_be_renewed, $renew_error ) = CanBookBeRenewed( $patron, $c );
$checkout->{can_be_renewed} = $can_be_renewed; # In the future this will be $checkout->can_be_renewed
$checkout->{renew_error} = $renew_error;
$checkout->{overdue} = $c->is_overdue;
push @checkouts, $checkout;
}
}

my $show_priority;
Expand All @@ -328,14 +331,15 @@
$template->param(
validuser => 1,
borrowername => $borrowername,
issues_count => scalar(@checkouts),
issues_count => scalar(@checkouts) || $pending_checkouts->count(),
ISSUES => \@checkouts,
HOLDS => $holds,
newissues => join(',',@newissueslist),
patronlogin => $patronlogin,
patronpw => $patronpw,
waiting_holds_count => $waiting_holds_count,
noitemlinks => 1 ,
load_checkouts => $load_checkouts,
borrowernumber => $patron->borrowernumber,
SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'),
AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
Expand Down

0 comments on commit 8c801ea

Please sign in to comment.