Jonathan Druart
062a70cb61
Little mistake from df97814
, $branches is a hash { branchcode =>
branchname }
Test plan:
Edit a biblio with the advanced editor
Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
The advanced editor works as expected
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
73 lines
2.5 KiB
Perl
Executable file
73 lines
2.5 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use Modern::Perl '2009';
|
|
|
|
use CGI;
|
|
use C4::ClassSource;
|
|
use C4::Context;
|
|
use C4::Biblio;
|
|
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 $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
|
|
my $results;
|
|
if( $branch_limit ) {
|
|
$results = $schema->resultset( "AuthorisedValue" )->search(
|
|
{ "authorised_values_branches.branchcode" => { "=", [ $branch_limit, undef ] } },
|
|
{ join => "authorised_values_branches", order_by => "lib" } );
|
|
} else {
|
|
$results = $schema->resultset( "AuthorisedValue" )->search(
|
|
undef,
|
|
{ order_by => "lib" } );
|
|
}
|
|
|
|
foreach my $result ( $results->all ) {
|
|
$authorised_values->{$result->category} ||= [];
|
|
push @{ $authorised_values->{$result->category} }, { value => $result->authorised_value, lib => $result->lib };
|
|
}
|
|
|
|
$response->param( framework => \@tags, authorised_values => $authorised_values );
|
|
|
|
C4::Service->return_success( $response );
|