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

(-)a/Koha/Hold.pm (+61 lines)
Lines 178-183 sub delete { Link Here
178
    return $deleted;
178
    return $deleted;
179
}
179
}
180
180
181
=head3 move_hold
182
183
$hold->move_hold();
184
185
=cut
186
187
sub move_hold {
188
    my ( $self, $args ) = @_;
189
190
    my $original              = $self;
191
    my $original_biblionumber = $self->biblionumber;
192
193
    my $patron = Koha::Patrons->find( { borrowernumber => $self->borrowernumber } );
194
    return { success => 0, error => 'Missing patron or target' } unless $patron;
195
196
    my ( $new_biblionumber, $new_itemnumber, $item, $canReserve );
197
198
    if ( $args->{new_itemnumber} ) {
199
        $item = Koha::Items->find( { itemnumber => $args->{new_itemnumber} } )
200
            or return { success => 0, error => 'Target item not found' };
201
202
        $new_itemnumber   = $item->itemnumber;
203
        $new_biblionumber = $item->biblionumber;
204
205
        $canReserve = C4::Reserves::CanItemBeReserved( $patron, $item, $self->branchcode, { ignore_hold_counts => 1 } );
206
    } elsif ( $args->{new_biblionumber} ) {
207
        $new_biblionumber = $args->{new_biblionumber};
208
209
        $canReserve = C4::Reserves::CanBookBeReserved(
210
            $patron->borrowernumber, $new_biblionumber, $self->branchcode,
211
            { ignore_hold_counts => 1 }
212
        );
213
    } else {
214
        return { success => 0, error => 'Missing itemnumber or biblionumber' };
215
    }
216
217
    return { success => 0, error => $canReserve->{status} }
218
        unless $canReserve->{status} eq 'OK';
219
220
    my $max = Koha::Holds->search(
221
        { biblionumber => $new_biblionumber },
222
        { order_by     => { -desc => 'priority' }, rows => 1 }
223
    )->next;
224
    my $base_priority = $max ? $max->priority : 0;
225
    my $priority      = $base_priority + 1;
226
    my $new_priority  = C4::Reserves::_ShiftPriority( $new_biblionumber, $priority );
227
228
    $self->update(
229
        {
230
            itemnumber   => $new_itemnumber,     # undef for biblio-level is fine
231
            biblionumber => $new_biblionumber,
232
            priority     => $new_priority,
233
        }
234
    );
235
236
    C4::Log::logaction( 'HOLDS', 'MODIFY', $self->reserve_id, $self, undef, $original )
237
        if C4::Context->preference('HoldsLog');
238
239
    return { success => 1, hold => $self };
240
}
241
181
=head3 set_transfer
242
=head3 set_transfer
182
243
183
=cut
244
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (-1 / +9 lines)
Lines 49-55 Link Here
49
            [%- END -%]
49
            [%- END -%]
50
            [% SET tr_class = hold.suspend ? 'suspend' : '' %]
50
            [% SET tr_class = hold.suspend ? 'suspend' : '' %]
51
            <tr class="[% tr_class | html %]">
51
            <tr class="[% tr_class | html %]">
52
                <td><input type="checkbox" class="select_hold" data-id="[% hold.reserve_id | html %]" /></td>
52
                <td
53
                    ><input
54
                        type="checkbox"
55
                        class="select_hold"
56
                        data-id="[% hold.reserve_id | html %]"
57
                        data-item_level_hold="[% hold.item_level_hold | html %]"
58
                        data-itemnumber="[% hold.itemnumber | html %]"
59
                        data-biblionumber="[% hold.biblionumber | html %]"
60
                /></td>
53
                <td>
61
                <td>
54
                    <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" />
62
                    <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" />
55
                    <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" />
63
                    <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+295 lines)
Lines 105-110 Link Here
105
        :disabled {
105
        :disabled {
106
            opacity: 0.5;
106
            opacity: 0.5;
107
        }
107
        }
108
        #toolbar {
109
            align-items: center;
110
        }
108
    </style>
111
    </style>
109
[% END %]
112
[% END %]
110
</head>
113
</head>
Lines 171-176 Link Here
171
        </div>
174
        </div>
172
    [% END %]
175
    [% END %]
173
176
177
    [% IF ( hold_move_successes ) %]
178
        <div class="alert alert-success">
179
            <p>Moved the following holds:</p>
180
            <ul>
181
                [% FOREACH hold IN hold_move_successes %]
182
                    <li>
183
                        <label>Hold ID: </label>
184
                        <span>[% hold.hold_id | html %]</span>
185
                        <span> - Moved from [%- INCLUDE 'biblio-title.inc' biblio=hold.original_biblio link = 1 -%] to [%- INCLUDE 'biblio-title.inc' biblio=hold.target_biblio link = 1 -%]</span>
186
                    </li>
187
                [% END %]
188
            </ul>
189
        </div>
190
    [% END %]
191
    [% IF ( hold_move_failures ) %]
192
        <div class="alert alert-warning">
193
            <strong>One or more holds were not moved due to following errors:</strong>
194
            <ul>
195
                [% FOREACH fail IN hold_move_failures %]
196
                    <li>
197
                        <label>Hold ID: </label>
198
                        <span>[% fail.hold_id | html %]</span>
199
                        [% SWITCH fail.error %]
200
                        [% CASE 'cannotReserveFromOtherBranches' %]
201
                            <span>Target item cannot be reserved from other branches</span>
202
                        [% CASE 'ageRestricted' %]
203
                            <span>The target record and/or items are age restricted</span>
204
                        [% CASE 'alreadypossession' %]
205
                            <span>Target item is already checked out to patron</span>
206
                        [% CASE 'noReservesAllowed' %]
207
                            <span>No holds are allowed on the target item(s)</span>
208
                        [% CASE 'tooManyReservesToday' %]
209
                            <span>Target item has too many holds placed on it today</span>
210
                        [% CASE 'tooManyReserves' %]
211
                            <span>Target item has too many holds placed on it</span>
212
                        [% CASE 'notReservable' %]
213
                            <span>Target item is not reservable</span>
214
                        [% CASE 'cannotReserveFromOtherBranches' %]
215
                            <span>Target item cannot be placed on reserve for this branch</span>
216
                        [% CASE 'branchNotInHoldGroup' %]
217
                            <span>Tagret item is not in the local hold group</span>
218
                        [% CASE 'notforloan' %]
219
                            <span>Target item is not for loan</span>
220
                        [% CASE 'damaged' %]
221
                            <span>Target item is damaged</span>
222
                        [% CASE %]
223
                            <span>Error: [% fail.error | html %]</span>
224
                        [% END %]
225
                    </li>
226
                [% END %]
227
            </ul>
228
        </div>
229
    [% END %]
230
174
    [% IF ( failed_holds ) %]
231
    [% IF ( failed_holds ) %]
175
        <div class="alert alert-warning">
232
        <div class="alert alert-warning">
176
            <strong>One or more holds were not placed due to following errors:</strong>
233
            <strong>One or more holds were not placed due to following errors:</strong>
Lines 1235-1240 Link Here
1235
                            </select>
1292
                            </select>
1236
                        [% END %]
1293
                        [% END %]
1237
                    </fieldset>
1294
                    </fieldset>
1295
                    [% IF ( CAN_user_reserveforothers_alter_hold_targets ) %]
1296
                        <div class="btn-group">
1297
                            <a class="btn btn-default btn-xs dropdown-toggle move_selected_holds" id="item_record_choice" role="button" data-bs-toggle="dropdown" href="#" aria-expanded="false"></a>
1298
                            <ul class="dropdown-menu" role="menu" aria-labelledby="item_record_choice" style="">
1299
                                <li><a class="dropdown-item move_hold_item" href="#">Item level holds to a different item</a></li>
1300
                                <li><a class="dropdown-item move_hold_record" href="#">Record level holds to a different record</a></li>
1301
                            </ul>
1302
                        </div>
1303
                    [% END %]
1238
                </div>
1304
                </div>
1239
                <div class="page-section">
1305
                <div class="page-section">
1240
                    [% FOREACH biblioloo IN biblioloop %]
1306
                    [% FOREACH biblioloo IN biblioloop %]
Lines 1416-1421 Link Here
1416
        </div>
1482
        </div>
1417
    </div>
1483
    </div>
1418
</div>
1484
</div>
1485
<div id="moveHoldItemModal" class="modal modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
1486
    <div class="modal-dialog">
1487
        <div class="modal-content">
1488
            <div class="modal-header">
1489
                <h1 class="modal-title">Move hold(s) to a different item</h1>
1490
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
1491
            </div>
1492
            <div class="modal-body">
1493
                <div id="move_hold_item_selection">
1494
                    <h3>1. Review holds to move</h3>
1495
                    <table class="table table-striped">
1496
                        <thead>
1497
                            <tr>
1498
                                <th>Hold ID</th>
1499
                                <th>Original hold</th>
1500
                                <th>Problem</th>
1501
                            </tr>
1502
                        </thead>
1503
                        <tbody> </tbody>
1504
                    </table>
1505
                </div>
1506
                <hr />
1507
                <div id="move_hold_item_search" class="alert alert-danger" style="display:none;"></div>
1508
                <form id="itemSearchForm">
1509
                    <div id="move_hold_item_searchform">
1510
                        <h3>2. Enter the item barcode of new hold target: </h3>
1511
                        <fieldset class="action">
1512
                            <input type="text" class="form-control" name="external_id" id="external_id" required />
1513
                            <button type="submit" class="btn btn-default mt-3">Search</button>
1514
                        </fieldset>
1515
                    </div>
1516
                </form>
1517
                <form id="move_hold_item_form" method="post" action="request.pl">
1518
                    <div id="itemResultMessage" class="mt-3"> </div>
1519
                    <div id="move_hold_item_confirm" style="display:none;">
1520
                        <h3>3. Confirm moving of holds:</h3>
1521
                        [% INCLUDE 'csrf-token.inc' %]
1522
                        <input type="hidden" name="op" value="cud-move_hold_item" />
1523
                        <button type="submit" class="btn btn-primary mt-3">Move selected holds</button>
1524
                        <input type="hidden" name="original_biblionumber" value="[% biblio.biblionumber %]" />
1525
                    </div>
1526
                </form>
1527
            </div>
1528
            <div class="modal-footer">
1529
                <button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
1530
            </div>
1531
        </div>
1532
    </div>
1533
</div>
1534
<div id="moveHoldBiblioModal" class="modal modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
1535
    <div class="modal-dialog">
1536
        <div class="modal-content">
1537
            <div class="modal-header">
1538
                <h1 class="modal-title">Move hold(s) to a different record</h1>
1539
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
1540
            </div>
1541
            <div class="modal-body">
1542
                <div id="move_hold_item_selection">
1543
                    <h3>1. Review holds to move</h3>
1544
                    <table class="table table-striped">
1545
                        <thead>
1546
                            <tr>
1547
                                <th>Hold ID</th>
1548
                                <th>Original hold</th>
1549
                                <th>Problem</th>
1550
                            </tr>
1551
                        </thead>
1552
                        <tbody> </tbody>
1553
                    </table>
1554
                </div>
1555
                <hr />
1556
                <div id="move_hold_biblio_search" class="alert alert-danger" style="display:none;"></div>
1557
                <form id="biblioSearchForm">
1558
                    <div id="move_hold_item_searchform">
1559
                        <h3>2. Enter the bibloinumber of the new hold target: </h3>
1560
                        <fieldset class="action">
1561
                            <input type="text" class="form-control" name="biblio_id" id="biblio_id" required />
1562
                            <button type="submit" class="btn btn-default mt-3">Search</button>
1563
                        </fieldset>
1564
                    </div>
1565
                </form>
1566
                <form id="move_hold_biblio_form" method="post" action="request.pl">
1567
                    <div id="biblioResultMessage" class="mt-3"> </div>
1568
                    <div id="move_hold_biblio_confirm" style="display:none;">
1569
                        <h3>3. Confirm moving of holds:</h3>
1570
                        [% INCLUDE 'csrf-token.inc' %]
1571
                        <input type="hidden" name="op" value="cud-move_hold_biblio" />
1572
                        <button type="submit" class="btn btn-primary mt-3">Move selected holds</button>
1573
                        <input type="hidden" name="original_biblionumber" value="[% biblio.biblionumber %]" />
1574
                    </div>
1575
                </form>
1576
            </div>
1577
            <div class="modal-footer">
1578
                <button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button>
1579
            </div>
1580
        </div>
1581
    </div>
1582
</div>
1419
<div id="hold-actions">
1583
<div id="hold-actions">
1420
    <form id="hold-actions-form"> [% INCLUDE 'csrf-token.inc' %] </form>
1584
    <form id="hold-actions-form"> [% INCLUDE 'csrf-token.inc' %] </form>
1421
</div>
1585
</div>
Lines 1468-1473 Link Here
1468
1632
1469
        var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
1633
        var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
1470
        var MSG_CANCEL_ALERT    = _("This action will cancel <span class='badge bg-danger'>%s</span> hold(s).");
1634
        var MSG_CANCEL_ALERT    = _("This action will cancel <span class='badge bg-danger'>%s</span> hold(s).");
1635
        var MSG_MOVE_SELECTED = _("Move selected (%s)");
1471
        $.fn.select2.defaults.set("width", "100%" );
1636
        $.fn.select2.defaults.set("width", "100%" );
1472
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1637
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1473
1638
Lines 1731-1736 Link Here
1731
        }
1896
        }
1732
1897
1733
         $(document).ready(function() {
1898
         $(document).ready(function() {
1899
            $("#itemSearchForm").on("submit", function (event) {
1900
                event.preventDefault();
1901
1902
                let externalID = $("#external_id").val();
1903
                let apiUrl = `/api/v1/items?external_id=${encodeURIComponent(externalID)}`;
1904
1905
                $.ajax({
1906
                    url: apiUrl,
1907
                    method: "GET",
1908
                    dataType: "json",
1909
                    success: function (data) {
1910
                        if (data.length > 0) {
1911
                            let resultHtml = "";
1912
                            $.each(data, function (index, item) {
1913
                                resultHtml += `
1914
                                    <div class="alert alert-success">
1915
                                        <strong>Biblionumber:</strong> ${item.biblio_id} <br>
1916
                                        <strong>Item:</strong> ${item.external_id} <br>
1917
                                        <input id="new_itemnumber_${item.item_id}" name="new_itemnumber" type="checkbox" value="${item.item_id}">
1918
                                        <label for="new_itemnumber_${item.item_id}">Move all selected item level holds to this item</label>
1919
                                        <input id="new_biblionumber_${item.item_id}" name="new_biblionumber" type="hidden" value="${item.biblio_id}">
1920
                                    </div>
1921
                                    <hr />
1922
                                `;
1923
                            });
1924
                            $("#itemResultMessage").html(resultHtml);
1925
                        } else {
1926
                            $("#itemResultMessage").html(`
1927
                                <div class="alert alert-warning">No item found with barcode: ${externalID}.</div>
1928
                            `);
1929
                        }
1930
                    },
1931
                });
1932
            });
1933
1934
            $("#biblioSearchForm").on("submit", function (event) {
1935
                event.preventDefault();
1936
1937
                let biblioID = $("#biblio_id").val();
1938
                let apiUrl = `/api/v1/items?q={"biblio_id":"${encodeURIComponent(biblioID)}"}`;
1939
1940
                $.ajax({
1941
                    url: apiUrl,
1942
                    method: "GET",
1943
                    dataType: "json",
1944
                    success: function (data) {
1945
                        if (data.length > 0) {
1946
                            let resultHtml = "";
1947
                            $.each(data, function (index, item) {
1948
                                resultHtml += `
1949
                                    <div class="alert alert-success">
1950
                                        <strong>Biblionumber:</strong> ${item.biblio_id} <br>
1951
                                        <input id="new_biblionumber_${item.biblio_id}" name="new_biblionumber" type="checkbox" value="${item.biblio_id}">
1952
                                        <label for="new_biblionumber_${item.biblio_id}">Move all selected record level holds to this record</label>
1953
                                    </div>
1954
                                    <hr />
1955
                                `;
1956
                            });
1957
                            $("#biblioResultMessage").html(resultHtml);
1958
                        } else {
1959
                            $("#biblioResultMessage").html(`
1960
                                <div class="alert alert-warning">No item found with barcode: ${biblioID}.</div>
1961
                            `);
1962
                        }
1963
                    },
1964
                });
1965
            });
1966
1967
            $(document).on("change", 'input[name="new_itemnumber"]', function() {
1968
                $('input[name="new_itemnumber"]').not(this).prop("checked", false);
1969
                if ( $('input[name="new_itemnumber"]:checked').length ){
1970
                    $('#move_hold_item_confirm').show();
1971
                } else {
1972
                    $('#move_hold_item_confirm').hide();
1973
                }
1974
            });
1975
1976
            $(document).on("change", 'input[name="new_biblionumber"]', function() {
1977
                $('input[name="new_biblionumber"]').not(this).prop("checked", false);
1978
                if ( $('input[name="new_biblionumber"]:checked').length ){
1979
                    $('#move_hold_biblio_confirm').show();
1980
                } else {
1981
                    $('#move_hold_biblio_confirm').hide();
1982
                }
1983
            });
1734
1984
1735
            $("#always_show_holds").change(function(){
1985
            $("#always_show_holds").change(function(){
1736
                if( $(this).prop('checked') ){
1986
                if( $(this).prop('checked') ){
Lines 1834-1839 Link Here
1834
            });
2084
            });
1835
2085
1836
            $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
2086
            $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
2087
            $('.move_selected_holds').html(MSG_MOVE_SELECTED.format($('.holds_table .select_hold:checked').length));
1837
2088
1838
            $('.holds_table .select_hold_all').click(function() {
2089
            $('.holds_table .select_hold_all').click(function() {
1839
                var table = $(this).parents('.holds_table');
2090
                var table = $(this).parents('.holds_table');
Lines 1841-1846 Link Here
1841
                $('.select_hold', table).prop('checked', !count);
2092
                $('.select_hold', table).prop('checked', !count);
1842
                $(this).prop('checked', !count);
2093
                $(this).prop('checked', !count);
1843
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
2094
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
2095
                $('.move_selected_holds').html(MSG_MOVE_SELECTED.format($('.holds_table .select_hold:checked').length));
1844
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
2096
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
1845
                $('#cancel_hold_alert').show();
2097
                $('#cancel_hold_alert').show();
1846
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
2098
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
Lines 1851-1861 Link Here
1851
                var count = $('.select_hold:not(:checked)', table).length;
2103
                var count = $('.select_hold:not(:checked)', table).length;
1852
                $('.select_hold_all', table).prop('checked', !count);
2104
                $('.select_hold_all', table).prop('checked', !count);
1853
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
2105
                $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
2106
                $('.move_selected_holds').html(MSG_MOVE_SELECTED.format($('.holds_table .select_hold:checked').length));
1854
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
2107
                $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length));
1855
                $('#cancel_hold_alert').show();
2108
                $('#cancel_hold_alert').show();
1856
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
2109
                localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1857
            });
2110
            });
1858
2111
2112
            $('.move_hold_item').click(function(e) {
2113
                e.preventDefault();
2114
                if($('.holds_table .select_hold:checked').length) {
2115
                    $('#itemResultMessage').empty();
2116
                    $('#move_hold_item_selection table tbody').empty();
2117
                    $('#moveHoldItemModal').modal('show');
2118
                    $('.select_hold:checked').each( function() {
2119
                        let reserve_id = $(this).data('id');
2120
                        let reserve_biblionumber = $(this).data('biblionumber');
2121
                        let reserve_itemnumber = $(this).data('itemnumber');
2122
                        let item_level_hold = $(this).data('item_level_hold');
2123
                        let error_message = $(this).data('item_level_hold') ? "" : _("Cannot move a waiting or record level hold");
2124
                        let found_status = $(this).data('found');
2125
                        $('#move_hold_item_selection table').append(`<tr><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a> Itemnumber: <a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${reserve_biblionumber}#item${reserve_itemnumber}">${reserve_itemnumber}</a></td><td>${error_message}</td></tr>`)
2126
                        if ( item_level_hold ) {
2127
                            $('#move_hold_item_form').append(`<input type="hidden" name="hold_id" value="${reserve_id}">`);
2128
                        }
2129
                    });
2130
                }
2131
            });
2132
2133
            $('.move_hold_record').click(function(e) {
2134
                e.preventDefault();
2135
                if($('.holds_table .select_hold:checked').length) {
2136
                    $('#biblioResultMessage').empty();
2137
                    $('#move_hold_item_selection table tbody').empty();
2138
                    $('#moveHoldBiblioModal').modal('show');
2139
                    $('.select_hold:checked').each( function() {
2140
                        let reserve_id = $(this).data('id');
2141
                        let reserve_biblionumber = $(this).data('biblionumber');
2142
                        let reserve_itemnumber = $(this).data('itemnumber');
2143
                        let item_level_hold = $(this).data('item_level_hold');
2144
                        let error_message = $(this).data('item_level_hold') ? _("Cannot move a waiting or item level hold") : "";
2145
                        let found_status = $(this).data('found');
2146
                        $('#move_hold_item_selection table').append(`<tr><td>${reserve_id}</td><td>Biblionumber: <a target="_blank" href="/cgi-bin/koha/reserve/request.pl?biblionumber=${reserve_biblionumber}">${reserve_biblionumber}</a></td><td>${error_message}</td></tr>`)
2147
                        if ( !item_level_hold ) {
2148
                            $('#move_hold_biblio_form').append(`<input type="hidden" name="hold_id" value="${reserve_id}">`);
2149
                        }
2150
                    });
2151
                }
2152
            });
2153
1859
            $('.cancel_selected_holds').click(function(e) {
2154
            $('.cancel_selected_holds').click(function(e) {
1860
                e.preventDefault();
2155
                e.preventDefault();
1861
                if($('.holds_table .select_hold:checked').length) {
2156
                if($('.holds_table .select_hold:checked').length) {
(-)a/reserve/request.pl (-3 / +56 lines)
Lines 44-49 use C4::Search qw( enabled_staff_search_views ); Link Here
44
use Koha::Biblios;
44
use Koha::Biblios;
45
use Koha::Checkouts;
45
use Koha::Checkouts;
46
use Koha::Holds;
46
use Koha::Holds;
47
use Koha::Hold;
47
use Koha::CirculationRules;
48
use Koha::CirculationRules;
48
use Koha::Items;
49
use Koha::Items;
49
use Koha::ItemTypes;
50
use Koha::ItemTypes;
Lines 90-95 my $exceeded_maxreserves; Link Here
90
my $exceeded_holds_per_record;
91
my $exceeded_holds_per_record;
91
my @failed_holds   = $input->multi_param('failed_holds');
92
my @failed_holds   = $input->multi_param('failed_holds');
92
my $form_submitted = $input->param('form_submitted');
93
my $form_submitted = $input->param('form_submitted');
94
my @biblionumbers  = $input->multi_param('biblionumber');
93
95
94
my $op = $input->param('op') || q{};
96
my $op = $input->param('op') || q{};
95
97
Lines 109-114 if ( $op eq 'cud-move' ) { Link Here
109
            $next_priority, $first_priority, $last_priority
111
            $next_priority, $first_priority, $last_priority
110
        );
112
        );
111
    }
113
    }
114
} elsif ( $op eq 'cud-move_hold_item' or $op eq 'cud-move_hold_biblio' ) {
115
    my @hold_ids              = $input->multi_param('hold_id');
116
    my $original_biblionumber = $input->param('original_biblionumber');
117
    my @moving_holds          = Koha::Holds->search(
118
        { reserve_id => \@hold_ids },
119
        { order_by   => { -asc => 'priority' } }
120
    )->as_list;
121
122
    my $new_biblionumber = $input->param('new_biblionumber');
123
    my $target_biblio    = Koha::Biblios->find($new_biblionumber);
124
125
    my %args = (
126
        new_biblionumber => $new_biblionumber,
127
    );
128
129
    # Only pass new_itemnumber if this is an item level move
130
    if ( $op eq 'cud-move_hold_item' ) {
131
        $args{new_itemnumber} = $input->param('new_itemnumber');
132
    }
133
134
    my @success_messages;
135
    my @error_messages;
136
137
    foreach my $hold (@moving_holds) {
138
        my $original_biblio = Koha::Biblios->find( $hold->biblionumber );
139
140
        my $result = $hold->move_hold( \%args );
141
142
        if ( $result->{success} ) {
143
            push @success_messages, {
144
                hold_id         => $hold->id,
145
                success         => 1,
146
                original_biblio => $original_biblio,
147
                target_biblio   => $target_biblio,
148
            };
149
        } else {
150
            push @error_messages, {
151
                hold_id         => $hold->id,
152
                success         => 0,
153
                original_biblio => $original_biblio,
154
                target_biblio   => $target_biblio,
155
                error           => $result->{error},
156
            };
157
        }
158
    }
159
160
    #Fix the priority on the original record
161
    C4::Reserves::_FixPriority( { biblionumber => $original_biblionumber } );
162
163
    $template->param(
164
        hold_move_successes => \@success_messages,
165
        hold_move_failures  => \@error_messages,
166
    );
167
112
} elsif ( $op eq 'cud-cancel' ) {
168
} elsif ( $op eq 'cud-cancel' ) {
113
    my $reserve_id          = $input->param('reserve_id');
169
    my $reserve_id          = $input->param('reserve_id');
114
    my $cancellation_reason = $input->param("cancellation-reason");
170
    my $cancellation_reason = $input->param("cancellation-reason");
Lines 172-179 if ($form_submitted) { Link Here
172
    }
228
    }
173
}
229
}
174
230
175
my @biblionumbers = $input->multi_param('biblionumber');
176
177
my $multi_hold = @biblionumbers > 1;
231
my $multi_hold = @biblionumbers > 1;
178
$template->param(
232
$template->param(
179
    multi_hold => $multi_hold,
233
    multi_hold => $multi_hold,
180
- 

Return to bug 31698