Bugzilla – Attachment 136770 Details for
Bug 31051
Show patron's 'savings' on the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31051: Show patron savings on the OPAC
Bug-31051-Show-patron-savings-on-the-OPAC.patch (text/plain), 8.43 KB, created by
ByWater Sandboxes
on 2022-06-30 13:42:37 UTC
(
hide
)
Description:
Bug 31051: Show patron savings on the OPAC
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2022-06-30 13:42:37 UTC
Size:
8.43 KB
patch
obsolete
>From 49ae0f7fe51eb8f74d31ce2ee893c29c39082655 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 28 Jun 2022 16:58:03 +1200 >Subject: [PATCH] Bug 31051: Show patron savings on the OPAC > >This new feature shows a patron how much they have saved by using the >library rather than purchasing items. Savings are calculated based on >item replacement prices. The system preference allows you to choose >where to display the savings - the user page, the summary box on the >OPAC homepage, or the checkout history page. > >To test: >1. Update database and restart services >2. Confirm the new OPACShowSavings system preference is found in the >OPAC tab of Administration -> global system preferences. There should be >no options selected. >3. Find a patron with a checkout history, or check out a few items to a >patron. >4. Test with different values of OPACShowSavings and confirm that >savings are shown in the expected places. > >Sponsored-by: Horowhenua Libraries Trust > >Signed-off-by: Marie-Luce <marie-luce.laflamme@inlibro.com> >--- > Koha/Patron.pm | 34 +++++++++++++++++++ > .../bootstrap/en/modules/opac-main.tt | 8 +++++ > .../en/modules/opac-readingrecord.tt | 7 ++++ > .../bootstrap/en/modules/opac-user.tt | 6 ++++ > opac/opac-main.pl | 8 ++++- > opac/opac-readingrecord.pl | 6 ++++ > opac/opac-user.pl | 5 +++ > 7 files changed, 73 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index c4788eaa68..bfa354f3e2 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -2184,6 +2184,40 @@ sub decoded_secret { > return $self->secret; > } > >+=head3 get_savings >+ >+ my $savings = $patron->get_savings; >+ >+Use the replacement price of patron's old and current issues to calculate how much they have 'saved' by using the library. >+ >+=cut >+ >+sub get_savings { >+ my ( $self ) = @_; >+ >+ my $savings = 0; >+ >+ # get old issues >+ my $old_issues_rs = $self->_result->old_issues; >+ my @old_itemnumbers = $old_issues_rs->get_column('itemnumber')->all; >+ >+ foreach my $itemnumber ( @old_itemnumbers ) { >+ my $item = Koha::Items->find( $itemnumber ); >+ $savings += $item->replacementprice; >+ } >+ >+ # get current issues >+ my $issues_rs = $self->_result->issues; >+ my @itemnumbers = $issues_rs->get_column('itemnumber')->all; >+ >+ foreach my $itemnumber ( @itemnumbers ) { >+ my $item = Koha::Items->find( $itemnumber ); >+ $savings += $item->replacementprice; >+ } >+ >+ return $savings; >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >index 76fa790f8f..9113ffce10 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -278,6 +278,14 @@ > </li> > [% END %] > [% END %] >+ [% IF savings %] >+ <li> >+ <a href="/cgi-bin/koha/opac-user.pl"> >+ <span class="count_label">[% savings | $Price with_symbol => 1 %]</span> >+ total savings >+ </a> >+ </li> >+ [% END %] > </ul> > </div> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >index c637e4ad97..b16f73621f 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >@@ -3,6 +3,7 @@ > [% USE KohaDates %] > [% USE TablesSettings %] > [% USE AdditionalContents %] >+[% USE Price %] > [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] > [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] > [% INCLUDE 'doc-head-open.inc' %] >@@ -53,6 +54,12 @@ > [% ELSE %] > <div id="opac-user-readingrec"> > >+ [% IF savings %] >+ <div class="alert alert-info"> >+ Congratulations, you have saved a total of [% savings | $Price with_symbol => 1 %] by using the [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog. >+ </div> >+ [% END %] >+ > <div class="resultscontrol resort js-hide"> > <form id="sortform" action="/cgi-bin/koha/opac-readingrecord.pl" method="get"> > [% UNLESS ( limit ) %]<input type="hidden" name="limit" value="full" />[% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index b0578c55d1..5d8e8ef008 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -162,6 +162,12 @@ > </div> > [% END # / IF patron_flagged %] > >+ [% IF savings %] >+ <div class="alert alert-info"> >+ Congratulations, you have saved a total of [% savings | $Price with_symbol => 1 %] by using the [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog. >+ </div> >+ [% END %] >+ > <div class="alert alert-info" id="notesaved" style="display:none;"></div> > [% IF ( OpacMySummaryNote ) %] > [% PROCESS koha_news_block news => OpacMySummaryNote %] >diff --git a/opac/opac-main.pl b/opac/opac-main.pl >index 779c06d587..78f7975a10 100755 >--- a/opac/opac-main.pl >+++ b/opac/opac-main.pl >@@ -94,7 +94,12 @@ if ( $patron ) { > }); > my $patron_note = $patron->opacnote; > my $total = $patron->account->balance; >- if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 || $patron_note || $patron_messages->count ) { >+ my $saving_display = C4::Context->preference('OPACShowSavings'); >+ my $savings = 0; >+ if ( $saving_display =~ /summary/ ) { >+ $savings = $patron->get_savings; >+ } >+ if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 || $patron_note || $patron_messages->count || $savings > 0 ) { > $template->param( > dashboard_info => 1, > checkouts => $checkouts, >@@ -104,6 +109,7 @@ if ( $patron ) { > total_owing => $total, > patron_messages => $patron_messages, > opacnote => $patron_note, >+ savings => $savings, > ); > } > } >diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl >index 927c37b275..55981483e9 100755 >--- a/opac/opac-readingrecord.pl >+++ b/opac/opac-readingrecord.pl >@@ -141,6 +141,12 @@ for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above > $template->param(JacketImages=>1); > } > >+my $saving_display = C4::Context->preference('OPACShowSavings'); >+if ( $saving_display =~ /checkouthistory/ ) { >+ my $patron = Koha::Patrons->find( $borrowernumber ); >+ $template->param( savings => $patron->get_savings ); >+} >+ > $template->param( > READING_RECORD => $issues, > limit => $limit, >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 86960e0c84..730b49e82c 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -167,6 +167,11 @@ if ( $borr->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') > } > } > >+my $saving_display = C4::Context->preference('OPACShowSavings'); >+if ( $saving_display =~ /user/ ) { >+ $template->param( savings => $patron->get_savings ); >+} >+ > # pass on any renew errors to the template for displaying > my $renew_error = $query->param('renew_error'); > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31051
:
136564
|
136664
|
136698
|
136699
|
136770
|
136772
|
136773
|
136779
|
136781
|
139100
|
139101
|
139102
|
139408
|
139409
|
139410
|
139911
|
139912
|
139913
|
139914
|
139937
|
143384
|
144082
|
144759
|
144760
|
144761
|
144762
|
144763
|
146431
|
146432
|
147189
|
147190