3 use Modern
::Perl
'2009';
14 my ( $query, $response ) = C4
::Service
->init( editcatalogue
=> 'edit_catalogue' );
16 my $frameworkcode = $query->param( 'frameworkcode' ) // '';
18 my $tagslib = GetMarcStructure
( 1, $frameworkcode );
22 foreach my $tag ( sort keys %$tagslib ) {
23 my $taglib = $tagslib->{$tag};
24 my $taginfo = { map { $_, $taglib->{$_} } grep { length $_ > 1 } keys %$taglib };
25 $taginfo->{subfields
} = [ map { [ $_, $taglib->{$_} ] } grep { length $_ == 1 } sort keys %$taglib ];
27 push @tags, [ $tag, $taginfo ];
30 my $schema = Koha
::Database
->new->schema;
31 my $authorised_values = {};
33 my $branches = { map { $_->branchcode => $_->branchname } Koha
::Libraries
->search_filtered };
34 $authorised_values->{branches
} = [];
35 foreach my $thisbranch ( sort keys %$branches ) {
36 push @
{ $authorised_values->{branches
} }, { value
=> $thisbranch, lib
=> $branches->{$thisbranch} };
39 $authorised_values->{itemtypes
} = [ $schema->resultset( "Itemtype" )->search( undef, {
40 columns
=> [ { value
=> 'itemtype' }, { lib
=> "description" } ],
41 order_by
=> "description",
42 result_class
=> 'DBIx::Class::ResultClass::HashRefInflator'
45 my $class_sources = GetClassSources
();
47 my $default_source = C4
::Context
->preference("DefaultClassificationSource");
49 foreach my $class_source (sort keys %$class_sources) {
50 next unless $class_sources->{$class_source}->{'used'} or
51 ($class_source eq $default_source);
52 push @
{ $authorised_values->{cn_source
} }, { value
=> $class_source, lib
=> $class_sources->{$class_source}->{'description'} };
55 my $avs = C4
::Koha
::GetAuthorisedValues
();
56 for my $av ( @
$avs ) {
57 push @
{ $authorised_values->{$av->{category
}} }, { value
=> $av->{authorised_value
}, lib
=> $av->{lib
} };
60 $response->param( framework
=> \
@tags, authorised_values
=> $authorised_values );
62 C4
::Service
->return_success( $response );