Bug 13437: Perltidy some plugin files before conversion
[koha.git] / cataloguing / value_builder / marc21_field_007.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
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 use strict;
21
22 #use warnings; FIXME - Bug 2505
23 use C4::Auth;
24 use CGI qw ( -utf8 );
25 use C4::Context;
26
27 use C4::Search;
28 use C4::Output;
29
30 =head1 DESCRIPTION
31
32 plugin_parameters : other parameters added when the plugin is called by the dopop function
33
34 =cut
35
36 sub plugin_javascript {
37     my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
38     my $function_name = $field_number;
39     my $res           = "
40 <script type=\"text/javascript\">
41 //<![CDATA[
42
43 function Clic$function_name(i) {
44         defaultvalue=document.getElementById(\"$field_number\").value;
45         newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_007.pl&index=$field_number&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
46
47 }
48 //]]>
49 </script>
50 ";
51
52     return ( $function_name, $res );
53 }
54
55 sub plugin {
56     my ($input) = @_;
57     my $index   = $input->param('index');
58     my $result  = $input->param('result');
59
60     my $dbh = C4::Context->dbh;
61
62     my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
63         {   template_name   => "cataloguing/value_builder/marc21_field_007.tt",
64             query           => $input,
65             type            => "intranet",
66             authnotrequired => 0,
67             flagsrequired   => { editcatalogue => '*' },
68             debug           => 1,
69         }
70     );
71     $result = "ta" unless $result;
72     my $f0 = substr( $result, 0, 1 );
73     my $f1 = substr( $result, 1, 1 );
74
75     #added new parameters to allow for all material types
76     my $f2  = substr( $result, 2,  1 );
77     my $f3  = substr( $result, 3,  1 );
78     my $f4  = substr( $result, 4,  1 );
79     my $f5  = substr( $result, 5,  1 );
80     my $f6  = substr( $result, 6,  1 );
81     my $f7  = substr( $result, 7,  1 );
82     my $f8  = substr( $result, 8,  1 );
83     my $f9  = substr( $result, 9,  1 );
84     my $f10 = substr( $result, 10, 1 );
85     my $f11 = substr( $result, 11, 1 );
86     my $f12 = substr( $result, 12, 1 );
87     my $f13 = substr( $result, 13, 1 );
88     my $f14 = substr( $result, 14, 1 );
89     my $f15 = substr( $result, 15, 1 );
90     my $f16 = substr( $result, 16, 1 );
91     my $f17 = substr( $result, 17, 1 );
92     my $f18 = substr( $result, 18, 1 );
93     my $f19 = substr( $result, 19, 1 );
94     my $f20 = substr( $result, 20, 1 );
95     my $f21 = substr( $result, 21, 1 );
96     my $f22 = substr( $result, 22, 1 );
97
98     #FIXME:  There is probably a more-elegant way to do this!
99     #FIXME:  Two of the material types treat position 06, 07, and 08 as a single
100     #three-char field.  This script works fine for creating values and sending them
101     #back to the MARC, but if there is already a value in the 007, it won't send
102     #it properly to the value builder for those two instances.  Not sure how to solve.
103     $template->param(
104         index     => $index,
105         f0        => $f0,
106         "f0$f0"   => $f0,
107         f1        => $f1,
108         "f1$f1"   => $f1,
109         f2        => $f2,
110         "f2$f2"   => $f2,
111         f3        => $f3,
112         "f3$f3"   => $f3,
113         f4        => $f4,
114         "f4$f4"   => $f4,
115         f5        => $f5,
116         "f5$f5"   => $f5,
117         f6        => $f6,
118         "f6$f6"   => $f6,
119         f7        => $f7,
120         "f7$f7"   => $f7,
121         f8        => $f8,
122         "f8$f8"   => $f8,
123         f9        => $f9,
124         "f9$f9"   => $f9,
125         f10       => $f10,
126         "f10$f10" => $f10,
127         f11       => $f11,
128         "f11$f11" => $f11,
129         f12       => $f12,
130         "f12$f12" => $f12,
131         f13       => $f13,
132         "f13$f13" => $f13,
133         f14       => $f14,
134         "f14$f14" => $f14,
135         f15       => $f15,
136         "f15$f15" => $f15,
137         f16       => $f16,
138         "f16$f16" => $f16,
139         f17       => $f17,
140         "f17$f17" => $f17,
141         f18       => $f18,
142         "f18$f18" => $f18,
143         f19       => $f19,
144         "f19$f19" => $f19,
145         f20       => $f20,
146         "f20$f20" => $f20,
147         f21       => $f21,
148         "f21$f21" => $f21,
149         f22       => $f22,
150         "f22$f22" => $f22,
151     );
152     output_html_with_http_headers $input, $cookie, $template->output;
153 }