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 467-472 sub has_items_waiting_or_intransit { Link Here
467
    return 0;
467
    return 0;
468
}
468
}
469
469
470
=head3 allowed_holds
471
472
my $holds_allowed_on_record_today = $biblio->allowed_holds( $patron_obj );
473
474
Calculates and returns the number of item-level holds a borrower is allowed to place on the record on a single day.
475
476
=cut
477
478
sub allowed_holds {
479
480
    my ( $self, $patron ) = @_;
481
482
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
483
484
    my $categorycode = $patron->categorycode;
485
    my $branchcode;
486
    $branchcode = $patron->branchcode if ( $controlbranch eq "PatronLibrary" );
487
488
    my $holds_allowed = 0;
489
    foreach my $item ( $self->items()->as_list() ) {
490
        my $itemtype = $item->effective_itemtype();
491
        $branchcode = $item->homebranch if ( $controlbranch eq "ItemHomeLibrary" );
492
493
        my $rule = C4::Reserves::GetHoldRule( $categorycode, $itemtype, $branchcode );
494
        my $holds_per_day = $rule ? $rule->{holds_per_day} : 0;
495
        if ( $holds_per_day ) {
496
            $holds_allowed = $holds_per_day if $holds_per_day > $holds_allowed;
497
        }
498
    }
499
    return $holds_allowed;
500
}
501
470
=head3 type
502
=head3 type
471
503
472
=cut
504
=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 677-684 Link Here
677
        };
677
        };
678
        var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
678
        var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
679
        columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
679
        columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
680
        var MSG_EXCEEDED_HOLDS_PER_RECORD = _("Patron has exceeded the number of holds for this record.");
680
        var MSG_EXCEEDED_HOLDS_PER_RECORD = _("Patron reached the maximum number of holds for this record.");
681
        var MSG_EXCEEDED_HOLDS_PER_DAY =  _("Patron reached the maximum number of holds allowed today.");
682
        var MSG_EXCEEDED_MAXRESERVES_SYSPREF = _("Patron reached the maximum number of holds allowed at once");
681
        var remainingHolds = "[% remaining_holds_for_record | html %]";
683
        var remainingHolds = "[% remaining_holds_for_record | html %]";
684
        var remainingHoldsToday = "[% remainig_holds_allowed_today | html %]";
685
        var maxreserves = "[% maxreserves | html %]";
682
686
683
        $(document).ready(function() {
687
        $(document).ready(function() {
684
            function ToggleHoldsToPlace() {
688
            function ToggleHoldsToPlace() {
Lines 824-831 Link Here
824
                } else {
828
                } else {
825
                    $("#requestany").prop("checked",true);
829
                    $("#requestany").prop("checked",true);
826
                }
830
                }
827
                if (remainingHolds - numchecked < 0) {
831
                if (remainingHolds - numchecked <= 0) {
828
                    alert(MSG_EXCEEDED_HOLDS_PER_RECORD);
832
                    alert(MSG_EXCEEDED_HOLDS_PER_RECORD);
833
                    [% IF !(Koha.Preference('AllowHoldPolicyOverride')) %]
834
                        $('input[name=checkitem]:not(:checked)').attr('disabled', 'disabled');
835
                    [% END %]
836
                }
837
                if (remainingHoldsToday - numchecked <= 0) {
838
                    alert(MSG_EXCEEDED_HOLDS_PER_DAY);
839
                    [% IF !(Koha.Preference('AllowHoldPolicyOverride')) %]
840
                        $('input[name=checkitem]:not(:checked)').attr('disabled', 'disabled');
841
                    [% END %]
842
                }
843
                if (maxreserves - numchecked <= 0) {
844
                    alert(MSG_EXCEEDED_MAXRESERVES_SYSPREF);
845
                    [% IF !(Koha.Preference('AllowHoldPolicyOverride')) %]
846
                        $('input[name=checkitem]:not(:checked)').attr('disabled', 'disabled');
847
                    [% END %]
829
                }
848
                }
830
            });
849
            });
831
            var prev_rank_request;
850
            var prev_rank_request;
(-)a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss (+1 lines)
Lines 3042-3047 button.closebtn { Link Here
3042
3042
3043
.hold-options {
3043
.hold-options {
3044
    clear: both;
3044
    clear: both;
3045
    width: auto;
3045
}
3046
}
3046
3047
3047
.toggle-hold-options {
3048
.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-504 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);
515
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled');
516
            }
517
            else if (nbCheked >= maxreserves) {
518
                alert(MSG_EXCEEDED_MAXRESERVES_SYSPREF);
502
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled');
519
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled');
503
            }
520
            }
504
            else {
521
            else {
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 298-304 if ( $query->param('place_reserve') ) { Link Here
298
            print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
301
            print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
299
            exit;
302
            exit;
300
        }
303
        }
301
        $canreserve = 0 unless CanBookBeReserved( $borrowernumber, $biblioNum ) eq 'OK';
304
        $canreserve = 0 unless CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
302
305
303
        unless ( $can_place_hold_if_available_at_pickup ) {
306
        unless ( $can_place_hold_if_available_at_pickup ) {
304
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
307
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
Lines 644-651 foreach my $biblioNum (@biblionumbers) { Link Here
644
647
645
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowernumber, $biblioNum );
648
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowernumber, $biblioNum );
646
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
649
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
650
651
    my $today_holds = Koha::Holds->search({
652
        borrowernumber => $borrowernumber,
653
        reservedate    => dt_from_string->date
654
    });
655
656
    my $biblio_record = Koha::Biblios->find( $biblioNum );
657
    my $patron_obj = Koha::Patrons->find( $borrowernumber );
658
    my $holds_allowed_on_record_today = $biblio_record->allowed_holds( $patron_obj );
659
    my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds->count();
647
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
660
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
661
    $biblioLoopIter{remaining_holds_allowed_today} = $remaining_holds_allowed_today;
648
662
663
    #Determine what is the lowest value
664
    my $lowestvalue = min($maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today);
665
    $biblioLoopIter{lowest_value} = $lowestvalue;
649
666
650
    push @$biblioLoop, \%biblioLoopIter;
667
    push @$biblioLoop, \%biblioLoopIter;
651
668
(-)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