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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-9 / +36 lines)
Lines 496-505 Link Here
496
                                    <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
496
                                    <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
497
                                </li>
497
                                </li>
498
498
499
                                [% IF remaining_holds_for_record > 1 %]
499
                                [% IF lowest_value > 1 %]
500
                                    <li>
500
                                    <li>
501
                                        <label for="holds_to_place_count">Holds to place (count)</label>
501
                                        <label for="holds_to_place_count">Holds to place (count)</label>
502
                                        <input type="text" inputmode="numeric" pattern="[0-9]*" id="holds_to_place_count" name="holds_to_place_count" maxlength="[% remaining_holds_for_record | html %]" value="1" />
502
                                        <input type="text" inputmode="numeric" pattern="[0-9]*" id="holds_to_place_count" name="holds_to_place_count" maxlength="[% lowest_value | html %]" value="1" />
503
                                    </li>
503
                                    </li>
504
                                [% ELSE %]
504
                                [% ELSE %]
505
                                    <input type="hidden" name="holds_to_place_count" value="1" />
505
                                    <input type="hidden" name="holds_to_place_count" value="1" />
Lines 584-592 Link Here
584
                                                                Hold must be record level
584
                                                                Hold must be record level
585
                                                            </span>
585
                                                            </span>
586
                                                        [% ELSIF ( itemloo.available ) %]
586
                                                        [% ELSIF ( itemloo.available ) %]
587
                                                            <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
587
                                                            <input type="checkbox" name="checkitem" value="[% itemloo.itemnumber | html %]" />
588
                                                        [% ELSIF ( itemloo.override ) %]
588
                                                        [% ELSIF ( itemloo.override ) %]
589
                                                            <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
589
                                                            <input type="checkbox" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
590
                                                            <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
590
                                                            <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
591
                                                        [% ELSE %]
591
                                                        [% ELSE %]
592
                                                            <span class="error">
592
                                                            <span class="error">
Lines 1051-1056 Link Here
1051
        columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1051
        columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1052
        $.fn.select2.defaults.set("width", "100%" );
1052
        $.fn.select2.defaults.set("width", "100%" );
1053
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1053
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1054
        var MSG_EXCEEDED_MAX_HOLDS = __("Patron reached the maximum number of holds.");
1055
        var max_holds = "[% lowest_value | $raw %]";
1054
1056
1055
        $(document).ready(function() {
1057
        $(document).ready(function() {
1056
            $('#cancellation-reason-fieldset').hide();
1058
            $('#cancellation-reason-fieldset').hide();
Lines 1367-1389 Link Here
1367
                if(this.checked){
1369
                if(this.checked){
1368
                    $("input[name=checkitem]").each(function() {
1370
                    $("input[name=checkitem]").each(function() {
1369
                        $(this).prop("checked", false);
1371
                        $(this).prop("checked", false);
1372
                        $("#holds_to_place_count").val('1');
1370
                    });
1373
                    });
1371
                }
1374
                }
1372
            });
1375
            });
1373
            $("input[name=checkitem]").click(function() {
1376
            $("input[name=checkitem]").click(function() {
1374
                onechecked = 0;
1377
                numchecked = 0;
1375
                $("input[name=checkitem]").each(function() {
1378
                $("input[name=checkitem]").each(function() {
1376
                    if(this.checked){
1379
                    if(this.checked){
1377
                        onechecked = 1;
1380
                        numchecked++;
1378
                    }
1381
                    }
1379
                });
1382
                });
1380
                if(onechecked == 1){
1383
                if(numchecked > 0){
1381
                    $("#requestany").prop("checked", false);
1384
                    if ( numchecked > max_holds ) {
1382
                    $("#holds_to_place_count").prop('disabled', true);
1385
                        alert(MSG_EXCEEDED_MAX_HOLDS);
1386
                        $(this).prop('checked',false);
1387
                    } else {
1388
                        $("#requestany").prop("checked", false);
1389
                        $("#holds_to_place_count").prop('disabled', true);
1390
                        $("#holds_to_place_count").val(numchecked);
1391
                    }
1383
                } else {
1392
                } else {
1384
                    $("#requestany").prop("checked",true);
1393
                    $("#requestany").prop("checked",true);
1385
                    $("#holds_to_place_count").prop('disabled', false);
1394
                    $("#holds_to_place_count").prop('disabled', false);
1386
                }
1395
                }
1396
                if ( remainingHold - numchecked <= 0 ) {
1397
                    alert(MSG_EXCEEDED_HOLDS_PER_RECORD);
1398
                    [% IF !Koha.Preference('AllowHoldPolicyOverride') %]
1399
                        $('input[name=checkitem]:not(:checked)').attr('disabled','disabled');
1400
                    [% END %]
1401
                }
1402
                if ( remainingHoldsToday - numchecked <= 0 ) {
1403
                    alert(MSG_EXCEEDED_HOLDS_PER_DAY);
1404
                    [% IF !Koha.Preference('AllowHoldPolicyOverride') %]
1405
                        $('input[name=checkitem]:not(:checked)').attr('disabled','disabled');
1406
                    [% END %]
1407
                }
1408
                if ( maxreserves - numchecked <= 0 ) {
1409
                    alert(MSG_EXCEEDED_MAXRESERVES_SYSPREF);
1410
                    [% IF !Koha.Preference('AllowHoldPolicyOverride') %]
1411
                        $('input[name=checkitem]:not(:checked)').attr('disabled','disabled');
1412
                    [% END %]
1413
                }
1387
            });
1414
            });
1388
            var prev_rank_request;
1415
            var prev_rank_request;
1389
            $("select[name=rank-request]").on("focus", function() {
1416
            $("select[name=rank-request]").on("focus", function() {
(-)a/reserve/placerequest.pl (-19 / +29 lines)
Lines 49-55 my $startdate = $input->param('reserve_date') || ''; Link Here
49
my @rank           = $input->multi_param('rank-request');
49
my @rank           = $input->multi_param('rank-request');
50
my $type           = $input->param('type');
50
my $type           = $input->param('type');
51
my $title          = $input->param('title');
51
my $title          = $input->param('title');
52
my $checkitem      = $input->param('checkitem');
52
my @checkitems     = $input->multi_param('checkitem');
53
my $expirationdate = $input->param('expiration_date');
53
my $expirationdate = $input->param('expiration_date');
54
my $itemtype       = $input->param('itemtype') || undef;
54
my $itemtype       = $input->param('itemtype') || undef;
55
my $non_priority   = $input->param('non_priority');
55
my $non_priority   = $input->param('non_priority');
Lines 62-67 $biblionumbers ||= $biblionumber . '/'; Link Here
62
62
63
my $bad_bibs = $input->param('bad_bibs');
63
my $bad_bibs = $input->param('bad_bibs');
64
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
64
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
65
$holds_to_place_count = scalar( @checkitems ) if @checkitems;
65
66
66
my %bibinfos = ();
67
my %bibinfos = ();
67
my @biblionumbers = split '/', $biblionumbers;
68
my @biblionumbers = split '/', $biblionumbers;
Lines 72-78 foreach my $bibnum (@biblionumbers) { Link Here
72
    $bibinfos{$bibnum} = \%bibinfo;
73
    $bibinfos{$bibnum} = \%bibinfo;
73
}
74
}
74
75
75
my $found;
76
my @found;
77
unless ( C4::Context->preference('ReservesNeedReturns') ) {
78
    foreach my $checkitem ( @checkitems ) {
79
        # if we have an item selected, and the pickup branch is the same as
80
        # the holdingbranch of the doc, we force the value $rank and $found
81
        $rank[0] = '0';
82
        my $item = Koha::Items->find( $checkitem );
83
        push @found, ( $item->holdingbranch eq $branch ? 'W' : undef );
84
    }
85
}
76
86
77
if ( $type eq 'str8' && $borrower ) {
87
if ( $type eq 'str8' && $borrower ) {
78
88
Lines 91-104 if ( $type eq 'str8' && $borrower ) { Link Here
91
        }
101
        }
92
102
93
        my $can_override = C4::Context->preference('AllowHoldPolicyOverride');
103
        my $can_override = C4::Context->preference('AllowHoldPolicyOverride');
94
        if ( defined $checkitem && $checkitem ne '' ) {
104
        if ( @checkitems and @checkitems == 1 ) {
95
105
            # item-level hold
96
            my $item = Koha::Items->find($checkitem);
106
            my $item = Koha::Items->find( $checkitems[0] );
97
98
            if ( $item->biblionumber ne $biblionumber ) {
99
                $biblionumber = $item->biblionumber;
100
            }
101
102
            my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $branch)->{status};
107
            my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $branch)->{status};
103
108
104
            if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) {
109
            if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) {
Lines 112-119 if ( $type eq 'str8' && $borrower ) { Link Here
112
                        expiration_date  => $expirationdate,
117
                        expiration_date  => $expirationdate,
113
                        notes            => $notes,
118
                        notes            => $notes,
114
                        title            => $title,
119
                        title            => $title,
115
                        itemnumber       => $checkitem,
120
                        itemnumber       => $checkitems[0],
116
                        found            => $found,
121
                        found            => $found[0],
117
                        itemtype         => $itemtype,
122
                        itemtype         => $itemtype,
118
                        non_priority     => $non_priority,
123
                        non_priority     => $non_priority,
119
                    }
124
                    }
Lines 121-127 if ( $type eq 'str8' && $borrower ) { Link Here
121
126
122
            }
127
            }
123
128
124
        } elsif (@biblionumbers > 1) {
129
        } elsif ( @biblionumbers > 1 ) {
130
            # hold on multiple titles (multi-hold)
125
            my $bibinfo = $bibinfos{$biblionumber};
131
            my $bibinfo = $bibinfos{$biblionumber};
126
            if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) {
132
            if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) {
127
                AddReserve(
133
                AddReserve(
Lines 134-141 if ( $type eq 'str8' && $borrower ) { Link Here
134
                        expiration_date  => $expirationdate,
140
                        expiration_date  => $expirationdate,
135
                        notes            => $notes,
141
                        notes            => $notes,
136
                        title            => $bibinfo->{title},
142
                        title            => $bibinfo->{title},
137
                        itemnumber       => $checkitem,
143
                        itemnumber       => undef,
138
                        found            => $found,
144
                        found            => undef,
139
                        itemtype         => $itemtype,
145
                        itemtype         => $itemtype,
140
                        non_priority     => $non_priority,
146
                        non_priority     => $non_priority,
141
                    }
147
                    }
Lines 144-163 if ( $type eq 'str8' && $borrower ) { Link Here
144
        } else {
150
        } else {
145
            # place a request on 1st available
151
            # place a request on 1st available
146
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
152
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
153
                my $item;
154
                if ( $checkitems[$i] ) {
155
                    $item = Koha::Items->find( $checkitems[$i] );
156
                }
147
                if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) {
157
                if ( $can_override || CanBookBeReserved($borrower->{'borrowernumber'}, $biblionumber)->{status} eq 'OK' ) {
148
                    AddReserve(
158
                    AddReserve(
149
                        {
159
                        {
150
                            branchcode       => $branch,
160
                            branchcode       => $branch,
151
                            borrowernumber   => $borrower->{'borrowernumber'},
161
                            borrowernumber   => $borrower->{'borrowernumber'},
152
                            biblionumber     => $biblionumber,
162
                            biblionumber     => ( $item ? $item->biblionumber : $biblionumber ),
153
                            priority         => $rank[0],
163
                            priority         => $rank[0],
154
                            reservation_date => $startdate,
164
                            reservation_date => $startdate,
155
                            expiration_date  => $expirationdate,
165
                            expiration_date  => $expirationdate,
156
                            notes            => $notes,
166
                            notes            => $notes,
157
                            title            => $title,
167
                            title            => $title,
158
                            itemnumber       => $checkitem,
168
                            itemnumber       => $checkitems[$i],
159
                            found            => $found,
169
                            found            => $found[$i],
160
                            itemtype         => $itemtype,
170
                            itemtype         => ( $item ? $item->effective_itemtype : undef ),
161
                            non_priority     => $non_priority,
171
                            non_priority     => $non_priority,
162
                        }
172
                        }
163
                    );
173
                    );
(-)a/reserve/request.pl (-5 / +26 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::Util 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 349-359 foreach my $biblionumber (@biblionumbers) { Link Here
349
        # we must find out what the maximum number of holds they can place for the patron is
350
        # we must find out what the maximum number of holds they can place for the patron is
350
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
351
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
351
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
352
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
352
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
353
        $template->param( max_holds_for_record => $max_holds_for_record );
354
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
355
    }
356
353
354
        # Determine how many holds the patron can place per day on this biblio record.
355
        # Then calculate how many holds the patron can place subtracting holds already placed today
356
        my $today_holds = Koha::Holds->search({
357
            borrowernumber => $patron->borrowernumber,
358
            reservedate => dt_from_string->date,
359
        })->count;
360
361
        my $biblio_obj = Koha::Biblios->find( $biblionumber );
362
        my $holds_allowed_on_record_today = $biblio_obj->allowed_holds( $patron );
363
        my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds;
364
        my $maxreserves = C4::Context->preference('maxreserves');
365
366
        $biblioloopiter{remaining_holds_for_record} = $remaining_holds_for_record;
367
        $biblioloopiter{remaining_holds_allowed_today} = $remaining_holds_allowed_today;
368
369
        # Determine what is the lowest value
370
        my $lowestvalue = min( $maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today );
371
372
        $template->param(
373
            max_holds_for_record => $max_holds_for_record,
374
            remaining_holds_for_record => $remaining_holds_for_record,
375
            lowest_value => $lowestvalue,
376
            remaining_holds_allowed_today => $remaining_holds_allowed_today,
377
        );
378
    }
357
379
358
    my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
380
    my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
359
    my $totalcount = $count;
381
    my $totalcount = $count;
360
- 

Return to bug 15565