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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-25 / +59 lines)
Lines 624-629 Link Here
624
                                                                        Only pickup locations within the same hold group are allowed
624
                                                                        Only pickup locations within the same hold group are allowed
625
                                                                    [% ELSIF itemloo.not_holdable == 'noReservesAllowed' %]
625
                                                                    [% ELSIF itemloo.not_holdable == 'noReservesAllowed' %]
626
                                                                        No reserves are allowed on this item
626
                                                                        No reserves are allowed on this item
627
                                                                    [% ELSIF itemloo.not_holdable == 'no_valid_pickup_location' %]
628
                                                                        No valid pickup location
627
                                                                    [% ELSE %]
629
                                                                    [% ELSE %]
628
                                                                        [% itemloo.not_holdable | html %]
630
                                                                        [% itemloo.not_holdable | html %]
629
                                                                    [% END %]
631
                                                                    [% END %]
Lines 721-730 Link Here
721
                                                        [% END %]
723
                                                        [% END %]
722
                                                    </td>
724
                                                    </td>
723
                                                    <td>
725
                                                    <td>
724
                                                    [% IF itemloo.any_pickup_location %]
726
                                                    [% IF (itemloo.pickup_locations_count > 0) %]
725
                                                        Any library
727
                                                        <select name="item_pickup" class="pickup_locations"
726
                                                    [% ELSE %]
728
                                                                data-item-id="[% itemloo.itemnumber | html %]"
727
                                                        [% itemloo.pickup_locations | html %]
729
                                                                data-patron-id="[% patron.borrowernumber | html %]"></select>
728
                                                    [% END %]
730
                                                    [% END %]
729
                                                    </td>
731
                                                    </td>
730
                                                </tr>
732
                                                </tr>
Lines 1187-1193 Link Here
1187
1189
1188
            [% UNLESS ( multi_hold ) %]
1190
            [% UNLESS ( multi_hold ) %]
1189
                $("#hold-request-form").on("submit", function(){
1191
                $("#hold-request-form").on("submit", function(){
1190
                    return check();
1192
                    return check($(this));
1191
                });
1193
                });
1192
            [% ELSE %]
1194
            [% ELSE %]
1193
                $("#hold-request-form").on("submit", function(){
1195
                $("#hold-request-form").on("submit", function(){
Lines 1288-1322 Link Here
1288
                    templateResult: display_pickup_location
1290
                    templateResult: display_pickup_location
1289
                });
1291
                });
1290
            });
1292
            });
1293
            $(".pickup_locations").each( function () {
1294
                var this_dropdown = $(this);
1295
                var patron_id = $(this).data('patron-id');
1296
                var item_id   = $(this).data('item-id');
1297
1298
                this_dropdown.select2({
1299
                    allowClear: true,
1300
                    ajax: {
1301
                        url: '/api/v1/items/' + encodeURIComponent(item_id) + '/pickup_locations',
1302
                        delay: 300, // wait 300 milliseconds before triggering the request
1303
                        dataType: 'json',
1304
                        data: function (params) {
1305
                            var search_term = (params.term === undefined) ? '' : params.term;
1306
                            var query = {
1307
                                "q": JSON.stringify({"name":{"-like":search_term+'%'}}),
1308
                                "_order_by": "name",
1309
                                "patron_id": patron_id
1310
                            };
1311
                            return query;
1312
                        },
1313
                        processResults: function (data) {
1314
                            var results = [];
1315
                            data.forEach( function ( pickup_location ) {
1316
                                results.push(
1317
                                    {
1318
                                        "id": pickup_location.library_id.escapeHtml(),
1319
                                        "text": pickup_location.name.escapeHtml(),
1320
                                        "needs_override": pickup_location.needs_override
1321
                                    }
1322
                                );
1323
                            });
1324
                            return { "results": results };
1325
                        }
1326
                    },
1327
                    templateResult: display_pickup_location
1328
                });
1329
            });
1291
        });
1330
        });
1292
1331
1293
        function check() {
1332
        function check( table ) {
1333
1294
            var msg = "";
1334
            var msg = "";
1295
            var count_reserv = 0;
1296
1335
1297
            // check if we have checkitem form
1336
            if ( $("#requestany").attr("checked") !== "checked" ) {
1298
            if (document.form.checkitem){
1337
                // requestany not selected, go through the item-specific cases
1299
                for (i=0;i<document.form.checkitem.length;i++){
1338
                if ( $('input[type="radio"]:checked').length > 0 ) {
1300
                    if (document.form.checkitem[i].checked == true) {
1339
                    // got item-specific hold requests in the form!
1301
                        count_reserv++ ;
1340
                    // verify they have a pickup location selected
1341
1342
                    if (table.find('input[type="radio"]:checked')
1343
                                .closest('tr')
1344
                                .find(".pickup_locations").val() === null) {
1345
1346
                        msg = _("- Please select a pickup location for the item" + "\n")
1302
                    }
1347
                    }
1303
                }
1348
                }
1304
                // for only one item, check the checkitem without consider the loop checkitem
1349
                else {
1305
                if (i==0){
1350
                    msg = (_("- Please select an item to place a hold") + "\n");
1306
                    if (document.form.checkitem.checked == true) {
1307
                        count_reserv++;
1308
                    }
1309
                }
1351
                }
1310
            }
1352
            }
1311
1353
1312
            if (document.form.requestany.checked == true){
1313
                count_reserv++ ;
1314
            }
1315
1316
            if (count_reserv == "0"){
1317
                msg += (_("- Please select an item to place a hold") + "\n");
1318
            }
1319
1320
            if (msg == "") {
1354
            if (msg == "") {
1321
                $('#hold-request-form').preventDoubleFormSubmit();
1355
                $('#hold-request-form').preventDoubleFormSubmit();
1322
                return(true);
1356
                return(true);
(-)a/reserve/placerequest.pl (-2 / +3 lines)
Lines 45-50 my $biblionumber = $input->param('biblionumber'); Link Here
45
my $borrowernumber = $input->param('borrowernumber');
45
my $borrowernumber = $input->param('borrowernumber');
46
my $notes          = $input->param('notes');
46
my $notes          = $input->param('notes');
47
my $branch         = $input->param('pickup');
47
my $branch         = $input->param('pickup');
48
my $item_pickup    = $input->param('item_pickup');
48
my $startdate      = $input->param('reserve_date') || '';
49
my $startdate      = $input->param('reserve_date') || '';
49
my @rank           = $input->multi_param('rank-request');
50
my @rank           = $input->multi_param('rank-request');
50
my $type           = $input->param('type');
51
my $type           = $input->param('type');
Lines 99-110 if ( $type eq 'str8' && $borrower ) { Link Here
99
                $biblionumber = $item->biblionumber;
100
                $biblionumber = $item->biblionumber;
100
            }
101
            }
101
102
102
            my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $branch)->{status};
103
            my $can_item_be_reserved = CanItemBeReserved($borrower->{'borrowernumber'}, $item->itemnumber, $item_pickup)->{status};
103
104
104
            if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) {
105
            if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) {
105
                AddReserve(
106
                AddReserve(
106
                    {
107
                    {
107
                        branchcode       => $branch,
108
                        branchcode       => $item_pickup,
108
                        borrowernumber   => $borrower->{'borrowernumber'},
109
                        borrowernumber   => $borrower->{'borrowernumber'},
109
                        biblionumber     => $biblionumber,
110
                        biblionumber     => $biblionumber,
110
                        priority         => $rank[0],
111
                        priority         => $rank[0],
(-)a/reserve/request.pl (-12 / +8 lines)
Lines 563-570 foreach my $biblionumber (@biblionumbers) { Link Here
563
563
564
                $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
564
                $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
565
565
566
                my $reserves_control_branch = $pickup || C4::Reserves::GetReservesControlBranch( $item, $patron_unblessed );
566
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
567
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber, $reserves_control_branch )->{status};
568
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
567
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
569
568
570
                $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
569
                $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
Lines 578-594 foreach my $biblionumber (@biblionumbers) { Link Here
578
                    && IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available)
577
                    && IsAvailableForItemLevelRequest($item_object, $patron, undef, $items_any_available)
579
                  )
578
                  )
580
                {
579
                {
581
                    $item->{available} = 1;
580
                    # Send the pickup locations count to the UI, the pickup locations will be pulled using the API
582
                    $num_available++;
581
                    $item->{pickup_locations_count} = $item_object->pickup_locations({ patron => $patron })->count;
583
582
                    if ( $item->{pickup_locations_count} > 0 ) {
584
                    if ( $branchitemrule->{'hold_fulfillment_policy'} eq 'any' )
583
                        $num_available++;
585
                    {
584
                        $item->{available} = 1;
586
                        $item->{any_pickup_location} = 1;
587
                    }
585
                    }
588
                    else {
586
                    else {
589
                        my @pickup_locations = $item_object->pickup_locations({ patron => $patron });
587
                        $item->{available} = 0;
590
588
                        $item->{not_holdable} = "no_valid_pickup_location";
591
                        $item->{pickup_locations} = join( ', ', map { $_->branchname } @pickup_locations );
592
                    }
589
                    }
593
590
594
                    push( @available_itemtypes, $item->{itype} );
591
                    push( @available_itemtypes, $item->{itype} );
595
- 

Return to bug 28338