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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (+9 lines)
Lines 175-180 Link Here
175
                                    <span>No barcode</span>
175
                                    <span>No barcode</span>
176
                                [%- END -%]
176
                                [%- END -%]
177
                            </a>
177
                            </a>
178
                            [%- IF hold.change_hold_type_allowed -%]
179
                                [%- IF hold.itemtype -%]
180
                                    <span style="display:none">Next available [% ItemTypes.GetDescription( hold.itemtype ) | html %] item</span>
181
                                [%- ELSE -%]
182
                                    <span style="display:none">Next available</span>
183
                                [%- END -%]
184
                                <a id="change_hold_type_icon" href="#" class="clear_date fa fa-fw fa-remove" aria-label="Change to next available item"></a>
185
                                <input id="change_hold_type" type="hidden" name="changeHoldType" value="0">
186
                            [%- END -%]
178
                        </em>
187
                        </em>
179
                    [%- ELSE -%]
188
                    [%- ELSE -%]
180
                        [%- IF hold.itemtype -%]
189
                        [%- IF hold.itemtype -%]
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (+20 lines)
Lines 441-444 $(document).ready(function() { Link Here
441
        window.location.href='request.pl?action=toggleSuspend&amp;reserve_id=' + reserve_id + '&amp;biblionumber=' + biblionumber + '&amp;suspend_until=' + suspend_until;
441
        window.location.href='request.pl?action=toggleSuspend&amp;reserve_id=' + reserve_id + '&amp;biblionumber=' + biblionumber + '&amp;suspend_until=' + suspend_until;
442
        return false;
442
        return false;
443
    });
443
    });
444
445
    $("a#change_hold_type_icon").on('click', function(e) {
446
        e.preventDefault();
447
        let change_type = $("input#change_hold_type").val();
448
        let only_item = $(this).siblings("span:first");
449
        let only_itemlink = $(this).siblings("a:first");
450
        let next_available = $(this).siblings("span:last");
451
        if (change_type==="1") {
452
            $("input#change_hold_type").val("0");
453
            next_available.hide();
454
            only_itemlink.show();
455
            only_item.show();
456
        } else {
457
            $("input#change_hold_type").val("1");
458
            only_itemlink.hide();
459
            only_item.hide();
460
            next_available.show();
461
        }
462
        return false;
463
    });
444
});
464
});
(-)a/reserve/modrequest.pl (-1 / +17 lines)
Lines 59-64 my $CancelBiblioNumber = $query->param('CancelBiblioNumber'); Link Here
59
my $CancelBorrowerNumber = $query->param('CancelBorrowerNumber');
59
my $CancelBorrowerNumber = $query->param('CancelBorrowerNumber');
60
my $CancelItemnumber = $query->param('CancelItemnumber');
60
my $CancelItemnumber = $query->param('CancelItemnumber');
61
61
62
my $change_hold_type = $query->param('changeHoldType');
63
62
# 2 possibilitys : cancel an item reservation, or modify or cancel the queded list
64
# 2 possibilitys : cancel an item reservation, or modify or cancel the queded list
63
65
64
# 1) cancel an item reservation by function ModReserveCancelAll (in reserves.pm)
66
# 1) cancel an item reservation by function ModReserveCancelAll (in reserves.pm)
Lines 94-100 else { Link Here
94
            } else {
96
            } else {
95
                $_->rethrow;
97
                $_->rethrow;
96
            }
98
            }
97
        }
99
        };
100
101
        if ( $change_hold_type ) {
102
            my $hold = Koha::Holds->find( $reserve_id[$i] );
103
104
            try {
105
                $hold->change_type;
106
            } catch {
107
                if ($_->isa('Koha::Exceptions::Hold::CannotChangeHoldType')){
108
                    warn $_;
109
                } else {
110
                    $_->rethrow;
111
                }
112
            }
113
        };
98
    }
114
    }
99
    my @biblio_ids = uniq @biblionumber;
115
    my @biblio_ids = uniq @biblionumber;
100
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
116
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
(-)a/reserve/request.pl (-1 / +11 lines)
Lines 593-598 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
593
        $template->param( always_show_holds => $always_show_holds );
593
        $template->param( always_show_holds => $always_show_holds );
594
        my $show_holds_now = $input->param('show_holds_now');
594
        my $show_holds_now = $input->param('show_holds_now');
595
        unless( (defined $always_show_holds && $always_show_holds eq 'DONT') && !$show_holds_now ){
595
        unless( (defined $always_show_holds && $always_show_holds eq 'DONT') && !$show_holds_now ){
596
            my $holds_count_per_patron = { map { $_->{borrowernumber} => $_->{hold_count} }
597
                @{ Koha::Holds->search( { biblionumber=> $biblionumber }, {
598
                    select => [ "borrowernumber", { count => { distinct => "reserve_id" } } ],
599
                    as => [ qw( borrowernumber hold_count ) ],
600
                    group_by => [ qw( borrowernumber ) ] }
601
                )->unblessed
602
            } };
596
            my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } )->as_list;
603
            my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } )->as_list;
597
            foreach my $res (
604
            foreach my $res (
598
                sort {
605
                sort {
Lines 643-648 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
643
                $reserve{non_priority}     = $res->non_priority();
650
                $reserve{non_priority}     = $res->non_priority();
644
                $reserve{object}           = $res;
651
                $reserve{object}           = $res;
645
652
653
                if ( $holds_count_per_patron->{ $reserve{'borrowernumber'} } == 1 ) {
654
                    $reserve{'change_hold_type_allowed'} = 1;
655
                }
656
646
                push( @reserveloop, \%reserve );
657
                push( @reserveloop, \%reserve );
647
            }
658
            }
648
        }
659
        }
649
- 

Return to bug 31692