Bug 22330: Transfer limits should be respected for placing holds in staff interface...
[koha.git] / reserve / placerequest.pl
index ee916ea..c614200 100755 (executable)
@@ -21,8 +21,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 
 use CGI qw ( -utf8 );
 use C4::Biblio;
@@ -33,6 +32,9 @@ use C4::Circulation;
 use C4::Members;
 use C4::Auth qw/checkauth/;
 
+use Koha::Items;
+use Koha::Patrons;
+
 my $input = CGI->new();
 
 checkauth($input, 0, { reserveforothers => 'place_holds' }, 'intranet');
@@ -51,7 +53,8 @@ my $checkitem      = $input->param('checkitem');
 my $expirationdate = $input->param('expiration_date');
 my $itemtype       = $input->param('itemtype') || undef;
 
-my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
+my $borrower = Koha::Patrons->find( $borrowernumber );
+$borrower = $borrower->unblessed if $borrower;
 
 my $multi_hold = $input->param('multi_hold');
 my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
@@ -69,18 +72,6 @@ foreach my $bibnum (@biblionumbers) {
 
 my $found;
 
-# if we have an item selectionned, and the pickup branch is the same as the holdingbranch
-# of the document, we force the value $rank and $found .
-if (defined $checkitem && $checkitem ne ''){
-    $holds_to_place_count = 1;
-    $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
-    my $item = $checkitem;
-    $item = GetItem($item);
-    if ( $item->{'holdingbranch'} eq $branch ){
-        $found = 'W' unless C4::Context->preference('ReservesNeedReturns');
-    }
-}
-
 if ( $type eq 'str8' && $borrower ) {
 
     foreach my $biblionumber ( keys %bibinfos ) {
@@ -98,9 +89,9 @@ if ( $type eq 'str8' && $borrower ) {
         }
 
         if ( defined $checkitem && $checkitem ne '' ) {
-            my $item = GetItem($checkitem);
-            if ( $item->{'biblionumber'} ne $biblionumber ) {
-                $biblionumber = $item->{'biblionumber'};
+            my $item = Koha::Items->find($checkitem);
+            if ( $item->biblionumber ne $biblionumber ) {
+                $biblionumber = $item->biblionumber;
             }
         }
 
@@ -128,11 +119,11 @@ if ( $type eq 'str8' && $borrower ) {
         print $input->redirect("request.pl?biblionumber=$biblionumber");
     }
 }
-elsif ( $borrower eq '' ) {
+elsif ( $borrowernumber eq '' ) {
     print $input->header();
     print "Invalid borrower number please try again";
 
     # Not sure that Dump() does HTML escaping. Use firebug or something to trace
     # instead.
-    #  print $input->Dump;
+    #print $input->Dump;
 }