use warnings;
use CGI;
+use C4::Acquisition qw( SearchOrders );
use C4::Auth qw(:DEFAULT get_session);
use C4::Branch;
use C4::Koha;
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
exit;
}
+
+# redirect if opacsuppression is enabled and biblio is suppressed
+if (C4::Context->preference('OpacSuppression')) {
+ # FIXME hardcoded; the suppression flag ought to be materialized
+ # as a column on biblio or the like
+ my $opacsuppressionfield = '942';
+ my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield);
+ # redirect to opac-blocked info page or 404?
+ my $opacsuppressionredirect;
+ if ( C4::Context->preference("OpacSuppressionRedirect") ) {
+ $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl";
+ } else {
+ $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl";
+ }
+ if ( $opacsuppressionfieldvalue &&
+ $opacsuppressionfieldvalue->subfield("n") &&
+ $opacsuppressionfieldvalue->subfield("n") == 1) {
+ # if OPAC suppression by IP address
+ if (C4::Context->preference('OpacSuppressionByIPRange')) {
+ my $IPAddress = $ENV{'REMOTE_ADDR'};
+ my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
+ if ($IPAddress !~ /^$IPRange/) {
+ print $query->redirect($opacsuppressionredirect);
+ exit;
+ }
+ } else {
+ print $query->redirect($opacsuppressionredirect);
+ exit;
+ }
+ }
+}
+
$template->param( biblionumber => $biblionumber );
# get biblionumbers stored in the cart
my $newbusc = rebuildBuscParam(\%arrParamsBusc);
$session->param("busc" => $newbusc);
}
- my ($previous, $next, $dataBiblioPaging);
+ my ($numberBiblioPaging, $dataBiblioPaging);
# Previous biblio
- if ($paging{'previous'}->{biblionumber}) {
- $previous = 'opac-detail.pl?biblionumber=' . $paging{'previous'}->{biblionumber} . '&query_desc=' . $query->param('query_desc');
- $dataBiblioPaging = GetBiblioData($paging{'previous'}->{biblionumber});
+ $numberBiblioPaging = $paging{'previous'}->{biblionumber};
+ if ($numberBiblioPaging) {
+ $template->param( 'previousBiblionumber' => $numberBiblioPaging );
+ $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
$template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
}
# Next biblio
- if ($paging{'next'}->{biblionumber}) {
- $next = 'opac-detail.pl?biblionumber=' . $paging{'next'}->{biblionumber} . '&query_desc=' . $query->param('query_desc');
- $dataBiblioPaging = GetBiblioData($paging{'next'}->{biblionumber});
+ $numberBiblioPaging = $paging{'next'}->{biblionumber};
+ if ($numberBiblioPaging) {
+ $template->param( 'nextBiblionumber' => $numberBiblioPaging );
+ $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
$template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
}
- $template->param('previous' => $previous, 'next' => $next);
# Partial list of biblio results
my @listResults;
for (my $j = 0; $j < @arrBiblios; $j++) {
my $separatebranch = C4::Context->preference('OpacSeparateHoldingsBranch');
my $viewallitems = $query->param('viewallitems');
my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 50;
+
+# Get items on order
+my ( @itemnumbers_on_order );
+if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
+ my $orders = C4::Acquisition::SearchOrders({
+ biblionumber => $biblionumber,
+ ordered => 1,
+ });
+ my $total_quantity = 0;
+ for my $order ( @$orders ) {
+ if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
+ for my $itemnumber ( C4::Acquisition::GetItemnumbersFromOrder( $order->{ordernumber} ) ) {
+ push @itemnumbers_on_order, $itemnumber;
+ }
+ }
+ $total_quantity += $order->{quantity};
+ }
+ $template->{VARS}->{acquisition_details} = {
+ total_quantity => $total_quantity,
+ };
+}
+
if ( not $viewallitems and @items > $max_items_to_display ) {
$template->param(
too_many_items => 1,
$itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
$itm->{transfertto} = $branches->{$transfertto}{branchname};
}
+
+ if ( C4::Context->preference('OPACAcquisitionDetails')
+ and C4::Context->preference('AcqCreateItem') eq 'ordering' )
+ {
+ $itm->{on_order} = 1
+ if grep /^$itm->{itemnumber}$/, @itemnumbers_on_order;
+ }
+
my $itembranch = $itm->{$separatebranch};
if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
if ($itembranch and $itembranch eq $currentbranch) {
}
}
+$template->param(
+ 'OpacLocationBranchToDisplay' => C4::Context->preference('OpacLocationBranchToDisplay') ,
+ 'OpacLocationBranchToDisplayShelving' => C4::Context->preference('OpacLocationBranchToDisplayShelving'),
+);
+
output_html_with_http_headers $query, $cookie, $template->output;