Bug 18422: (QA follow-up) Check if select2 is available before using it
[koha.git] / cataloguing / value_builder / marc21_leader.pl
blob755300a827a7a87b366326f679cd0b07f0ad82b2
1 #!/usr/bin/perl
3 # Converted to new plugin style (Bug 13437)
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Modern::Perl;
23 use CGI qw ( -utf8 );
25 use C4::Auth;
26 use C4::Context;
27 use C4::Output;
29 my $builder = sub {
30 my ( $params ) = @_;
31 my $function_name = $params->{id};
32 my $res = "
33 <script type=\"text/javascript\">
34 //<![CDATA[
36 function Focus$function_name(event) {
37 if(!document.getElementById(event.data.id).value){
38 document.getElementById(event.data.id).value = ' nam a22 7a 4500';
42 function Click$function_name(event) {
43 defaultvalue=document.getElementById(event.data.id).value;
44 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_leader.pl&index=\"+ event.data.id +\"&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
47 //]]>
48 </script>
51 return $res;
54 my $launcher = sub {
55 my ( $params ) = @_;
56 my $input = $params->{cgi};
57 my $index = $input->param('index');
58 my $result = $input->param('result');
60 my $dbh = C4::Context->dbh;
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
63 { template_name => "cataloguing/value_builder/marc21_leader.tt",
64 query => $input,
65 type => "intranet",
66 authnotrequired => 0,
67 flagsrequired => { editcatalogue => '*' },
68 debug => 1,
71 $result = " nam a22 7a 4500" unless $result;
72 my $f5 = substr( $result, 5, 1 );
73 my $f6 = substr( $result, 6, 1 );
74 my $f7 = substr( $result, 7, 1 );
75 my $f8 = substr( $result, 8, 1 );
76 my $f17 = substr( $result, 17, 1 );
77 my $f18 = substr( $result, 18, 1 );
78 my $f19 = substr( $result, 19, 1 );
79 my $f2023 = substr( $result, 20, 4 );
80 $template->param(
81 index => $index,
82 "f5$f5" => 1,
83 "f6$f6" => 1,
84 "f7$f7" => 1,
85 "f8$f8" => 1,
86 "f17$f17" => 1,
87 "f18$f18" => 1,
88 "f19$f19" => 1,
89 "f2023" => $f2023,
91 output_html_with_http_headers $input, $cookie, $template->output;
94 return { builder => $builder, launcher => $launcher };