Replaced expressions of the form "$x = $x <op> $y" with "$x <op>= $y".
[koha.git] / marc / MARCdetail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 use HTML::Template;
22 require Exporter;       # FIXME - Is this really necessary?
23 use C4::Context;
24 use C4::Output;  # contains gettemplate
25 use CGI;
26 use C4::Search;
27 use MARC::Record;
28 use C4::Biblio;
29 use C4::Catalogue;
30
31 my $query=new CGI;
32
33 my $biblionumber=$query->param('bib');
34 my $tag=$query->param('tag');
35 if (! defined $tag) { $tag='2XX';}
36 #print STDERR "BIB : $biblionumber // TAG : $tag\n";
37 if (! defined $biblionumber) {
38     my $template = gettemplate("MARCdetailbiblioselect.tmpl");
39     print "Content-Type: text/html\n\n", $template->output;
40
41 } else {
42     &showmarcrecord($biblionumber,$tag);
43 }
44
45 sub showmarcrecord {
46     my ($biblionumber,$tag) = @_;
47     my $dbh = C4::Context->dbh;
48     my $sth=$dbh->prepare("select liblibrarian from marc_subfield_structure where tagfield=? and tagsubfield=?");
49     my $record =MARCgetbiblio($dbh,$biblionumber);
50 # open template
51     my $template = gettemplate("MARCdetail.tmpl");
52 # fill arrays
53     my @loop_data =();
54     my @fields = $record->field($tag);
55     foreach my $field (@fields) {
56         my @subf=$field->subfields;
57         for my $i (0..$#subf) {
58             $sth->execute($field->tag(), $subf[$i][0]);
59             my $row=$sth->fetchrow_hashref;
60             my %row_data;
61             $row_data{marc_lib}=$row->{'liblibrarian'};
62             $row_data{marc_value}=$subf[$i][1];
63             $row_data{marc_tag}=$field->tag().$subf[$i][0];
64             push(@loop_data, \%row_data);
65 #           print $field->tag(), " ", $field->indicator(1),$field->indicator(2), "subf: ", $subf[$i][0]," =",$subf[$i][1]," <-- \n";
66         }
67     }
68
69 # fill template with arrays
70     $template->param(biblionumber => $biblionumber);
71     $template->param(marc =>\@loop_data);
72     print "Content-Type: text/html\n\n", $template->output;
73
74 }