Bug 10480: Follow-up for unimarc_field_686a/_700-4.pl
[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
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22 use strict;
23 #use warnings; FIXME - Bug 2505
24 use C4::Auth;
25 use CGI qw ( -utf8 );
26 use C4::Context;
27
28 use C4::Search;
29 use C4::Output;
30
31 sub plugin_javascript {
32 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
33 my $function_name= $field_number;
34 my $res  = "
35 <script>
36 function Clic$function_name(subfield_managed) {
37         defaultvalue=document.getElementById(\"$field_number\").value;
38         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');
39
40 }
41 </script>
42 ";
43
44 return ($function_name,$res);
45 }
46
47 sub plugin {
48 my ($input) = @_;
49         my $index= $input->param('index');
50         my $index2= $input->param('index2');
51         $index2=-1 unless($index2);
52         my $result= $input->param('result');
53
54
55         my $dbh = C4::Context->dbh;
56
57     my ($template, $loggedinuser, $cookie) = get_template_and_user(
58         {
59             template_name   => "cataloguing/value_builder/unimarc_field_700-4.tt",
60             query           => $input,
61             type            => "intranet",
62             authnotrequired => 0,
63             flagsrequired   => { editcatalogue => '*' },
64             debug           => 1,
65         }
66     );
67         $template->param(index => $index,
68                                                         index2 => $index2,
69                                                         "f1_$result" => "f1_".$result,
70                                                         );
71         output_html_with_http_headers $input, $cookie, $template->output;
72 }