From 70c76edacaeca23682c4794ef009dce57752d4ac Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Thu, 7 Mar 2019 15:58:41 -0300 Subject: [PATCH] Bug 21772: Add holds and account information to SCO This patch introduces holds and account information to the SCO page. It uses the introduced include files that are also used in OPAC (opac-user.pl and opac-account.pl). To test: 1) Have a patron that has holds and account lines 2) Enable the SCO module 3) Use the patron's cardnumber to get to its details => SUCCESS: New tabs are presented, and they display holds and account information as expected 4) Sign off :-D Sponsored-by: City of Portsmouth Public Library Signed-off-by: Sarah Cornell Signed-off-by: Josef Moravec --- .../opac-tmpl/bootstrap/en/modules/sco/sco-main.tt | 179 ++++++++++++--------- opac/sco/sco-main.pl | 35 ++++ 2 files changed, 135 insertions(+), 79 deletions(-) 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 317a8d3683..68bbacf433 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 @@ -251,87 +251,108 @@
-
- [% IF ( issues_count ) %] - - - - - - - - - - - [% UNLESS ( nofines ) %] - - [% END %] - - - - [% FOREACH ISSUE IN ISSUES %] - - - - - [% IF ( ISSUE.overdue ) %] - - [% ELSE %] - - [% END %] - + [% END # / FOREACH ISSUE %] + +
Checkouts for [% borrowername | html %] ([% issues_count | html %] total)
Checked out onTitleCall no.DueRenewFines
[% ISSUE.issuedate | html %] - [% UNLESS ( noitemlinks ) %] - [% ISSUE.title | html %] - [% ELSE %] - [% ISSUE.title | html %] - [% END %] - [% IF ( newissues.match(ISSUE.barcode)) %] - NEW - [% END %] - [% ISSUE.author | html %] - ([% ISSUE.barcode | html %]) - [% ISSUE.itemcallnumber | html %][% ISSUE.date_due | $KohaDates as_due_date => 1 %][% ISSUE.date_due | $KohaDates as_due_date => 1 %] -
- - - - [% IF ISSUE.can_be_renewed %] - - - [% UNLESS ( ISSUE.renew ) %] - - [% ELSE %] - - [% END %] - [% ELSE %] - [% IF ISSUE.renew_error == 'auto_renew' OR ISSUE.renew_error == 'auto_too_soon' %] - This item has been scheduled for automatic renewal and cannot be renewed - [% ELSIF ISSUE.renew_error == 'onsite_checkout' %] - This is a on-site checkout, it cannot be renewed. - [% ELSE %] - No renewals allowed +
+ +
+
+
+ [% IF ( issues_count ) %] + + + + + + + + + + + [% UNLESS ( nofines ) %] + + [% END %] + + + + [% FOREACH ISSUE IN ISSUES %] + + + + + [% IF ( ISSUE.overdue ) %] + + [% ELSE %] + [% END %] - [% IF Koha.Preference('AllowSelfCheckReturns') %] - - - + + [% UNLESS ( nofines ) %] + [% END %] - [% END %] - - - [% UNLESS ( nofines ) %] - - [% END %] - - [% END # / FOREACH ISSUE %] - -
Checkouts for [% borrowername | html %] ([% issues_count | html %] total)
Checked out onTitleCall no.DueRenewFines
[% ISSUE.issuedate | html %] + [% UNLESS ( noitemlinks ) %] + [% ISSUE.title | html %] + [% ELSE %] + [% ISSUE.title | html %] + [% END %] + [% IF ( newissues.match(ISSUE.barcode)) %] + NEW + [% END %] + [% ISSUE.author | html %] + ([% ISSUE.barcode | html %]) + [% ISSUE.itemcallnumber | html %][% ISSUE.date_due | $KohaDates as_due_date => 1 %][% ISSUE.date_due | $KohaDates as_due_date => 1 %] + + + + + [% IF ISSUE.can_be_renewed %] + + + [% UNLESS ( ISSUE.renew ) %] + + [% ELSE %] + + [% END %] + [% ELSE %] + [% IF ISSUE.renew_error == 'auto_renew' OR ISSUE.renew_error == 'auto_too_soon' %] + This item has been scheduled for automatic renewal and cannot be renewed + [% ELSIF ISSUE.renew_error == 'onsite_checkout' %] + This is a on-site checkout, it cannot be renewed. + [% ELSE %] + No renewals allowed + [% END %] + [% IF Koha.Preference('AllowSelfCheckReturns') %] + + + + [% END %] + [% END %] + + + [% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %] + - [% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %] -
- [% ELSE %] -

You currently have nothing checked out.

- [% END # / IF issues_count %] -
+
+ [% ELSE %] +

You currently have nothing checked out.

+ [% END # / IF issues_count %] +
+
+
+ [% IF HOLDS.count > 0 %] + [% PROCESS 'holds-table.inc' HOLDS = HOLDS, SuspendHoldsOpac = SuspendHoldsOpac, showpriority = showpriority, AutoResumeSuspendedHolds = AutoResumeSuspendedHolds, onlyinfo = 'true' %] + [% ELSE %] +

You currently have no pending holds.

+ [% END %] +
+
+ [% PROCESS 'account-table.inc' %] +
+
+
[% ELSE # IF validuser %]
diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 9ec86422c0..458e52e57c 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -272,17 +272,52 @@ if ($borrower) { push @checkouts, $checkout; } + my $show_priority; + for ( C4::Context->preference("OPACShowHoldQueueDetails") ) { + m/priority/ and $show_priority = 1; + } + + my $patron = Koha::Patrons->find( $borrower->{borrowernumber} ); + my $total = $patron->account->balance; + my $accts = Koha::Account::Lines->search( + { borrowernumber => $borrower->{borrowernumber} }, + { order_by => { -desc => 'accountlines_id' } } + ); + + my @accountlines; + while ( my $line = $accts->next ) { + my $accountline = $line->unblessed; + $accountline->{'amount'} = sprintf( "%.2f", $accountline->{'amount'} || '0.00'); + if ( $accountline->{'amount'} >= 0 ) { + $accountline->{'amountcredit'} = 1; + } + $accountline->{'amountoutstanding'} = + sprintf( "%.2f", $accountline->{'amountoutstanding'} || '0.00' ); + if ( $accountline->{'amountoutstanding'} >= 0 ) { + $accountline->{'amountoutstandingcredit'} = 1; + } + push @accountlines, $accountline; + } + + my $holds = $patron->holds; + $template->param( validuser => 1, borrowername => $borrowername, issues_count => scalar(@checkouts), ISSUES => \@checkouts, + HOLDS => $holds, newissues => join(',',@newissueslist), patronid => $patronid, patronlogin => $patronlogin, patronpw => $patronpw, noitemlinks => 1 , borrowernumber => $borrower->{'borrowernumber'}, + SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), + AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), + showpriority => $show_priority, + ACCOUNT_LINES => \@accountlines, + total => sprintf( "%.2f", $total ), ); my $patron_messages = Koha::Patron::Messages->search( -- 2.11.0