- }
- # here we actually do the reserveration. Stage 3.
- if ($query->param('request') eq 'any'){
- # place a request on 1st available
- AddReserve($branch,$borrowernumber,$biblionumber,'a',\@realbi,$rank,$notes,$bibdata->{'title'},$checkitem,$found);
- } else {
- AddReserve($branch,$borrowernumber,$biblionumber,'a',\@realbi,$rank,$notes,$bibdata->{'title'},$checkitem, $found);
- }
- print $query->redirect("/cgi-bin/koha/opac-user.pl");
-}
-else {
-
- # Here we check that the borrower can actually make reserves Stage 1.
- my $noreserves = 0;
- my $maxoutstanding = C4::Context->preference("maxoutstanding");
- $template->param( noreserve => 1 ) unless $maxoutstanding;
- if ( $borr->{'amountoutstanding'} > $maxoutstanding ) {
- my $amount = sprintf "\$%.02f", $borr->{'amountoutstanding'};
- $template->param( message => 1 );
- $noreserves = 1;
- $template->param( too_much_oweing => $amount );
- }
- if ( $borr->{gonenoaddress} eq 1 ) {
- $noreserves = 1;
- $template->param(
- message => 1,
- GNA => 1
- );
- }
- if ( $borr->{lost} eq 1 ) {
- $noreserves = 1;
- $template->param(
- message => 1,
- lost => 1
- );
- }
- if ( $borr->{debarred} eq 1 ) {
- $noreserves = 1;
- $template->param(
- message => 1,
- debarred => 1
- );
- }
- my @reserves = GetReservesFromBorrowernumber( $borrowernumber );
- $template->param( RESERVES => \@reserves );
- if ( scalar(@$reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) {
- $template->param( message => 1 );
- $noreserves = 1;
- $template->param( too_many_reserves => scalar($reserves));
- }
- foreach my $res (@$reserves) {
- if ( $res->{'biblionumber'} == $biblionumber ) {
- $template->param( message => 1 );
- $noreserves = 1;
- $template->param( already_reserved => 1 );