Bug 17600: Standardize our EXPORT_OK
[srvgit] / reserve / placerequest.pl
index 0b4a12c..5ee8dce 100755 (executable)
 use Modern::Perl;
 
 use CGI qw ( -utf8 );
-use C4::Biblio;
-use C4::Items;
-use C4::Output;
-use C4::Reserves;
-use C4::Circulation;
-use C4::Members;
-use C4::Auth qw/checkauth/;
+use C4::Reserves qw( CanItemBeReserved AddReserve CanBookBeReserved );
+use C4::Auth qw( checkauth );
 
 use Koha::Items;
 use Koha::Patrons;
@@ -52,6 +47,7 @@ my $title          = $input->param('title');
 my $checkitem      = $input->param('checkitem');
 my $expirationdate = $input->param('expiration_date');
 my $itemtype       = $input->param('itemtype') || undef;
+my $non_priority   = $input->param('non_priority');
 
 my $borrower = Koha::Patrons->find( $borrowernumber );
 $borrower = $borrower->unblessed if $borrower;
@@ -66,8 +62,9 @@ my %bibinfos = ();
 my @biblionumbers = split '/', $biblionumbers;
 foreach my $bibnum (@biblionumbers) {
     my %bibinfo = ();
-    $bibinfo{title} = $input->param("title_$bibnum");
-    $bibinfo{rank} = $input->param("rank_$bibnum");
+    $bibinfo{title}  = $input->param("title_$bibnum");
+    $bibinfo{rank}   = $input->param("rank_$bibnum");
+    $bibinfo{pickup} = $input->param("pickup_$bibnum");
     $bibinfos{$bibnum} = \%bibinfo;
 }
 
@@ -92,18 +89,20 @@ if ( $type eq 'str8' && $borrower ) {
         my $can_override = C4::Context->preference('AllowHoldPolicyOverride');
         if ( defined $checkitem && $checkitem ne '' ) {
 
+            my $item_pickup_location = $input->param("item_pickup_$checkitem");
+
             my $item = Koha::Items->find($checkitem);
 
             if ( $item->biblionumber ne $biblionumber ) {
                 $biblionumber = $item->biblionumber;
             }
 
-            my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $branch)->{status};
+            my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $item_pickup_location)->{status};
 
             if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) {
                 AddReserve(
                     {
-                        branchcode       => $branch,
+                        branchcode       => $item_pickup_location,
                         borrowernumber   => $borrower->{'borrowernumber'},
                         biblionumber     => $biblionumber,
                         priority         => $rank[0],
@@ -114,6 +113,7 @@ if ( $type eq 'str8' && $borrower ) {
                         itemnumber       => $checkitem,
                         found            => $found,
                         itemtype         => $itemtype,
+                        non_priority     => $non_priority,
                     }
                 );
 
@@ -124,7 +124,7 @@ if ( $type eq 'str8' && $borrower ) {
             if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) {
                 AddReserve(
                     {
-                        branchcode       => $branch,
+                        branchcode       => $bibinfo->{pickup},
                         borrowernumber   => $borrower->{'borrowernumber'},
                         biblionumber     => $biblionumber,
                         priority         => $bibinfo->{rank},
@@ -135,6 +135,7 @@ if ( $type eq 'str8' && $borrower ) {
                         itemnumber       => $checkitem,
                         found            => $found,
                         itemtype         => $itemtype,
+                        non_priority     => $non_priority,
                     }
                 );
             }
@@ -155,6 +156,7 @@ if ( $type eq 'str8' && $borrower ) {
                             itemnumber       => $checkitem,
                             found            => $found,
                             itemtype         => $itemtype,
+                            non_priority     => $non_priority,
                         }
                     );
                 }