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 471-480 Link Here
471
                                    <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
471
                                    <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
472
                                </li>
472
                                </li>
473
473
474
                                [% IF remaining_holds_for_record > 1 %]
474
                                [% IF lowest_value > 1 %]
475
                                    <li>
475
                                    <li>
476
                                        <label for="holds_to_place_count">Holds to place (count)</label>
476
                                        <label for="holds_to_place_count">Holds to place (count)</label>
477
                                        <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" />
477
                                        <input type="text" inputmode="numeric" pattern="[0-9]*" id="holds_to_place_count" name="holds_to_place_count" maxlength="[% lowest_value | html %]" value="1" />
478
                                    </li>
478
                                    </li>
479
                                [% ELSE %]
479
                                [% ELSE %]
480
                                    <input type="hidden" name="holds_to_place_count" value="1" />
480
                                    <input type="hidden" name="holds_to_place_count" value="1" />
Lines 559-567 Link Here
559
                                                                Hold must be record level
559
                                                                Hold must be record level
560
                                                            </span>
560
                                                            </span>
561
                                                        [% ELSIF ( itemloo.available ) %]
561
                                                        [% ELSIF ( itemloo.available ) %]
562
                                                            <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
562
                                                            <input type="checkbox" name="checkitem" value="[% itemloo.itemnumber | html %]" />
563
                                                        [% ELSIF ( itemloo.override ) %]
563
                                                        [% ELSIF ( itemloo.override ) %]
564
                                                            <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
564
                                                            <input type="checkbox" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
565
                                                            <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
565
                                                            <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
566
                                                        [% ELSE %]
566
                                                        [% ELSE %]
567
                                                            <span class="error">
567
                                                            <span class="error">
Lines 1015-1020 Link Here
1015
            cannotBeTransferred: _("Cannot be transferred to pickup library")
1015
            cannotBeTransferred: _("Cannot be transferred to pickup library")
1016
        }
1016
        }
1017
        columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1017
        columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1018
        var MSG_EXCEEDED_MAX_HOLDS = __("Patron reached the maximum number of holds.");
1019
        var max_holds = "[% lowest_value | $raw %]";
1018
1020
1019
        $(document).ready(function() {
1021
        $(document).ready(function() {
1020
            $('#cancellation-reason-fieldset').hide();
1022
            $('#cancellation-reason-fieldset').hide();
Lines 1273-1295 Link Here
1273
                if(this.checked){
1275
                if(this.checked){
1274
                    $("input[name=checkitem]").each(function() {
1276
                    $("input[name=checkitem]").each(function() {
1275
                        $(this).prop("checked", false);
1277
                        $(this).prop("checked", false);
1278
                        $("#holds_to_place_count").val('1');
1276
                    });
1279
                    });
1277
                }
1280
                }
1278
            });
1281
            });
1279
            $("input[name=checkitem]").click(function() {
1282
            $("input[name=checkitem]").click(function() {
1280
                onechecked = 0;
1283
                numchecked = 0;
1281
                $("input[name=checkitem]").each(function() {
1284
                $("input[name=checkitem]").each(function() {
1282
                    if(this.checked){
1285
                    if(this.checked){
1283
                        onechecked = 1;
1286
                        numchecked++;
1284
                    }
1287
                    }
1285
                });
1288
                });
1286
                if(onechecked == 1){
1289
                if(numchecked > 0){
1287
                    $("#requestany").prop("checked", false);
1290
                    if ( numchecked > max_holds ) {
1288
                    $("#holds_to_place_count").prop('disabled', true);
1291
                        alert(MSG_EXCEEDED_MAX_HOLDS);
1292
                        $(this).prop('checked',false);
1293
                    } else {
1294
                        $("#requestany").prop("checked", false);
1295
                        $("#holds_to_place_count").prop('disabled', true);
1296
                        $("#holds_to_place_count").val(numchecked);
1297
                    }
1289
                } else {
1298
                } else {
1290
                    $("#requestany").prop("checked",true);
1299
                    $("#requestany").prop("checked",true);
1291
                    $("#holds_to_place_count").prop('disabled', false);
1300
                    $("#holds_to_place_count").prop('disabled', false);
1292
                }
1301
                }
1302
                if ( remainingHold - numchecked <= 0 ) {
1303
                    alert(MSG_EXCEEDED_HOLDS_PER_RECORD);
1304
                    [% IF !Koha.Preference('AllowHoldPolicyOverride') %]
1305
                        $('input[name=checkitem]:not(:checked)').attr('disabled','disabled');
1306
                    [% END %]
1307
                }
1308
                if ( remainingHoldsToday - numchecked <= 0 ) {
1309
                    alert(MSG_EXCEEDED_HOLDS_PER_DAY);
1310
                    [% IF !Koha.Preference('AllowHoldPolicyOverride') %]
1311
                        $('input[name=checkitem]:not(:checked)').attr('disabled','disabled');
1312
                    [% END %]
1313
                }
1314
                if ( maxreserves - numchecked <= 0 ) {
1315
                    alert(MSG_EXCEEDED_MAXRESERVES_SYSPREF);
1316
                    [% IF !Koha.Preference('AllowHoldPolicyOverride') %]
1317
                        $('input[name=checkitem]:not(:checked)').attr('disabled','disabled');
1318
                    [% END %]
1319
                }
1293
            });
1320
            });
1294
            var prev_rank_request;
1321
            var prev_rank_request;
1295
            $("select[name=rank-request]").on("focus", function() {
1322
            $("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 343-353 foreach my $biblionumber (@biblionumbers) { Link Here
343
        # we must find out what the maximum number of holds they can place for the patron is
344
        # we must find out what the maximum number of holds they can place for the patron is
344
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
345
        my $max_holds_for_record = GetMaxPatronHoldsForRecord( $patron->borrowernumber, $biblionumber );
345
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
346
        my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
346
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
347
        $template->param( max_holds_for_record => $max_holds_for_record );
348
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
349
    }
350
347
348
        # Determine how many holds the patron can place per day on this biblio record.
349
        # Then calculate how many holds the patron can place subtracting holds already placed today
350
        my $today_holds = Koha::Holds->search({
351
            borrowernumber => $patron->borrowernumber,
352
            reservedate => dt_from_string->date,
353
        })->count;
354
355
        my $biblio_obj = Koha::Biblios->find( $biblionumber );
356
        my $holds_allowed_on_record_today = $biblio_obj->allowed_holds( $patron );
357
        my $remaining_holds_allowed_today = $holds_allowed_on_record_today - $today_holds;
358
        my $maxreserves = C4::Context->preference('maxreserves');
359
360
        $biblioloopiter{remaining_holds_for_record} = $remaining_holds_for_record;
361
        $biblioloopiter{remaining_holds_allowed_today} = $remaining_holds_allowed_today;
362
363
        # Determine what is the lowest value
364
        my $lowestvalue = min( $maxreserves, $remaining_holds_for_record, $remaining_holds_allowed_today );
365
366
        $template->param(
367
            max_holds_for_record => $max_holds_for_record,
368
            remaining_holds_for_record => $remaining_holds_for_record,
369
            lowest_value => $lowestvalue,
370
            remaining_holds_allowed_today => $remaining_holds_allowed_today,
371
        );
372
    }
351
373
352
    my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
374
    my $count = Koha::Holds->search( { biblionumber => $biblionumber } )->count();
353
    my $totalcount = $count;
375
    my $totalcount = $count;
354
- 

Return to bug 15565