"Fossies" - the Fresh Open Source Software Archive

Member "koha-19.11.15/svc/cataloguing/framework" (23 Feb 2021, 2043 Bytes) of package /linux/misc/koha-19.11.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use Modern::Perl '2009';
    4 
    5 use CGI;
    6 use C4::ClassSource;
    7 use C4::Context;
    8 use C4::Biblio;
    9 use C4::Koha;
   10 use C4::Service;
   11 use Koha::Database;
   12 use Koha::Libraries;
   13 
   14 my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' );
   15 
   16 my $frameworkcode = $query->param( 'frameworkcode' ) // '';
   17 
   18 my $tagslib = GetMarcStructure( 1, $frameworkcode );
   19 
   20 my @tags;
   21 
   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 ];
   26 
   27     push @tags, [ $tag, $taginfo ];
   28 }
   29 
   30 my $schema = Koha::Database->new->schema;
   31 my $authorised_values = {};
   32 
   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} };
   37 }
   38 
   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'
   43 } ) ];
   44 
   45 my $class_sources = GetClassSources();
   46 
   47 my $default_source = C4::Context->preference("DefaultClassificationSource");
   48 
   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'} };
   53 }
   54 
   55 my $avs = C4::Koha::GetAuthorisedValues();
   56 for my $av ( @$avs ) {
   57     push @{ $authorised_values->{$av->{category}} }, { value => $av->{authorised_value}, lib => $av->{lib} };
   58 }
   59 
   60 $response->param( framework => \@tags, authorised_values => $authorised_values );
   61 
   62 C4::Service->return_success( $response );