1 package Koha::Library::Group;
3 # Copyright ByWater Solutions 2016
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 use Koha::DateUtils qw(dt_from_string);
28 use base qw(Koha::Object);
32 Koha::Library::Group - Koha Library::Group object class
40 =head3 my @children = $self->get_children()
48 Koha::Library::Groups->search( { parent_id => $self->id }, { order_by => [ 'title', 'branchcode' ] } );
55 my $library = $group->library();
57 Returns the library for this group if one exists
64 return unless $self->branchcode;
66 return Koha::Libraries->find( $self->branchcode );
69 =head3 libraries_not_direct_children
71 my @libraries = $group->libraries_not_direct_children();
73 Returns the libraries *not* set as direct children of this group
77 sub libraries_not_direct_children {
80 my @children = Koha::Library::Groups->search(
82 parent_id => $self->id,
83 branchcode => { '!=' => undef },
85 { order_by => 'branchcode' }
88 my @branchcodes = map { $_->branchcode } @children;
90 return Koha::Libraries->search( { branchcode => { -not_in => \@branchcodes } } );
100 my $now = dt_from_string;
101 $self->updated_on($now);
102 $self->created_on($now) unless $self->in_storage();
104 return $self->SUPER::store(@_);
112 return 'LibraryGroup';
117 Kyle M Hall <kyle@bywatersolutions.com>