From 572fc218870784d68b928ad27ff3baef80d1b57f Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Wed, 17 Nov 2021 14:17:30 +0000
Subject: [PATCH] Bug 29043: Remaining bug is the incorrect title "Place a hold
 on No title"

This version takes account of the batch-mode.

I only just add the line:

$template->param( biblio => $biblio ) if scalar @biblionumbers == 1;

inside the foreach loop. All my other patch-fixes are obsolete.
---
 .../prog/en/modules/reserve/request.tt        | 54 +++----------------
 reserve/request.pl                            | 19 +------
 2 files changed, 7 insertions(+), 66 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
index 59ff7e6e9f..1dd3558459 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
@@ -105,17 +105,6 @@
                 </div>
             [% END %]
 
-            [% IF ( messagetransfert ) %]
-                <div class="dialog message">
-                    <h2>Hold found for ([% nextreservtitle | html %]), please transfer</h2>
-                    <p>Hold placed by : <strong> [% nextreservsurname | html %] [% nextreservfirstname | html %]</strong> at : <strong> [% branchname | html %] </strong>, Please transfer this item.
-                    </p>
-                    <form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
-                        <input type="submit" class="button" />
-                    </form>
-                </div>
-            [% END %]
-
             [% UNLESS ( multi_hold ) %]
                 <h1>Place a hold on [% INCLUDE 'biblio-title.inc' link = 1 %]</h1>
             [% ELSE %]
@@ -325,30 +314,16 @@
                                             [% IF ( biblioloo.checked_previously ) %]
                                                 <span>Patron has previously checked out this title</span><br/>
                                             [% END %]
-                                            [% IF ( biblioloo.alreadyres ) %]
+                                            [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
                                                 <ul>
-                                            [% ELSE %]
-                                                [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
-                                                    <ul>
-                                                [% END %]
                                             [% END %]
 
-                                            [% IF ( biblioloo.alreadyres ) %]
-                                                <li>
-                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
-                                                    <strong>already has a hold</strong> on this item
-                                                </li>
-                                            [% END %]
                                             [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
                                             [% END %]
 
-                                            [% IF ( biblioloo.alreadyres ) %]
+                                            [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
                                                 </ul>
-                                            [% ELSE %]
-                                                [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
-                                                    </ul>
-                                                [% END %]
                                             [% END %]
                                         </td>
                                     </tr>
@@ -367,7 +342,7 @@
                     </div>
                 [% END %]
 
-                [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
+                [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || none_available || alreadypossession || ageRestricted ) %]
                     <div class="dialog alert">
 
                         [% UNLESS ( multi_hold ) %]
@@ -381,8 +356,6 @@
                                     <li><strong>Too many holds for this record: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% max_holds_for_record | html %] hold(s) on this record.</li>
                                 [% ELSIF ( alreadypossession ) %]
                                     <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>is already in possession</strong> of one item.</li>
-                                [% ELSIF ( alreadyreserved ) %]
-                                    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>already has a hold</strong> on this item.</li>
                                 [% ELSIF ( ageRestricted ) %]
                                     <li><strong>Age restricted</strong></li>
                                 [% ELSIF ( none_available ) %]
@@ -539,7 +512,6 @@
                                         <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
                                     [% END %]
                                     <input type="hidden" name="biblioitem" value="[% biblioitemnumber | html %]" />
-                                    <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
                                 </li>
 
                                 [% IF remaining_holds_for_record > 1 %]
@@ -838,30 +810,16 @@
                                             [% IF ( biblioloo.checked_previously ) %]
                                                 <span>Patron has previously checked out this title</span><br/>
                                             [% END %]
-                                            [% IF ( biblioloo.alreadyres ) %]
+                                            [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
                                                 <ul>
-                                            [% ELSE %]
-                                                [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
-                                                    <ul>
-                                                [% END %]
                                             [% END %]
 
-                                            [% IF ( biblioloo.alreadyres ) %]
-                                                <li>
-                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
-                                                    <strong>already has a hold</strong> on this item
-                                                </li>
-                                            [% END %]
                                             [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
                                             [% END %]
 
-                                            [% IF ( biblioloo.alreadyres ) %]
+                                            [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
                                                 </ul>
-                                            [% ELSE %]
-                                                [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
-                                                    </ul>
-                                                [% END %]
                                             [% END %]
                                         </td>
                                         <td>
@@ -905,7 +863,7 @@
 
             [% UNLESS ( patron ) %]
                 [% IF ( reserveloop ) %]
-                    <form id="existing_holds" name="T[% time | html %]" action="modrequest.pl" method="post" style="display:block">
+                    <form id="existing_holds" name="form_existing_holds" action="modrequest.pl" method="post" style="display:block">
                         [% IF ( multi_hold ) %]
                             <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
                         [% END %]
diff --git a/reserve/request.pl b/reserve/request.pl
index 6affcecc3d..76d00f35bf 100755
--- a/reserve/request.pl
+++ b/reserve/request.pl
@@ -328,7 +328,6 @@ foreach my $biblionumber (@biblionumbers) {
     }
 
     my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
-    my $totalcount = $count;
 
     # adding a fixed value for priority options
     my $fixedRank = $count+1;
@@ -354,13 +353,7 @@ foreach my $biblionumber (@biblionumbers) {
         $biblioloopiter{title} = $biblio->title;
         $biblioloopiter{rank} = $fixedRank;
 
-        # get the time for the form name...
-        my $time = time();
-
-        $template->param(
-                         time        => $time,
-                         fixedRank   => $fixedRank,
-                        );
+        $template->param( fixedRank => $fixedRank );
 
     unless( $patron ){
 
@@ -775,13 +768,3 @@ $template->param(
 
 # printout the page
 output_html_with_http_headers $input, $cookie, $template->output;
-
-sub sort_borrowerlist {
-    my $borrowerslist = shift;
-    my $ref           = [];
-    push @{$ref}, sort {
-        uc( $a->{surname} . $a->{firstname} ) cmp
-          uc( $b->{surname} . $b->{firstname} )
-    } @{$borrowerslist};
-    return $ref;
-}
-- 
2.25.1