plugin rewrited to works with addbiblio.
[koha.git] / cataloguing / value_builder / marc21_field_007.pl
1
2 #!/usr/bin/perl
3
4 # $Id$
5
6 # Copyright 2000-2002 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 use strict;
24 use C4::Auth;
25 use CGI;
26 use C4::Context;
27
28 use C4::Search;
29 use C4::Output;
30
31 =head1
32
33 plugin_parameters : other parameters added when the plugin is called by the dopop function
34
35 =cut
36
37 sub plugin_parameters {
38 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
39 return "";
40 }
41
42 sub plugin_javascript {
43 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
44 my $function_name= $field_number;
45 my $res="
46 <script>
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(\"plugin_launcher.pl?plugin_name=marc21_field_007.pl&index=$field_number&result=\"+defaultvalue,\"unimarc field 100\",'width=1000,height=600,toolbar=false,scrollbars=yes');
58
59 }
60 </script>
61 ";
62
63 return ($function_name,$res);
64 }
65 sub plugin {
66 my ($input) = @_;
67         my $index= $input->param('index');
68         my $result= $input->param('result');
69
70
71         my $dbh = C4::Context->dbh;
72
73 my ($template, $loggedinuser, $cookie)
74     = get_template_and_user({template_name => "value_builder/marc21_field_007.tmpl",
75                              query => $input,
76                              type => "intranet",
77                              authnotrequired => 0,
78                              flagsrequired => {editcatalogue => 1},
79                              debug => 1,
80                              });
81         $result = "ta" unless $result;
82         my $f0 = substr($result,0,1);
83         my $f1 = substr($result,1,4);
84
85         $template->param(                               index => $index,
86                                                         f0 => $f0,
87                                                         "f0$f0" => $f0,
88                                                         f1 => $f1,
89                                                         "f1$f1" => $f1,
90                                         );
91         output_html_with_http_headers $input, $cookie, $template->output;
92 }
93
94 1;