Bug 5448: Refactor Boolean.pm
[koha.git] / cataloguing / value_builder / marc21_field_006.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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 use strict;
21 #use warnings; FIXME - Bug 2505
22 use C4::Auth;
23 use CGI;
24 use C4::Context;
25
26 use C4::Search;
27 use C4::Output;
28
29 =head1 DESCRIPTION
30
31 plugin_parameters : other parameters added when the plugin is called by the dopop function
32
33 =cut
34
35 sub plugin_parameters {
36     my ($dbh, $record, $tagslib, $i, $tabloop) = @_;
37     return "";
38 }
39
40 sub plugin_javascript {
41     my ($dbh, $record, $tagslib, $field_number, $tabloop) = @_;
42     my $function_name = $field_number;
43     my $res           = "
44 <script type=\"text/javascript\">
45 //<![CDATA[
46
47 function Focus$function_name(subfield_managed) {
48 return 1;
49 }
50
51 function Blur$function_name(subfield_managed) {
52         return 1;
53 }
54
55 function Clic$function_name(i) {
56         defaultvalue=document.getElementById(\"$field_number\").value;
57         newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=marc21_field_006.pl&index=$field_number&result=\"+defaultvalue,\"tag_editor\",'width=1000,height=600,toolbar=false,scrollbars=yes');
58
59 }
60 //]]>
61 </script>
62 ";
63
64     return ($function_name, $res);
65 }
66
67 sub plugin {
68     my ($input) = @_;
69     my $index   = $input->param('index');
70     my $result  = $input->param('result');
71
72     my $dbh = C4::Context->dbh;
73
74     my ($template, $loggedinuser, $cookie) = get_template_and_user(
75         {   template_name   => "cataloguing/value_builder/marc21_field_006.tmpl",
76             query           => $input,
77             type            => "intranet",
78             authnotrequired => 0,
79             flagsrequired   => { editcatalogue => '*' },
80             debug           => 1,
81         }
82     );
83     $result = "a|||||r|||| 00| 0 " unless $result;
84
85     #   $result = "a     r     00  0 " unless $result;
86     my $f0   = substr($result, 0,  1);
87     my $f014 = substr($result, 1,  4);
88     my $f5   = substr($result, 5,  1);
89     my $f6   = substr($result, 6,  1);
90     my $f710 = substr($result, 7,  4);
91     my $f11  = substr($result, 11, 1);
92     my $f12  = substr($result, 12, 1);
93     my $f13  = substr($result, 13, 1);
94     my $f14  = substr($result, 14, 1);
95     my $f15  = substr($result, 15, 1);
96     my $f16  = substr($result, 16, 1);
97     my $f17  = substr($result, 17, 1);
98
99     $template->param(
100         index       => $index,
101         f0          => $f0,
102         "f0$f0"     => $f0,
103         f014        => $f014,
104         "f014$f014" => $f014,
105         f5          => $f5,
106         "f5$f5"     => $f5,
107         f6          => $f6,
108         "f6$f6"     => $f6,
109         f710        => $f710,
110         "f710$f710" => $f710,
111         f11         => $f11,
112         "f11$f11"   => $f11,
113         f12         => $f12,
114         "f12$f12"   => $f12,
115         f13         => $f13,
116         "f13$f13"   => $f13,
117         f14         => $f14,
118         "f14$f14"   => $f14,
119         f15         => $f15,
120         "f15$f15"   => $f15,
121         f16         => $f16,
122         "f16$f16"   => $f16,
123         f17         => $f17,
124         "f17$f17"   => $f17,
125     );
126     output_html_with_http_headers $input, $cookie, $template->output;
127 }
128
129 1;