|
Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 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. |
| 9 |
# |
| 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. |
| 14 |
# |
| 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>. |
| 17 |
|
| 18 |
use Modern::Perl; |
| 19 |
|
| 20 |
use C4::Auth qw( get_template_and_user ); |
| 21 |
use C4::Output qw( output_html_with_http_headers ); |
| 22 |
|
| 23 |
use Koha::I18N; |
| 24 |
|
| 25 |
my $builder = sub { |
| 26 |
my $params = shift; |
| 27 |
my $id = $params->{id}; |
| 28 |
|
| 29 |
return qq| |
| 30 |
<script> |
| 31 |
function Click$id(event) { |
| 32 |
event.preventDefault(); |
| 33 |
const value = document.getElementById(event.data.id).value; |
| 34 |
const url = new URL('/cgi-bin/koha/cataloguing/plugin_launcher.pl', location); |
| 35 |
url.searchParams.set('plugin_name', 'unimarc_field_146h.pl'); |
| 36 |
url.searchParams.set('id', event.data.id); |
| 37 |
url.searchParams.set('value', value); |
| 38 |
window.open(url.toString(), 'tag_editor', 'width=700,height=700,toolbar=false,scrollbars=yes'); |
| 39 |
} |
| 40 |
</script>|; |
| 41 |
}; |
| 42 |
|
| 43 |
my $launcher = sub { |
| 44 |
my $params = shift; |
| 45 |
my $cgi = $params->{cgi}; |
| 46 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ |
| 47 |
template_name => "cataloguing/value_builder/unimarc_field_146h.tt", |
| 48 |
query => $cgi, |
| 49 |
type => 'intranet', |
| 50 |
flagsrequired => { editcatalogue => '*' }, |
| 51 |
}); |
| 52 |
|
| 53 |
my @options = ( |
| 54 |
{ value => 'a', label => __('performers total') }, |
| 55 |
{ value => 'b', label => __('brass instruments') }, |
| 56 |
{ value => 'c', label => __('choirs') }, |
| 57 |
{ value => 'd', label => __('wind instruments') }, |
| 58 |
{ value => 'e', label => __('electro-acoustic instruments') }, |
| 59 |
{ value => 'i', label => __('instruments total') }, |
| 60 |
{ value => 'j', label => __('solo instruments') }, |
| 61 |
{ value => 'k', label => __('keyboard instruments') }, |
| 62 |
{ value => 'l', label => __('solo voices') }, |
| 63 |
{ value => 'm', label => __('miscellaneous, other instruments') }, |
| 64 |
{ value => 'o', label => __('orchestras') }, |
| 65 |
{ value => 'p', label => __('percussion instruments') }, |
| 66 |
{ value => 'q', label => __('conductors') }, |
| 67 |
{ value => 's', label => __('bowed string instruments') }, |
| 68 |
{ value => 't', label => __('plucked string instruments') }, |
| 69 |
{ value => 'v', label => __('voices total') }, |
| 70 |
{ value => 'w', label => __('woodwind instruments') }, |
| 71 |
{ value => 'x', label => __('choral voices') }, |
| 72 |
{ value => 'y', label => __('ensemble instruments') }, |
| 73 |
{ value => 'z', label => __('devices, other performers') }, |
| 74 |
); |
| 75 |
|
| 76 |
my $value = $cgi->param('value'); |
| 77 |
my $number = substr($value, 0, 3); |
| 78 |
my $category = substr($value, 3, 1); |
| 79 |
|
| 80 |
$template->param( |
| 81 |
id => scalar $cgi->param('id'), |
| 82 |
number => $number, |
| 83 |
category => $category, |
| 84 |
options => \@options, |
| 85 |
); |
| 86 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
| 87 |
}; |
| 88 |
|
| 89 |
return { builder => $builder, launcher => $launcher }; |