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