1 package Koha
::AuthorisedValues
;
3 # Copyright ByWater Solutions 2014
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.
26 use Koha
::AuthorisedValue
;
27 use Koha
::MarcSubfieldStructures
;
29 use base
qw(Koha::Objects);
33 Koha::AuthorisedValues - Koha Authorised value Object set class
41 =head3 Koha::AuthorisedValues->search();
43 my @objects = Koha::AuthorisedValues->search($params);
48 my ( $self, $params, $attributes ) = @_;
50 my $branchcode = $params->{branchcode
};
51 delete( $params->{branchcode
} );
57 'authorised_values_branches.branchcode' => undef,
58 'authorised_values_branches.branchcode' => $branchcode,
62 my $join = $branchcode ?
{ join => 'authorised_values_branches' } : {};
64 $attributes = { %$attributes, %$join };
65 return $self->SUPER::search
( { %$params, %$or, }, $attributes );
68 sub search_by_marc_field
{
69 my ( $self, $params ) = @_;
70 my $frameworkcode = $params->{frameworkcode
} || '';
71 my $tagfield = $params->{tagfield
};
72 my $tagsubfield = $params->{tagsubfield
};
74 return unless $tagfield or $tagsubfield;
76 return $self->SUPER::search
(
77 { 'marc_subfield_structures.frameworkcode' => $frameworkcode,
78 ( defined $tagfield ?
( 'marc_subfield_structures.tagfield' => $tagfield ) : () ),
79 ( defined $tagsubfield ?
( 'marc_subfield_structures.tagsubfield' => $tagsubfield ) : () ),
81 { join => { category
=> 'marc_subfield_structures' } }
85 sub search_by_koha_field
{
86 my ( $self, $params ) = @_;
87 my $frameworkcode = $params->{frameworkcode
} || '';
88 my $kohafield = $params->{kohafield
};
89 my $category = $params->{category
};
90 my $authorised_value = $params->{authorised_value
};
92 return unless $kohafield;
94 return $self->SUPER::search
(
95 { 'marc_subfield_structures.frameworkcode' => $frameworkcode,
96 'marc_subfield_structures.kohafield' => $kohafield,
97 ( defined $category ?
( category_name
=> $category ) : () ),
98 ( $authorised_value ?
( authorised_value
=> $authorised_value ) : () ),
100 { join => { category
=> 'marc_subfield_structures' },
108 my $rs = $self->_resultset->search(
111 select => ['category'],
113 order_by
=> 'category',
116 return map $_->get_column('category'), $rs->all;
124 return 'AuthorisedValue';
128 return 'Koha::AuthorisedValue';
133 Kyle M Hall <kyle@bywatersolutions.com>