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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-39 / +96 lines)
Lines 406-427 Link Here
406
                                    <strong>Too many holds: </strong> Patron can only place a maximum of [% maxreserves | html %] total holds.
406
                                    <strong>Too many holds: </strong> Patron can only place a maximum of [% maxreserves | html %] total holds.
407
                                </div>
407
                                </div>
408
                            [% END %]
408
                            [% END %]
409
                            [% IF ( patron.is_expired ) %]
409
                            [% FOREACH message IN messages %]
410
                                <div>
410
                                <div>
411
                                    <i class="fa-solid fa-triangle-exclamation"></i>
411
                                    <i class="fa-solid fa-triangle-exclamation"></i>
412
                                    <strong>Account has expired</strong>
412
                                    [% IF message.message == 'expired' %]
413
                                </div>
413
                                        <strong>Account has expired</strong>
414
                            [% END %]
414
                                    [% ELSIF message.message == 'restricted' %]
415
                            [% IF patron.is_debarred %]
415
                                        <strong>Patron has restrictions</strong>
416
                                <div>
416
                                    [% ELSIF message.message == 'debt_limit' %]
417
                                    <i class="fa-solid fa-triangle-exclamation"></i>
417
                                        <strong>Patron has outstanding fines: [% message.payload.total_outstanding | $Price %]</strong>
418
                                    <strong>Patron has restrictions</strong>
418
                                    [% ELSIF message.message == 'bad_address' %]
419
                                </div>
419
                                        <strong>Patron's address is flagged as incorrect</strong>
420
                            [% END %]
420
                                    [% ELSIF message.message == 'card_lost' %]
421
                            [% IF member.amount_outstanding && Koha.Preference('maxoutstanding') && member.amount_outstanding > Koha.Preference('maxoutstanding') %]
421
                                        <strong>Patron's library card is marked as lost</strong>
422
                                <div>
422
                                    [% ELSIF message.message == 'hold_limit' %]
423
                                    <i class="fa-solid fa-triangle-exclamation"></i>
423
                                        <strong>Too many holds: </strong> Patron can only place a maximum of [% message.payload.max_holds | html %] total holds.
424
                                    <strong>Patron has outstanding fines: [% member.amount_outstanding | $Price %]</strong>
424
                                    [% END %]
425
                                </div>
425
                                </div>
426
                            [% END %]
426
                            [% END %]
427
427
Lines 436-442 Link Here
436
                </ol>
436
                </ol>
437
                [% UNLESS ( multi_hold ) %]
437
                [% UNLESS ( multi_hold ) %]
438
                    <fieldset class="action">
438
                    <fieldset class="action">
439
                        <input type="submit" class="btn btn-primary" value="Place hold" />
439
                        [% IF messages.size && Koha.Preference('AllowHoldPolicyOverride') %]
440
                            [% FOREACH message IN messages %]
441
                                <input type="hidden" name="override_[% message.message | html %]" value="1" />
442
                            [% END %]
443
                            <input type="submit" class="btn btn-danger" value="Place hold with overrides" />
444
                        [% ELSE %]
445
                            <input type="submit" class="btn btn-primary" value="Place hold" />
446
                        [% END %]
440
                    </fieldset>
447
                    </fieldset>
441
                [% ELSE %]
448
                [% ELSE %]
442
                    <table id="requesttitles">
449
                    <table id="requesttitles">
Lines 573-594 Link Here
573
            </div>
580
            </div>
574
        [% END # /IF ( exceeded_maxreserves || ... %]
581
        [% END # /IF ( exceeded_maxreserves || ... %]
575
582
576
        [% IF ( patron.is_expired || diffbranch || patron.is_debarred || ( amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') ) ) %]
583
        [% IF messages.size || diffbranch %]
577
            <div class="alert alert-info">
584
            <div class="alert alert-info">
578
                <ul>
585
                <ul>
579
                    [% IF ( patron.is_expired ) %]
586
                    [% FOREACH message IN messages %]
580
                        <li>[% INCLUDE 'patron-title.inc' patron => patron no_title => 1 no_cardnumber => 1 hide_patron_infos_if_needed => 1 %]: <strong>Account has expired</strong></li>
587
                        <li>
581
                    [% END %]
588
                            [% INCLUDE 'patron-title.inc' patron => patron no_title => 1 no_cardnumber => 1 hide_patron_infos_if_needed => 1 %]:
582
589
                            [% IF message.message == 'expired' %]
583
                    [% IF patron.is_debarred %]
590
                                <strong>Account has expired</strong>
584
                        <li>[% INCLUDE 'patron-title.inc' patron => patron no_title => 1 no_cardnumber => 1 hide_patron_infos_if_needed => 1 %]: <strong>Patron has restrictions</strong></li>
591
                            [% ELSIF message.message == 'restricted' %]
585
                    [% END %]
592
                                <strong>Patron has restrictions</strong>
586
593
                            [% ELSIF message.message == 'debt_limit' %]
587
                    [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
594
                                <strong>Patron has outstanding fines: [% message.payload.total_outstanding | $Price %]</strong>
588
                        <li
595
                            [% ELSIF message.message == 'bad_address' %]
589
                            >[% INCLUDE 'patron-title.inc' patron => patron no_title => 1 no_cardnumber => 1 hide_patron_infos_if_needed => 1 link_to => 'members_pay' %]:
596
                                <strong>Patron's address is flagged as incorrect</strong>
590
                            <strong>Patron has outstanding fines: [% amount_outstanding | $Price %]</strong></li
597
                            [% ELSIF message.message == 'card_lost' %]
591
                        >
598
                                <strong>Patron's library card is marked as lost</strong>
599
                            [% ELSIF message.message == 'hold_limit' %]
600
                                <strong>Too many holds: </strong> Patron can only place a maximum of [% message.payload.max_holds | html %] total holds.
601
                            [% END %]
602
                        </li>
592
                    [% END %]
603
                    [% END %]
593
604
594
                    [% IF ( diffbranch ) %]
605
                    [% IF ( diffbranch ) %]
Lines 600-606 Link Here
600
                </ul>
611
                </ul>
601
                <!-- /.dialog.message -->
612
                <!-- /.dialog.message -->
602
            </div>
613
            </div>
603
        [% END # /IF patron.is_expired || diffbranch ... %]
614
        [% END # /IF messages.size || diffbranch %]
604
615
605
        [% IF ( messageborrower ) %]
616
        [% IF ( messageborrower ) %]
606
            <div class="alert alert-warning">
617
            <div class="alert alert-warning">
Lines 735-742 Link Here
735
746
736
                        <fieldset class="action">
747
                        <fieldset class="action">
737
                            [% IF ( patron.borrowernumber ) %]
748
                            [% IF ( patron.borrowernumber ) %]
738
                                [% IF ( override_required ) %]
749
                                [% IF Koha.Preference('AllowHoldPolicyOverride') && (messages.size || override_required) %]
739
                                    <button type="submit" id="hold_grp_btn" class="btn btn-primary"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
750
                                    [% FOREACH message IN messages %]
751
                                        <input type="hidden" name="override_[% message.message | html %]" value="1" />
752
                                    [% END %]
753
                                    [% IF ( override_required ) %]
754
                                        <button type="submit" id="hold_grp_btn" class="btn btn-danger"><i class="fa fa-exclamation-triangle "></i> Place hold with overrides</button>
755
                                    [% ELSIF ( none_available ) %]
756
                                        <button type="submit" id="hold_grp_btn" disabled="disabled" class="btn btn-danger btn-disabled">Place hold with overrides</button>
757
                                    [% ELSE %]
758
                                        <button type="submit" id="hold_grp_btn" class="btn btn-danger">Place hold with overrides</button>
759
                                    [% END %]
760
                                [% ELSIF ( override_required ) %]
761
                                    <button type="submit" id="hold_grp_btn" class="btn btn-primary warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
740
                                [% ELSIF ( none_available ) %]
762
                                [% ELSIF ( none_available ) %]
741
                                    <button type="submit" id="hold_grp_btn" disabled="disabled" class="btn btn-primary btn-disabled">Place hold</button>
763
                                    <button type="submit" id="hold_grp_btn" disabled="disabled" class="btn btn-primary btn-disabled">Place hold</button>
742
                                [% ELSE %]
764
                                [% ELSE %]
Lines 830-837 Link Here
830
                            [% END %]
852
                            [% END %]
831
                            <fieldset class="action">
853
                            <fieldset class="action">
832
                                [% IF ( patron.borrowernumber ) %]
854
                                [% IF ( patron.borrowernumber ) %]
833
                                    [% IF ( override_required ) %]
855
                                    [% IF Koha.Preference('AllowHoldPolicyOverride') && (messages.size || override_required) %]
834
                                        <button type="submit" id="hold_any_btn" class="btn btn-primary"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
856
                                        [% FOREACH message IN messages %]
857
                                            <input type="hidden" name="override_[% message.message | html %]" value="1" />
858
                                        [% END %]
859
                                        [% IF ( override_required ) %]
860
                                            <button type="submit" id="hold_any_btn" class="btn btn-danger"><i class="fa fa-exclamation-triangle "></i> Place hold with overrides</button>
861
                                        [% ELSIF ( none_available ) %]
862
                                            <button type="submit" id="hold_any_btn" disabled="disabled" class="btn btn-danger btn-disabled">Place hold with overrides</button>
863
                                        [% ELSE %]
864
                                            <button type="submit" id="hold_any_btn" class="btn btn-danger">Place hold with overrides</button>
865
                                        [% END %]
866
                                    [% ELSIF ( override_required ) %]
867
                                        <button type="submit" id="hold_any_btn" class="btn btn-primary warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
835
                                    [% ELSIF ( none_available ) %]
868
                                    [% ELSIF ( none_available ) %]
836
                                        <button type="submit" id="hold_any_btn" disabled="disabled" class="btn btn-primary btn-disabled">Place hold</button>
869
                                        <button type="submit" id="hold_any_btn" disabled="disabled" class="btn btn-primary btn-disabled">Place hold</button>
837
                                    [% ELSE %]
870
                                    [% ELSE %]
Lines 1088-1095 Link Here
1088
                        [% END # /IF hiddencount %]
1121
                        [% END # /IF hiddencount %]
1089
                        <fieldset class="action">
1122
                        <fieldset class="action">
1090
                            [% IF ( patron.borrowernumber ) %]
1123
                            [% IF ( patron.borrowernumber ) %]
1091
                                [% IF ( override_required ) %]
1124
                                [% IF Koha.Preference('AllowHoldPolicyOverride') && (messages.size || override_required) %]
1092
                                    <button type="submit" id="hold_item_btn" class="btn btn-primary"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
1125
                                    [% FOREACH message IN messages %]
1126
                                        <input type="hidden" name="override_[% message.message | html %]" value="1" />
1127
                                    [% END %]
1128
                                    [% IF ( override_required ) %]
1129
                                        <button type="submit" id="hold_item_btn" class="btn btn-danger"><i class="fa fa-exclamation-triangle "></i> Place hold with overrides</button>
1130
                                    [% ELSIF ( none_available ) %]
1131
                                        <button type="submit" id="hold_item_btn" disabled="disabled" class="btn btn-danger btn-disabled">Place hold with overrides</button>
1132
                                    [% ELSE %]
1133
                                        <button type="submit" id="hold_item_btn" class="btn btn-danger">Place hold with overrides</button>
1134
                                    [% END %]
1135
                                [% ELSIF ( override_required ) %]
1136
                                    <button type="submit" id="hold_item_btn" class="btn btn-primary warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
1093
                                [% ELSIF ( none_available ) %]
1137
                                [% ELSIF ( none_available ) %]
1094
                                    <button type="submit" id="hold_item_btn" disabled="disabled" class="btn btn-primary btn-disabled">Place hold</button>
1138
                                    <button type="submit" id="hold_item_btn" disabled="disabled" class="btn btn-primary btn-disabled">Place hold</button>
1095
                                [% ELSE %]
1139
                                [% ELSE %]
Lines 1246-1259 Link Here
1246
                </fieldset>
1290
                </fieldset>
1247
                <fieldset class="action">
1291
                <fieldset class="action">
1248
                    [% IF ( patron AND patron.borrowernumber ) %]
1292
                    [% IF ( patron AND patron.borrowernumber ) %]
1249
                        [% IF ( override_required ) %]
1293
                        [% IF Koha.Preference('AllowHoldPolicyOverride') && (messages.size || override_required) %]
1250
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary "><i class="fa fa-exclamation-triangle "></i> Place holds</button>
1294
                            [% FOREACH message IN messages %]
1295
                                <input type="hidden" name="override_[% message.message | html %]" value="1" />
1296
                            [% END %]
1297
                            [% IF ( override_required ) %]
1298
                                <button type="submit" id="hold_multi_btn" class="btn btn-danger"><i class="fa fa-exclamation-triangle "></i> Place holds with overrides</button>
1299
                            [% ELSIF ( no_bibs_available ) %]
1300
                                <button type="submit" id="hold_multi_btn" class="btn btn-danger btn-disabled" disabled="disabled">Place holds with overrides</button>
1301
                            [% ELSIF ( none_available ) %]
1302
                                <button type="submit" id="hold_multi_btn" class="btn btn-danger">Place holds with overrides</button>
1303
                            [% ELSE %]
1304
                                <button type="submit" id="hold_multi_btn" class="btn btn-danger">Place holds with overrides</button>
1305
                            [% END %]
1306
                        [% ELSIF ( override_required ) %]
1307
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary warning"><i class="fa fa-exclamation-triangle "></i> Place holds</button>
1251
                        [% ELSIF ( no_bibs_available ) %]
1308
                        [% ELSIF ( no_bibs_available ) %]
1252
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary btn-disabled" disabled="disabled">Place holds</button>
1309
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary btn-disabled" disabled="disabled">Place holds</button>
1253
                        [% ELSIF ( none_available ) %]
1310
                        [% ELSIF ( none_available ) %]
1254
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary">Place holds</button>
1311
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary">Place holds</button>
1255
                        [% ELSE %]
1312
                        [% ELSE %]
1256
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary" id="multi_hold_submit">Place holds</button>
1313
                            <button type="submit" id="hold_multi_btn" class="btn btn-primary">Place holds</button>
1257
                        [% END %]
1314
                        [% END %]
1258
                    [% END # /IF patron %]
1315
                    [% END # /IF patron %]
1259
                </fieldset>
1316
                </fieldset>
(-)a/reserve/request.pl (-22 / +38 lines)
Lines 85-91 my $club_hold = $input->param('club') || ''; Link Here
85
my $messageborrower;
85
my $messageborrower;
86
my $messageclub;
86
my $messageclub;
87
my $warnings;
87
my $warnings;
88
my $messages;
89
my $exceeded_maxreserves;
88
my $exceeded_maxreserves;
90
my $exceeded_holds_per_record;
89
my $exceeded_holds_per_record;
91
my @failed_holds   = $input->multi_param('failed_holds');
90
my @failed_holds   = $input->multi_param('failed_holds');
Lines 243-272 if ( $borrowernumber_hold && !$op ) { Link Here
243
    # we check the reserves of the user, and if they can reserve a document
242
    # we check the reserves of the user, and if they can reserve a document
244
    # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
243
    # FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ...
245
244
246
    my $reserves_count = $patron->holds->count_holds;
245
    # Check for staff overrides
246
    my %overrides = ();
247
    if ( C4::Context->preference('AllowHoldPolicyOverride') ) {
248
        $overrides{expired}     = 1 if $input->param('override_expired');
249
        $overrides{debt_limit}  = 1 if $input->param('override_debt_limit');
250
        $overrides{bad_address} = 1 if $input->param('override_bad_address');
251
        $overrides{card_lost}   = 1 if $input->param('override_card_lost');
252
        $overrides{restricted}  = 1 if $input->param('override_restricted');
253
        $overrides{hold_limit}  = 1 if $input->param('override_hold_limit');
254
    }
247
255
248
    my $new_reserves_count = scalar(@biblionumbers);
256
    # Check if we can place holds for this patron
257
    my $can_place_holds_result = $patron->can_place_holds(
258
        {
259
            no_short_circuit => 1,            # Collect all validation errors for staff review
260
            overrides        => \%overrides
261
        }
262
    );
249
263
250
    my $maxreserves = C4::Context->preference('maxreserves');
264
    my @hold_validation_messages = @{ $can_place_holds_result->messages };
251
    $template->param( maxreserves => $maxreserves );
252
265
253
    if ( $maxreserves
266
    # Set warnings flag if there are any validation issues
254
        && ( $reserves_count + $new_reserves_count > $maxreserves ) )
267
    if (@hold_validation_messages) {
255
    {
268
        $warnings = 1;
256
        my $new_reserves_allowed =
269
257
              $maxreserves - $reserves_count > 0
270
        # Check specifically for hold limit exceeded to set legacy variable
258
            ? $maxreserves - $reserves_count
271
        for my $message (@hold_validation_messages) {
259
            : 0;
272
            if ( $message->message eq 'hold_limit' ) {
260
        $warnings             = 1;
273
                $exceeded_maxreserves = 1;
261
        $exceeded_maxreserves = 1;
274
                last;
262
        $template->param(
275
            }
263
            new_reserves_allowed => $new_reserves_allowed,
276
        }
264
            new_reserves_count   => $new_reserves_count,
265
            reserves_count       => $reserves_count,
266
            maxreserves          => $maxreserves,
267
        );
268
    }
277
    }
269
278
279
    # Basic counts for template use
280
    my $reserves_count     = $patron->holds->count;
281
    my $new_reserves_count = scalar(@biblionumbers);
282
    my $maxreserves        = C4::Context->preference('maxreserves');
283
270
    # check if the borrower make the reserve in a different branch
284
    # check if the borrower make the reserve in a different branch
271
    if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
285
    if ( $patron->branchcode ne C4::Context->userenv->{'branch'} ) {
272
        $diffbranch = 1;
286
        $diffbranch = 1;
Lines 276-284 if ( $borrowernumber_hold && !$op ) { Link Here
276
    $template->param(
290
    $template->param(
277
        patron             => $patron,
291
        patron             => $patron,
278
        diffbranch         => $diffbranch,
292
        diffbranch         => $diffbranch,
279
        messages           => $messages,
293
        messages           => \@hold_validation_messages,
280
        warnings           => $warnings,
294
        warnings           => $warnings,
281
        amount_outstanding => $amount_outstanding,
295
        amount_outstanding => $amount_outstanding,
296
        reserves_count     => $reserves_count,
297
        new_reserves_count => $new_reserves_count,
298
        maxreserves        => $maxreserves,
282
    );
299
    );
283
}
300
}
284
301
285
- 

Return to bug 40237