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
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.
23 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
56 use C4
::Serials
; # uses getsubscriptionfrom biblionumber
58 use C4
::Members
; # GetMember
59 use C4
::External
::Amazon
;
61 my $query = CGI
->new();
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
64 template_name
=> "opac-ISBDdetail.tmpl",
72 my $biblionumber = $query->param('biblionumber');
74 $template->param( 'AllowOnShelfHolds' => C4
::Context
->preference('AllowOnShelfHolds') );
75 $template->param( 'ItemsIssued' => CountItemsIssued
( $biblionumber ) );
77 my $marcflavour = C4
::Context
->preference("marcflavour");
78 my $record = GetMarcBiblio
($biblionumber);
80 print $query->redirect("/cgi-bin/koha/errors/404.pl");
83 # some useful variables for enhanced content;
84 # in each case, we're grabbing the first value we find in
85 # the record and normalizing it
86 my $upc = GetNormalizedUPC
($record,$marcflavour);
87 my $ean = GetNormalizedEAN
($record,$marcflavour);
88 my $oclc = GetNormalizedOCLCNumber
($record,$marcflavour);
89 my $isbn = GetNormalizedISBN
(undef,$record,$marcflavour);
90 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
92 normalized_upc
=> $upc,
93 normalized_ean
=> $ean,
94 normalized_oclc
=> $oclc,
95 normalized_isbn
=> $isbn,
96 content_identifier_exists
=> $content_identifier_exists,
99 #coping with subscriptions
100 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
101 my $dbh = C4
::Context
->dbh;
102 my $dat = TransformMarcToKoha
( $dbh, $record );
104 GetSubscriptions
( $dat->{title
}, $dat->{issn
}, $biblionumber );
106 foreach my $subscription (@subscriptions) {
108 my $serials_to_display;
109 $cell{subscriptionid
} = $subscription->{subscriptionid
};
110 $cell{subscriptionnotes
} = $subscription->{notes
};
111 $cell{branchcode
} = $subscription->{branchcode
};
113 #get the three latest serials.
114 $serials_to_display = $subscription->{opacdisplaycount
};
115 $serials_to_display = C4
::Context
->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
116 $cell{opacdisplaycount
} = $serials_to_display;
117 $cell{latestserials
} =
118 GetLatestSerials
( $subscription->{subscriptionid
}, $serials_to_display );
123 subscriptions
=> \
@subs,
124 subscriptionsnumber
=> $subscriptionsnumber,
128 my $res = GetISBDView
($biblionumber, "opac");
129 my @items = &GetItemsInfo
($biblionumber, 'opac');
131 my $itemtypes = GetItemTypes
();
132 for my $itm (@items) {
134 if ( (not $itm->{'wthdrawn'} )
135 && (not $itm->{'itemlost'} )
136 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
137 && (not $itemtypes->{$itm->{'itype'}}->{notforloan
} )
138 && ($itm->{'itemnumber'} ) );
141 my $reviews = getreviews
( $biblionumber, 1 );
142 foreach ( @
$reviews ) {
143 my $borrower_number_review = $_->{borrowernumber
};
144 my $borrowerData = GetMember
('borrowernumber' =>$borrower_number_review);
145 # setting some borrower info into this hash
146 $_->{title
} = $borrowerData->{'title'};
147 $_->{surname
} = $borrowerData->{'surname'};
148 $_->{firstname
} = $borrowerData->{'firstname'};
153 RequestOnOpac
=> C4
::Context
->preference("RequestOnOpac"),
154 AllowOnShelfHolds
=> C4
::Context
->preference('AllowOnShelfHolds'),
155 norequests
=> $norequests,
157 biblionumber
=> $biblionumber,
162 #not used unless preference set
163 if ( C4
::Context
->preference("OPACAmazonEnabled") == 1 ) {
165 my $amazon_details = &get_amazon_details
( $isbn, $record, $marcflavour );
167 foreach my $result ( @
{ $amazon_details->{Details
} } ) {
168 $template->param( item_description
=> $result->{ProductDescription
} );
169 $template->param( image
=> $result->{ImageUrlMedium
} );
170 $template->param( list_price
=> $result->{ListPrice
} );
171 $template->param( amazon_url
=> $result->{url
} );
176 for my $details ( @
{ $amazon_details->{Details
} } ) {
177 next unless $details->{SimilarProducts
};
178 for my $product ( @
{ $details->{SimilarProducts
}->{Product
} } ) {
179 push @products, +{ Product
=> $product };
181 next unless $details->{Reviews
};
182 for my $product ( @
{ $details->{Reviews
}->{AvgCustomerRating
} } ) {
183 $template->param( rating
=> $product * 20 );
185 for my $reviews ( @
{ $details->{Reviews
}->{CustomerReview
} } ) {
188 Summary
=> $reviews->{Summary
},
189 Comment
=> $reviews->{Comment
},
193 $template->param( SIMILAR_PRODUCTS
=> \
@products );
194 $template->param( AMAZONREVIEWS
=> \
@reviews );
197 output_html_with_http_headers
$query, $cookie, $template->output;