From 6d54541839ab83c1569e61bb7df2facde25401f3 Mon Sep 17 00:00:00 2001
From: Aleisha Amohia <aleishaamohia@hotmail.com>
Date: Mon, 20 Nov 2017 00:32:14 +0000
Subject: [PATCH] Bug 19532: Only recall items checked out by other users

... shouldn't be able to recall items that are currently checked out by
yourself.
---
 koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt | 4 ++++
 koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc       | 2 +-
 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt           | 4 ++--
 opac/opac-detail.pl                                             | 4 ++++
 opac/opac-user.pl                                               | 2 +-
 5 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt
index effb431..ddd0bd2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/recalls_waiting.tt
@@ -146,6 +146,10 @@
 
                 </div>
 
+                [% ELSE %]
+
+                    <div class="dialog message">No recalls have been made.</div>
+
                 [% END %]
 
             </div>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
index 3c8400c..223359f 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
@@ -38,7 +38,7 @@
             <span class="item-status checkedout">Checked out</span>
         [% END %]
     [% END %]
-    [% IF loggedinusername %]<a href="/cgi-bin/koha/opac-recall.pl?itemnumber=[% item.itemnumber %]" class="btn btn-default btn-xs">Recall</a>[% END %]
+    [% IF item.avail_for_recall %]<a href="/cgi-bin/koha/opac-recall.pl?itemnumber=[% item.itemnumber %]" class="btn btn-default btn-xs">Recall</a>[% END %]
 [% END %]
 
 [% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]
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 41244c3..e2e1ed5 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
@@ -240,11 +240,11 @@ Using this account is not recommended because some parts of Koha will not functi
                                                 <td class="title">
                                                     <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ISSUE.biblionumber %]">[% ISSUE.title |html %] [% FOREACH subtitl IN ISSUE.subtitle %] [% subtitl.subfield %][% END %]</a>
                                                     [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron %][% END %]
-                                                    [% IF ( ISSUE.recalled ) %]This item has been recalled. Please return by the new due date.[% END %]
+                                                    [% IF ( ISSUE.recalled ) %]<br><i>This item has been recalled. Please return by the new due date.</i>[% END %]
                                                 </td>
 
                                                 <td class="author">[% ISSUE.author %]</td>
-                                                [% IF ( ISSUE.overdue ) %]
+                                                [% IF ( ISSUE.overdue || ISSUE.recalled ) %]
                                                     <td class="date_due overdue">
                                                         <span title="[% ISSUE.date_due %]">
                                                             <span class="tdlabel">Date due:</span>
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 819e426..1378bde 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -705,6 +705,10 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
           if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
     }
 
+    if ( $itm->{datedue} && $borrowernumber && $itm->{borrowernumber} != $borrowernumber ) {
+        $itm->{avail_for_recall} = 1;
+    }
+
     my $itembranch = $itm->{$separatebranch};
     if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
         if ($itembranch and $itembranch eq $currentbranch) {
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index e3274c3..3af026c 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -237,7 +237,7 @@ if ($issues){
             }
         }
 
-        my $recall = Koha::Recalls->find($issue->{itemnumber});
+        my $recall = Koha::Recalls->find({ itemnumber => $issue->{itemnumber} });
         if (defined $recall){
             $issue->{recalled} = 1;
         }
-- 
2.1.4