Bug 31307: Remove 'already_reserved' flag from opac-reserve.pl
[koha-ffzg.git] / opac / opac-reserve.pl
index e62a3ba..a4cacfe 100755 (executable)
@@ -25,7 +25,7 @@ use C4::Auth qw( get_template_and_user );
 use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
 use C4::Circulation qw( GetBranchItemRule GetTransfers );
 use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
-use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
+use C4::Biblio qw( GetBiblioData GetFrameworkCode );
 use C4::Items qw( GetHostItemsInfo GetItemsInfo );
 use C4::Output qw( output_html_with_http_headers );
 use C4::Context;
@@ -150,7 +150,10 @@ foreach my $biblioNumber (@biblionumbers) {
 
     my @itemInfos = GetItemsInfo($biblioNumber);
 
-    my $marcrecord= GetMarcBiblio({ biblionumber => $biblioNumber });
+    my $biblio = Koha::Biblios->find( $biblioNumber );
+    next unless $biblio;
+
+    my $marcrecord = $biblio->metadata->record;
 
     # flag indicating existence of at least one item linked via a host record
     # adding items linked via host biblios
@@ -165,9 +168,6 @@ foreach my $biblioNumber (@biblionumbers) {
     }
 
     # Compute the priority rank.
-    my $biblio = Koha::Biblios->find( $biblioNumber );
-    next unless $biblio;
-
     $biblioData->{object} = $biblio;
     my $holds = $biblio->holds;
     my $rank = $holds->count;
@@ -506,7 +506,7 @@ foreach my $biblioNum (@biblionumbers) {
         # change the background color.
         my $issue = Koha::Checkouts->find( { itemnumber => $itemNum } );
         if ( $issue ) {
-            $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issue->date_due, 'sql'), as_due_date => 1 });
+            $itemLoopIter->{dateDue} = $issue->date_due;
             $itemLoopIter->{onloan} = 'onloan';
         }
 
@@ -515,7 +515,7 @@ foreach my $biblioNum (@biblionumbers) {
 
         if ( my $first_hold = $holds->next ) {
             $itemLoopIter->{backgroundcolor} = 'reserved';
-            $itemLoopIter->{reservedate}     = output_pref({ dt => dt_from_string($first_hold->reservedate), dateonly => 1 }); # FIXME Should be formatted in the template
+            $itemLoopIter->{reservedate}     = $first_hold->reservedate;
             $itemLoopIter->{ExpectedAtLibrary}         = $first_hold->branchcode;
             $itemLoopIter->{waitingdate} = $first_hold->waitingdate;
         }
@@ -563,10 +563,9 @@ foreach my $biblioNum (@biblionumbers) {
         my $patron_unblessed = $patron->unblessed;
         my $branch = GetReservesControlBranch( $itemInfo, $patron_unblessed );
 
-        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
         # items_any_available defined outside of the current loop,
         # so we avoiding loop inside IsAvailableForItemLevelRequest:
-        $policy_holdallowed &&=
+        my $policy_holdallowed =
             CanItemBeReserved( $patron, $item )->{status} eq 'OK' &&
             IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available);