ISBD in librarian interface
[koha.git] / ISBDdetail.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 =head1 NAME
21
22 ISBDdetail.pl : script to show a biblio in ISBD format
23
24 =head1 SYNOPSIS
25
26
27 =head1 DESCRIPTION
28
29 This script needs a biblionumber in bib parameter (bibnumber
30 from koha style DB.  Automaticaly maps to marc biblionumber).
31
32 =head1 FUNCTIONS
33
34 =over 2
35
36 =cut
37
38
39 use strict;
40 require Exporter;
41 use C4::Auth;
42 use C4::Context;
43 use C4::Output;
44 use C4::Interface::CGI::Output;
45 use CGI;
46 use C4::Search;
47 use MARC::Record;
48 use C4::Biblio;
49 use C4::Catalogue;
50 use HTML::Template;
51
52 my $query=new CGI;
53
54 my $dbh=C4::Context->dbh;
55
56 my $biblionumber=$query->param('bib');
57 my $bibid = $query->param('bibid');
58 $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
59 $biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
60 my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
61 my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
62
63 my $record =MARCgetbiblio($dbh,$bibid);
64 # open template
65 my ($template, $loggedinuser, $cookie)
66                 = get_template_and_user({template_name => "catalogue/ISBDdetail.tmpl",
67                              query => $query,
68                              type => "intranet",
69                              authnotrequired => 1,
70                              debug => 1,
71                              });
72
73 my $ISBD = C4::Context->preference('ISBD');
74 my @fields = $record->fields();
75 foreach my $field (@fields) {
76         my $tag = $field->tag();
77         if ($tag<10) {
78         } else {
79                 my @subf = $field->subfields;
80                 for my $i (0..$#subf) {
81                         my $subfieldcode = $subf[$i][0];
82                         my $subfieldvalue = $subf[$i][1];
83                         my $tagsubf = $tag.$subfieldcode;
84                         $ISBD =~ s/\[(.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue\[$1$tagsubf$2]$2$3/g;
85                 }
86         }
87 }
88 $ISBD =~ s/\[(.*?)]//g;
89 $ISBD =~ s/\n/<br>/g;
90 $template->param(ISBD => $ISBD,
91                                 biblionumber => $biblionumber);
92
93 output_html_with_http_headers $query, $cookie, $template->output;
94