Bug 30506: Value builder for field 182
[koha.git] / cataloguing / value_builder / unimarc_field_182-2.pl
1 #!/usr/bin/perl
2
3
4 # This file is part of Koha.
5 #
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18
19 use Modern::Perl;
20
21 use Date::Calc;
22
23 use Koha::Util::FrameworkPlugin qw(wrapper);
24 use C4::Auth qw( get_template_and_user );
25 use CGI qw ( -utf8 );
26 use C4::Context;
27 use C4::Output qw( output_html_with_http_headers );
28
29 my $builder= sub {
30     my $params = shift;
31     my $id = $params->{id};
32
33     return qq|
34 <script>
35
36 function Click$id(event) {
37     var fieldvalue=\$('#'+event.data.id).val();
38     window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_182-2.pl&index=\"+event.data.id+\"&result=\"+fieldvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes');
39     return false; /* prevents scrolling */
40 }
41 </script>|;
42 };
43
44 my $launcher= sub {
45     my $params = shift;
46     my $cgi = $params->{cgi};
47     my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
48         template_name => "cataloguing/value_builder/unimarc_field_182-2.tt",
49         query => $cgi,
50         type => "intranet",
51         flagsrequired => {editcatalogue => '*'},
52     });
53     $template->param(
54         index => scalar $cgi->param('index'),
55         result => scalar $cgi->param('result'),
56     );
57     output_html_with_http_headers $cgi, $cookie, $template->output;
58 };
59
60 return { builder => $builder, launcher => $launcher };