From 8946f5744624a7788226aeb4c241d0e38989522a Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 13 Nov 2017 02:22:09 +0000 Subject: [PATCH] Bug 19532: Cancel recall and see recalls in OPAC This patch adds ability for user to cancel a recall They can also see their recalls in the user summary Signed-off-by: Nick Clemens --- Koha/Recall.pm | 43 ++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 97 +++++++++++++++++++++- opac/opac-recall.pl | 4 + opac/opac-user.pl | 8 ++ 4 files changed, 150 insertions(+), 2 deletions(-) diff --git a/Koha/Recall.pm b/Koha/Recall.pm index 596aafa..64779c8 100644 --- a/Koha/Recall.pm +++ b/Koha/Recall.pm @@ -41,6 +41,49 @@ sub _type { return 'Recall'; } +=head3 biblio + +Returns the related Koha::Biblio object for this hold + +=cut + +sub biblio { + my ($self) = @_; + + $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() ); + + return $self->{_biblio}; +} + +=head3 item + +Returns the related Koha::Item object for this Hold + +=cut + +sub item { + + my ($self) = @_; + + $self->{_item} ||= Koha::Items->find( $self->itemnumber() ); + + return $self->{_item}; +} + +=head3 branch + +Returns the related Koha::Library object for this Hold + +=cut + +sub branch { + my ($self) = @_; + + $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() ); + + return $self->{_branch}; +} + =head3 is_waiting Returns true if recall is awaiting pickup 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 629ead9..5a81d4a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -159,7 +159,8 @@ [% END %] [% IF ( RESERVES.count ) %]
  • Holds ([% RESERVES.count | html %])
  • [% END %] - [% IF Koha.Preference('ArticleRequests') && logged_in_user.article_requests_current %]
  • Article requests ([% logged_in_user.article_requests_current.count | html %])
  • [% END %] + [% IF ( RECALLS.count ) %]
  • Recalls ([% RECALLS.count | html %])
  • [% END %] + [% IF Koha.Preference('ArticleRequests') && borrower.article_requests_current %]
  • Article requests ([% borrower.article_requests_current.count | html %])
  • [% END %] [% IF ( OverDriveCirculation ) %]
  • OverDrive Account
  • [% END %] @@ -244,7 +245,8 @@ [% ISSUE.title | html %] [% FOREACH subtitl IN ISSUE.subtitle %] [% subtitl.subfield | html %][% END %] - [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron | html %][% END %] + [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron %][% END %] + [% IF ( ISSUE.recalled ) %]This item has been recalled. Please return by the new due date.[% END %] [% ISSUE.author | html %] @@ -786,6 +788,92 @@ [% END # / #RESERVES.count %] + [% IF RECALLS.count %] +
    + + + + + + + + + + + + + + [% FOREACH RECALL IN RECALLS %] + + + + + + + [% END %] + +
    Recalls ([% RECALLS.count %])
    TitlePlaced onExpires onPick up locationStatusCancel
    + + [% RECALL.biblio.title %] + [% FOREACH s IN RECALL.biblio.subtitles %] + [% s %] + [% END %] + [% RECALL.item.enumchron %] + + [% RECALL.biblio.author %] + + + Recall date: + [% RECALL.recalldate | $KohaDates %] + + + [% IF ( RECALL.is_waiting ) %] + [% IF ( RECALL.expirationdate ) %] + + Expiration: + [% RECALL.expirationdate | $KohaDates %] + + [% ELSE %] + + Expiration: + Never expires + + [% END %] + [% ELSIF ( RECALL.has_expired && RECALL.expirationdate ) %] + + Expiration: + [% RECALL.expirationdate | $KohaDates %] + + [% ELSE %] + - + [% END %] + + Pick up location: + [% RECALL.branch.branchname %] + + Status: + [% IF ( RECALL.is_requested ) %] + Requested + [% ELSIF ( RECALL.is_waiting ) %] + Ready for pickup + [% ELSIF ( RECALL.has_expired ) %] + Expired + [% END %] + + [% IF ( !RECALL.cancellationdate ) %] +
    + + + + +
    + [% ELSE %] + Cancelled + [% END %] +
    + + [% END # / # RECALLS.count %] + [% IF Koha.Preference('ArticleRequests') %]
    [% IF logged_in_user.article_requests_current.count %] @@ -917,6 +1005,7 @@ var MSG_CONFIRM_DELETE_HOLD = _("Are you sure you want to cancel this hold?"); var MSG_CONFIRM_SUSPEND_HOLDS = _("Are you sure you want to suspend all holds?"); var MSG_CONFIRM_RESUME_HOLDS = _("Are you sure you want to resume all suspended holds?"); + var MSG_CONFIRM_CANCEL_RECALL = _("Are you sure you want to undo this recall?"); $(document).ready(function(){ $('#opac-user-views').tabs(); @@ -925,6 +1014,10 @@ $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs"); $(".suspend-until").prop("readonly",1); + $("#cancel_recall").click(function(e){ + return confirmDelete(MSG_CONFIRM_CANCEL_RECALL); + }); + var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table"); dTables.each(function(){ var thIndex = $(this).find("th.psort").index(); diff --git a/opac/opac-recall.pl b/opac/opac-recall.pl index 72602a5..09e15d6 100755 --- a/opac/opac-recall.pl +++ b/opac/opac-recall.pl @@ -85,6 +85,10 @@ if ($op eq 'request'){ $error = 'failed'; } } +} elsif ($op eq 'cancel'){ + my $recall_id = $query->param('recall_id'); + Koha::Recalls->find($recall_id)->delete; + print $query->redirect('/cgi-bin/koha/opac-user.pl'); } $template->param( diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 500042d..c27c150 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -42,6 +42,7 @@ use Koha::Patron::Attribute::Types; use Koha::Patron::Messages; use Koha::Patron::Discharge; use Koha::Patrons; +use Koha::Recalls; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; @@ -247,6 +248,11 @@ if ( $pending_checkouts->count ) { # Useless test } } + my $recall = Koha::Recalls->find($issue->{itemnumber}); + if (defined $recall){ + $issue->{recalled} = 1; + } + if ( $c->is_overdue ) { push @overdues, $issue; $overdues_count++; @@ -299,9 +305,11 @@ $template->param( show_barcode => 1 ) if $show_barcode; # now the reserved items.... my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } ); +my $recalls = Koha::Recalls->search( { borrowernumber => $borrowernumber } ); $template->param( RESERVES => $reserves, + RECALLS => $recalls, showpriority => $show_priority, ); -- 2.1.4