1 package Koha::Biblio::ItemGroup;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use base qw(Koha::Object);
22 use Koha::Biblio::ItemGroup::Items;
23 use Koha::Exceptions::Object;
28 Koha::Biblio::ItemGroup - Koha ItemGroup Object class
38 Overloaded I<store> method that takes care of creation date handling.
45 unless ( $self->in_storage ) {
49 created_on => \'NOW()'
54 return $self->SUPER::store();
59 my $items = $item_group->items;
61 Returns all the items linked to the item group.
68 my $items_rs = $self->_result->item_group_items;
69 my @item_ids = $items_rs->get_column('item_id')->all;
71 return Koha::Items->new->empty unless @item_ids;
73 return Koha::Items->search(
84 $item_group->add_item({ item_id => $item_id });
89 my ($self, $params) = @_;
91 my $item_id = $params->{item_id};
93 my $item = Koha::Items->find( $item_id );
94 unless ( $item->biblionumber == $self->biblio_id ) {
95 Koha::Exceptions::Object::FKConstraint->throw(
96 broken_fk => 'biblio_id'
100 Koha::Biblio::ItemGroup::Item->new(
102 item_group_id => $self->id,
110 =head3 to_api_mapping
112 This method returns the mapping for representing a Koha::Biblio::ItemGroup object
119 created_on => 'creation_date',
120 updated_on => 'modification_date'
124 =head2 Internal methods
139 return 'Koha::Biblio::ItemGroup';