Bug 30477: Add new UNIMARC installer translation files
[koha.git] / cataloguing / value_builder / marc21_leader.pl
1 #!/usr/bin/perl
2
3 # Converted to new plugin style (Bug 13437)
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
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.
13 #
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.
18 #
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>.
21
22 use Modern::Perl;
23 use CGI qw ( -utf8 );
24
25 use C4::Auth qw( get_template_and_user );
26 use C4::Context;
27 use C4::Output qw( output_html_with_http_headers );
28
29 my $builder = sub {
30     my ( $params ) = @_;
31     my $function_name = $params->{id};
32     my $res           = "
33 <script>
34
35 function Focus$function_name(event) {
36     if(!document.getElementById(event.data.id).value){
37         document.getElementById(event.data.id).value = '     nam a22     7a 4500';
38     }
39 }
40
41 function Click$function_name(event) {
42     defaultvalue=document.getElementById(event.data.id).value;
43     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');
44 }
45
46 </script>
47 ";
48
49     return $res;
50 };
51
52 my $launcher = sub {
53     my ( $params ) = @_;
54     my $input = $params->{cgi};
55     my $index   = $input->param('index');
56     my $result  = $input->param('result');
57
58     my $dbh = C4::Context->dbh;
59
60     my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61         {   template_name   => "cataloguing/value_builder/marc21_leader.tt",
62             query           => $input,
63             type            => "intranet",
64             flagsrequired   => { editcatalogue => '*' },
65         }
66     );
67     $result = "     nam a22     7a 4500" unless $result;
68     my $f5    = substr( $result, 5,  1 );
69     my $f6    = substr( $result, 6,  1 );
70     my $f7    = substr( $result, 7,  1 );
71     my $f8    = substr( $result, 8,  1 );
72     my $f17   = substr( $result, 17, 1 );
73     my $f18   = substr( $result, 18, 1 );
74     my $f19   = substr( $result, 19, 1 );
75     my $f2023 = substr( $result, 20, 4 );
76     $template->param(
77         index     => $index,
78         "f5$f5"   => 1,
79         "f6$f6"   => 1,
80         "f7$f7"   => 1,
81         "f8$f8"   => 1,
82         "f17$f17" => 1,
83         "f18$f18" => 1,
84         "f19$f19" => 1,
85         "f2023"   => $f2023,
86     );
87     output_html_with_http_headers $input, $cookie, $template->output;
88 };
89
90 return { builder => $builder, launcher => $launcher };