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

(-)a/C4/Reserves.pm (+1 lines)
Lines 4-9 package C4::Reserves; Link Here
4
#           2006 SAN Ouest Provence
4
#           2006 SAN Ouest Provence
5
#           2007-2010 BibLibre Paul POULAIN
5
#           2007-2010 BibLibre Paul POULAIN
6
#           2011 Catalyst IT
6
#           2011 Catalyst IT
7
#           2018 Catalyst IT
7
#
8
#
8
# This file is part of Koha.
9
# This file is part of Koha.
9
#
10
#
(-)a/Koha/Biblio.pm (+32 lines)
Lines 425-430 sub has_items_waiting_or_intransit { Link Here
425
    return 0;
425
    return 0;
426
}
426
}
427
427
428
=head3 allowed_holds
429
430
my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron_obj );
431
432
Calculates and returns the number of item-level holds a borrower is allowed to place on the record on a single day.
433
434
=cut
435
436
sub allowed_holds {
437
438
    my ( $self, $patron ) = @_;
439
440
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
441
442
    my $categorycode = $patron->categorycode;
443
    my $branchcode;
444
    $branchcode = $patron->branchcode if ( $controlbranch eq "PatronLibrary" );
445
446
    my $holds_allowed = 0;
447
    foreach my $item ( $self->items()->as_list() ) {
448
        my $itemtype = $item->effective_itemtype();
449
        $branchcode = $item->homebranch if ( $controlbranch eq "ItemHomeLibrary" );
450
451
        my $rule = C4::Reserves::GetHoldRule( $categorycode, $itemtype, $branchcode );
452
        my $holds_per_day = $rule ? $rule->{holds_per_day} : 0;
453
        if ( $holds_per_day ) {
454
            $holds_allowed = $holds_per_day if $holds_per_day > $holds_allowed;
455
        }
456
    }
457
    return $holds_allowed;
458
}
459
428
=head3 type
460
=head3 type
429
461
430
=cut
462
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-3 / +22 lines)
Lines 249-255 Link Here
249
          [% IF remaining_holds_for_record > 1 %]
249
          [% IF remaining_holds_for_record > 1 %]
250
              <li>
250
              <li>
251
                   <label for="holds_to_place_count">Holds to place (count)</label>
251
                   <label for="holds_to_place_count">Holds to place (count)</label>
252
                   <input type="number" name="holds_to_place_count" min="1" max="[% remaining_holds_for_record | html %]" step="1" value="1" />
252
                   <input type="number" name="holds_to_place_count" min="1" max="[% lowest_value | html %]" step="1" value="1" />
253
              </li>
253
              </li>
254
            [% ELSE %]
254
            [% ELSE %]
255
                <input type="hidden" name="holds_to_place_count" value="1" />
255
                <input type="hidden" name="holds_to_place_count" value="1" />
Lines 671-678 Link Here
671
            [% END %][% END %][% END %]
671
            [% END %][% END %][% END %]
672
        };
672
        };
673
        var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
673
        var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
674
        var MSG_EXCEEDED_HOLDS_PER_RECORD = _("Patron has exceeded the number of holds for this record.");
674
        var MSG_EXCEEDED_HOLDS_PER_RECORD = _("Patron reached the maximum number of holds for this record.");
675
        var MSG_EXCEEDED_HOLDS_PER_DAY =  _("Patron reached the maximum number of holds allowed today.");
676
        var MSG_EXCEEDED_MAXRESERVES_SYSPREF = _("Patron reached the maximum number of holds allowed at once");
675
        var remainingHolds = "[% remaining_holds_for_record | html %]";
677
        var remainingHolds = "[% remaining_holds_for_record | html %]";
678
        var remainingHoldsToday = "[% remainig_holds_allowed_today | html %]";
679
        var maxreserves = "[% maxreserves | html %]";
676
680
677
        $(document).ready(function() {
681
        $(document).ready(function() {
678
            function ToggleHoldsToPlace() {
682
            function ToggleHoldsToPlace() {
Lines 808-815 Link Here
808
                } else {
812
                } else {
809
                    $("#requestany").prop("checked",true);
813
                    $("#requestany").prop("checked",true);
810
                }
814
                }
811
                if (remainingHolds - numchecked < 0) {
815
                if (remainingHolds - numchecked <= 0) {
812
                    alert(MSG_EXCEEDED_HOLDS_PER_RECORD);
816
                    alert(MSG_EXCEEDED_HOLDS_PER_RECORD);
817
                    [% IF !(Koha.Preference('AllowHoldPolicyOverride')) %]
818
                        $('input[name=checkitem]:not(:checked)').attr('disabled', 'disabled');
819
                    [% END %]
820
                }
821
                if (remainingHoldsToday - numchecked <= 0) {
822
                    alert(MSG_EXCEEDED_HOLDS_PER_DAY);
823
                    [% IF !(Koha.Preference('AllowHoldPolicyOverride')) %]
824
                        $('input[name=checkitem]:not(:checked)').attr('disabled', 'disabled');
825
                    [% END %]
826
                }
827
                if (maxreserves - numchecked <= 0) {
828
                    alert(MSG_EXCEEDED_MAXRESERVES_SYSPREF);
829
                    [% IF !(Koha.Preference('AllowHoldPolicyOverride')) %]
830
                        $('input[name=checkitem]:not(:checked)').attr('disabled', 'disabled');
831
                    [% END %]
813
                }
832
                }
814
            });
833
            });
815
            var prev_rank_request;
834
            var prev_rank_request;
(-)a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss (+1 lines)
Lines 3004-3009 button.closebtn { Link Here
3004
3004
3005
.hold-options {
3005
.hold-options {
3006
    clear: both;
3006
    clear: both;
3007
    width: auto;
3007
}
3008
}
3008
3009
3009
.toggle-hold-options {
3010
.toggle-hold-options {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-5 / +45 lines)
Lines 156-161 Link Here
156
                                [% FOREACH bibitemloo IN bibitemloop %]
156
                                [% FOREACH bibitemloo IN bibitemloop %]
157
                                    <div class="holdrow">
157
                                    <div class="holdrow">
158
                                        <input id="remaining_holds_[% bibitemloo.biblionumber | html %]" type="hidden" value="[% bibitemloo.remaining_holds_for_record | html %]"/>
158
                                        <input id="remaining_holds_[% bibitemloo.biblionumber | html %]" type="hidden" value="[% bibitemloo.remaining_holds_for_record | html %]"/>
159
                                        <input id="remaining_holds_allowed_today[% bibitemloo.biblionumber | html %]" type="hidden" value="[% bibitemloo.remaining_holds_allowed_today | html %]"/>
159
                                        <p>
160
                                        <p>
160
                                            [% IF ( bibitemloo.holdable ) %]
161
                                            [% IF ( bibitemloo.holdable ) %]
161
                                                <span title="[% bibitemloo.biblionumber %]" style="padding:.3em">
162
                                                <span title="[% bibitemloo.biblionumber %]" style="padding:.3em">
Lines 302-309 Link Here
302
                                                            </li>
303
                                                            </li>
303
                                                        [% END # / IF OpacHoldNotes %]
304
                                                        [% END # / IF OpacHoldNotes %]
304
305
306
                                                        [% IF bibitemloo.itemholdable %]
305
                                                        <!-- ITEM HOLDS -->
307
                                                        <!-- ITEM HOLDS -->
306
                                                        <li class="lradio place_on_type" style="display:none;">
308
                                                        <li class="lradio place_on_type" style="display:none;">
309
                                                            [% IF NOT bibitemloo.force_hold %]
307
                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber | html %]">Next available item</label>
310
                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber | html %]">Next available item</label>
308
                                                                <input type="radio" name="reqtype_[% bibitemloo.biblionumber | html %]"
311
                                                                <input type="radio" name="reqtype_[% bibitemloo.biblionumber | html %]"
309
                                                                        id="reqany_[% bibitemloo.biblionumber | html %]"
312
                                                                        id="reqany_[% bibitemloo.biblionumber | html %]"
Lines 311-316 Link Here
311
                                                                        value="Any"
314
                                                                        value="Any"
312
                                                                        checked="checked"
315
                                                                        checked="checked"
313
                                                                />
316
                                                                />
317
                                                            [% END %]
314
                                                            <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber | html %]">A specific item</label>
318
                                                            <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber | html %]">A specific item</label>
315
                                                            <input type="radio" name="reqtype_[% bibitemloo.biblionumber | html %]"
319
                                                            <input type="radio" name="reqtype_[% bibitemloo.biblionumber | html %]"
316
                                                                   id="reqspecific_[% bibitemloo.biblionumber | html %]"
320
                                                                   id="reqspecific_[% bibitemloo.biblionumber | html %]"
Lines 318-323 Link Here
318
                                                                   value="Specific"
322
                                                                   value="Specific"
319
                                                            />
323
                                                            />
320
                                                        </li>
324
                                                        </li>
325
                                                        [% END # / IF bibitemloo.itemholdable %]
321
                                                    </ul>
326
                                                    </ul>
322
327
323
                                                    [% IF bibitemloo.remaining_holds_for_record > 1 %]
328
                                                    [% IF bibitemloo.remaining_holds_for_record > 1 %]
Lines 325-331 Link Here
325
                                                        <div id="holds_to_place_[% bibitemloo.biblionumber | html %]" class="hold-options holds-to-place">
330
                                                        <div id="holds_to_place_[% bibitemloo.biblionumber | html %]" class="hold-options holds-to-place">
326
                                                            <label>Holds to place (count)</label>
331
                                                            <label>Holds to place (count)</label>
327
                                                            <select name="holds_to_place_count_[% bibitemloo.biblionumber | html %]">
332
                                                            <select name="holds_to_place_count_[% bibitemloo.biblionumber | html %]">
328
                                                            [% WHILE count <= bibitemloo.remaining_holds_for_record %]
333
                                                            [% WHILE count <= bibitemloo.lowest_value %]
329
                                                                <option value="[% count | html %]">[% count | html %]</option>
334
                                                                <option value="[% count | html %]">[% count | html %]</option>
330
                                                                [% SET count = count + 1 %]
335
                                                                [% SET count = count + 1 %]
331
                                                            [% END %]
336
                                                            [% END %]
Lines 462-468 Link Here
462
<script>
467
<script>
463
// <![CDATA[
468
// <![CDATA[
464
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
469
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
465
    var MSG_MAX_HOLDS_EXCEEDED = _("Maximum number of reserve exceded.");
470
    var MSG_MAX_HOLDS_EXCEEDED = _("Maximum number of holds for this record reached.");
471
    var MSG_EXCEEDED_HOLDS_PER_DAY =  _("Maximum number of holds allowed today reached.");
472
    var MSG_EXCEEDED_MAXRESERVES_SYSPREF = _("Maximum number of holds allowed at once reached");
466
473
467
        // Clear the contents of an input field
474
        // Clear the contents of an input field
468
        $(".clearfield").on("click",function(e){
475
        $(".clearfield").on("click",function(e){
Lines 497-506 Link Here
497
        $('.checkitem').click(function(e) {
504
        $('.checkitem').click(function(e) {
498
            var bibNum = suffixOf($(this).attr("name"), "_");
505
            var bibNum = suffixOf($(this).attr("name"), "_");
499
            var nbCheked = $("input[name='checkitem_"+bibNum+"']:checked").length;
506
            var nbCheked = $("input[name='checkitem_"+bibNum+"']:checked").length;
500
            var remaining = $("input[id='remaining_holds_"+bibNum+"']").val();
507
            var remaining = $("input[id='remaining_holds_allowed_today"+bibNum+"']").val();
508
            var maxreserves = "[% maxreserves | html %]";
501
            if (nbCheked >= remaining) {
509
            if (nbCheked >= remaining) {
510
                alert(MSG_MAX_HOLDS_EXCEEDED);
511
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled');
512
            }
513
            else if (nbCheked >= remaining_holds_today) {
514
                alert(MSG_EXCEEDED_HOLDS_PER_DAY);
502
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled');
515
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled');
503
            }
516
            }
517
            else if (nbCheked >= maxreserves) {
518
                alert(MSG_EXCEEDED_MAXRESERVES_SYSPREF);
519
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled'); 
520
            }
504
            else {
521
            else {
505
                $('.checkitem_'+bibNum).attr('disabled', false);
522
                $('.checkitem_'+bibNum).attr('disabled', false);
506
            }
523
            }
Lines 530-537 Link Here
530
                    $("#toggle-hold-options-[% bibitemloo.biblionumber | html %]").click();
547
                    $("#toggle-hold-options-[% bibitemloo.biblionumber | html %]").click();
531
                    $("#reqany_[% bibitemloo.biblionumber | html %]").attr('checked', true);
548
                    $("#reqany_[% bibitemloo.biblionumber | html %]").attr('checked', true);
532
                [% END %]
549
                [% END %]
533
                $("#reqany_[% bibitemloo.biblionumber | html %]").attr('disabled', 'disabled');
534
                $("#reqspecific_[% bibitemloo.biblionumber | html %]").attr('disabled', 'disabled');
535
            [% END %]
550
            [% END %]
536
            [% IF bibitemloo.reqholdnotes %]
551
            [% IF bibitemloo.reqholdnotes %]
537
                $("#holdnotes_[% bibitemloo.biblionumber | html %]").attr( 'required', true );
552
                $("#holdnotes_[% bibitemloo.biblionumber | html %]").attr( 'required', true );
Lines 562-567 Link Here
562
            if ( $(checkbox).is(":checked") && select_specific ) {
577
            if ( $(checkbox).is(":checked") && select_specific ) {
563
                $(newCopiesRowId).show();
578
                $(newCopiesRowId).show();
564
                $(holdsToPlaceCountId).hide();
579
                $(holdsToPlaceCountId).hide();
580
581
                //Check if maximum holds is reached and if it has then disable un-checked item checkboxes and display message
582
                var nbCheked = 1;
583
                var remaining = $("input[id='remaining_holds_"+biblioNum+"']").val();
584
                var remaining_holds_today = $("input[id='remaining_holds_allowed_today"+biblioNum+"']").val();
585
                var maxreserves = "[% maxreserves | html %]";
586
                if (nbCheked == remaining) {
587
                    if (remaining != '1') {
588
                        alert(MSG_MAX_HOLDS_EXCEEDED);
589
                    }
590
591
                    $("input[name='checkitem_"+biblioNum+"']:not(:checked)").attr('disabled', 'disabled');
592
                }
593
                else if (nbCheked == remaining_holds_today) {
594
                    if (remaining_holds_today != '1') {
595
                        alert(MSG_EXCEEDED_HOLDS_PER_DAY);
596
                    }
597
                    $("input[name='checkitem_"+biblioNum+"']:not(:checked)").attr('disabled', 'disabled');
598
                }
599
                else if (nbCheked == maxreserves) {
600
                    if (maxreserves != '1') {
601
                        alert(MSG_EXCEEDED_MAXRESERVES_SYSPREF);
602
                    }
603
                    $("input[name='checkitem_"+biblioNum+"']:not(:checked)").attr('disabled', 'disabled');
604
                }
565
            } else {
605
            } else {
566
                $(newCopiesRowId).hide();
606
                $(newCopiesRowId).hide();
567
                $(holdsToPlaceCountId).show();
607
                $(holdsToPlaceCountId).show();
(-)a/opac/opac-reserve.pl (-2 / +19 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 65-70 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
65
    }
66
    }
66
);
67
);
67
68
69
$template->param(maxreserves => $maxreserves);
70
68
my ($show_holds_count, $show_priority);
71
my ($show_holds_count, $show_priority);
69
for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
72
for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
70
    m/holds/o and $show_holds_count = 1;
73
    m/holds/o and $show_holds_count = 1;
Lines 113-119 my @biblionumbers = ref($query->param('biblionumbers')) eq 'Array' Link Here
113
    : split(/\//, $query->param('biblionumbers'));
116
    : split(/\//, $query->param('biblionumbers'));
114
117
115
unless (@biblionumbers) {
118
unless (@biblionumbers) {
116
    push(@biblionumbers, $query->param('biblionumber'));
119
    push(@biblionumbers, $query->multi_param('biblionumber'));
117
}
120
}
118
121
119
# Pass the numbers to the page so they can be fed back
122
# Pass the numbers to the page so they can be fed back
Lines 283-289 if ( $query->param('place_reserve') ) { Link Here
283
            print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
286
            print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
284
            exit;
287
            exit;
285
        }
288
        }
286
        $canreserve = 0 unless CanBookBeReserved( $borrowernumber, $biblioNum ) eq 'OK';
289
        $canreserve = 0 unless CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
287
290
288
        unless ( $can_place_hold_if_available_at_pickup ) {
291
        unless ( $can_place_hold_if_available_at_pickup ) {
289
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
292
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
Lines 629-636 foreach my $biblioNum (@biblionumbers) { Link Here
629
632
630
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowernumber, $biblioNum );
633
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowernumber, $biblioNum );
631
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
634
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
635
636
    my $today_holds = Koha::Holds->search({
637
        borrowernumber => $borrowernumber,
638
        reservedate    => dt_from_string->date
639
    });
640
641
    my $biblio_record = Koha::Biblios->find( $biblioNum );
642
    my $patron_obj = Koha::Patrons->find( $borrowernumber );
643
    my $holds_allowed_on_record_today = $biblio_record->allowed_holds( $patron_obj );
644
    my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds->count();
632
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
645
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
646
    $biblioLoopIter{remaining_holds_allowed_today} = $remaining_holds_allowed_today;
633
647
648
    #Determine what is the lowest value
649
    my $lowestvalue = min($maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today);
650
    $biblioLoopIter{lowest_value} = $lowestvalue;
634
651
635
    push @$biblioLoop, \%biblioLoopIter;
652
    push @$biblioLoop, \%biblioLoopIter;
636
653
(-)a/reserve/request.pl (-1 / +24 lines)
Lines 30-35 use Modern::Perl; Link Here
30
30
31
use CGI qw ( -utf8 );
31
use CGI qw ( -utf8 );
32
use List::MoreUtils qw/uniq/;
32
use List::MoreUtils qw/uniq/;
33
use List::Uil qw[min max];
33
use Date::Calc qw/Date_to_Days/;
34
use Date::Calc qw/Date_to_Days/;
34
use C4::Output;
35
use C4::Output;
35
use C4::Auth;
36
use C4::Auth;
Lines 39-45 use C4::Items; Link Here
39
use C4::Koha;
40
use C4::Koha;
40
use C4::Serials;
41
use C4::Serials;
41
use C4::Circulation;
42
use C4::Circulation;
42
use Koha::DateUtils;
43
use C4::Utils::DataTables::Members;
43
use C4::Utils::DataTables::Members;
44
use C4::Members;
44
use C4::Members;
45
use C4::Search;		# enabled_staff_search_views
45
use C4::Search;		# enabled_staff_search_views
Lines 264-272 foreach my $biblionumber (@biblionumbers) { Link Here
264
        # we must find out what the maximum number of holds they can place for the patron is
264
        # we must find out what the maximum number of holds they can place for the patron is
265
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
265
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
266
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
266
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
267
268
        # Determine how many holds the patron can place per day on this biblio record.
269
        # Then calculate how many holds the patron can place subtracting holds already placed today
270
        my $today_holds = Koha::Holds->search({
271
            borrowernumber => $patron->borrowernumber,
272
            reservedate    => dt_from_string->date
273
        });
274
275
        my $biblio_record = Koha::Biblios->find( $biblionumber );
276
        my $patron_obj = Koha::Patrons->find( $patron->borrowernumber );
277
        my $holds_allowed_on_record_today = $biblio_record->allowed_holds( $patron_obj );
278
        my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds->count();
279
        my $maxreserves = C4::Context->preference('maxreserves');
280
267
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
281
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
282
        $biblioloopiter{remaining_holds_allowed_today} = $holds_allowed_on_record_today;
283
284
        # Determine what is the lowest value
285
        my $lowestvalue = min($maxreserves, $biblioloopiter{remaining_holds_for_record}, $biblioloopiter{remaining_holds_allowed_today});
286
287
        $template->param( lowest_value => $lowestvalue );
268
        $template->param( max_holds_for_record => $max_holds_for_record );
288
        $template->param( max_holds_for_record => $max_holds_for_record );
269
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
289
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
290
        $template->param( holds_allowed_on_record_today => $holds_allowed_on_record_today );
291
        $template->param( remaining_holds_allowed_today => $remaining_holds_allowed_today );
292
        $template->param( maxreserves => $maxreserves );
270
293
271
        { # alreadypossession
294
        { # alreadypossession
272
            # Check to see if patron is allowed to place holds on records where the
295
            # Check to see if patron is allowed to place holds on records where the
(-)a/t/db_dependent/Reserves/MultiplePerRecord.t (-2 / +18 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2016 ByWater Solutions
3
# Copyright 2016 ByWater Solutions
4
# Copyright 2018 Catalyst IT
4
#
5
#
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 19-25 Link Here
19
20
20
use Modern::Perl;
21
use Modern::Perl;
21
22
22
use Test::More tests => 38;
23
use Test::More tests => 42;
23
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
24
use t::lib::Mocks;
25
use t::lib::Mocks;
25
26
Lines 197-207 my $rule4 = $rules_rs->new( Link Here
197
        branchcode       => '*',
198
        branchcode       => '*',
198
        reservesallowed  => 4,
199
        reservesallowed  => 4,
199
        holds_per_record => 4,
200
        holds_per_record => 4,
201
        holds_per_day    => 4,
200
    }
202
    }
201
)->insert();
203
)->insert();
202
204
203
$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} );
205
$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} );
204
is( $max, 4, 'GetMaxPatronHoldsForRecord returns max of 4' );
206
is( $max, 4, 'GetMaxPatronHoldsForRecord returns max of 4' );
207
208
my $biblio_record = Koha::Biblios->find( $biblio->{biblionumber} );
209
my $patron_obj = Koha::Patrons->find( $patron->{borrowernumber} );
210
211
my $holds_per_day = $biblio_record->allowed_holds( $patron_obj );
212
is( $holds_per_day, 4, 'GetAllowedHoldsForPatronToday returns max of 4' );
213
205
$rule = C4::Reserves::GetHoldRule(
214
$rule = C4::Reserves::GetHoldRule(
206
    $category->{categorycode},
215
    $category->{categorycode},
207
    $itemtype2->{itemtype},
216
    $itemtype2->{itemtype},
Lines 212-217 is( $rule->{itemtype}, $itemtype2->{itemtype}, 'Got rule with univers Link Here
212
is( $rule->{branchcode},       '*',                       'Got rule with universal branchcode' );
221
is( $rule->{branchcode},       '*',                       'Got rule with universal branchcode' );
213
is( $rule->{reservesallowed},  4,                         'Got reservesallowed of 4' );
222
is( $rule->{reservesallowed},  4,                         'Got reservesallowed of 4' );
214
is( $rule->{holds_per_record}, 4,                         'Got holds_per_record of 4' );
223
is( $rule->{holds_per_record}, 4,                         'Got holds_per_record of 4' );
224
is( $rule->{holds_per_day},    4,                         'Got holds_per_day of 4' );
215
225
216
my $rule5 = $rules_rs->new(
226
my $rule5 = $rules_rs->new(
217
    {
227
    {
Lines 220-230 my $rule5 = $rules_rs->new( Link Here
220
        branchcode       => $library->{branchcode},
230
        branchcode       => $library->{branchcode},
221
        reservesallowed  => 5,
231
        reservesallowed  => 5,
222
        holds_per_record => 5,
232
        holds_per_record => 5,
233
        holds_per_day    => 5,
223
    }
234
    }
224
)->insert();
235
)->insert();
225
236
226
$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} );
237
$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} );
227
is( $max, 5, 'GetMaxPatronHoldsForRecord returns max of 1' );
238
is( $max, 5, 'GetMaxPatronHoldsForRecord returns max of 1' );
239
240
$holds_per_day = $biblio_record->allowed_holds( $patron_obj );
241
is( $holds_per_day, 5, 'GetAllowedHoldsForPatronToday returns max of 5' );
242
228
$rule = C4::Reserves::GetHoldRule(
243
$rule = C4::Reserves::GetHoldRule(
229
    $category->{categorycode},
244
    $category->{categorycode},
230
    $itemtype2->{itemtype},
245
    $itemtype2->{itemtype},
Lines 235-240 is( $rule->{itemtype}, $itemtype2->{itemtype}, 'Got rule with univers Link Here
235
is( $rule->{branchcode},       $library->{branchcode},    'Got rule with specific branchcode' );
250
is( $rule->{branchcode},       $library->{branchcode},    'Got rule with specific branchcode' );
236
is( $rule->{reservesallowed},  5,                         'Got reservesallowed of 5' );
251
is( $rule->{reservesallowed},  5,                         'Got reservesallowed of 5' );
237
is( $rule->{holds_per_record}, 5,                         'Got holds_per_record of 5' );
252
is( $rule->{holds_per_record}, 5,                         'Got holds_per_record of 5' );
253
is( $rule->{holds_per_day},    5,                         'Got holds_per_day of 5' );
238
254
239
$rule1->delete();
255
$rule1->delete();
240
$rule2->delete();
256
$rule2->delete();
Lines 273-278 $rule = $rules_rs->new( Link Here
273
        branchcode       => '*',
289
        branchcode       => '*',
274
        reservesallowed  => 2,
290
        reservesallowed  => 2,
275
        holds_per_record => 2,
291
        holds_per_record => 2,
292
        holds_per_day    => 2,
276
    }
293
    }
277
)->insert();
294
)->insert();
278
295
279
- 

Return to bug 15565