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>.
24 opac-ISBDdetail.pl - script to show a biblio in ISBD format
28 This script needs a biblionumber as parameter
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
52 use C4
::Serials
; # uses getsubscriptionfrom biblionumber
54 use Koha
::CirculationRules
;
57 use Koha
::RecordProcessor
;
60 my $query = CGI
->new();
61 my $biblionumber = $query->param('biblionumber');
63 $biblio = Koha
::Biblios
->find( $biblionumber, { prefetch
=> [ 'metadata', 'items' ] } ) if $biblionumber;
65 print $query->redirect('/cgi-bin/koha/errors/404.pl');
70 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
72 template_name
=> "opac-ISBDdetail.tt",
75 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
80 my $patron = Koha
::Patrons
->find($loggedinuser);
82 my $opachiddenitems_rules;
84 my $yaml = C4
::Context
->preference('OpacHiddenItems') . "\n\n";
85 $opachiddenitems_rules = YAML
::Load
($yaml);
88 unless ( $patron and $patron->category->override_hidden_items ) {
89 # only skip this check if there's a logged in user
90 # and its category overrides OpacHiddenItems
91 if ( $biblio->hidden_in_opac({ rules
=> $opachiddenitems_rules }) ) {
92 print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
97 my $record = $biblio->metadata->record;
98 my $marcflavour = C4
::Context
->preference("marcflavour");
100 my $record_processor = Koha
::RecordProcessor
->new({
101 filters
=> 'ViewPolicy',
104 frameworkcode
=> $biblio->frameworkcode
107 $record_processor->process($record);
109 # get biblionumbers stored in the cart
110 if(my $cart_list = $query->cookie("bib_list")){
111 my @cart_list = split(/\//, $cart_list);
112 if ( grep {$_ eq $biblionumber} @cart_list) {
113 $template->param( incart
=> 1 );
117 # some useful variables for enhanced content;
118 # in each case, we're grabbing the first value we find in
119 # the record and normalizing it
120 my $upc = GetNormalizedUPC
( $record, $marcflavour );
121 my $ean = GetNormalizedEAN
( $record, $marcflavour );
122 my $oclc = GetNormalizedOCLCNumber
( $record, $marcflavour );
123 my $isbn = GetNormalizedISBN
( undef, $record, $marcflavour );
124 my $content_identifier_exists;
125 if ( $isbn or $ean or $oclc or $upc ) {
126 $content_identifier_exists = 1;
129 normalized_upc
=> $upc,
130 normalized_ean
=> $ean,
131 normalized_oclc
=> $oclc,
132 normalized_isbn
=> $isbn,
133 content_identifier_exists
=> $content_identifier_exists,
136 #coping with subscriptions
137 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
138 my $dat = TransformMarcToKoha
( $record );
140 my @subscriptions = SearchSubscriptions
({ biblionumber
=> $biblionumber, orderby
=> 'title' });
142 foreach my $subscription (@subscriptions) {
144 my $serials_to_display;
145 $cell{subscriptionid
} = $subscription->{subscriptionid
};
146 $cell{subscriptionnotes
} = $subscription->{notes
};
147 $cell{branchcode
} = $subscription->{branchcode
};
149 #get the three latest serials.
150 $serials_to_display = $subscription->{opacdisplaycount
};
151 $serials_to_display = C4
::Context
->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
152 $cell{opacdisplaycount
} = $serials_to_display;
153 $cell{latestserials
} =
154 GetLatestSerials
( $subscription->{subscriptionid
}, $serials_to_display );
159 subscriptions
=> \
@subs,
160 subscriptionsnumber
=> $subscriptionsnumber,
164 my $allow_onshelf_holds;
165 my $res = GetISBDView
({
167 'template' => 'opac',
168 'framework' => $biblio->frameworkcode
171 my $items = $biblio->items;
172 while ( my $item = $items->next ) {
177 && ($item->notforloan < 0 || not $item->notforloan )
178 && !Koha
::ItemTypes
->find($item->effective_itemtype)->notforloan
179 && $item->itemnumber;
181 $allow_onshelf_holds = Koha
::CirculationRules
->get_onshelfholds_policy( { item
=> $item, patron
=> $patron } )
182 unless $allow_onshelf_holds;
185 if( $allow_onshelf_holds || CountItemsIssued
($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
186 $template->param( ReservableItems
=> 1 );
190 RequestOnOpac
=> C4
::Context
->preference("RequestOnOpac"),
191 norequests
=> $norequests,
196 #Search for title in links
197 my $marccontrolnumber = GetMarcControlnumber
($record, $marcflavour);
198 my $marcissns = GetMarcISSN
( $record, $marcflavour );
199 my $issn = $marcissns->[0] || '';
201 if (my $search_for_title = C4
::Context
->preference('OPACSearchForTitleIn')){
202 $dat->{title
} =~ s/\/+$//; # remove trailing slash
203 $dat->{title
} =~ s/\s+$//; # remove trailing space
204 $search_for_title = parametrized_url
(
207 TITLE
=> $dat->{title
},
208 AUTHOR
=> $dat->{author
},
211 CONTROLNUMBER
=> $marccontrolnumber,
212 BIBLIONUMBER
=> $biblionumber,
215 $template->param('OPACSearchForTitleIn' => $search_for_title);
218 if( C4
::Context
->preference('ArticleRequests') ) {
219 my $itemtype = Koha
::ItemTypes
->find($biblio->itemtype);
220 my $artreqpossible = $patron
221 ?
$biblio->can_article_request( $patron )
223 ?
$itemtype->may_article_request
225 $template->param( artreqpossible
=> $artreqpossible );
228 output_html_with_http_headers
$query, $cookie, $template->output;