From 7cd73928cd23cbb19e79e7209c2484d2dcde511b Mon Sep 17 00:00:00 2001 From: Katrin Fischer <katrin.fischer.83@web.de> Date: Thu, 15 Mar 2018 08:40:12 +0000 Subject: [PATCH] Bug 20400: Add routing list tab in OPAC This patch adds the base for the new feature: Show a list of the serial titles a patron is on routing lists for in the OPAC. Test plan applies to the complete patch set: To test: - Apply all patches - Make sure RoutingSerials is not activated - Check patron account in OPAC - no tab should appear - Activate RoutingSerials - Create subscriptions and different routing lists, test with: - Patron with no routing list entries = no tab - Patron with one or more routing list entries = tab appears --- .../opac-tmpl/bootstrap/en/includes/usermenu.inc | 9 +++ .../bootstrap/en/modules/opac-routing-lists.tt | 69 ++++++++++++++++++++++ opac/opac-routing-lists.pl | 68 +++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-routing-lists.tt create mode 100644 opac/opac-routing-lists.pl diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc index 7d27f22..0e8c5bd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -96,6 +96,15 @@ <a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1">your lists</a></li> [% END %] + [% IF Koha.Preference( 'RoutingSerials' ) == 1 %] + [% IF ( routinglistsview ) %] + <li class="active"> + [% ELSE %] + <li> + [% END %] + <a href="/cgi-bin/koha/opac-routing-lists.pl">your routing lists</a></li> + [% END %] + [% IF Koha.Preference( 'useDischarge' ) == 1 %] [% IF ( dischargeview ) %] <li class="active"> diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-routing-lists.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-routing-lists.tt new file mode 100644 index 0000000..0384c93 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-routing-lists.tt @@ -0,0 +1,69 @@ +[% USE Koha %] +[% USE KohaDates %] +[% INCLUDE 'doc-head-open.inc' %] +<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your routing lists</title> +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %] + <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" /> +[% END %] +</head> + +[% INCLUDE 'bodytag.inc' bodyid='opac-account' bodyclass='scrollto' %] +[% INCLUDE 'masthead.inc' %] + +<div class="main"> + <ul class="breadcrumb"> + <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li> + <li><a href="/cgi-bin/koha/opac-routing-lists.pl">[% INCLUDE 'patron-title.inc' category_type = BORROWER_INFO.category_type firstname = BORROWER_INFO.firstname surname = BORROWER_INFO.surname othernames = BORROWER_INFO.othernames cardnumber = BORROWER_INFO.cardnumber %]</a> <span class="divider">›</span></li> + <li><a href="#">Your routing lists</a></li> + </ul> + + <div class="container-fluid"> + <div class="row-fluid"> + <div class="span2"> + <div id="navigation"> + [% INCLUDE 'navigation.inc' IsPatronPage=1 %] + </div> + </div> + <div class="span10"> + <div id="user-routing-lists" class="maincontent"> + + + <h3>Routing lists</h3> + + [% IF ( subscriptionLoop ) %] + <p id="routing-list-intro">You are subscribed to the routing lists for folloging serial titles. If you wish to make changes, please contact the library.</p> + <table class="table table-bordered table-striped" id="routingtable"> + <thead> + <tr> + <th>Subscription title</th> + </tr> + </thead> + + <tbody> + [% FOREACH subscription IN subscriptionLoop %] + [% IF ( subscripLoop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %] + <td> + <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% subscription.biblionumber %]"> + [% subscription.title %] + </a> + </td> + </tr> + [% END %] + </tbody> + </table> + [% ELSE %] + <p>You are currently not listed on any routing lists.</p> + [% END %] + </div> + </div> <!-- / .span10 --> + </div> <!-- / .row-fluid --> + </div> <!-- / .container-fluid --> +</div> <!-- / .main --> + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] +[% INCLUDE 'datatables.inc' %] +<script type="text/javascript"> +</script> +[% END %] diff --git a/opac/opac-routing-lists.pl b/opac/opac-routing-lists.pl new file mode 100644 index 0000000..55e3878 --- /dev/null +++ b/opac/opac-routing-lists.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see <http://www.gnu.org/licenses>. + + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Members; +use C4::Auth; +use C4::Output; +use C4::Serials; +use Koha::Patrons; +use Koha::Subscriptions; + +my $query = new CGI; +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-routing-lists.tt", + query => $query, + type => "opac", + authnotrequired => 0, + debug => 1, + } +); + +my $patron = Koha::Patrons->find( $borrowernumber ); +my $category = $patron->category; +my $borrower= $patron->unblessed; +$borrower->{description} = $category->description; +$borrower->{category_type} = $category->category_type; +$template->param( BORROWER_INFO => $borrower ); + + +my $count; +my @borrowerSubscriptions; +($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber ); +my @subscripLoop; + +foreach my $num_res (@borrowerSubscriptions) { + my %getSubscrip; + $getSubscrip{subscriptionid} = $num_res->{'subscriptionid'}; + $getSubscrip{title} = $num_res->{'title'}; + $getSubscrip{borrowernumber} = $num_res->{'borrowernumber'}; + my $subscription = Koha::Subscriptions->find( $num_res->{'subscriptionid'} ); + $getSubscrip{biblionumber} = $subscription->biblionumber(); + push( @subscripLoop, \%getSubscrip ); +} + +$template->param( + countSubscrip => scalar @subscripLoop, + subscriptionLoop => \@subscripLoop, + routinglistview => 1 +); + +output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.1.4