X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FItems.pm;h=8f3ef3346900fe53aa77e05c7ed6b51f7c9f57b5;hb=529ed6faa43b6c2543695ec594fe891139cca83f;hp=5d2f8aeb573c78a493d94e545bc97d07e47553c5;hpb=cf5a1d5e5905664cd1a73691a75ecca40e575b99;p=koha.git diff --git a/C4/Items.pm b/C4/Items.pm index 5d2f8aeb57..8f3ef33469 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -21,82 +21,67 @@ package C4::Items; use strict; #use warnings; FIXME - Bug 2505 -use Carp; -use C4::Context; -use C4::Koha; -use C4::Biblio; -use Koha::DateUtils; -use MARC::Record; -use C4::ClassSource; -use C4::Log; -use List::MoreUtils qw/any/; -use YAML qw/Load/; -use DateTime::Format::MySQL; -use Data::Dumper; # used as part of logging item record changes, not just for - # debugging; so please don't remove this - -use Koha::AuthorisedValues; -use Koha::DateUtils qw/dt_from_string/; -use Koha::Database; - -use Koha::Biblioitems; -use Koha::Items; -use Koha::ItemTypes; -use Koha::SearchEngine; -use Koha::SearchEngine::Search; -use Koha::Libraries; - use vars qw(@ISA @EXPORT); - BEGIN { + require Exporter; + @ISA = qw(Exporter); - require Exporter; - @ISA = qw( Exporter ); - - # function exports @EXPORT = qw( GetItem AddItemFromMarc AddItem AddItemBatchFromMarc ModItemFromMarc - Item2Marc + Item2Marc ModItem ModDateLastSeen ModItemTransfer DelItem - CheckItemPreSave - GetItemsForInventory - GetItemInfosOf - GetItemsByBiblioitemnumber GetItemsInfo - GetItemsLocationInfo - GetHostItemsInfo - GetItemnumbersForBiblio - get_hostitemnumbers_of - GetItemnumberFromBarcode - GetBarcodeFromItemnumber + GetItemsLocationInfo + GetHostItemsInfo + get_hostitemnumbers_of GetHiddenItemnumbers ItemSafeToDelete DelItemCheck - MoveItemFromBiblio - GetLatestAcquisitions - + MoveItemFromBiblio + GetLastAcquisitions CartToShelf ShelfToCart - - GetAnalyticsCount - + GetAnalyticsCount SearchItemsByField SearchItems - PrepareItemrecordDisplay - ); } +use Carp; +use C4::Context; +use C4::Koha; +use C4::Biblio; +use Koha::DateUtils; +use MARC::Record; +use C4::ClassSource; +use C4::Log; +use List::MoreUtils qw(any); +use YAML qw(Load); +use DateTime::Format::MySQL; +use Data::Dumper; # used as part of logging item record changes, not just for + # debugging; so please don't remove this + +use Koha::AuthorisedValues; +use Koha::DateUtils qw(dt_from_string); +use Koha::Database; + +use Koha::Biblioitems; +use Koha::Items; +use Koha::ItemTypes; +use Koha::SearchEngine; +use Koha::SearchEngine::Search; +use Koha::Libraries; + =head1 NAME C4::Items - item management functions @@ -236,12 +221,12 @@ sub AddItemFromMarc { my $dbh = C4::Context->dbh; # parse item hash from MARC - my $frameworkcode = GetFrameworkCode( $biblionumber ); - my ($itemtag,$itemsubfield)=GetMarcFromKohaField("items.itemnumber",$frameworkcode); - - my $localitemmarc=MARC::Record->new; - $localitemmarc->append_fields($source_item_marc->field($itemtag)); - my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items'); + my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber ); + my ($itemtag,$itemsubfield)=C4::Biblio::GetMarcFromKohaField("items.itemnumber",$frameworkcode); + + my $localitemmarc=MARC::Record->new; + $localitemmarc->append_fields($source_item_marc->field($itemtag)); + my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items'); my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode); return AddItem($item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields); } @@ -272,7 +257,7 @@ sub AddItem { my $biblionumber = shift; my $dbh = @_ ? shift : C4::Context->dbh; - my $frameworkcode = @_ ? shift : GetFrameworkCode($biblionumber); + my $frameworkcode = @_ ? shift : C4::Biblio::GetFrameworkCode($biblionumber); my $unlinked_item_subfields; if (@_) { $unlinked_item_subfields = shift; @@ -365,7 +350,7 @@ sub AddItemBatchFromMarc { $record = $record->clone(); # loop through the item tags and start creating items my @bad_item_fields = (); - my ($itemtag, $itemsubfield) = &GetMarcFromKohaField("items.itemnumber",''); + my ($itemtag, $itemsubfield) = C4::Biblio::GetMarcFromKohaField("items.itemnumber",''); my $item_sequence_num = 0; ITEMFIELD: foreach my $item_field ($record->field($itemtag)) { $item_sequence_num++; @@ -442,10 +427,11 @@ Returns item record =cut sub _build_default_values_for_mod_marc { - my ($frameworkcode) = @_; + # Has no framework parameter anymore, since Default is authoritative + # for Koha to MARC mappings. my $cache = Koha::Caches->get_instance(); - my $cache_key = "default_value_for_mod_marc-$frameworkcode"; + my $cache_key = "default_value_for_mod_marc-"; my $cached = $cache->get_from_cache($cache_key); return $cached if $cached; @@ -484,10 +470,8 @@ sub _build_default_values_for_mod_marc { while ( my ( $field, $default_value ) = each %$default_values ) { my $kohafield = $field; $kohafield =~ s|^([^\.]+)$|items.$1|; - $default_values_for_mod_from_marc{$field} = - $default_value - if C4::Koha::IsKohaFieldLinked( - { kohafield => $kohafield, frameworkcode => $frameworkcode } ); + $default_values_for_mod_from_marc{$field} = $default_value + if C4::Biblio::GetMarcFromKohaField( $kohafield ); } $cache->set_in_cache($cache_key, \%default_values_for_mod_from_marc); @@ -499,27 +483,34 @@ sub ModItemFromMarc { my $biblionumber = shift; my $itemnumber = shift; - my $dbh = C4::Context->dbh; - my $frameworkcode = GetFrameworkCode($biblionumber); - my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); + my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber); + my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); my $localitemmarc = MARC::Record->new; $localitemmarc->append_fields( $item_marc->field($itemtag) ); - my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); - my $default_values = _build_default_values_for_mod_marc($frameworkcode); + my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); + my $default_values = _build_default_values_for_mod_marc(); foreach my $item_field ( keys %$default_values ) { $item->{$item_field} = $default_values->{$item_field} unless exists $item->{$item_field}; } my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); - ModItem($item, $biblionumber, $itemnumber, $dbh, $frameworkcode, $unlinked_item_subfields); + ModItem( $item, $biblionumber, $itemnumber, { unlinked_item_subfields => $unlinked_item_subfields } ); return $item; } =head2 ModItem - ModItem({ column => $newvalue }, $biblionumber, $itemnumber); +ModItem( + { column => $newvalue }, + $biblionumber, + $itemnumber, + { + [ unlinked_item_subfields => $unlinked_item_subfields, ] + [ log_action => 1, ] + } +); Change one or more columns in an item record and update the MARC representation of the item. @@ -527,9 +518,11 @@ the MARC representation of the item. The first argument is a hashref mapping from item column names to the new values. The second and third arguments are the biblionumber and itemnumber, respectively. +The fourth, optional parameter (additional_params) may contain the keys +unlinked_item_subfields and log_action. -The fourth, optional parameter, C<$unlinked_item_subfields>, contains -an arrayref containing subfields present in the original MARC +C<$unlinked_item_subfields> contains an arrayref containing +subfields present in the original MARC representation of the item (e.g., from the item editor) that are not mapped to C columns directly but should instead be stored in C and included in @@ -540,33 +533,32 @@ the derived value of a column such as C, this routine will perform the necessary calculation and set the value. +If log_action is set to false, the action will not be logged. +If log_action is true or undefined, the action will be logged. + =cut sub ModItem { - my $item = shift; - my $biblionumber = shift; - my $itemnumber = shift; + my ( $item, $biblionumber, $itemnumber, $additional_params ) = @_; + my $log_action = $additional_params->{log_action} // 1; + my $unlinked_item_subfields = $additional_params->{unlinked_item_subfields}; + + return unless %$item; + $item->{'itemnumber'} = $itemnumber or return; # if $biblionumber is undefined, get it from the current item unless (defined $biblionumber) { $biblionumber = _get_single_item_column('biblionumber', $itemnumber); } - my $dbh = @_ ? shift : C4::Context->dbh; - my $frameworkcode = @_ ? shift : GetFrameworkCode( $biblionumber ); - - my $unlinked_item_subfields; - if (@_) { - $unlinked_item_subfields = shift; + if ($unlinked_item_subfields) { $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields); }; - $item->{'itemnumber'} = $itemnumber or return; - - my @fields = qw( itemlost withdrawn ); + my @fields = qw( itemlost withdrawn damaged ); # Only call GetItem if we need to set an "on" date field - if ( $item->{itemlost} || $item->{withdrawn} ) { + if ( $item->{itemlost} || $item->{withdrawn} || $item->{damaged} ) { my $pre_mod_item = GetItem( $item->{'itemnumber'} ); for my $field (@fields) { if ( defined( $item->{$field} ) @@ -604,7 +596,8 @@ sub ModItem { # item status is possible ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); - logaction("CATALOGUING", "MODIFY", $itemnumber, "item ".Dumper($item)) if C4::Context->preference("CataloguingLog"); + logaction( "CATALOGUING", "MODIFY", $itemnumber, "item " . Dumper($item) ) + if $log_action && C4::Context->preference("CataloguingLog"); } =head2 ModItemTransfer @@ -624,6 +617,8 @@ sub ModItemTransfer { # Remove the 'shelving cart' location status if it is being used. CartToShelf( $itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") ); + $dbh->do("UPDATE branchtransfers SET datearrived = NOW(), comments = ? WHERE itemnumber = ? AND datearrived IS NULL", undef, "Canceled, new transfer from $frombranch to $tobranch created", $itemnumber); + #new entry in branchtransfers.... my $sth = $dbh->prepare( "INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch) @@ -637,18 +632,24 @@ sub ModItemTransfer { =head2 ModDateLastSeen - ModDateLastSeen($itemnum); +ModDateLastSeen( $itemnumber, $leave_item_lost ); Mark item as seen. Is called when an item is issued, returned or manually marked during inventory/stocktaking. -C<$itemnum> is the item number +C<$itemnumber> is the item number +C<$leave_item_lost> determines if a lost item will be found or remain lost =cut sub ModDateLastSeen { - my ($itemnumber) = @_; - + my ( $itemnumber, $leave_item_lost ) = @_; + my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); - ModItem({ itemlost => 0, datelastseen => $today }, undef, $itemnumber); + + my $params; + $params->{datelastseen} = $today; + $params->{itemlost} = 0 unless $leave_item_lost; + + ModItem( $params, undef, $itemnumber, { log_action => 0 } ); } =head2 DelItem @@ -666,7 +667,8 @@ sub DelItem { my $biblionumber = $params->{biblionumber}; unless ($biblionumber) { - $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber($itemnumber); + my $item = Koha::Items->find( $itemnumber ); + $biblionumber = $item ? $item->biblio->biblionumber : undef; } # If there is no biblionumber for the given itemnumber, there is nothing to delete @@ -731,10 +733,10 @@ sub CheckItemPreSave { # check for duplicate barcode if (exists $item_ref->{'barcode'} and defined $item_ref->{'barcode'}) { - my $existing_itemnumber = GetItemnumberFromBarcode($item_ref->{'barcode'}); - if ($existing_itemnumber) { + my $existing_item= Koha::Items->find({barcode => $item_ref->{'barcode'}}); + if ($existing_item) { if (!exists $item_ref->{'itemnumber'} # new item - or $item_ref->{'itemnumber'} != $existing_itemnumber) { # existing item + or $item_ref->{'itemnumber'} != $existing_item->itemnumber) { # existing item $errors{'duplicate_barcode'} = $item_ref->{'barcode'}; } } @@ -766,11 +768,6 @@ The following functions provide various ways of getting an item record, a set of item records, or lists of authorized values for certain item fields. -Some of the functions in this group are candidates -for refactoring -- for example, some of the code -in C and C -has copy-and-paste work. - =cut =head2 GetItemsForInventory @@ -883,8 +880,8 @@ sub GetItemsForInventory { $query .= 'WHERE '; $query .= join ' AND ', @where_strings; } - $query .= ' ORDER BY items.cn_sort, itemcallnumber, title'; my $count_query = $select_count . $query; + $query .= ' ORDER BY items.cn_sort, itemcallnumber, title'; $query .= " LIMIT $offset, $size" if ($offset and $size); $query = $select_columns . $query; my $sth = $dbh->prepare($query); @@ -923,78 +920,6 @@ sub GetItemsForInventory { return (\@results, $iTotalRecords); } -=head2 GetItemInfosOf - - GetItemInfosOf(@itemnumbers); - -=cut - -sub GetItemInfosOf { - my @itemnumbers = @_; - - my $itemnumber_values = @itemnumbers ? join( ',', @itemnumbers ) : "''"; - - my $dbh = C4::Context->dbh; - my $query = " - SELECT * - FROM items - WHERE itemnumber IN ($itemnumber_values) - "; - return $dbh->selectall_hashref($query, 'itemnumber'); -} - -=head2 GetItemsByBiblioitemnumber - - GetItemsByBiblioitemnumber($biblioitemnumber); - -Returns an arrayref of hashrefs suitable for use in a TMPL_LOOP -Called by C - -=cut - -sub GetItemsByBiblioitemnumber { - my ( $bibitem ) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT * FROM items WHERE items.biblioitemnumber = ?") || die $dbh->errstr; - # Get all items attached to a biblioitem - my $i = 0; - my @results; - $sth->execute($bibitem) || die $sth->errstr; - while ( my $data = $sth->fetchrow_hashref ) { - # Foreach item, get circulation information - my $sth2 = $dbh->prepare( "SELECT * FROM issues,borrowers - WHERE itemnumber = ? - AND issues.borrowernumber = borrowers.borrowernumber" - ); - $sth2->execute( $data->{'itemnumber'} ); - if ( my $data2 = $sth2->fetchrow_hashref ) { - # if item is out, set the due date and who it is out too - $data->{'date_due'} = $data2->{'date_due'}; - $data->{'cardnumber'} = $data2->{'cardnumber'}; - $data->{'borrowernumber'} = $data2->{'borrowernumber'}; - } - else { - # set date_due to blank, so in the template we check itemlost, and withdrawn - $data->{'date_due'} = ''; - } # else - # Find the last 3 people who borrowed this item. - my $query2 = "SELECT * FROM old_issues, borrowers WHERE itemnumber = ? - AND old_issues.borrowernumber = borrowers.borrowernumber - ORDER BY returndate desc,timestamp desc LIMIT 3"; - $sth2 = $dbh->prepare($query2) || die $dbh->errstr; - $sth2->execute( $data->{'itemnumber'} ) || die $sth2->errstr; - my $i2 = 0; - while ( my $data2 = $sth2->fetchrow_hashref ) { - $data->{"timestamp$i2"} = $data2->{'timestamp'}; - $data->{"card$i2"} = $data2->{'cardnumber'}; - $data->{"borrower$i2"} = $data2->{'borrowernumber'}; - $i2++; - } - push(@results,$data); - } - return (\@results); -} - =head2 GetItemsInfo @results = GetItemsInfo($biblionumber); @@ -1217,44 +1142,40 @@ sub GetItemsLocationInfo { =head2 GetHostItemsInfo - $hostiteminfo = GetHostItemsInfo($hostfield); - Returns the iteminfo for items linked to records via a host field + $hostiteminfo = GetHostItemsInfo($hostfield); + Returns the iteminfo for items linked to records via a host field =cut sub GetHostItemsInfo { - my ($record) = @_; - my @returnitemsInfo; - - if (C4::Context->preference('marcflavour') eq 'MARC21' || - C4::Context->preference('marcflavour') eq 'NORMARC'){ - foreach my $hostfield ( $record->field('773') ) { - my $hostbiblionumber = $hostfield->subfield("0"); - my $linkeditemnumber = $hostfield->subfield("9"); - my @hostitemInfos = GetItemsInfo($hostbiblionumber); - foreach my $hostitemInfo (@hostitemInfos){ - if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ - push (@returnitemsInfo,$hostitemInfo); - last; - } - } - } - } elsif ( C4::Context->preference('marcflavour') eq 'UNIMARC'){ - foreach my $hostfield ( $record->field('461') ) { - my $hostbiblionumber = $hostfield->subfield("0"); - my $linkeditemnumber = $hostfield->subfield("9"); - my @hostitemInfos = GetItemsInfo($hostbiblionumber); - foreach my $hostitemInfo (@hostitemInfos){ - if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ - push (@returnitemsInfo,$hostitemInfo); - last; - } - } - } - } - return @returnitemsInfo; -} + my ($record) = @_; + my @returnitemsInfo; + if( !C4::Context->preference('EasyAnalyticalRecords') ) { + return @returnitemsInfo; + } + + my @fields; + if( C4::Context->preference('marcflavour') eq 'MARC21' || + C4::Context->preference('marcflavour') eq 'NORMARC') { + @fields = $record->field('773'); + } elsif( C4::Context->preference('marcflavour') eq 'UNIMARC') { + @fields = $record->field('461'); + } + + foreach my $hostfield ( @fields ) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + my @hostitemInfos = GetItemsInfo($hostbiblionumber); + foreach my $hostitemInfo (@hostitemInfos) { + if( $hostitemInfo->{itemnumber} eq $linkeditemnumber ) { + push @returnitemsInfo, $hostitemInfo; + last; + } + } + } + return @returnitemsInfo; +} =head2 GetLastAcquisitions @@ -1307,26 +1228,6 @@ 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_hostitemnumbers_of my @itemnumbers_of = get_hostitemnumbers_of($biblionumber); @@ -1341,7 +1242,7 @@ references on array of itemnumbers. sub get_hostitemnumbers_of { my ($biblionumber) = @_; - my $marcrecord = GetMarcBiblio($biblionumber); + my $marcrecord = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber }); return unless $marcrecord; @@ -1361,7 +1262,12 @@ sub get_hostitemnumbers_of { foreach my $hostfield ( $marcrecord->field($tag) ) { my $hostbiblionumber = $hostfield->subfield($biblio_s); + next unless $hostbiblionumber; # have tag, don't have $biblio_s subfield my $linkeditemnumber = $hostfield->subfield($item_s); + if ( ! $linkeditemnumber ) { + warn "ERROR biblionumber $biblionumber has 773^0, but doesn't have 9"; + next; + } my $is_from_biblio = Koha::Items->search({ itemnumber => $linkeditemnumber, biblionumber => $hostbiblionumber }); push @returnhostitemnumbers, $linkeditemnumber if $is_from_biblio; @@ -1370,53 +1276,27 @@ sub get_hostitemnumbers_of { return @returnhostitemnumbers; } - -=head2 GetItemnumberFromBarcode - - $result = GetItemnumberFromBarcode($barcode); - -=cut - -sub GetItemnumberFromBarcode { - my ($barcode) = @_; - my $dbh = C4::Context->dbh; - - my $rq = - $dbh->prepare("SELECT itemnumber FROM items WHERE items.barcode=?"); - $rq->execute($barcode); - my ($result) = $rq->fetchrow; - return ($result); -} - -=head2 GetBarcodeFromItemnumber - - $result = GetBarcodeFromItemnumber($itemnumber); - -=cut - -sub GetBarcodeFromItemnumber { - my ($itemnumber) = @_; - my $dbh = C4::Context->dbh; - - my $rq = - $dbh->prepare("SELECT barcode FROM items WHERE items.itemnumber=?"); - $rq->execute($itemnumber); - my ($result) = $rq->fetchrow; - return ($result); -} - =head2 GetHiddenItemnumbers - my @itemnumbers_to_hide = GetHiddenItemnumbers(@items); + my @itemnumbers_to_hide = GetHiddenItemnumbers({ items => \@items, borcat => $category }); Given a list of items it checks which should be hidden from the OPAC given the current configuration. Returns a list of itemnumbers corresponding to -those that should be hidden. +those that should be hidden. Optionally takes a borcat parameter for certain borrower types +to be excluded =cut sub GetHiddenItemnumbers { - my (@items) = @_; + my $params = shift; + my $items = $params->{items}; + if (my $exceptions = C4::Context->preference('OpacHiddenItemsExceptions') and $params->{'borcat'}){ + foreach my $except (split(/\|/, $exceptions)){ + if ($params->{'borcat'} eq $except){ + return; # we don't hide anything for this borrower category + } + } + } my @resultitems; my $yaml = C4::Context->preference('OpacHiddenItems'); @@ -1433,7 +1313,7 @@ sub GetHiddenItemnumbers { my $dbh = C4::Context->dbh; # For each item - foreach my $item (@items) { + foreach my $item (@$items) { # We check each rule foreach my $field (keys %$hidingrules) { @@ -1499,7 +1379,7 @@ sub GetMarcItem { my $itemrecord = GetItem($itemnumber); - # Tack on 'items.' prefix to column names so that TransformKohaToMarc will work. + # Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work. # Also, don't emit a subfield if the underlying field is blank. @@ -1513,8 +1393,13 @@ sub Item2Marc { defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () } keys %{ $itemrecord } }; - my $itemmarc = TransformKohaToMarc($mungeditem); - my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",GetFrameworkCode($biblionumber)||''); + my $framework = C4::Biblio::GetFrameworkCode( $biblionumber ); + my $itemmarc = C4::Biblio::TransformKohaToMarc( + $mungeditem, { no_split => 1}, + ); + my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( + "items.itemnumber", $framework, + ); my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'}); if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) { @@ -2140,7 +2025,7 @@ sub _marc_from_item_hash { my $item_marc = MARC::Record->new(); foreach my $item_field ( keys %{$mungeditem} ) { - my ( $tag, $subfield ) = GetMarcFromKohaField( $item_field, $frameworkcode ); + my ( $tag, $subfield ) = C4::Biblio::GetMarcFromKohaField( $item_field, $frameworkcode ); next unless defined $tag and defined $subfield; # skip if not mapped to MARC field my @values = split(/\s?\|\s?/, $mungeditem->{$item_field}, -1); foreach my $value (@values){ @@ -2354,7 +2239,7 @@ sub _SearchItems_build_where_fragment { # items.more_subfields_xml, depending on the MARC field. my $xpath; my $sqlfield; - my ($itemfield) = GetMarcFromKohaField('items.itemnumber'); + my ($itemfield) = C4::Biblio::GetMarcFromKohaField('items.itemnumber'); if ($marcfield eq $itemfield) { $sqlfield = 'more_subfields_xml'; $xpath = '//record/datafield/subfield[@code="' . $marcsubfield . '"]'; @@ -2561,13 +2446,13 @@ sub PrepareItemrecordDisplay { my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_; my $dbh = C4::Context->dbh; - $frameworkcode = &GetFrameworkCode($bibnum) if $bibnum; - my ( $itemtagfield, $itemtagsubfield ) = &GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); + $frameworkcode = C4::Biblio::GetFrameworkCode($bibnum) if $bibnum; + my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); # Note: $tagslib obtained from GetMarcStructure() in 'unsafe' mode is # a shared data structure. No plugin (including custom ones) should change # its contents. See also GetMarcStructure. - my $tagslib = &GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } ); + my $tagslib = GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } ); # return nothing if we don't have found an existing framework. return q{} unless $tagslib;