From b0d66aec69fe2475183d8041b93ab1d5d683d9d9 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Wed, 6 May 2020 19:38:19 -0300 Subject: [PATCH] Bug 20936: Add patron's hold history menu in OPAC This patch adds patron's hold history in OPAC. To test: 1. apply this patch 2. Find a patron, place several holds and cancel or fulfill them 3. Go to patron's opac CHECK => There is no 'your holds history' option in menu 4. In admin preferences enable OPACHoldsHistory 5. Go back to patron's opac SUCCESS => There is a 'your holds history' menu option => Holds history displays all holds 6. Change order, and list limit SUCCESS => All controls work as expected 7. Sign off. Signed-off-by: Todd --- .../opac-tmpl/bootstrap/en/includes/usermenu.inc | 25 ++- .../bootstrap/en/modules/opac-holdshistory.tt | 188 +++++++++++++++++++++ opac/opac-holdshistory.pl | 83 +++++++++ 3 files changed, 289 insertions(+), 7 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt create mode 100755 opac/opac-holdshistory.pl diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc index f1cdfa5ab2..882b69d94b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -58,14 +58,16 @@ your search history [% END %] - [% IF ( opacreadinghistory ) %] - [% IF ( readingrecview ) %] -
  • - [% ELSE %] -
  • + [% IF opacreadinghistory || Koha.Preference('OPACHoldsHistory') == 1 %] + [% IF opacreadinghistory %] + [% IF ( readingrecview ) %] +
  • + [% ELSE %] +
  • + [% END %] + your reading history
  • [% END %] - your reading history - [% IF ( OPACPrivacy ) %] + [% IF ( OPACPrivacy || Koha.Preference('OPACHoldsPrivacy') == 1 ) %] [% IF ( privacyview ) %]
  • [% ELSE %] @@ -75,6 +77,15 @@ [% END %] [% END # / opacreadinghistory %] + [% IF Koha.Preference('OPACHoldsHistory') == 1 %] + [% IF ( holdshistoryview ) %] +
  • + [% ELSE %] +
  • + [% END %] + your holds history
  • + [% END %] + [% IF Koha.Preference( 'suggestion' ) == 1 %] [% IF ( suggestionsview ) %]
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt new file mode 100644 index 0000000000..a1e2481c43 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt @@ -0,0 +1,188 @@ +[% USE raw %] +[% USE Koha %] +[% USE KohaDates %] +[% USE ColumnsSettings %] +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › Your holds history +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %] + +[% END %] + +[% INCLUDE 'bodytag.inc' bodyid='opac-holdshistory' %] +[% INCLUDE 'masthead.inc' %] + +
    + + +
    +
    +
    + +
    +
    +
    +

    Holds history

    + + [% IF !holds %] + You have never placed a hold from this library. + [% ELSE %] +
    +
    +
    +
    +
    + [% IF ( unlimit ) %][% END %] + + +
    +
    + + [% UNLESS unlimit %] +

    + Showing 50 items. Show all items +

    + [% ELSE %] +

    + Showing all items. Show 50 items +

    + [% END %] +
    + + + + + + + + + + + + [% IF show_itemtype_column %] + + [% END %] + + + + + [% FOREACH hold IN holds %] + + + + + + + + + + [% IF show_itemtype_column %] + + [% END %] + + + [% END %] + +
    TitleAuthorBarcodeLibraryHold dateExpiration dateWaiting dateCancellation dateRequested item typeStatus
    [% INCLUDE 'biblio-title.inc' biblio=hold.biblio %][% hold.biblio.author | html %][% hold.item.barcode | html %][% Branches.GetName( hold.branchcode ) | html %][% hold.reservedate | $KohaDates %] + [% IF hold.expirationdate %] + [% hold.expirationdate | $KohaDates %] + [% ELSE %] + + [% END %] + + [% IF hold.waitingdate %] + [% hold.waitingdate | $KohaDates %] + [% ELSE %] + + [% END %] + + [% IF hold.cancellationdate %] + [% hold.cancellationdate | $KohaDates %] + [% ELSE %] + + [% END %] + + [% IF hold.itemtype %] + [% ItemTypes.GetDescription( hold.itemtype ) | html %] + [% ELSE %] + Any item type + [% END %] + + [% IF hold.found == 'F' %] + Fulfilled + [% ELSIF hold.cancellationdate %] + Cancelled + [% ELSIF hold.found == 'W' %] + Waiting + [% ELSIF hold.found == 'T' %] + In transit + [% ELSE %] + Pending + [% END %] +
    +
    +
    + [% END # / IF old_holds_count %] +
    +
    +
    +
    +
    + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] +[% INCLUDE 'datatables.inc' %] + +[% END %] diff --git a/opac/opac-holdshistory.pl b/opac/opac-holdshistory.pl new file mode 100755 index 0000000000..e4efdaf7a5 --- /dev/null +++ b/opac/opac-holdshistory.pl @@ -0,0 +1,83 @@ +#!/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 . + + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Auth; +use C4::Output; + +use Koha::Patrons; + +my $query = new CGI; +my @all_holds; + +# if opacreadinghistory is disabled, leave immediately +unless ( C4::Context->preference('OPACHoldsHistory') ) { + print $query->redirect("/cgi-bin/koha/errors/404.pl"); + exit; +} + +my ( $template, $patron_id, $cookie ) = get_template_and_user( + { + template_name => "opac-holdshistory.tt", + query => $query, + type => "opac" + } +); + +my $patron = Koha::Patrons->find( $patron_id ); + +my $holds = $patron->holds; +my $old_holds = $patron->old_holds; + +while (my $hold = $holds->next) { + push @all_holds, $hold; +} + +while (my $hold = $old_holds->next) { + push @all_holds, $hold; +} + +my $sort = $query->param('sort'); + +$sort = 'reservedate' unless $sort; + +if($sort eq 'reservedate') { + @all_holds = sort {$b->$sort cmp $a->$sort} @all_holds; +} else { + my ($obj, $col) = split /\./, $sort; + @all_holds = sort {$a->$obj->$col cmp $b->$obj->$col} @all_holds; +} + +my $unlimit = $query->param('unlimit'); + +unless($unlimit) { + @all_holds = splice(@all_holds, 0, 50); +} + +$template->param( + holdshistoryview => 1, + patron => $patron, + holds => \@all_holds, + unlimit => $unlimit, + sort => $sort +); + +output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.11.0