Bug 9823: Refactor return from GetReservesFromBiblionumber
[koha.git] / catalogue / ISBDdetail.pl
blobdd1c5c8763892fa015ff5215658a136b1f9f06df
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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.
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.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 =head1 NAME
22 ISBDdetail.pl : script to show a biblio in ISBD format
24 =head1 SYNOPSIS
26 =cut
28 =head1 DESCRIPTION
30 This script needs a biblionumber as parameter
32 =head1 FUNCTIONS
34 =cut
36 use strict;
37 #use warnings; FIXME - Bug 2505
39 use C4::Auth;
40 use C4::Context;
41 use C4::Output;
42 use CGI;
43 use C4::Koha;
44 use C4::Biblio;
45 use C4::Items;
46 use C4::Members; # to use GetMember
47 use C4::Branch; # GetBranchDetail
48 use C4::Serials; # CountSubscriptionFromBiblionumber
49 use C4::Search; # enabled_staff_search_views
51 #---- Internal function
54 my $query = new CGI;
55 my $dbh = C4::Context->dbh;
57 my $biblionumber = $query->param('biblionumber');
59 # open template
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62 template_name => "catalogue/ISBDdetail.tmpl",
63 query => $query,
64 type => "intranet",
65 authnotrequired => 0,
66 flagsrequired => { catalogue => 1 },
70 my $res = GetISBDView($biblionumber, "intranet");
71 if ( not defined $res ) {
72 # biblionumber invalid -> report and exit
73 $template->param( unknownbiblionumber => 1,
74 biblionumber => $biblionumber
76 output_html_with_http_headers $query, $cookie, $template->output;
77 exit;
80 if($query->cookie("holdfor")){
81 my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
82 $template->param(
83 holdfor => $query->cookie("holdfor"),
84 holdfor_surname => $holdfor_patron->{'surname'},
85 holdfor_firstname => $holdfor_patron->{'firstname'},
86 holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
90 # count of item linked with biblio
91 my $itemcount = GetItemsCount($biblionumber);
92 $template->param( count => $itemcount);
93 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
95 if ($subscriptionsnumber) {
96 my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
97 my $subscriptiontitle = $subscriptions->[0]{'bibliotitle'};
98 $template->param(
99 subscriptionsnumber => $subscriptionsnumber,
100 subscriptiontitle => $subscriptiontitle,
103 my $record = GetMarcBiblio($biblionumber);
105 $template->param (
106 ISBD => $res,
107 biblionumber => $biblionumber,
108 isbdview => 1,
109 z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)),
110 ocoins => GetCOinSBiblio($record),
111 C4::Search::enabled_staff_search_views,
112 searchid => $query->param('searchid'),
116 my $holds = C4::Reserves::GetReservesFromBiblionumber({ biblionumber => $biblionumber, all_dates => 1 });
117 my $holdcount = scalar( @$holds );
118 $template->param( holdcount => $holdcount, holds => $holds );
120 output_html_with_http_headers $query, $cookie, $template->output;