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 under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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.tmpl.
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
54 use C4
::Serials
; # uses getsubscriptionfrom biblionumber
56 use C4
::Members
; # GetMember
57 use C4
::External
::Amazon
;
59 my $query = CGI
->new();
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
62 template_name
=> "opac-ISBDdetail.tmpl",
65 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
70 my $biblionumber = $query->param('biblionumber');
72 $template->param( 'AllowOnShelfHolds' => C4
::Context
->preference('AllowOnShelfHolds') );
73 $template->param( 'ItemsIssued' => CountItemsIssued
( $biblionumber ) );
75 my $marcflavour = C4
::Context
->preference("marcflavour");
76 my $record = GetMarcBiblio
($biblionumber);
78 print $query->redirect("/cgi-bin/koha/errors/404.pl");
81 # some useful variables for enhanced content;
82 # in each case, we're grabbing the first value we find in
83 # the record and normalizing it
84 my $upc = GetNormalizedUPC
($record,$marcflavour);
85 my $ean = GetNormalizedEAN
($record,$marcflavour);
86 my $oclc = GetNormalizedOCLCNumber
($record,$marcflavour);
87 my $isbn = GetNormalizedISBN
(undef,$record,$marcflavour);
88 my $content_identifier_exists;
89 if ( $isbn or $ean or $oclc or $upc ) {
90 $content_identifier_exists = 1;
93 normalized_upc
=> $upc,
94 normalized_ean
=> $ean,
95 normalized_oclc
=> $oclc,
96 normalized_isbn
=> $isbn,
97 content_identifier_exists
=> $content_identifier_exists,
100 #coping with subscriptions
101 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
102 my $dbh = C4
::Context
->dbh;
103 my $dat = TransformMarcToKoha
( $dbh, $record );
104 my @subscriptions = GetSubscriptions
( undef, undef, $biblionumber );
107 foreach my $subscription (@subscriptions) {
109 my $serials_to_display;
110 $cell{subscriptionid
} = $subscription->{subscriptionid
};
111 $cell{subscriptionnotes
} = $subscription->{notes
};
112 $cell{branchcode
} = $subscription->{branchcode
};
114 #get the three latest serials.
115 $serials_to_display = $subscription->{opacdisplaycount
};
116 $serials_to_display = C4
::Context
->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
117 $cell{opacdisplaycount
} = $serials_to_display;
118 $cell{latestserials
} =
119 GetLatestSerials
( $subscription->{subscriptionid
}, $serials_to_display );
124 subscriptions
=> \
@subs,
125 subscriptionsnumber
=> $subscriptionsnumber,
129 my $res = GetISBDView
($biblionumber, "opac");
130 my @items = GetItemsInfo
( $biblionumber );
132 my $itemtypes = GetItemTypes
();
133 for my $itm (@items) {
135 if ( (not $itm->{'wthdrawn'} )
136 && (not $itm->{'itemlost'} )
137 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
138 && (not $itemtypes->{$itm->{'itype'}}->{notforloan
} )
139 && ($itm->{'itemnumber'} ) );
142 my $reviews = getreviews
( $biblionumber, 1 );
143 foreach ( @
$reviews ) {
144 my $borrower_number_review = $_->{borrowernumber
};
145 my $borrowerData = GetMember
('borrowernumber' =>$borrower_number_review);
146 # setting some borrower info into this hash
147 $_->{title
} = $borrowerData->{'title'};
148 $_->{surname
} = $borrowerData->{'surname'};
149 $_->{firstname
} = $borrowerData->{'firstname'};
154 RequestOnOpac
=> C4
::Context
->preference("RequestOnOpac"),
155 AllowOnShelfHolds
=> C4
::Context
->preference('AllowOnShelfHolds'),
156 norequests
=> $norequests,
158 biblionumber
=> $biblionumber,
162 #Search for title in links
163 if (my $search_for_title = C4
::Context
->preference('OPACSearchForTitleIn')){
164 $dat->{author
} ?
$search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
165 $dat->{title
} =~ s/\/+$//; # remove trailing slash
166 $dat->{title
} =~ s/\s+$//; # remove trailing space
167 $dat->{title
} ?
$search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
168 $isbn ?
$search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
169 $template->param('OPACSearchForTitleIn' => $search_for_title);
173 #not used unless preference set
174 if ( C4
::Context
->preference("OPACAmazonEnabled") == 1 ) {
176 my $amazon_details = &get_amazon_details
( $isbn, $record, $marcflavour );
178 foreach my $result ( @
{ $amazon_details->{Details
} } ) {
179 $template->param( item_description
=> $result->{ProductDescription
} );
180 $template->param( image
=> $result->{ImageUrlMedium
} );
181 $template->param( list_price
=> $result->{ListPrice
} );
182 $template->param( amazon_url
=> $result->{url
} );
187 for my $details ( @
{ $amazon_details->{Details
} } ) {
188 next unless $details->{SimilarProducts
};
189 for my $product ( @
{ $details->{SimilarProducts
}->{Product
} } ) {
190 push @products, +{ Product
=> $product };
192 next unless $details->{Reviews
};
193 for my $product ( @
{ $details->{Reviews
}->{AvgCustomerRating
} } ) {
194 $template->param( rating
=> $product * 20 );
196 for my $reviews ( @
{ $details->{Reviews
}->{CustomerReview
} } ) {
199 Summary
=> $reviews->{Summary
},
200 Comment
=> $reviews->{Comment
},
204 $template->param( SIMILAR_PRODUCTS
=> \
@products );
205 $template->param( AMAZONREVIEWS
=> \
@reviews );
208 output_html_with_http_headers
$query, $cookie, $template->output;