b997250026
This patch allows to create additional fields for order lines. Once created, these fields can be filled during order line creation or modification. If additional field is linked to a MARC field, there are two possible scenario: - MARC field mode = get: The field cannot be modified and its value is retrieved from the bibliographic record (current behaviour) - MARC field mode = set: The field can be modified and its value is saved to the bibliographic record (new behaviour) If additional field is linked to an authorised value category, then authorised values are used. If not directly linked to an authorised value category, but linked to a MARC field, a search for an AV category is made on MARC default framework. This patch doesn't display additional fields value anywhere (except in order line creation/modification). Future patches will do that. Test plan: 1/ Go to Acquisitions home 2/ In the left menu, click on "Add order line fields" 3/ Click on "New field" button 4/ Give the field a name (unique), no AV category and no MARC field. 5/ Save. 6/ Create 5 other fields: a/ no AV category, a MARC field not linked to AV category, MARC field mode = get b/ no AV category, a MARC field not linked to AV category, MARC field mode = set c/ no AV category, a MARC field linked to AV category, MARC field mode = get d/ no AV category, a MARC field linked to AV category, MARC field mode = set e/ an AV category, no MARC field 7/ Create everything you need to be able to create order lines (supplier, basket, ...) 8/ Create an order line. At bottom of the page, you should see your additional fields, with authorised values dropdrown list for fields (c), (d) and (e). Fields (a) and (c) should be disabled. 9/ Fill these fields with some data and save order line 10/ check that data was correctly saved into biblio for fields (b) and (d), but not for (a) and (c) 11/ modify the same order line, check that values you've filled are correctly retrieved and that values for (a) and (c) were correctly retrieved from the bibliographic record 12/ modify all values, save, and check biblio once again Signed-off-by: Harold Dramer <harold.dramer@nyls.edu> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
136 lines
3.9 KiB
Perl
Executable file
136 lines
3.9 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 qw( get_template_and_user );
|
|
use C4::Output qw( output_html_with_http_headers );
|
|
use Koha::AdditionalFields;
|
|
|
|
my $input = CGI->new;
|
|
|
|
my %flagsrequired;
|
|
$flagsrequired{parameters} = 'manage_additional_fields';
|
|
|
|
my $tablename = $input->param('tablename');
|
|
my $op = $input->param('op') // ( $tablename ? 'list' : 'list_tables' );
|
|
|
|
if( $op ne 'list_tables' ){
|
|
$flagsrequired{acquisition} = 'order_manage' if $tablename eq 'aqbasket';
|
|
$flagsrequired{serials} = 'edit_subscription' if $tablename eq 'subscription';
|
|
}
|
|
|
|
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|
{
|
|
template_name => "admin/additional-fields.tt",
|
|
query => $input,
|
|
type => "intranet",
|
|
flagsrequired => \%flagsrequired,
|
|
}
|
|
);
|
|
|
|
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 $marcfield_mode = $input->param('marcfield_mode') // 'get';
|
|
my $searchable = $input->param('searchable') ? 1 : 0;
|
|
if ( $field_id and $name ) {
|
|
my $updated = 0;
|
|
eval {
|
|
my $af = Koha::AdditionalFields->find($field_id);
|
|
$af->set({
|
|
name => $name,
|
|
authorised_value_category => $authorised_value_category,
|
|
marcfield => $marcfield,
|
|
marcfield_mode => $marcfield_mode,
|
|
searchable => $searchable,
|
|
});
|
|
$updated = $af->store ? 1 : 0;
|
|
};
|
|
push @messages, {
|
|
code => 'update',
|
|
number => $updated,
|
|
};
|
|
} elsif ( $name ) {
|
|
my $inserted = 0;
|
|
eval {
|
|
my $af = Koha::AdditionalField->new({
|
|
tablename => $tablename,
|
|
name => $name,
|
|
authorised_value_category => $authorised_value_category,
|
|
marcfield => $marcfield,
|
|
marcfield_mode => $marcfield_mode,
|
|
searchable => $searchable,
|
|
});
|
|
$inserted = $af->store ? 1 : 0;
|
|
};
|
|
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::AdditionalFields->find($field_id);
|
|
$deleted = $af->delete;
|
|
};
|
|
push @messages, {
|
|
code => 'delete',
|
|
number => $deleted,
|
|
};
|
|
$op = 'list';
|
|
}
|
|
|
|
if ( $op eq 'add_form' ) {
|
|
my $field;
|
|
if ( $field_id ) {
|
|
$field = Koha::AdditionalFields->find($field_id);
|
|
}
|
|
|
|
$tablename = $field->tablename if $field;
|
|
|
|
$template->param(
|
|
field => $field,
|
|
);
|
|
}
|
|
|
|
if ( $op eq 'list' ) {
|
|
my $fields = Koha::AdditionalFields->search( { tablename => $tablename } );
|
|
$template->param( fields => $fields );
|
|
}
|
|
|
|
$template->param(
|
|
op => $op,
|
|
tablename => $tablename,
|
|
messages => \@messages,
|
|
);
|
|
|
|
output_html_with_http_headers $input, $cookie, $template->output;
|