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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-3 / +18 lines)
Lines 338-343 Link Here
338
                                                        />
338
                                                        />
339
                                                    </li>
339
                                                    </li>
340
                                                [% END # / IF bibitemloo.itemholdable %]
340
                                                [% END # / IF bibitemloo.itemholdable %]
341
342
                                                [% IF lowest_value %]
343
                                                    <li id="max_holds" style="display:none;" data-val="[% lowest_value | html %]"><strong>Maximum holds allowed:</strong> [% lowest_value | html %]</li>
344
                                                [% END %]
341
                                            </ul>
345
                                            </ul>
342
346
343
                                            [% IF bibitemloo.itemholdable %]
347
                                            [% IF bibitemloo.itemholdable %]
Lines 367-373 Link Here
367
                                                        <tr class="[% itemLoo.backgroundcolor | html %]">
371
                                                        <tr class="[% itemLoo.backgroundcolor | html %]">
368
                                                            <td class="copynumber">
372
                                                            <td class="copynumber">
369
                                                                [% IF ( itemLoo.available ) %]
373
                                                                [% IF ( itemLoo.available ) %]
370
                                                                    <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
374
                                                                    <input type="checkbox" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
371
                                                                [% ELSE %]
375
                                                                [% ELSE %]
372
                                                                    <input disabled="disabled" type="radio" aria-label="Cannot be put on hold" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber | html %]"
376
                                                                    <input disabled="disabled" type="radio" aria-label="Cannot be put on hold" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber | html %]"
373
                                                                           style="display:none;" />
377
                                                                           style="display:none;" />
Lines 469-474 Link Here
469
<script>
473
<script>
470
// <![CDATA[
474
// <![CDATA[
471
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
475
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
476
    var MSG_EXCEEDED_MAX_HOLDS = __("Patron reached the maximum number of holds.");
477
    var max_holds = $("#max_holds");
472
478
473
        // Clear the contents of an input field
479
        // Clear the contents of an input field
474
        $(".clearfield").on("click",function(e){
480
        $(".clearfield").on("click",function(e){
Lines 478-485 Link Here
478
484
479
    // Select the first item available
485
    // Select the first item available
480
    function select_first_available(id){
486
    function select_first_available(id){
481
        var radios = $("input:radio[name='checkitem_" + id + "']");
487
        var checkboxes = $("input:checkbox[name='checkitem_" + id + "']");
482
        $(radios).first().attr("checked", "checked");
488
        $(checkboxes).first().attr("checked", "checked");
483
    }
489
    }
484
490
485
    $(document).ready(function() {
491
    $(document).ready(function() {
Lines 571-578 Link Here
571
            // If the checkbox is checked AND we want a specific item, we display the items block
577
            // If the checkbox is checked AND we want a specific item, we display the items block
572
            if ( $(checkbox).is(":checked") && select_specific ) {
578
            if ( $(checkbox).is(":checked") && select_specific ) {
573
                $(newCopiesRowId).show();
579
                $(newCopiesRowId).show();
580
                $("#max_holds").show();
574
            } else {
581
            } else {
575
                $(newCopiesRowId).hide();
582
                $(newCopiesRowId).hide();
583
                $("#max_holds").hide();
576
             }
584
             }
577
        };
585
        };
578
586
Lines 702-707 Link Here
702
            [% END %]
710
            [% END %]
703
        [% END %]
711
        [% END %]
704
712
713
        $(".checkitem").change(function(e){
714
            if ( $(".checkitem:checked").length > max_holds.data('val') ) {
715
                e.preventDefault();
716
                alert(MSG_EXCEEDED_MAX_HOLDS);
717
                $(this).prop('checked',false);
718
            }
719
        });
705
 });
720
 });
706
// ]]>
721
// ]]>
707
</script>
722
</script>
(-)a/opac/opac-reserve.pl (-1 / +41 lines)
Lines 44-49 use Koha::Libraries; Link Here
44
use Koha::Patrons;
44
use Koha::Patrons;
45
use Date::Calc qw/Today Date_to_Days/;
45
use Date::Calc qw/Today Date_to_Days/;
46
use List::MoreUtils qw/uniq/;
46
use List::MoreUtils qw/uniq/;
47
use List::Util qw[min max];
47
48
48
my $maxreserves = C4::Context->preference("maxreserves");
49
my $maxreserves = C4::Context->preference("maxreserves");
49
50
Lines 214-219 if ( $query->param('place_reserve') ) { Link Here
214
        $selectedItems = "$bib/$item/$branch/";
215
        $selectedItems = "$bib/$item/$branch/";
215
    }
216
    }
216
217
218
    my @multi_bibs = $query->multi_param('single_bib');
219
    if ( $query->param('reserve_mode') eq 'multi' and @multi_bibs == 1 ) {
220
        # multiple holds on same record
221
        my $biblionumber = $query->param('single_bib');
222
        my @itemnumbers = $query->multi_param("checkitem_$biblionumber");
223
        my $branch = $query->param('branch');
224
        foreach my $itemnumber ( @itemnumbers ) {
225
            $selectedItems .= "$biblionumber/$itemnumber/$branch/";
226
        }
227
    }
228
217
    $selectedItems =~ s!/$!!;
229
    $selectedItems =~ s!/$!!;
218
    my @selectedItems = split /\//, $selectedItems, -1;
230
    my @selectedItems = split /\//, $selectedItems, -1;
219
231
Lines 464-469 foreach my $biblioNum (@biblionumbers) { Link Here
464
476
465
    my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list };
477
    my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list };
466
478
479
    # For a librarian to be able to place multiple record holds for a patron for a record,
480
    # we must find out what the maximum number of holds they can place for the patron is
481
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblioNum );
482
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
483
484
    # Determine how many holds the patron can place per day on this biblio record.
485
    # Then calculate how many holds the patron can place subtracting holds already placed today
486
    my $today_holds = Koha::Holds->search({
487
        borrowernumber => $patron->borrowernumber,
488
        reservedate => dt_from_string->date,
489
    })->count;
490
491
    my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron );
492
    my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds;
493
    my $maxreserves = C4::Context->preference('maxreserves');
494
495
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
496
    $biblioLoopIter{remaining_holds_allowed_today} = $remaining_holds_allowed_today;
497
498
    # Determine what is the lowest value
499
    my $lowestvalue = min( $maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today );
500
501
    $template->param(
502
        max_holds_for_record => $max_holds_for_record,
503
        remaining_holds_for_record => $remaining_holds_for_record,
504
        lowest_value => $lowestvalue,
505
        remaining_holds_allowed_today => $remaining_holds_allowed_today,
506
    );
507
467
    # Only keep the items that are visible in the opac (i.e. those in %visible_items)
508
    # Only keep the items that are visible in the opac (i.e. those in %visible_items)
468
    # FIXME: We should get rid of itemInfos altogether and use $visible_items
509
    # FIXME: We should get rid of itemInfos altogether and use $visible_items
469
    $biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ];
510
    $biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ];
470
- 

Return to bug 15565