[Koha-patches] [PATCH] Use biblioitems.itemtype as a default for items.itype

Michael Hafen mdhafen at tech.washk12.org
Fri Sep 12 18:14:41 CEST 2008


This correct the html select default in additem.pl, and enforces use of
biblioitems.itemtype as the default in Items::AddItem.  The code in
Items is to catch items added through MARC record staging.
---
 C4/Items.pm            |    6 ++++++
 cataloguing/additem.pl |   11 +++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/C4/Items.pm b/C4/Items.pm
index dd78f98..a780903 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -224,6 +224,12 @@ sub AddItem {
     _set_derived_columns_for_add($item);
     $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields);
     # FIXME - checks here
+    unless ( $item->{itype} ) {  # default to biblioitem.itemtype if no itype
+        my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
+        $itype_sth->execute( $item->{'biblionumber'} );
+        ( $item->{'itype'} ) = $itype_sth->fetchrow_array;
+    }
+
 	my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} );
     $item->{'itemnumber'} = $itemnumber;
 
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index f8780c2..d99e584 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -348,14 +348,17 @@ foreach my $tag (sort keys %{$tagslib}) {
           $sth->execute;
           push @authorised_values, ""
             unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
-            
-          my $itemtype;
-          
+                      
           while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
               push @authorised_values, $itemtype;
               $authorised_lib{$itemtype} = $description;
           }
-          $value = $itemtype unless ($value);
+
+          my $default_itemtype;
+          my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
+          $itype_sth->execute( $biblionumber );
+          ( $default_itemtype ) = $itype_sth->fetchrow_array;
+          $value = $default_itemtype unless ($value);
   
           #---- class_sources
       }
-- 
1.5.4.3




More information about the Koha-patches mailing list