Resynching Savannah
[koha.git] / catalogue / detailprint.pl
1 #!/usr/bin/perl
2 # NOTE: Use standard 8-space tabs for this file (indents are 4 spaces)
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA  02111-1307 USA
20 use strict;
21 require Exporter;
22 use C4::Search;
23 use C4::Auth;
24 use C4::Serials; #uses getsubscriptionfrom biblionumber
25 use C4::Interface::CGI::Output;
26 use CGI;
27 use C4::Biblio;
28 use C4::Context;
29
30 my $dbh=C4::Context->dbh;
31 my $query=new CGI;
32 my ($template, $borrowernumber, $cookie) 
33     = get_template_and_user({template_name => "catalogue/detailprint.tmpl",
34                              query => $query,
35                              type => "intranet",
36                              authnotrequired => 1,
37                              flagsrequired => {borrow => 1},
38                              });
39
40 my $biblionumber=$query->param('biblionumber');
41 $template->param(biblionumber => $biblionumber);
42 my $retrieve_from=C4::Context->preference('retrieve_from');
43 my ($record,$frameworkcode);
44 my @itemrecords;
45 my @items;
46 if ($retrieve_from eq "zebra"){
47 ($record,@itemrecords)=ZEBRAgetrecord($biblionumber);
48 }else{
49  $record =XMLgetbiblio($dbh,$biblionumber);
50 $record=XML_xml2hash_onerecord($record);
51 my @itemxmls=XMLgetallitems($dbh,$biblionumber);
52         foreach my $itemrecord(@itemxmls){
53         my $itemhash=XML_xml2hash_onerecord($itemrecord);
54         push @itemrecords, $itemhash;
55         }
56 }       
57
58 my $dat = XMLmarc2koha_onerecord($dbh,$record,"biblios");
59 my $norequests = 1;
60 foreach my $itemrecord (@itemrecords){
61
62 my $item= XMLmarc2koha_onerecord($dbh,$itemrecord,"holdings");
63 $item=ItemInfo($dbh,$item);
64 $item->{itemtype}=$dat->{itemtype};
65   $norequests = 0 unless $item->{'notforloan'};
66    $item->{$item->{'publictype'}} = 1; ## NOT sure what this is kept from old db probably useless now
67 push @items,$item;
68 }
69
70 my $subscriptionsnumber = GetSubscriptionsFromBiblionumber($biblionumber);
71
72 $dat->{'count'}=@items;
73 $template->param(count =>$dat->{'count'});
74 $template->param(norequests => $norequests);
75
76   ## get notes subjects and URLS from MARC record
77         
78         my $marcflavour = C4::Context->preference("marcflavour");
79         my $marcnotesarray = &getMARCnotes($dbh,$record,$marcflavour);
80         my $marcsubjctsarray = &getMARCsubjects($dbh,$record,$marcflavour);
81         my $marcurlssarray = &getMARCurls($dbh,$record,$marcflavour);
82         $template->param(MARCURLS => $marcurlssarray);
83         $template->param(MARCNOTES => $marcnotesarray);
84         $template->param(MARCSUBJCTS => $marcsubjctsarray);
85
86
87 my @results = ($dat,);
88
89 my $resultsarray=\@results;
90 my $itemsarray=\@items;
91
92
93 $template->param(BIBLIO_RESULTS => $resultsarray,
94                                 ITEM_RESULTS => $itemsarray,
95                                 subscriptionsnumber => $subscriptionsnumber,
96 );
97
98 output_html_with_http_headers $query, $cookie, $template->output;