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
GetItemsInfo
- GetItemsLocationInfo
- GetHostItemsInfo
- get_hostitemnumbers_of
+ GetItemsLocationInfo
+ GetHostItemsInfo
+ get_hostitemnumbers_of
GetHiddenItemnumbers
ItemSafeToDelete
DelItemCheck
- MoveItemFromBiblio
- GetLatestAcquisitions
-
+ MoveItemFromBiblio
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
my $dbh = C4::Context->dbh;
# parse item hash from MARC
- 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);
+ 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 = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
+ my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
+ return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields );
}
=head2 AddItem
$item->{'itemnumber'} = $itemnumber;
- ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" );
+ C4::Biblio::ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" );
logaction( "CATALOGUING", "ADD", $itemnumber, "item" )
if C4::Context->preference("CataloguingLog");
my $localitemmarc = MARC::Record->new;
$localitemmarc->append_fields( $item_marc->field($itemtag) );
- my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
+ 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}
}
);
-Change one or more columns in an item record and update
-the MARC representation of the item.
+Change one or more columns in an item record.
The first argument is a hashref mapping from item column
names to the new values. The second and third arguments
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);
$item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields);
};
- $item->{'itemnumber'} = $itemnumber or return;
-
my @fields = qw( itemlost withdrawn damaged );
# Only call GetItem if we need to set an "on" date field
my $offset = $parameters->{'offset'} // '';
my $size = $parameters->{'size'} // '';
my $statushash = $parameters->{'statushash'} // '';
+ my $ignore_waiting_holds = $parameters->{'ignore_waiting_holds'} // '';
my $dbh = C4::Context->dbh;
my ( @bind_params, @where_strings );
push @where_strings, 'issues.date_due IS NULL';
}
+ if ( $ignore_waiting_holds ) {
+ $query .= "LEFT JOIN reserves ON items.itemnumber = reserves.itemnumber ";
+ push( @where_strings, q{(reserves.found != 'W' OR reserves.found IS NULL)} );
+ }
+
if ( @where_strings ) {
$query .= 'WHERE ';
$query .= join ' AND ', @where_strings;
return @returnitemsInfo;
}
-=head2 GetLastAcquisitions
-
- my $lastacq = GetLastAcquisitions({'branches' => ('branch1','branch2'),
- 'itemtypes' => ('BK','BD')}, 10);
-
-=cut
-
-sub GetLastAcquisitions {
- my ($data,$max) = @_;
-
- my $itemtype = C4::Context->preference('item-level_itypes') ? 'itype' : 'itemtype';
-
- my $number_of_branches = @{$data->{branches}};
- my $number_of_itemtypes = @{$data->{itemtypes}};
-
-
- my @where = ('WHERE 1 ');
- $number_of_branches and push @where
- , 'AND holdingbranch IN ('
- , join(',', ('?') x $number_of_branches )
- , ')'
- ;
-
- $number_of_itemtypes and push @where
- , "AND $itemtype IN ("
- , join(',', ('?') x $number_of_itemtypes )
- , ')'
- ;
-
- my $query = "SELECT biblio.biblionumber as biblionumber, title, dateaccessioned
- FROM items RIGHT JOIN biblio ON (items.biblionumber=biblio.biblionumber)
- RIGHT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber)
- @where
- GROUP BY biblio.biblionumber
- ORDER BY dateaccessioned DESC LIMIT $max";
-
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare($query);
-
- $sth->execute((@{$data->{branches}}, @{$data->{itemtypes}}));
-
- my @results;
- while( my $row = $sth->fetchrow_hashref){
- push @results, {date => $row->{dateaccessioned}
- , biblionumber => $row->{biblionumber}
- , title => $row->{title}};
- }
-
- return @results;
-}
-
=head2 get_hostitemnumbers_of
my @itemnumbers_of = get_hostitemnumbers_of($biblionumber);
=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');
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) {
} keys %{ $itemrecord }
};
my $framework = C4::Biblio::GetFrameworkCode( $biblionumber );
- my $itemmarc = C4::Biblio::TransformKohaToMarc(
- $mungeditem, { no_split => 1},
- );
+ my $itemmarc = C4::Biblio::TransformKohaToMarc( $mungeditem ); # Bug 21774: no_split parameter removed to allow cloned subfields
my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField(
"items.itemnumber", $framework,
);
my $original_item_marc = shift;
my $frameworkcode = shift;
- my $marcstructure = GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
+ my $marcstructure = C4::Biblio::GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
# assume that this record has only one field, and that that
# field contains only the item information
# 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;