TransformHTMLToXML bug default_ind_to_space
[koha.git] / reserve / request.pl
index eb41244..58b42b3 100755 (executable)
@@ -26,6 +26,7 @@ script to place reserves/requests
 =cut
 
 use strict;
+use warnings;
 use C4::Branch; # GetBranches get_branchinfos_of
 use CGI;
 use List::MoreUtils qw/uniq/;
@@ -39,6 +40,7 @@ use C4::Koha;
 use C4::Circulation;
 use C4::Dates qw/format_date/;
 use C4::Members;
+use C4::Search;                # enabled_staff_search_views
 
 my $dbh = C4::Context->dbh;
 my $sth;
@@ -110,12 +112,15 @@ if ($cardnumber) {
     }
 
     # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
-    my $expiry = $borrowerinfo->{dateexpiry};
-    unless ($expiry and $expiry ne '0000-00-00' and
-            Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry)) {
+    my $expiry_date = $borrowerinfo->{dateexpiry};
+    my $expiry = 0; # flag set if patron account has expired
+    if ($expiry_date and $expiry_date ne '0000-00-00' and
+            Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
                $messages = $expiry = 1;
+    }else{
+        $expiry = 0;
     }
-     
+
 
     # check if the borrower make the reserv in a different branch
     if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) {
@@ -166,7 +171,7 @@ if ($borrowerslist) {
             '%s, %s ... (%s - %s) ... %s',
             $borrower->{surname},    $borrower->{firstname},
             $borrower->{cardnumber}, $borrower->{categorycode},
-            $borrower->{streetaddress},
+            $borrower->{address},
         );
     }
 
@@ -253,10 +258,13 @@ foreach my $biblioitemnumber (@biblioitemnumbers) {
       my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } )
     {
         my $item = $iteminfos_of->{$itemnumber};
-    $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
-    $item->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $item->{itype} }{imageurl};
-        $item->{homebranchname} =
-          $branches->{ $item->{homebranch} }{branchname};
+        unless (C4::Context->preference('item-level_itypes')) {
+            $item->{itype} = $biblioitem->{itemtype};
+        }
+
+        $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
+        $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
+        $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
 
         # if the holdingbranch is different than the homebranch, we show the
         # holdingbranch of the document too
@@ -329,7 +337,7 @@ foreach my $biblioitemnumber (@biblioitemnumbers) {
         if (! C4::Context->preference("canreservefromotherbranches")){
         # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
         my $userenv = C4::Context->userenv; 
-        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
+        if ( ($userenv) && ( $userenv->{flags} %2 != 1 ) ) {
             $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
         } 
         }
@@ -390,6 +398,13 @@ foreach my $res ( sort { $a->{found} cmp $b->{found} } @$reserves ) {
         }
         # set found to 1 if reserve is waiting for patron pickup
         $reserve{'found'} = 1 if $res->{'found'} eq 'W';
+    } elsif ($res->{priority} > 0) {
+        if (defined($res->{itemnumber})) {
+            my $item = GetItem($res->{itemnumber});
+            $reserve{'itemnumber'}  = $res->{'itemnumber'};
+            $reserve{'barcodenumber'}   = $item->{'barcode'};
+            $reserve{'item_level_hold'} = 1;
+        }
     }
     
 #     get borrowers reserve info