use C4::Biblio;
use C4::Items;
use C4::Output;
-use C4::Dates qw/format_date/;
use C4::Context;
use C4::Members;
use C4::Branch; # GetBranches
use C4::Overdues;
use C4::Debug;
use Koha::DateUtils;
-use Koha::Borrower::Debarments qw(IsDebarred);
+use Koha::Libraries;
+use Koha::Patron::Debarments qw(IsDebarred);
use Date::Calc qw/Today Date_to_Days/;
-# use Data::Dumper;
my $maxreserves = C4::Context->preference("maxreserves");
my $query = new CGI;
+
+# if RequestOnOpac (for placing holds) is disabled, leave immediately
+if ( ! C4::Context->preference('RequestOnOpac') ) {
+ print $query->redirect("/cgi-bin/koha/errors/404.pl");
+ exit;
+}
+
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-reserve.tt",
query => $query,
type => "opac",
authnotrequired => 0,
- flagsrequired => { borrow => 1 },
debug => 1,
}
);
&get_out($query, $cookie, $template->output);
}
+ my $failed_holds = 0;
while (@selectedItems) {
my $biblioNum = shift(@selectedItems);
my $itemNum = shift(@selectedItems);
my $canreserve = 0;
- my $singleBranchMode = C4::Context->preference("singleBranchMode");
+ my $singleBranchMode = Koha::Libraries->search->count == 1;
if ( $singleBranchMode || !$OPACChooseBranch )
{ # single branch mode or disabled user choosing
$branch = $borr->{'branchcode'};
# Here we actually do the reserveration. Stage 3.
if ($canreserve) {
- AddReserve(
+ my $reserve_id = AddReserve(
$branch, $borrowernumber,
- $biblioNum, 'a',
+ $biblioNum,
[$biblioNum], $rank,
$startdate, $expiration_date,
$notes, $biblioData->{title},
$itemNum, $found
);
+ $failed_holds++ unless $reserve_id;
++$reserve_cnt;
}
}
- print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");
+ print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
exit;
}
$noreserves = 1;
$template->param( too_much_oweing => $amount );
}
+
if ( $borr->{gonenoaddress} && ($borr->{gonenoaddress} == 1) ) {
$noreserves = 1;
$template->param(
GNA => 1
);
}
+
if ( $borr->{lost} && ($borr->{lost} == 1) ) {
$noreserves = 1;
$template->param(
lost => 1
);
}
+
if ( IsDebarred($borrowernumber) ) {
$noreserves = 1;
$template->param(
- message => 1,
- debarred => 1
+ message => 1,
+ debarred => 1,
+ debarred_comment => $borr->{debarredcomment},
+ debarred_date => $borr->{debarred},
);
}
$biblioLoopIter{mandatorynotes}=0; #FIXME: For future use
if (!$itemLevelTypes && $biblioData->{itemtype}) {
- $biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description};
+ $biblioLoopIter{translated_description} = $itemTypes->{$biblioData->{itemtype}}{translated_description};
$biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemTypes->{$biblioData->{itemtype}}{imageurl};
}
foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
- $debug and warn $itemInfo->{'notforloan'};
-
- # Get reserve fee.
- my $fee = GetReserveFee(undef, $borrowernumber, $itemInfo->{'biblionumber'}, 'a',
- ( $itemInfo->{'biblioitemnumber'} ) );
- $itemInfo->{'reservefee'} = sprintf "%.02f", ($fee ? $fee : 0.0);
-
if ($itemLevelTypes && $itemInfo->{itype}) {
- $itemInfo->{description} = $itemTypes->{$itemInfo->{itype}}{description};
+ $itemInfo->{translated_description} = $itemTypes->{$itemInfo->{itype}}{translated_description};
$itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemTypes->{$itemInfo->{itype}}{imageurl};
}
$itemLoopIter->{enumchron} = $itemInfo->{enumchron};
$itemLoopIter->{copynumber} = $itemInfo->{copynumber};
if ($itemLevelTypes) {
- $itemLoopIter->{description} = $itemInfo->{description};
+ $itemLoopIter->{translated_description} = $itemInfo->{translated_description};
$itemLoopIter->{imageurl} = $itemInfo->{imageurl};
}
my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
# the item could be reserved for this borrower vi a host record, flag this
+ $reservedfor //= '';
if ($reservedfor eq $borrowernumber){
$itemLoopIter->{already_reserved} = 1;
}
if ( defined $reservedate ) {
$itemLoopIter->{backgroundcolor} = 'reserved';
- $itemLoopIter->{reservedate} = format_date($reservedate);
+ $itemLoopIter->{reservedate} = output_pref({ dt => dt_from_string($reservedate), dateonly => 1 });
$itemLoopIter->{ReservedForBorrowernumber} = $reservedfor;
$itemLoopIter->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$itemLoopIter->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
my ( $transfertwhen, $transfertfrom, $transfertto ) =
GetTransfers($itemNum);
if ( $transfertwhen && ($transfertwhen ne '') ) {
- $itemLoopIter->{transfertwhen} = format_date($transfertwhen);
+ $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
$itemLoopIter->{transfertfrom} =
$branches->{$transfertfrom}{branchname};
$itemLoopIter->{transfertto} = $branches->{$transfertto}{branchname};
my $branch = GetReservesControlBranch( $itemInfo, $borr );
my $policy_holdallowed = !$itemLoopIter->{already_reserved};
- if ($policy_holdallowed) {
- if (my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} )) {
- $policy_holdallowed =
- ($branchitemrule->{'holdallowed'} == 2) ||
- ($branchitemrule->{'holdallowed'} == 1
- && $borr->{'branchcode'} eq $itemInfo->{'homebranch'});
- } else {
- $policy_holdallowed = 0; # No rule - not allowed
- }
- }
$policy_holdallowed &&=
IsAvailableForItemLevelRequest($itemInfo,$borr) &&
CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
);
}
-output_html_with_http_headers $query, $cookie, $template->output;
-
+output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };