View | Details | Raw Unified | Return to bug 40101
Collapse All | Expand All

(-)a/opac/opac-reserve.pl (-51 / +28 lines)
Lines 39-44 use Koha::Items; Link Here
39
use Koha::ItemTypes;
39
use Koha::ItemTypes;
40
use Koha::Checkouts;
40
use Koha::Checkouts;
41
use Koha::Libraries;
41
use Koha::Libraries;
42
use Koha::Logger;
42
use Koha::Patrons;
43
use Koha::Patrons;
43
use List::MoreUtils qw( uniq );
44
use List::MoreUtils qw( uniq );
44
45
Lines 112-176 if ( $#biblionumbers < 0 && $op ne 'cud-place_reserve' ) { Link Here
112
# Here we check that the borrower can actually make reserves Stage 1.
113
# Here we check that the borrower can actually make reserves Stage 1.
113
#
114
#
114
#
115
#
115
my $noreserves = 0;
116
if ( $category->effective_BlockExpiredPatronOpacActions_contains('hold') ) {
117
    if ( $patron->is_expired ) {
118
116
119
        # cannot reserve, their card has expired and the rules set mean this is not allowed
117
my $can_place_holds = $patron->can_place_holds( { no_short_circuit => 1 } );
120
        $noreserves = 1;
121
        $template->param( message => 1, expired_patron => 1 );
122
    }
123
}
124
125
my $maxoutstanding    = C4::Context->preference("maxoutstanding");
126
my $amountoutstanding = $patron->account->balance;
127
if ( $amountoutstanding && ( $amountoutstanding > $maxoutstanding ) ) {
128
    my $amount = sprintf "%.02f", $amountoutstanding;
129
    $template->param( message => 1 );
130
    $noreserves = 1;
131
    $template->param( too_much_oweing => $amount );
132
}
133
134
if ( $patron->gonenoaddress && ( $patron->gonenoaddress == 1 ) ) {
135
    $noreserves = 1;
136
    $template->param(
137
        message => 1,
138
        GNA     => 1
139
    );
140
}
141
118
142
if ( $patron->lost && ( $patron->lost == 1 ) ) {
119
if ( !$can_place_holds ) {
143
    $noreserves = 1;
144
    $template->param(
145
        message => 1,
146
        lost    => 1
147
    );
148
}
149
120
150
if ( $patron->is_debarred ) {
151
    $noreserves = 1;
152
    $template->param(
153
        message          => 1,
154
        debarred         => 1,
155
        debarred_comment => $patron->debarredcomment,
156
        debarred_date    => $patron->debarred,
157
    );
158
}
159
160
my $holds          = $patron->holds;
161
my $reserves_count = $holds->count;
162
$template->param( RESERVES => $holds->unblessed );
163
if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) {
164
    $template->param( message => 1 );
121
    $template->param( message => 1 );
165
    $noreserves = 1;
166
    $template->param( too_many_reserves => $holds->count );
167
}
168
122
169
if ($noreserves) {
123
    my $messages = $can_place_holds->messages();
124
    foreach my $msg ( @{$messages} ) {
125
        if ( $msg->message eq 'expired' ) {
126
            $template->param( expired_patron => 1 );
127
        } elsif ( $msg->message eq 'debt_limit' ) {
128
            $template->param( too_much_oweing => sprintf( "%.02f", $msg->{payload}->{total_outstanding} ) );
129
        } elsif ( $msg->message eq 'bad_address' ) {
130
            $template->param( GNA => 1 );
131
        } elsif ( $msg->message eq 'card_lost' ) {
132
            $template->param( lost => 1 );
133
        } elsif ( $msg->message eq 'restricted' ) {
134
            $template->param(
135
                debarred         => 1,
136
                debarred_comment => $patron->debarredcomment,
137
                debarred_date    => $patron->debarred,
138
            );
139
        } elsif ( $msg->message eq 'hold_limit' ) {
140
            $template->param( too_many_reserves => $msg->{payload}->{total_holds} );
141
        } else {
142
            Koha::Logger->get->warn( sprintf( "Unhandled 'can_place_holds' error code: %s", $msg->message ) );
143
        }
144
    }
145
170
    output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
146
    output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
171
    exit;
147
    exit;
172
}
148
}
173
149
150
my $reserves_count = $patron->holds->count;
151
174
# pass the pickup branch along....
152
# pass the pickup branch along....
175
my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '';
153
my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '';
176
$template->param( branch => $branch );
154
$template->param( branch => $branch );
177
- 

Return to bug 40101