added autocomplete="off"
[koha.git] / C4 / Items.pm
index 0b91b65..04cb417 100644 (file)
@@ -458,8 +458,7 @@ sub ModItemFromMarc {
 
 =head2 ModItem
 
-  ModItem({ column => $newvalue }, $biblionumber, 
-                  $itemnumber[, $original_item_marc]);
+  ModItem({ column => $newvalue }, $biblionumber, $itemnumber);
 
 Change one or more columns in an item record and update
 the MARC representation of the item.
@@ -1214,6 +1213,7 @@ sub GetItemsInfo {
             $data->{cardnumber}     = $idata->{cardnumber};
             $data->{surname}     = $idata->{surname};
             $data->{firstname}     = $idata->{firstname};
+            $data->{lastreneweddate} = $idata->{lastreneweddate};
             $datedue                = $idata->{'date_due'};
         if (C4::Context->preference("IndependantBranches")){
         my $userenv = C4::Context->userenv;
@@ -1228,7 +1228,7 @@ sub GetItemsInfo {
                        $serial = 1;
         }
                if ( $datedue eq '' ) {
-            my ( $restype, $reserves ) =
+            my ( $restype, $reserves, undef ) =
               C4::Reserves::CheckReserves( $data->{'itemnumber'} );
 # Previous conditional check with if ($restype) is not needed because a true
 # result for one item will result in subsequent items defaulting to this true
@@ -1629,41 +1629,45 @@ sub GetHiddenItemnumbers {
     my @resultitems;
 
     my $yaml = C4::Context->preference('OpacHiddenItems');
+    $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
     my $hidingrules;
     eval {
-       $hidingrules = YAML::Load($yaml);
+        $hidingrules = YAML::Load($yaml);
     };
     if ($@) {
-       warn "Unable to parse OpacHiddenItems syspref : $@";
-       return ();
-    } else {
+        warn "Unable to parse OpacHiddenItems syspref : $@";
+        return ();
+    }
     my $dbh = C4::Context->dbh;
 
-       # For each item
-       foreach my $item (@items) {
+    # For each item
+    foreach my $item (@items) {
 
-           # We check each rule
-           foreach my $field (keys %$hidingrules) {
-               my $query = "SELECT $field from items where itemnumber = ?";
-               my $sth = $dbh->prepare($query);        
-               $sth->execute($item->{'itemnumber'});
-               my ($result) = $sth->fetchrow;
+        # We check each rule
+        foreach my $field (keys %$hidingrules) {
+            my $val;
+            if (exists $item->{$field}) {
+                $val = $item->{$field};
+            }
+            else {
+                my $query = "SELECT $field from items where itemnumber = ?";
+                $val = $dbh->selectrow_array($query, undef, $item->{'itemnumber'});
+            }
+            $val = '' unless defined $val;
 
-               # If the results matches the values in the yaml file
-               if (any { $result eq $_ } @{$hidingrules->{$field}}) {
+            # If the results matches the values in the yaml file
+            if (any { $val eq $_ } @{$hidingrules->{$field}}) {
 
-                   # We add the itemnumber to the list
-                   push @resultitems, $item->{'itemnumber'};       
+                # We add the itemnumber to the list
+                push @resultitems, $item->{'itemnumber'};
 
-                   # If at least one rule matched for an item, no need to test the others
-                   last;
-               }
-           }
-       }
-       return @resultitems;
+                # If at least one rule matched for an item, no need to test the others
+                last;
+            }
+        }
     }
-
- }
+    return @resultitems;
+}
 
 =head3 get_item_authorised_values
 
@@ -2210,7 +2214,7 @@ sub DelItemCheck {
     if ($onloan){
         $error = "book_on_loan" 
     }
-    elsif ( C4::Context->userenv->{flags} & 1 and
+    elsif ( !(C4::Context->userenv->{flags} & 1) and
             C4::Context->preference("IndependantBranches") and
            (C4::Context->userenv->{branch} ne
              $item->{C4::Context->preference("HomeOrHoldingBranch")||'homebranch'}) )