This will work in 2.2 now as well as 3.0
[koha.git] / catalogue / detail.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5 use C4::Auth;
6 use C4::Bull; #uses getsubscriptionfrom biblionumber
7 use C4::Interface::CGI::Output;
8 use HTML::Template;
9 use C4::Biblio;
10 use C4::SearchMarc;
11
12 my $query=new CGI;
13 my ($template, $borrowernumber, $cookie) 
14     = get_template_and_user({template_name => "catalogue/detail.tmpl",
15                              query => $query,
16                              type => "intranet",
17                              authnotrequired => 1,
18                              flagsrequired => {borrow => 1},
19                              });
20
21 my $biblionumber=$query->param('biblionumber');
22 if (!$biblionumber){
23     $biblionumber=$query->param('bib');
24     }
25 $template->param(biblionumber => $biblionumber);
26
27
28 # change back when ive fixed request.pl
29 my @items                                 = &ItemInfo(undef, $biblionumber, 'intra');
30 my $dat                                   = &bibdata($biblionumber);
31 my ($authorcount, $addauthor)             = &getaddauthor($biblionumber);
32 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
33 my ($websitecount, @websites)             = &getwebsites($biblionumber);
34 my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber);
35
36 $dat->{'count'}=@items;
37
38 $dat->{'additional'}=$addauthor->[0]->{'author'};
39 for (my $i = 1; $i < $authorcount; $i++) {
40         $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
41 } # for
42
43 my $norequests = 1;
44 foreach my $itm (@items) {
45     $norequests = 0 unless $itm->{'notforloan'};
46     $itm->{$itm->{'publictype'}} = 1;
47 }
48
49 $template->param(norequests => $norequests);
50
51   ## get notes and subjects from MARC record
52 my $marc = C4::Context->preference("marc");
53 if ($marc eq "yes") {
54         my $dbh = C4::Context->dbh;
55         my $marcflavour = C4::Context->preference("marcflavour");
56         my $marcnotesarray = &getMARCnotes($dbh,$biblionumber,$marcflavour);
57         my $marcsubjctsarray = &getMARCsubjects($dbh,$biblionumber,$marcflavour);
58
59         $template->param(MARCNOTES => $marcnotesarray);
60         $template->param(MARCSUBJCTS => $marcsubjctsarray);
61 }
62
63 my @results = ($dat,);
64
65 my $resultsarray=\@results;
66 my $itemsarray=\@items;
67 my $webarray=\@webbiblioitems;
68 my $sitearray=\@websites;
69
70 $template->param(BIBLIO_RESULTS => $resultsarray,
71                                 ITEM_RESULTS => $itemsarray,
72                                 WEB_RESULTS => $webarray,
73                                 SITE_RESULTS => $sitearray,
74                                 subscriptionsnumber => $subscriptionsnumber,
75 );
76
77 output_html_with_http_headers $query, $cookie, $template->output;