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
27 This script needs a biblionumber as parameter
31 The template is in <templates_dir>/catalogue/ISBDdetail.tmpl.
32 this template must be divided into 11 "tabs".
34 The first 10 tabs present the biblio, the 11th one presents
35 the items attached to the biblio
53 use C4
::Serials
; # uses getsubscriptionfrom biblionumber
55 use C4
::Members
; # GetMember
56 use C4
::External
::Amazon
;
58 my $query = CGI
->new();
59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
61 template_name
=> "opac-ISBDdetail.tmpl",
64 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
69 my $biblionumber = $query->param('biblionumber');
71 $template->param( 'AllowOnShelfHolds' => C4
::Context
->preference('AllowOnShelfHolds') );
72 $template->param( 'ItemsIssued' => CountItemsIssued
( $biblionumber ) );
74 my $marcflavour = C4
::Context
->preference("marcflavour");
75 my $record = GetMarcBiblio
($biblionumber);
77 print $query->redirect("/cgi-bin/koha/errors/404.pl");
80 # some useful variables for enhanced content;
81 # in each case, we're grabbing the first value we find in
82 # the record and normalizing it
83 my $upc = GetNormalizedUPC
($record,$marcflavour);
84 my $ean = GetNormalizedEAN
($record,$marcflavour);
85 my $oclc = GetNormalizedOCLCNumber
($record,$marcflavour);
86 my $isbn = GetNormalizedISBN
(undef,$record,$marcflavour);
87 my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
89 normalized_upc
=> $upc,
90 normalized_ean
=> $ean,
91 normalized_oclc
=> $oclc,
92 normalized_isbn
=> $isbn,
93 content_identifier_exists
=> $content_identifier_exists,
96 #coping with subscriptions
97 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
98 my $dbh = C4
::Context
->dbh;
99 my $dat = TransformMarcToKoha
( $dbh, $record );
101 GetSubscriptions
( $dat->{title
}, $dat->{issn
}, $biblionumber );
103 foreach my $subscription (@subscriptions) {
105 my $serials_to_display;
106 $cell{subscriptionid
} = $subscription->{subscriptionid
};
107 $cell{subscriptionnotes
} = $subscription->{notes
};
108 $cell{branchcode
} = $subscription->{branchcode
};
110 #get the three latest serials.
111 $serials_to_display = $subscription->{opacdisplaycount
};
112 $serials_to_display = C4
::Context
->preference('OPACSerialIssueDisplayCount') unless $serials_to_display;
113 $cell{opacdisplaycount
} = $serials_to_display;
114 $cell{latestserials
} =
115 GetLatestSerials
( $subscription->{subscriptionid
}, $serials_to_display );
120 subscriptions
=> \
@subs,
121 subscriptionsnumber
=> $subscriptionsnumber,
125 my $res = GetISBDView
($biblionumber, "opac");
126 my @items = &GetItemsInfo
($biblionumber, 'opac');
128 my $itemtypes = GetItemTypes
();
129 for my $itm (@items) {
131 if ( (not $itm->{'wthdrawn'} )
132 && (not $itm->{'itemlost'} )
133 && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
134 && (not $itemtypes->{$itm->{'itype'}}->{notforloan
} )
135 && ($itm->{'itemnumber'} ) );
138 my $reviews = getreviews
( $biblionumber, 1 );
139 foreach ( @
$reviews ) {
140 my $borrower_number_review = $_->{borrowernumber
};
141 my $borrowerData = GetMember
('borrowernumber' =>$borrower_number_review);
142 # setting some borrower info into this hash
143 $_->{title
} = $borrowerData->{'title'};
144 $_->{surname
} = $borrowerData->{'surname'};
145 $_->{firstname
} = $borrowerData->{'firstname'};
150 RequestOnOpac
=> C4
::Context
->preference("RequestOnOpac"),
151 AllowOnShelfHolds
=> C4
::Context
->preference('AllowOnShelfHolds'),
152 norequests
=> $norequests,
154 biblionumber
=> $biblionumber,
158 #Search for title in links
159 if (my $search_for_title = C4
::Context
->preference('OPACSearchForTitleIn')){
160 $dat->{author
} ?
$search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
161 $dat->{title
} =~ s/\/+$//; # remove trailing slash
162 $dat->{title
} =~ s/\s+$//; # remove trailing space
163 $dat->{title
} ?
$search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
164 $isbn ?
$search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
165 $template->param('OPACSearchForTitleIn' => $search_for_title);
169 #not used unless preference set
170 if ( C4
::Context
->preference("OPACAmazonEnabled") == 1 ) {
172 my $amazon_details = &get_amazon_details
( $isbn, $record, $marcflavour );
174 foreach my $result ( @
{ $amazon_details->{Details
} } ) {
175 $template->param( item_description
=> $result->{ProductDescription
} );
176 $template->param( image
=> $result->{ImageUrlMedium
} );
177 $template->param( list_price
=> $result->{ListPrice
} );
178 $template->param( amazon_url
=> $result->{url
} );
183 for my $details ( @
{ $amazon_details->{Details
} } ) {
184 next unless $details->{SimilarProducts
};
185 for my $product ( @
{ $details->{SimilarProducts
}->{Product
} } ) {
186 push @products, +{ Product
=> $product };
188 next unless $details->{Reviews
};
189 for my $product ( @
{ $details->{Reviews
}->{AvgCustomerRating
} } ) {
190 $template->param( rating
=> $product * 20 );
192 for my $reviews ( @
{ $details->{Reviews
}->{CustomerReview
} } ) {
195 Summary
=> $reviews->{Summary
},
196 Comment
=> $reviews->{Comment
},
200 $template->param( SIMILAR_PRODUCTS
=> \
@products );
201 $template->param( AMAZONREVIEWS
=> \
@reviews );
204 output_html_with_http_headers
$query, $cookie, $template->output;