Bug 25261: (QA follow-up) Catch check in SIP Checkout
[koha-ffzg.git] / circ / pendingreserves.pl
index 22c93f7..dd6ae76 100755 (executable)
@@ -46,7 +46,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         template_name   => "circ/pendingreserves.tt",
         query           => $input,
         type            => "intranet",
-        authnotrequired => 0,
         flagsrequired   => { circulate => "circulate_remaining_permissions" },
         debug           => 1,
     }
@@ -56,7 +55,8 @@ my @messages;
 if ( $op eq 'cancel_reserve' and $reserve_id ) {
     my $hold = Koha::Holds->find( $reserve_id );
     if ( $hold ) {
-        $hold->cancel;
+        my $cancellation_reason = $input->param('cancellation-reason');
+        $hold->cancel({ cancellation_reason => $cancellation_reason });
         push @messages, { type => 'message', code => 'hold_cancelled' };
     }
 } elsif ( $op =~ m|^mark_as_lost| ) {
@@ -200,7 +200,11 @@ my $strsth =
                     ORDER BY items.itemnumber SEPARATOR '|') l_enumchron,
             GROUP_CONCAT(DISTINCT items.copynumber
                     ORDER BY items.itemnumber SEPARATOR '|') l_copynumber,
+            GROUP_CONCAT(DISTINCT items.barcode
+                    ORDER BY items.itemnumber SEPARATOR '|') l_barcode,
             biblio.title,
+            biblio.copyrightdate,
+            biblioitems.publicationyear,
             biblio.subtitle,
             biblio.medium,
             biblio.part_number,
@@ -224,7 +228,7 @@ my $strsth =
     $sqldatewhere
     AND (reserves.itemnumber IS NULL OR reserves.itemnumber = items.itemnumber)
     AND items.itemnumber NOT IN (SELECT itemnumber FROM branchtransfers where datearrived IS NULL)
-    AND items.itemnumber NOT IN (select itemnumber FROM reserves where found IS NOT NULL)
+    AND items.itemnumber NOT IN (SELECT itemnumber FROM reserves WHERE found IS NOT NULL AND itemnumber IS NOT NULL)
     AND issues.itemnumber IS NULL
     AND reserves.priority <> 0 
     AND reserves.suspend = 0
@@ -233,7 +237,7 @@ my $strsth =
     ";
     # GROUP BY reserves.biblionumber allows only items that are not checked out, else multiples occur when 
     #    multiple patrons have a hold on an item
-
+#FIXME "found IS NOT NULL AND itemnumber IS NOT NULL" is just a workaround: see BZ 25726
 
 if (C4::Context->preference('IndependentBranches')){
     $strsth .= " AND items.holdingbranch=? ";
@@ -264,6 +268,7 @@ while ( my $data = $sth->fetchrow_hashref ) {
             itemcallnumber   => [split('\|', $data->{l_itemcallnumber})],
             enumchron        => [split('\|', $data->{l_enumchron})],
             copyno           => [split('\|', $data->{l_copynumber})],
+            barcode          => [split('\|', $data->{l_barcode})],
             count            => $data->{icount},
             rcount           => $data->{rcount},
             pullcount        => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
@@ -273,6 +278,7 @@ while ( my $data = $sth->fetchrow_hashref ) {
             holdingbranch    => $data->{holdingbranch},
             homebranch       => $data->{homebranch},
             itemnumber       => $data->{itemnumber},
+            publicationyear  => C4::Context->preference('marcflavour') eq "MARC21" ? $data->{copyrightdate} : $data->{publicationyear},
         }
     );
 }