new and modified plugins for unimarc biblio management.
[koha.git] / 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 CGI;
24 use C4::Context;
25 use HTML::Template;
26 use C4::Search;
27 use C4::Output;
28
29 =head1 NAME
30
31 plugin unimarc_field_700-4
32
33 =head1 SYNOPSIS
34
35 This plug-in deals with unimarc field 700-4 (
36
37 =head1 DESCRIPTION
38
39 =head1 FUNCTIONS
40
41 =over 2
42
43 =cut
44
45 sub plugin_parameters {
46 my ($dbh,$record,$tagslib,$morethan,$begin_tabloop) = @_;
47 my $index2; # the resulting index
48 my $i;          # counter
49 # loop to find 700$a subfield. We look for the 1st after $i
50 for (my $tabloop = $begin_tabloop; $tabloop<=9;$tabloop++) {
51         my @loop_data =();
52         foreach my $tag (keys %{$tagslib}) {
53 # loop through each subfield
54                 foreach my $subfield (keys %{$tagslib->{$tag}}) {
55                         next if ($subfield eq 'lib'); # skip lib and tabs, which are koha internal
56                         next if ($subfield eq 'tab');
57                         next if ($tagslib->{$tag}->{$subfield}->{tab}  ne $tabloop);
58                         if ($tag eq '700' && $subfield eq 'a' && $i>$morethan) {
59                                 $index2 = $i;
60                         }
61                         $i++;
62                 }
63         }
64 }
65 #       my $index2=6;
66         return "&index2=$index2";
67 }
68
69 sub plugin_javascript {
70 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
71 return ("","");
72 }
73
74 sub plugin {
75 my ($input) = @_;
76         my %env;
77
78 #       my $input = new CGI;
79         my $index= $input->param('index');
80         my $index2= $input->param('index2');
81         $index2=-1 unless($index2);
82         my $result= $input->param('result');
83
84
85         my $dbh = C4::Context->dbh;
86
87         my $template = gettemplate("value_builder/unimarc_field_700-4.tmpl",0);
88         $template->param(index => $index,
89                                                         index2 => $index2,
90                                                         "f1_$result" => "f1_".$result,
91                                                         );
92         print "Content-Type: text/html\n\n", $template->output;
93 }
94
95 1;