Jonathan Druart
e6e09c540f
The subroutine C4::Koha::GetAuthorisedValueCategories just retrieves all the authorised value categories. We already have a method in the Koha::AuthorisedValues module to do this job, let's use it! Technical explanations: The new subroutine of the AuthorisedValues TT plugin will allow to get the authorised value categories from the templates. The new html_helpers include file will get rid of the if selected else end statements. Bug 15758 already uses this file, see the commit description for more informations. Test plan: 1/ Create or edit a new fund (aqbudgets.pl), the fields "statistic 1" and "statistic 2" should be correctly filled with the list of authorised value categories 2/ Edit subfields for a biblio and authority framework. The "Authorized value" dropdown list should be correctly filled on both pages 3/ Create new items search fields (from the administration area), same as previously, the authorised value category dropdown list should be correctly filled 4/ Add and edit patron attribute types, check the authorised value category list. Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
124 lines
3.3 KiB
Perl
Executable file
124 lines
3.3 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# This file is part of Koha.
|
|
#
|
|
# Copyright 2013 BibLibre
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it under the
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 3 of the License, or (at your option) any later
|
|
# version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with Koha; if not, see <http://www.gnu.org/licenses>.
|
|
|
|
use Modern::Perl;
|
|
use CGI;
|
|
use C4::Auth;
|
|
use C4::Koha;
|
|
use C4::Output;
|
|
use Koha::AdditionalField;
|
|
|
|
my $input = new CGI;
|
|
|
|
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|
{
|
|
template_name => "serials/add_fields.tt",
|
|
query => $input,
|
|
type => "intranet",
|
|
authnotrequired => 0,
|
|
flagsrequired => { serials => '*' },
|
|
debug => 1,
|
|
}
|
|
);
|
|
|
|
my $op = $input->param('op') // 'list';
|
|
my $field_id = $input->param('field_id');
|
|
my @messages;
|
|
|
|
if ( $op eq 'add' ) {
|
|
my $name = $input->param('name') // q{};
|
|
my $authorised_value_category = $input->param('authorised_value_category') // q{};
|
|
my $marcfield = $input->param('marcfield') // q{};
|
|
my $searchable = $input->param('searchable') ? 1 : 0;
|
|
if ( $field_id and $name ) {
|
|
my $updated = 0;
|
|
eval {
|
|
my $af = Koha::AdditionalField->new({
|
|
id => $field_id,
|
|
name => $name,
|
|
authorised_value_category => $authorised_value_category,
|
|
marcfield => $marcfield,
|
|
searchable => $searchable,
|
|
});
|
|
$updated = $af->update;
|
|
};
|
|
push @messages, {
|
|
code => 'update',
|
|
number => $updated,
|
|
};
|
|
} elsif ( $name ) {
|
|
my $inserted = 0;
|
|
eval {
|
|
my $af = Koha::AdditionalField->new({
|
|
tablename => 'subscription',
|
|
name => $name,
|
|
authorised_value_category => $authorised_value_category,
|
|
marcfield => $marcfield,
|
|
searchable => $searchable,
|
|
});
|
|
$inserted = $af->insert;
|
|
};
|
|
push @messages, {
|
|
code => 'insert',
|
|
number => $inserted,
|
|
};
|
|
} else {
|
|
push @messages, {
|
|
code => 'insert',
|
|
number => 0,
|
|
};
|
|
}
|
|
$op = 'list';
|
|
}
|
|
|
|
if ( $op eq 'delete' ) {
|
|
my $deleted = 0;
|
|
eval {
|
|
my $af = Koha::AdditionalField->new( { id => $field_id } );
|
|
$deleted = $af->delete;
|
|
$deleted = 0 if $deleted eq '0E0';
|
|
};
|
|
push @messages, {
|
|
code => 'delete',
|
|
number => $deleted,
|
|
};
|
|
$op = 'list';
|
|
}
|
|
|
|
if ( $op eq 'add_form' ) {
|
|
my $field;
|
|
if ( $field_id ) {
|
|
$field = Koha::AdditionalField->new( { id => $field_id } )->fetch;
|
|
}
|
|
|
|
$template->param(
|
|
field => $field,
|
|
);
|
|
}
|
|
|
|
if ( $op eq 'list' ) {
|
|
my $fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
|
|
$template->param( fields => $fields );
|
|
}
|
|
|
|
$template->param(
|
|
op => $op,
|
|
messages => \@messages,
|
|
);
|
|
|
|
output_html_with_http_headers $input, $cookie, $template->output;
|