X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FItems.pm;h=52423a27d5153ec51ceb1ae213b7d3fa2813e73c;hb=bd1d643fadb1f867881ca455bb1709cfae54cd61;hp=676c91b37ef3b2c6139d1bc2070c1b4b344c83bb;hpb=0ef6b0d5c618c2bd4d0ec942e870a6f989632ca0;p=koha_gimpoz diff --git a/C4/Items.pm b/C4/Items.pm index 676c91b37e..52423a27d5 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -30,6 +30,7 @@ use MARC::Record; use C4::ClassSource; use C4::Log; use List::MoreUtils qw/any/; +use C4::Search; use Data::Dumper; # used as part of logging item record changes, not just for # debugging; so please don't remove this @@ -66,6 +67,7 @@ BEGIN { GetItemsInfo GetItemsLocationInfo GetHostItemsInfo + GetItemnumbersForBiblio get_itemnumbers_of get_hostitemnumbers_of GetItemnumberFromBarcode @@ -307,7 +309,7 @@ Sequence number of original item tag in the MARC record. Item barcode, provide to assist in the construction of useful error messages. -=item error_condition +=item error_code Code representing the error condition. Can be 'duplicate_barcode', 'invalid_homebranch', or 'invalid_holdingbranch'. @@ -327,6 +329,9 @@ sub AddItemBatchFromMarc { my @errors = (); my $dbh = C4::Context->dbh; + # We modify the record, so lets work on a clone so we don't change the + # original. + $record = $record->clone(); # loop through the item tags and start creating items my @bad_item_fields = (); my ($itemtag, $itemsubfield) = &GetMarcFromKohaField("items.itemnumber",''); @@ -1185,7 +1190,9 @@ sub GetItemsInfo { items.notforloan as itemnotforloan, itemtypes.description, itemtypes.notforloan as notforloan_per_itemtype, - holding.branchurl + holding.branchurl, + holding.branchname, + holding.opac_info as branch_opac_info FROM items LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode LEFT JOIN branches AS home ON items.homebranch=home.branchcode @@ -1490,6 +1497,26 @@ sub GetLastAcquisitions { return @results; } +=head2 GetItemnumbersForBiblio + + my $itemnumbers = GetItemnumbersForBiblio($biblionumber); + +Given a single biblionumber, return an arrayref of all the corresponding itemnumbers + +=cut + +sub GetItemnumbersForBiblio { + my $biblionumber = shift; + my @items; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber = ?"); + $sth->execute($biblionumber); + while (my $result = $sth->fetchrow_hashref) { + push @items, $result->{'itemnumber'}; + } + return \@items; +} + =head2 get_itemnumbers_of my @itemnumbers_of = get_itemnumbers_of(@biblionumbers); @@ -2573,6 +2600,7 @@ sub PrepareItemrecordDisplay { $subfield_data{subfield} = $subfield; $subfield_data{countsubfield} = $cntsubf++; $subfield_data{kohafield} = $tagslib->{$tag}->{$subfield}->{'kohafield'}; + $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".int(rand(1000000)); # $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; $subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib}; @@ -2711,8 +2739,6 @@ sub PrepareItemrecordDisplay { my $extended_param = plugin_parameters( $dbh, $temp, $tagslib, $subfield_data{id}, undef ); my ( $function_name, $javascript ) = plugin_javascript( $dbh, $temp, $tagslib, $subfield_data{id}, undef ); $subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms? - my $index_subfield = int(rand(1000000)); - $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_subfield; $subfield_data{marc_value} = qq[