(bug #3458) fix die and unimarc 700-4 plugin
[koha.git] / cataloguing / value_builder / unimarc_field_700-4.pl
1 #!/usr/bin/perl
2
3 # written 10/5/2002 by Paul
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 under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 use strict;
23 use C4::Auth;
24 use CGI;
25 use C4::Context;
26
27 use C4::Search;
28 use C4::Output;
29
30 =head1 NAME
31
32 plugin unimarc_field_700-4
33
34 =head1 SYNOPSIS
35
36 This plug-in deals with unimarc field 700-4 (
37
38 =head1 DESCRIPTION
39
40 =head1 FUNCTIONS
41
42 =over 2
43
44 =cut
45
46 sub plugin_parameters {
47 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
48 return "";
49 }
50
51 sub plugin_javascript {
52 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
53 my $function_name= $field_number;
54 my $res  = "
55 <script>
56 function Focus$function_name(index) {
57         return 1;
58 }
59
60 function Blur$function_name(subfield_managed) {
61         return 1;
62 }
63
64 function Clic$function_name(subfield_managed) {
65         defaultvalue=document.getElementById(\"$field_number\").value;
66         newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_700-4.pl&result=\"+defaultvalue+\"&index=$field_number\",\"value builder\",'width=500,height=400,toolbar=false,scrollbars=yes');
67
68 }
69 </script>
70 ";
71
72 return ($function_name,$res);
73 }
74
75 sub plugin {
76 my ($input) = @_;
77         my $index= $input->param('index');
78         my $index2= $input->param('index2');
79         $index2=-1 unless($index2);
80         my $result= $input->param('result');
81
82
83         my $dbh = C4::Context->dbh;
84
85         my ($template, $loggedinuser, $cookie)
86         = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_700-4.tmpl",
87                                         query => $input,
88                                         type => "intranet",
89                                         authnotrequired => 0,
90                                         flagsrequired => {editcatalogue => 1},
91                                         debug => 1,
92                                         });
93         $template->param(index => $index,
94                                                         index2 => $index2,
95                                                         "f1_$result" => "f1_".$result,
96                                                         );
97         output_html_with_http_headers $input, $cookie, $template->output;
98 }
99
100 1;