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 339-344 Link Here
339
                                                        />
339
                                                        />
340
                                                    </li>
340
                                                    </li>
341
                                                [% END # / IF bibitemloo.itemholdable %]
341
                                                [% END # / IF bibitemloo.itemholdable %]
342
343
                                                [% IF lowest_value %]
344
                                                    <li id="max_holds" style="display:none;" data-val="[% lowest_value | html %]"><strong>Maximum holds allowed:</strong> [% lowest_value | html %]</li>
345
                                                [% END %]
342
                                            </ul>
346
                                            </ul>
343
347
344
                                            [% IF bibitemloo.itemholdable %]
348
                                            [% IF bibitemloo.itemholdable %]
Lines 368-374 Link Here
368
                                                        <tr class="[% itemLoo.backgroundcolor | html %]">
372
                                                        <tr class="[% itemLoo.backgroundcolor | html %]">
369
                                                            <td class="copynumber">
373
                                                            <td class="copynumber">
370
                                                                [% IF ( itemLoo.available ) %]
374
                                                                [% IF ( itemLoo.available ) %]
371
                                                                    <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
375
                                                                    <input type="checkbox" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
372
                                                                [% ELSE %]
376
                                                                [% ELSE %]
373
                                                                    <input disabled="disabled" type="radio" aria-label="Cannot be put on hold" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber | html %]"
377
                                                                    <input disabled="disabled" type="radio" aria-label="Cannot be put on hold" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber | html %]"
374
                                                                           style="display:none;" />
378
                                                                           style="display:none;" />
Lines 470-475 Link Here
470
<script>
474
<script>
471
// <![CDATA[
475
// <![CDATA[
472
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
476
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
477
    var MSG_EXCEEDED_MAX_HOLDS = __("Patron reached the maximum number of holds.");
478
    var max_holds = $("#max_holds");
473
479
474
        // Clear the contents of an input field
480
        // Clear the contents of an input field
475
        $(".clearfield").on("click",function(e){
481
        $(".clearfield").on("click",function(e){
Lines 479-486 Link Here
479
485
480
    // Select the first item available
486
    // Select the first item available
481
    function select_first_available(id){
487
    function select_first_available(id){
482
        var radios = $("input:radio[name='checkitem_" + id + "']");
488
        var checkboxes = $("input:checkbox[name='checkitem_" + id + "']");
483
        $(radios).first().attr("checked", "checked");
489
        $(checkboxes).first().attr("checked", "checked");
484
    }
490
    }
485
491
486
    $(document).ready(function() {
492
    $(document).ready(function() {
Lines 572-579 Link Here
572
            // If the checkbox is checked AND we want a specific item, we display the items block
578
            // If the checkbox is checked AND we want a specific item, we display the items block
573
            if ( $(checkbox).is(":checked") && select_specific ) {
579
            if ( $(checkbox).is(":checked") && select_specific ) {
574
                $(newCopiesRowId).show();
580
                $(newCopiesRowId).show();
581
                $("#max_holds").show();
575
            } else {
582
            } else {
576
                $(newCopiesRowId).hide();
583
                $(newCopiesRowId).hide();
584
                $("#max_holds").hide();
577
             }
585
             }
578
        };
586
        };
579
587
Lines 703-708 Link Here
703
            [% END %]
711
            [% END %]
704
        [% END %]
712
        [% END %]
705
713
714
        $(".checkitem").change(function(e){
715
            if ( $(".checkitem:checked").length > max_holds.data('val') ) {
716
                e.preventDefault();
717
                alert(MSG_EXCEEDED_MAX_HOLDS);
718
                $(this).prop('checked',false);
719
            }
720
        });
706
 });
721
 });
707
// ]]>
722
// ]]>
708
</script>
723
</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 466-471 foreach my $biblioNum (@biblionumbers) { Link Here
466
478
467
    my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list };
479
    my $visible_items = { map { $_->itemnumber => $_ } $biblio->items->filter_by_visible_in_opac( { patron => $patron } )->as_list };
468
480
481
    # For a librarian to be able to place multiple record holds for a patron for a record,
482
    # we must find out what the maximum number of holds they can place for the patron is
483
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblioNum );
484
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
485
486
    # Determine how many holds the patron can place per day on this biblio record.
487
    # Then calculate how many holds the patron can place subtracting holds already placed today
488
    my $today_holds = Koha::Holds->search({
489
        borrowernumber => $patron->borrowernumber,
490
        reservedate => dt_from_string->date,
491
    })->count;
492
493
    my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron );
494
    my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds;
495
    my $maxreserves = C4::Context->preference('maxreserves');
496
497
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
498
    $biblioLoopIter{remaining_holds_allowed_today} = $remaining_holds_allowed_today;
499
500
    # Determine what is the lowest value
501
    my $lowestvalue = min( $maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today );
502
503
    $template->param(
504
        max_holds_for_record => $max_holds_for_record,
505
        remaining_holds_for_record => $remaining_holds_for_record,
506
        lowest_value => $lowestvalue,
507
        remaining_holds_allowed_today => $remaining_holds_allowed_today,
508
    );
509
469
    # Only keep the items that are visible in the opac (i.e. those in %visible_items)
510
    # Only keep the items that are visible in the opac (i.e. those in %visible_items)
470
    # FIXME: We should get rid of itemInfos altogether and use $visible_items
511
    # FIXME: We should get rid of itemInfos altogether and use $visible_items
471
    $biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ];
512
    $biblioData->{itemInfos} = [ grep { $visible_items->{ $_->{itemnumber} } } @{ $biblioData->{itemInfos} } ];
472
- 

Return to bug 15565