rel_3_0 moved to HEAD
[koha.git] / catalogue / detail.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18 # $Id$
19
20 use strict;
21 require Exporter;
22 use CGI;
23 use C4::Auth;
24 use C4::Serials;    #uses getsubscriptionfrom biblionumber
25 use C4::Interface::CGI::Output;
26 use C4::Biblio;
27 use C4::Serials;
28
29 my $query = new CGI;
30 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
31     {
32         template_name   => "catalogue/detail.tmpl",
33         query           => $query,
34         type            => "intranet",
35         authnotrequired => 0,
36         flagsrequired   => { catalogue => 1 },
37     }
38 );
39
40 my $biblionumber = $query->param('biblionumber');
41
42 # change back when ive fixed request.pl
43 my @items = &GetItemsInfo( $biblionumber, 'intra' );
44 my $dat = &GetBiblioData($biblionumber);
45 #coping with subscriptions
46 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
47 my @subscriptions       = GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
48
49 my @subs;
50 foreach my $subscription (@subscriptions) {
51     my %cell;
52     $cell{subscriptionid}    = $subscription->{subscriptionid};
53     $cell{subscriptionnotes} = $subscription->{notes};
54
55     #get the three latest serials.
56     $cell{latestserials} =
57       GetLatestSerials( $subscription->{subscriptionid}, 3 );
58     push @subs, \%cell;
59 }
60
61 $dat->{'count'} = @items;
62
63 my $norequests = 1;
64 foreach my $itm (@items) {
65     $norequests = 0
66       unless ( ( $itm->{'notforloan'} > 0 )
67         || ( $itm->{'itemnotforloan'} > 0 ) );
68     $itm->{ $itm->{'publictype'} } = 1;
69 }
70
71 $template->param( norequests => $norequests );
72
73 ## get notes and subjects from MARC record
74     my $dbh              = C4::Context->dbh;
75     my $marcflavour      = C4::Context->preference("marcflavour");
76     my $record           = GetMarcBiblio($biblionumber);
77     my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
78     my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
79     my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
80
81     $template->param(
82         MARCNOTES   => $marcnotesarray,
83         MARCSUBJCTS => $marcsubjctsarray,
84         MARCAUTHORS => $marcauthorsarray
85     );
86
87 my @results = ( $dat, );
88 foreach ( keys %{$dat} ) {
89     $template->param( "$_" => $dat->{$_} . "" );
90 }
91
92 $template->param(
93     ITEM_RESULTS        => \@items,
94     biblionumber        => $biblionumber,
95     subscriptions       => \@subs,
96     subscriptionsnumber => $subscriptionsnumber,
97     subscriptiontitle   => $dat->{title},
98 );
99
100 output_html_with_http_headers $query, $cookie, $template->output;