bug 4862 - Change label of Browse by subject or author to Authority search
[koha.git] / reserve / request.pl
index ff01850..5bcaca2 100755 (executable)
@@ -65,23 +65,11 @@ my $showallitems = $input->param('showallitems');
 my $branches = GetBranches();
 my $itemtypes = GetItemTypes();
 
-my $default = C4::Context->userenv->{branch};
-my @values;
-my %label_of;
-
-foreach my $branchcode (sort keys %{$branches} ) {
-    push @values, $branchcode;
-    $label_of{$branchcode} = $branches->{$branchcode}->{branchname};
+my $userbranch = '';
+if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+    $userbranch = C4::Context->userenv->{'branch'};
 }
-my $CGIbranch = CGI::scrolling_list(
-                                    -name     => 'pickup',
-                                    -id          => 'pickup',
-                                    -values   => \@values,
-                                    -default  => $default,
-                                    -labels   => \%label_of,
-                                    -size     => 1,
-                                    -multiple => 0,
-                                   );
+
 
 # Select borrowers infos
 my $findborrower = $input->param('findborrower');
@@ -113,7 +101,8 @@ if ( $action eq 'move' ) {
 } elsif ( $action eq 'toggleSuspend' ) {
   my $borrowernumber = $input->param('borrowernumber');
   my $biblionumber   = $input->param('biblionumber');
-  ToggleSuspend( $borrowernumber, $biblionumber );
+  my $suspend_until  = $input->param('suspend_until');
+  ToggleSuspend( $borrowernumber, $biblionumber, $suspend_until );
 }
 
 if ($findborrower) {
@@ -243,9 +232,16 @@ foreach my $biblionumber (@biblionumbers) {
     my $dat          = GetBiblioData($biblionumber);
 
     unless ( CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber) ) {
-               $warnings = 1;
+               $warnings = 1;
         $maxreserves = 1;
     }
+
+    my $alreadypossession;
+    if (not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowerinfo->{borrowernumber},$biblionumber)) {
+        $warnings = 1;
+        $alreadypossession = 1;
+    }
+
     # get existing reserves .....
     my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1);
     my $totalcount = $count;
@@ -267,7 +263,8 @@ foreach my $biblionumber (@biblionumbers) {
     $template->param( alreadyreserved => $alreadyreserved,
                       messages => $messages,
                       warnings => $warnings,
-                                         maxreserves=>$maxreserves
+                 maxreserves=>$maxreserves,
+                     alreadypossession => $alreadypossession,
                                          );
 
 
@@ -573,7 +570,7 @@ foreach my $biblionumber (@biblionumbers) {
         $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
         $reserve{'optionloop'} = \@optionloop;
         $reserve{'suspend'} = $res->{'suspend'};
-        $reserve{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref");
+        $reserve{'suspend_until'} = $res->{'suspend_until'};
         push( @reserveloop, \%reserve );
     }
 
@@ -581,8 +578,7 @@ foreach my $biblionumber (@biblionumbers) {
     my $time = time();
 
     $template->param(
-                     CGIbranch   => $CGIbranch,
-
+                     branchloop  => GetBranchesLoop($userbranch),
                      time        => $time,
                      fixedRank   => $fixedRank,
                     );
@@ -622,7 +618,6 @@ foreach my $biblionumber (@biblionumbers) {
 
 $template->param( biblioloop => \@biblioloop );
 $template->param( biblionumbers => $biblionumbers );
-$template->param( DHTMLcalendar_dateformat  => C4::Dates->DHTMLcalendar() );
 
 if ($multihold) {
     $template->param( multi_hold => 1 );
@@ -632,7 +627,10 @@ if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
     $template->param( reserve_in_future => 1 );
 }
 
-$template->param( AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds') );
+$template->param(
+    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
+    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
+);
 
 # printout the page
 output_html_with_http_headers $input, $cookie, $template->output;