small bugfixes
[koha_fer] / 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 use HTML::Template;
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,$morethan,$begin_tabloop) = @_;
48 my $index2; # the resulting index
49 my $i;          # counter
50 # loop to find 700$a subfield. We look for the 1st after $i
51 for (my $tabloop = $begin_tabloop; $tabloop<=9;$tabloop++) {
52         my @loop_data =();
53         foreach my $tag (keys %{$tagslib}) {
54 # loop through each subfield
55                 foreach my $subfield (keys %{$tagslib->{$tag}}) {
56                         next if ($subfield eq 'lib'); # skip lib and tabs, which are koha internal
57                         next if ($subfield eq 'tab');
58                         next if ($tagslib->{$tag}->{$subfield}->{tab}  ne $tabloop);
59                         if ($tag eq '700' && $subfield eq 'a' && $i>$morethan) {
60                                 $index2 = $i;
61                         }
62                         $i++;
63                 }
64         }
65 }
66 #       my $index2=6;
67         return "&index2=$index2";
68 }
69
70 sub plugin_javascript {
71 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
72 return ("","");
73 }
74
75 sub plugin {
76 my ($input) = @_;
77         my %env;
78
79 #       my $input = new CGI;
80         my $index= $input->param('index');
81         my $index2= $input->param('index2');
82         $index2=-1 unless($index2);
83         my $result= $input->param('result');
84
85
86         my $dbh = C4::Context->dbh;
87
88         my ($template, $loggedinuser, $cookie)
89         = get_template_and_user({template_name => "value_builder/unimarc_field_700-4.tmpl",
90                                         query => $input,
91                                         type => "intranet",
92                                         authnotrequired => 0,
93                                         flagsrequired => {parameters => 1},
94                                         debug => 1,
95                                         });
96         $template->param(index => $index,
97                                                         index2 => $index2,
98                                                         "f1_$result" => "f1_".$result,
99                                                         );
100         print $input->header(-cookie => $cookie),$template->output;
101 }
102
103 1;