Koha/svc/cataloguing/framework
Jonathan Druart 3495de67d4 Bug 20760: Fill authorised values in svc framework
To test:
 1 - Map a marc field to an authorised value in the default framework -
say 300$c -> CCODE
 2 - Open the advanced cataloguing editor
 3 - Create a new field 300$c - note there is no dropdown
 4 - browse to: /cgi-bin/koha/svc/cataloguing/framework?callback=define
 5 - Note the many instance of
Koha::Schema::ResultSet::AuthorisedValueCategory->HASH...
 6 - Apply patch
 7 - Restart memcached and plack
 8 - reload/recreate record in rancor
 9 - Note that 300$c is now a dropdown as expected
10 - repeate 4
11 - note the authorised values look correct in response

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-06-15 10:34:33 +00:00

62 lines
2 KiB
Perl
Executable file

#!/usr/bin/perl
use Modern::Perl '2009';
use CGI;
use C4::ClassSource;
use C4::Context;
use C4::Biblio;
use C4::Koha;
use C4::Service;
use Koha::Database;
use Koha::Libraries;
my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' );
my $frameworkcode = $query->param( 'frameworkcode' ) // '';
my $tagslib = GetMarcStructure( 1, $frameworkcode );
my @tags;
foreach my $tag ( sort keys %$tagslib ) {
my $taglib = $tagslib->{$tag};
my $taginfo = { map { $_, $taglib->{$_} } grep { length $_ > 1 } keys %$taglib };
$taginfo->{subfields} = [ map { [ $_, $taglib->{$_} ] } grep { length $_ == 1 } sort keys %$taglib ];
push @tags, [ $tag, $taginfo ];
}
my $schema = Koha::Database->new->schema;
my $authorised_values = {};
my $branches = { map { $_->branchcode => $_->branchname } Koha::Libraries->search_filtered };
$authorised_values->{branches} = [];
foreach my $thisbranch ( sort keys %$branches ) {
push @{ $authorised_values->{branches} }, { value => $thisbranch, lib => $branches->{$thisbranch} };
}
$authorised_values->{itemtypes} = [ $schema->resultset( "Itemtype" )->search( undef, {
columns => [ { value => 'itemtype' }, { lib => "description" } ],
order_by => "description",
result_class => 'DBIx::Class::ResultClass::HashRefInflator'
} ) ];
my $class_sources = GetClassSources();
my $default_source = C4::Context->preference("DefaultClassificationSource");
foreach my $class_source (sort keys %$class_sources) {
next unless $class_sources->{$class_source}->{'used'} or
($class_source eq $default_source);
push @{ $authorised_values->{cn_source} }, { value => $class_source, lib => $class_sources->{$class_source}->{'description'} };
}
my $avs = C4::Koha::GetAuthorisedValues();
for my $av ( @$avs ) {
push @{ $authorised_values->{$av->{category}} }, { value => $av->{authorised_value}, lib => $av->{lib} };
}
$response->param( framework => \@tags, authorised_values => $authorised_values );
C4::Service->return_success( $response );