3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use C4::Auth qw( get_template_and_user );
23 use C4::Output qw( output_html_with_http_headers );
26 use Koha::CodeList::Unimarc::MediumOfPerformance;
30 my $id = $params->{id};
34 function Click$id (event) {
35 event.preventDefault();
36 const value = document.getElementById(event.data.id).value;
37 const url = new URL('/cgi-bin/koha/cataloguing/plugin_launcher.pl', location);
38 url.searchParams.set('plugin_name', 'unimarc_field_146f.pl');
39 url.searchParams.set('id', event.data.id);
40 url.searchParams.set('value', value);
41 window.open(url.toString(), 'tag_editor', 'width=700,height=700,toolbar=false,scrollbars=yes');
48 my $cgi = $params->{cgi};
49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
50 template_name => "cataloguing/value_builder/unimarc_field_146f.tt",
53 flagsrequired => { editcatalogue => '*' },
56 my @category_optgroups = (
57 { label => __('Woodwinds'), values => Koha::CodeList::Unimarc::MediumOfPerformance->woodwinds() },
58 { label => __('Brass instruments'), values => Koha::CodeList::Unimarc::MediumOfPerformance->brass() },
59 { label => __('Strings, bowed'), values => Koha::CodeList::Unimarc::MediumOfPerformance->strings_bowed() },
60 { label => __('Strings, plucked'), values => Koha::CodeList::Unimarc::MediumOfPerformance->strings_plucked() },
61 { label => __('Keyboard'), values => Koha::CodeList::Unimarc::MediumOfPerformance->keyboard() },
62 { label => __('Percussion'), values => Koha::CodeList::Unimarc::MediumOfPerformance->percussion() },
63 { label => __('Electric / electronic instruments and devices'), values => Koha::CodeList::Unimarc::MediumOfPerformance->electronic() },
64 { label => __('Miscellaneous, other, unspecified instruments'), values => Koha::CodeList::Unimarc::MediumOfPerformance->misc() },
67 foreach my $optgroup (@category_optgroups) {
68 my $values = delete $optgroup->{values};
69 $optgroup->{options} = [
71 { value => $_, label => __( $values->{$_} ) }
76 my $tessitura_hash = Koha::CodeList::Unimarc::MediumOfPerformance->tessitura();
77 my @tessitura_options = map {
78 { value => $_, label => __p('tessitura', $tessitura_hash->{$_}) }
79 } sort keys %$tessitura_hash;
81 my $number_of_hands_or_keys_hash = Koha::CodeList::Unimarc::MediumOfPerformance->number_of_hands_or_keys();
82 my @number_of_hands_or_keys_options = map {
83 { value => $_, label => __p('music', $number_of_hands_or_keys_hash->{$_}) }
84 } sort keys %$number_of_hands_or_keys_hash;
86 my $other_hash = Koha::CodeList::Unimarc::MediumOfPerformance->other();
87 my @other_options = map {
88 { value => $_, label => __($other_hash->{$_}) }
89 } sort keys %$other_hash;
91 my $other2_hash = Koha::CodeList::Unimarc::MediumOfPerformance->other2();
92 my @other2_options = map {
93 { value => $_, label => __($other2_hash->{$_}) }
94 } sort keys %$other2_hash;
96 my $value = $cgi->param('value');
97 my $number = substr($value, 0, 2);
98 unless (Scalar::Util::looks_like_number($number)) {
101 my $category = substr($value, 2, 3);
102 my $tessitura = substr($value, 5, 1);
103 my $number_of_hands_or_keys = substr($value, 6, 1);
104 my $other = substr($value, 7, 1);
105 my $other2 = substr($value, 8, 1);
108 id => scalar $cgi->param('id'),
110 category => $category,
111 tessitura => $tessitura,
112 number_of_hands_or_keys => $number_of_hands_or_keys,
115 category_optgroups => \@category_optgroups,
116 tessitura_options => \@tessitura_options,
117 number_of_hands_or_keys_options => \@number_of_hands_or_keys_options,
118 other_options => \@other_options,
119 other2_options => \@other2_options,
121 output_html_with_http_headers $cgi, $cookie, $template->output;
124 return { builder => $builder, launcher => $launcher };