Bug 5670: Add a confirmation message on delete
[koha.git] / opac / opac-ISBDdetail.pl
blob357f2f851d499d07ee9f8340e826ac8c998d9bbb
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
4 # parts copyright 2010 BibLibre
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 =head1 NAME
24 opac-ISBDdetail.pl - script to show a biblio in ISBD format
26 =head1 DESCRIPTION
28 This script needs a biblionumber as parameter
30 It shows the biblio
32 The template is in <templates_dir>/catalogue/ISBDdetail.tt.
33 this template must be divided into 11 "tabs".
35 The first 10 tabs present the biblio, the 11th one presents
36 the items attached to the biblio
38 =head1 FUNCTIONS
40 =cut
42 use Modern::Perl;
44 use C4::Auth;
45 use C4::Context;
46 use C4::Output;
47 use CGI qw ( -utf8 );
48 use MARC::Record;
49 use C4::Biblio;
50 use C4::Items;
51 use C4::Reserves;
52 use C4::Acquisition;
53 use C4::Serials; # uses getsubscriptionfrom biblionumber
54 use C4::Koha;
55 use C4::Members; # GetMember
56 use Koha::RecordProcessor;
59 my $query = CGI->new();
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62 template_name => "opac-ISBDdetail.tt",
63 query => $query,
64 type => "opac",
65 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
66 debug => 1,
70 my $biblionumber = $query->param('biblionumber');
71 $biblionumber = int($biblionumber);
73 # get biblionumbers stored in the cart
74 if(my $cart_list = $query->cookie("bib_list")){
75 my @cart_list = split(/\//, $cart_list);
76 if ( grep {$_ eq $biblionumber} @cart_list) {
77 $template->param( incart => 1 );
81 $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
83 my $marcflavour = C4::Context->preference("marcflavour");
85 my @items = GetItemsInfo($biblionumber);
86 if (scalar @items >= 1) {
87 my @hiddenitems = GetHiddenItemnumbers(@items);
89 if (scalar @hiddenitems == scalar @items ) {
90 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
91 exit;
95 my $record = GetMarcBiblio($biblionumber,1);
96 if ( ! $record ) {
97 print $query->redirect("/cgi-bin/koha/errors/404.pl");
98 exit;
100 my $framework = GetFrameworkCode( $biblionumber );
101 my $record_processor = Koha::RecordProcessor->new({
102 filters => 'ViewPolicy',
103 options => {
104 interface => 'opac',
105 frameworkcode => $framework
108 $record_processor->process($record);
110 # some useful variables for enhanced content;
111 # in each case, we're grabbing the first value we find in
112 # the record and normalizing it
113 my $upc = GetNormalizedUPC($record,$marcflavour);
114 my $ean = GetNormalizedEAN($record,$marcflavour);
115 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
116 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
117 my $content_identifier_exists;
118 if ( $isbn or $ean or $oclc or $upc ) {
119 $content_identifier_exists = 1;
121 $template->param(
122 normalized_upc => $upc,
123 normalized_ean => $ean,
124 normalized_oclc => $oclc,
125 normalized_isbn => $isbn,
126 content_identifier_exists => $content_identifier_exists,
129 #coping with subscriptions
130 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
131 my $dbh = C4::Context->dbh;
132 my $dat = TransformMarcToKoha( $record );
134 my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
135 my @subs;
136 foreach my $subscription (@subscriptions) {
137 my %cell;
138 my $serials_to_display;
139 $cell{subscriptionid} = $subscription->{subscriptionid};
140 $cell{subscriptionnotes} = $subscription->{notes};
141 $cell{branchcode} = $subscription->{branchcode};
143 #get the three latest serials.
144 $serials_to_display = $subscription->{opacdisplaycount};
145 $serials_to_display = C4::Context->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
146 $cell{opacdisplaycount} = $serials_to_display;
147 $cell{latestserials} =
148 GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display );
149 push @subs, \%cell;
152 $template->param(
153 subscriptions => \@subs,
154 subscriptionsnumber => $subscriptionsnumber,
157 my $norequests = 1;
158 my $allow_onshelf_holds;
159 my $res = GetISBDView({
160 'record' => $record,
161 'template' => 'opac',
162 'framework' => $framework
165 my $itemtypes = GetItemTypes();
166 my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
167 for my $itm (@items) {
168 $norequests = 0
169 if $norequests
170 && !$itm->{'withdrawn'}
171 && !$itm->{'itemlost'}
172 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'})
173 && !$itemtypes->{$itm->{'itype'}}->{notforloan}
174 && $itm->{'itemnumber'};
176 $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower)
177 unless $allow_onshelf_holds;
180 $template->param(
181 RequestOnOpac => C4::Context->preference("RequestOnOpac"),
182 AllowOnShelfHolds => $allow_onshelf_holds,
183 norequests => $norequests,
184 ISBD => $res,
185 biblionumber => $biblionumber,
188 #Search for title in links
189 my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
190 my $marcissns = GetMarcISSN ( $record, $marcflavour );
191 my $issn = $marcissns->[0] || '';
193 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
194 $dat->{title} =~ s/\/+$//; # remove trailing slash
195 $dat->{title} =~ s/\s+$//; # remove trailing space
196 $search_for_title = parametrized_url(
197 $search_for_title,
199 TITLE => $dat->{title},
200 AUTHOR => $dat->{author},
201 ISBN => $isbn,
202 ISSN => $issn,
203 CONTROLNUMBER => $marccontrolnumber,
204 BIBLIONUMBER => $biblionumber,
207 $template->param('OPACSearchForTitleIn' => $search_for_title);
210 output_html_with_http_headers $query, $cookie, $template->output;