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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-222 / +223 lines)
Lines 1601-1607 Link Here
1601
        const apply_patron_autocomplete = [% !( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) && PatronAutoComplete ? 1 : 0 | html %];
1601
        const apply_patron_autocomplete = [% !( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) && PatronAutoComplete ? 1 : 0 | html %];
1602
        const url_biblio_params = '[% url_biblio_params | url %]';
1602
        const url_biblio_params = '[% url_biblio_params | url %]';
1603
    </script>
1603
    </script>
1604
1605
    <script>
1604
    <script>
1606
        $(document).ready(function () {
1605
        $(document).ready(function () {
1607
            $("#patron_holds_table").kohaTable(
1606
            $("#patron_holds_table").kohaTable(
Lines 1624-1665 Link Here
1624
            cannotReserveFromOtherBranches: _("Patron is from different library"),
1623
            cannotReserveFromOtherBranches: _("Patron is from different library"),
1625
            itemAlreadyOnHold: _("Patron already has hold for this item"),
1624
            itemAlreadyOnHold: _("Patron already has hold for this item"),
1626
            cannotBeTransferred: _("Cannot be transferred to pickup library"),
1625
            cannotBeTransferred: _("Cannot be transferred to pickup library"),
1627
            pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1626
            pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed"),
1628
        }
1627
        };
1629
1628
1630
        $.fn.select2.defaults.set("width", "100%" );
1629
        $.fn.select2.defaults.set("width", "100%");
1631
        $.fn.select2.defaults.set("dropdownAutoWidth", true );
1630
        $.fn.select2.defaults.set("dropdownAutoWidth", true);
1632
1631
1633
        $(document).ready(function() {
1632
        $(document).ready(function () {
1634
            $('#cancellation-reason-div').hide();
1633
            $("#cancellation-reason-div").hide();
1635
            $('.rank-request').on('change', function() {
1634
            $(".rank-request").on("change", function () {
1636
                if ( $(".rank-request option:selected[value='del']").length ) {
1635
                if ($(".rank-request option:selected[value='del']").length) {
1637
                    $('#cancellation-reason-div').show();
1636
                    $("#cancellation-reason-div").show();
1638
                } else {
1637
                } else {
1639
                    $('#cancellation-reason-div').hide();
1638
                    $("#cancellation-reason-div").hide();
1640
                }
1639
                }
1641
            });
1640
            });
1642
1641
1643
            if( $("#circ_holds_select").length > 0 ){
1642
            if ($("#circ_holds_select").length > 0) {
1644
                /* Set active tab based on whether a club search was submitted */
1643
                /* Set active tab based on whether a club search was submitted */
1645
                var tabs = $("#circ_holds_select li:eq(" + active_tab + ") a").tab("show");
1644
                var tabs = $("#circ_holds_select li:eq(" + active_tab + ") a").tab("show");
1646
                $( tabs[0].hash ).find("input.focus").focus();
1645
                $(tabs[0].hash).find("input.focus").focus();
1647
1646
1648
                /* Change active focus when tabs change */
1647
                /* Change active focus when tabs change */
1649
                $("#circ_holds_select a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
1648
                $("#circ_holds_select a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
1650
                    active_tab = e.target.hash;
1649
                    active_tab = e.target.hash;
1651
                    $( active_tab ).find("input.focus").focus();
1650
                    $(active_tab).find("input.focus").focus();
1652
                });
1651
                });
1653
            }
1652
            }
1654
1653
1655
1656
            ToggleHoldsToPlace();
1654
            ToggleHoldsToPlace();
1657
            $("#requestany,.requestspecific[name='request'],.requestgrp").on('change', function(){
1655
            $("#requestany,.requestspecific[name='request'],.requestgrp").on("change", function () {
1658
                ToggleHoldsToPlace();
1656
                ToggleHoldsToPlace();
1659
            });
1657
            });
1660
1658
1661
            if (prefs.UseBranchTransferLimits){
1659
            if (prefs.UseBranchTransferLimits) {
1662
                $("#pickup,#pickup-next-avail,#pickup-item-group").on('change', function(){
1660
                $("#pickup,#pickup-next-avail,#pickup-item-group").on("change", function () {
1663
                    var pickup = $(this).val();
1661
                    var pickup = $(this).val();
1664
                    var url = "?pickup=" + pickup;
1662
                    var url = "?pickup=" + pickup;
1665
                    url += "&borrowernumber=" + borrowernumber;
1663
                    url += "&borrowernumber=" + borrowernumber;
Lines 1673-1762 Link Here
1673
                dom: '<"top pager"ilf>t',
1671
                dom: '<"top pager"ilf>t',
1674
            });
1672
            });
1675
1673
1676
            $("#club-request-form").on("submit", function() {
1674
            $("#club-request-form").on("submit", function () {
1677
                let $t = $(this);
1675
                let $t = $(this);
1678
                $('.clubalert, .holdalert').addClass('hide');
1676
                $(".clubalert, .holdalert").addClass("hide");
1679
                const data = {
1677
                const data = {
1680
                    pickup_library_id: $('select[name="pickup"]').val()
1678
                    pickup_library_id: $('select[name="pickup"]').val(),
1681
                };
1679
                };
1682
                if($('input[name="checkitem"]:checked').length)
1680
                if ($('input[name="checkitem"]:checked').length) data.item_id = $('input[name="checkitem"]:checked').val();
1683
                    data.item_id = $('input[name="checkitem"]:checked').val();
1681
                if ($('input[name="item_group_id"]:checked').length) data.item_group_id = $('input[name="item_group_id"]:checked').val();
1684
                if($('input[name="item_group_id"]:checked').length)
1682
                if ($('input[name="borrowernumber"]').length) data.patron_id = $('input[name="borrowernumber"]').val();
1685
                    data.item_group_id = $('input[name="item_group_id"]:checked').val();
1683
                if ($('textarea[name="notes"]').length) data.notes = $('textarea[name="notes"]').val() || null;
1686
                if($('input[name="borrowernumber"]').length)
1684
                if ($('input[name="itemtype"]').length) {
1687
                    data.patron_id = $('input[name="borrowernumber"]').val();
1685
                    data.item_type = $('input[name="itemtype"]').val() || null;
1688
                if($('textarea[name="notes"]').length)
1689
                    data.notes = $('textarea[name="notes"]').val()||null;
1690
                if($('input[name="itemtype"]').length) {
1691
                    data.item_type = $('input[name="itemtype"]').val()||null;
1692
                }
1686
                }
1693
                if($('input[name="default_patron_home"]:checked').length) {
1687
                if ($('input[name="default_patron_home"]:checked').length) {
1694
                    data.default_patron_home = 1;
1688
                    data.default_patron_home = 1;
1695
                }
1689
                }
1696
1690
1697
                const count = $('input[name="holds_to_place_count"]').length?$('input[name="holds_to_place_count"]').val():1;
1691
                const count = $('input[name="holds_to_place_count"]').length ? $('input[name="holds_to_place_count"]').val() : 1;
1698
                var newloc = 'request.pl?';
1692
                var newloc = "request.pl?";
1699
                biblionumbers.forEach(function (biblionumber) {
1693
                biblionumbers.forEach(function (biblionumber) {
1700
                    newloc += '&biblionumber=' + biblionumber;
1694
                    newloc += "&biblionumber=" + biblionumber;
1701
                });
1695
                });
1702
1696
1703
                biblionumbers.forEach(function(biblionumber) {
1697
                biblionumbers.forEach(function (biblionumber) {
1704
                    data.biblio_id = biblionumber;
1698
                    data.biblio_id = biblionumber;
1705
                    let options = {
1699
                    let options = {
1706
                        url: $t.attr('action'),
1700
                        url: $t.attr("action"),
1707
                        method: $t.attr('method').toUpperCase(),
1701
                        method: $t.attr("method").toUpperCase(),
1708
                        contentType: 'application/json',
1702
                        contentType: "application/json",
1709
                        data: JSON.stringify(data)
1703
                        data: JSON.stringify(data),
1710
                    };
1704
                    };
1711
                    for(let i = 0; i < count; i++) {
1705
                    for (let i = 0; i < count; i++) {
1712
                        $.ajax(options)
1706
                        $.ajax(options)
1713
                        .then(function(result) {
1707
                            .then(function (result) {
1714
                            document.location = newloc;
1708
                                document.location = newloc;
1715
                        })
1709
                            })
1716
                        .fail(function(err) {
1710
                            .fail(function (err) {
1717
                            var message = err.responseJSON.error;
1711
                                var message = err.responseJSON.error;
1718
                            var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/);
1712
                                var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/);
1719
                            if(match && ERROR_MAP[match[1]]) {
1713
                                if (match && ERROR_MAP[match[1]]) {
1720
                                message = '<div><strong>'+_("Cannot place hold")+'</strong></div><div>'+ERROR_MAP[match[1]]+'</div>'
1714
                                    message = "<div><strong>" + _("Cannot place hold") + "</strong></div><div>" + ERROR_MAP[match[1]] + "</div>";
1721
                            }
1715
                                }
1722
                            $('.clubalert, .holdalert').removeClass('hide').html(message);
1716
                                $(".clubalert, .holdalert").removeClass("hide").html(message);
1723
                        });
1717
                            });
1724
                    }
1718
                    }
1725
                });
1719
                });
1726
1720
1727
                return false;
1721
                return false;
1728
            });
1722
            });
1729
1723
1730
            if (!multi_hold){
1724
            if (!multi_hold) {
1731
                $("#hold-request-form").on("submit", function(e){
1725
                $("#hold-request-form").on("submit", function (e) {
1732
                    return check(e, $(this));
1726
                    return check(e, $(this));
1733
                });
1727
                });
1734
            } else {
1728
            } else {
1735
                $("#hold-request-form").on("submit", function(){
1729
                $("#hold-request-form").on("submit", function () {
1736
                    return checkMultiHold();
1730
                    return checkMultiHold();
1737
                });
1731
                });
1738
            }
1732
            }
1739
1733
1740
            $(".pickup_location_dropdown").each( function () {
1734
            $(".pickup_location_dropdown").each(function () {
1741
                $(this).pickup_locations_dropdown();
1735
                $(this).pickup_locations_dropdown();
1742
            });
1736
            });
1743
1737
1744
            $("#pickup_multi").select2({
1738
            $("#pickup_multi").select2({
1745
                width: '30%',
1739
                width: "30%",
1746
                allowClear: true
1740
                allowClear: true,
1747
            });
1741
            });
1748
1742
1749
            $('.multi_pickup_select').select2({
1743
            $(".multi_pickup_select").select2({
1750
                width: '100%',
1744
                width: "100%",
1751
                allowClear: true
1745
                allowClear: true,
1752
            });
1746
            });
1753
1747
1754
            $("#pickup_multi").on("change", function() {
1748
            $("#pickup_multi").on("change", function () {
1755
                var selection = $(this).val();
1749
                var selection = $(this).val();
1756
                if ( selection != '' ) {
1750
                if (selection != "") {
1757
                    $(".multi_pickup_select").each(function() {
1751
                    $(".multi_pickup_select").each(function () {
1758
                        var valid_pickup_locations = $(this).data('pickup-locations');
1752
                        var valid_pickup_locations = $(this).data("pickup-locations");
1759
                        if ( valid_pickup_locations.includes(selection) ) {
1753
                        if (valid_pickup_locations.includes(selection)) {
1760
                            $(this).val(selection);
1754
                            $(this).val(selection);
1761
                            $(this).trigger("change");
1755
                            $(this).trigger("change");
1762
                        }
1756
                        }
Lines 1764-1770 Link Here
1764
                }
1758
                }
1765
            });
1759
            });
1766
1760
1767
            $("#pickup,#pickup-item-group,#pickup-next-avail").each( function () {
1761
            $("#pickup,#pickup-item-group,#pickup-next-avail").each(function () {
1768
                $(this).pickup_locations_dropdown();
1762
                $(this).pickup_locations_dropdown();
1769
            });
1763
            });
1770
1764
Lines 1774-2053 Link Here
1774
        });
1768
        });
1775
1769
1776
        function ToggleHoldsToPlace() {
1770
        function ToggleHoldsToPlace() {
1777
            if ( $("#requestany").prop('checked') ) {
1771
            if ($("#requestany").prop("checked")) {
1778
                $(".disable_request_any").prop('disabled',true).addClass('disabled').removeClass('enabled');
1772
                $(".disable_request_any").prop("disabled", true).addClass("disabled").removeClass("enabled");
1779
                $(".enable_request_any").prop('disabled',false).removeClass('disabled').addClass('enabled');
1773
                $(".enable_request_any").prop("disabled", false).removeClass("disabled").addClass("enabled");
1780
                $(".requestspecific,.requestgrp").prop('checked', false);
1774
                $(".requestspecific,.requestgrp").prop("checked", false);
1781
            } else if( $(".requestspecific").prop('checked') ) {
1775
            } else if ($(".requestspecific").prop("checked")) {
1782
                $(".disable_request_specific").prop('disabled',true).addClass('disabled').removeClass('enabled');
1776
                $(".disable_request_specific").prop("disabled", true).addClass("disabled").removeClass("enabled");
1783
                $(".enable_request_specific").prop('disabled',false).removeClass('disabled').addClass('enabled');
1777
                $(".enable_request_specific").prop("disabled", false).removeClass("disabled").addClass("enabled");
1784
                $("#requestany,.requestgrp").prop('checked', false);
1778
                $("#requestany,.requestgrp").prop("checked", false);
1785
            } else {
1779
            } else {
1786
                $(".disable_request_group").prop('disabled',true).addClass('disabled').removeClass('enabled');
1780
                $(".disable_request_group").prop("disabled", true).addClass("disabled").removeClass("enabled");
1787
                $(".enable_request_group").prop('disabled',false).removeClass('disabled').addClass('enabled');
1781
                $(".enable_request_group").prop("disabled", false).removeClass("disabled").addClass("enabled");
1788
                $("#requestany,.requestspecific").prop('checked', false);
1782
                $("#requestany,.requestspecific").prop("checked", false);
1789
            }
1783
            }
1790
        }
1784
        }
1791
1785
1792
        $('.any_specific').click(function() {
1786
        $(".any_specific").click(function () {
1793
            const fieldset = $(this).find('fieldset:first');
1787
            const fieldset = $(this).find("fieldset:first");
1794
1788
1795
            if ( fieldset.hasClass('disabled') ) {
1789
            if (fieldset.hasClass("disabled")) {
1796
                $('.enable_request_specific, .enable_request_any, .enable_request_group').removeClass('enabled');
1790
                $(".enable_request_specific, .enable_request_any, .enable_request_group").removeClass("enabled");
1797
                const specific_cb = $(this).find('#requestspecificitem');
1791
                const specific_cb = $(this).find("#requestspecificitem");
1798
                const any_cb = $(this).find('#requestany');
1792
                const any_cb = $(this).find("#requestany");
1799
                const itemgroup_cb = $(this).find('#requestgrp');
1793
                const itemgroup_cb = $(this).find("#requestgrp");
1800
1794
1801
                if ( specific_cb.length ) {
1795
                if (specific_cb.length) {
1802
                    specific_cb.prop('checked', true);
1796
                    specific_cb.prop("checked", true);
1803
                } else if ( any_cb.length ) {
1797
                } else if (any_cb.length) {
1804
                    any_cb.prop('checked', true);
1798
                    any_cb.prop("checked", true);
1805
                } else {
1799
                } else {
1806
                    itemgroup_cb.prop('checked', true);
1800
                    itemgroup_cb.prop("checked", true);
1807
                }
1801
                }
1808
1802
1809
                fieldset.removeClass('disabled').addClass('enabled');
1803
                fieldset.removeClass("disabled").addClass("enabled");
1810
                ToggleHoldsToPlace();
1804
                ToggleHoldsToPlace();
1811
            }
1805
            }
1812
        });
1806
        });
1813
1807
1814
        function check( e, table ) {
1808
        function check(e, table) {
1815
1816
            var msg = "";
1809
            var msg = "";
1817
1810
1818
            if ( $(".requestspecific").is(":checked") ) {
1811
            if ($(".requestspecific").is(":checked")) {
1819
                // requestany not selected, go through the item-specific cases
1812
                // requestany not selected, go through the item-specific cases
1820
                var selected_items = $('#requestspecific input[name="checkitem"]:checked');
1813
                var selected_items = $('#requestspecific input[name="checkitem"]:checked');
1821
                if ( selected_items.length > 0 ) {
1814
                if (selected_items.length > 0) {
1822
                    // got item-specific hold requests in the form!
1815
                    // got item-specific hold requests in the form!
1823
                    // verify they have a pickup location selected
1816
                    // verify they have a pickup location selected
1824
1817
1825
                    if ( selected_items.closest('tr').find(".pickup_locations").val() == '' ) {
1818
                    if (selected_items.closest("tr").find(".pickup_locations").val() == "") {
1826
1819
                        msg = _("- Please select a pickup location for the item") + "\n";
1827
                        msg = _("- Please select a pickup location for the item") + "\n"
1828
                    }
1820
                    }
1829
                }
1821
                } else {
1830
                else {
1831
                    msg = _("- Please select an item to place a hold") + "\n";
1822
                    msg = _("- Please select an item to place a hold") + "\n";
1832
                }
1823
                }
1833
            } else if ( $("#requestgrp").is(":checked") ) {
1824
            } else if ($("#requestgrp").is(":checked")) {
1834
                var selected_group = $('#requestgroup input[type="radio"]:checked');
1825
                var selected_group = $('#requestgroup input[type="radio"]:checked');
1835
                if( selected_group.length > 0 ){
1826
                if (selected_group.length > 0) {
1836
                    if( $("#pickup-item-group").length < 1 || $("#pickup-item-grp").val() == "" ){
1827
                    if ($("#pickup-item-group").length < 1 || $("#pickup-item-grp").val() == "") {
1837
                        msg = _("- Please select a pickup location for this hold" + "\n");
1828
                        msg = _("- Please select a pickup location for this hold" + "\n");
1838
                    }
1829
                    }
1839
                } else {
1830
                } else {
1840
                    msg = (_("- Please select an item group to place a hold") + "\n");
1831
                    msg = _("- Please select an item group to place a hold") + "\n";
1841
                }
1832
                }
1842
            } else {
1833
            } else {
1843
                // Requesting next available
1834
                // Requesting next available
1844
                if( $("#pickup-next-avail").length < 1 || $("#pickup-next-avail").val() == "" || $('#pickup-next-avail').val() === null ){
1835
                if ($("#pickup-next-avail").length < 1 || $("#pickup-next-avail").val() == "" || $("#pickup-next-avail").val() === null) {
1845
                    msg = _("- Please select a pickup location for this hold") + "\n";
1836
                    msg = _("- Please select a pickup location for this hold") + "\n";
1846
                }
1837
                }
1847
            }
1838
            }
1848
1839
1849
1850
            if (msg == "") {
1840
            if (msg == "") {
1851
                $('#hold-request-form').preventDoubleFormSubmit();
1841
                $("#hold-request-form").preventDoubleFormSubmit();
1852
                return(true);
1842
                return true;
1853
            } else {
1843
            } else {
1854
                e.preventDefault();
1844
                e.preventDefault();
1855
                alert(msg);
1845
                alert(msg);
1856
                return(false);
1846
                return false;
1857
            }
1847
            }
1858
        }
1848
        }
1859
1849
1860
        function checkMultiHold() {
1850
        function checkMultiHold() {
1861
1862
            var selected_bibs = $(".multi_hold_item_checkbox:checked");
1851
            var selected_bibs = $(".multi_hold_item_checkbox:checked");
1863
            if ( selected_bibs.length > 0 ) {
1852
            if (selected_bibs.length > 0) {
1864
                // there are biblios selected in the form!
1853
                // there are biblios selected in the form!
1865
                // verify they have a pickup location selected
1854
                // verify they have a pickup location selected
1866
1855
1867
                var pickup_not_set = 0;
1856
                var pickup_not_set = 0;
1868
                selected_bibs.each(function() {
1857
                selected_bibs.each(function () {
1869
                    if ( $(this).closest('tr').find(".multi_pickup_select").val() === "" ) {
1858
                    if ($(this).closest("tr").find(".multi_pickup_select").val() === "") {
1870
                        pickup_not_set++;
1859
                        pickup_not_set++;
1871
                    }
1860
                    } else {
1872
                    else {
1873
                        var bibnum = $(this).attr("title");
1861
                        var bibnum = $(this).attr("title");
1874
                    }
1862
                    }
1875
                });
1863
                });
1876
                if ( pickup_not_set > 0 ) {
1864
                if (pickup_not_set > 0) {
1877
                    alert( _("Please make sure all selected titles have a pickup location set") + "\n" );
1865
                    alert(_("Please make sure all selected titles have a pickup location set") + "\n");
1878
                    return false;
1866
                    return false;
1879
                }
1867
                }
1880
            }
1868
            } else {
1881
            else {
1869
                alert(_("Please select at least one title") + "\n");
1882
                alert( _("Please select at least one title") + "\n" );
1883
                return false;
1870
                return false;
1884
            }
1871
            }
1885
1872
1886
            $('#hold-request-form').preventDoubleFormSubmit();
1873
            $("#hold-request-form").preventDoubleFormSubmit();
1887
1874
1888
            return true;
1875
            return true;
1889
        }
1876
        }
1890
1877
1891
         $(document).ready(function() {
1878
        $(document).ready(function () {
1892
1879
            $("#always_show_holds").change(function () {
1893
            $("#always_show_holds").change(function(){
1880
                if ($(this).prop("checked")) {
1894
                if( $(this).prop('checked') ){
1895
                    document.cookie = "always_show_holds=DO";
1881
                    document.cookie = "always_show_holds=DO";
1896
                } else {
1882
                } else {
1897
                    document.cookie = "always_show_holds=DONT";
1883
                    document.cookie = "always_show_holds=DONT";
1898
                }
1884
                }
1899
            });
1885
            });
1900
            $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
1886
            $("input.needsoverride").click(function () {
1887
                // This must be before the radio button/checkbox switch logic
1901
                var itemnumber = this.value;
1888
                var itemnumber = this.value;
1902
                var msg = '';
1889
                var msg = "";
1903
1890
1904
                switch (override_items[itemnumber].holdallowed) {
1891
                switch (override_items[itemnumber].holdallowed) {
1905
                    case "not_allowed": msg = _("This item normally cannot be put on hold."); break;
1892
                    case "not_allowed":
1906
                    case "from_home_library": msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1893
                        msg = _("This item normally cannot be put on hold.");
1894
                        break;
1895
                    case "from_home_library":
1896
                        msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch);
1897
                        break;
1907
                }
1898
                }
1908
1899
1909
                msg += "\n\n" + _("Place hold on this item?");
1900
                msg += "\n\n" + _("Place hold on this item?");
1910
1901
1911
                return confirm(msg);
1902
                return confirm(msg);
1912
            });
1903
            });
1913
            $("button.warning").click(function() {
1904
            $("button.warning").click(function () {
1914
                return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
1905
                return confirm(_("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?"));
1915
            });
1906
            });
1916
            var prev_rank_request;
1907
            var prev_rank_request;
1917
            $("select[name=rank-request]").on("focus", function() {
1908
            $("select[name=rank-request]")
1918
                prev_rank_request = parseInt($(this).val());
1909
                .on("focus", function () {
1919
            }).change(function() {
1910
                    prev_rank_request = parseInt($(this).val());
1920
                var this_rank = $(this);
1911
                })
1921
                var new_rank = parseInt(this_rank.val());
1912
                .change(function () {
1922
                var old_rank = prev_rank_request;
1913
                    var this_rank = $(this);
1923
1914
                    var new_rank = parseInt(this_rank.val());
1924
                if ( isNaN( old_rank ) ) {
1915
                    var old_rank = prev_rank_request;
1925
                    $("select[name=rank-request]").not('[disabled]').not(this_rank).each(function() {
1916
1926
                        var current_rank = parseInt($(this).val());
1917
                    if (isNaN(old_rank)) {
1927
                        if ( !isNaN(current_rank) && current_rank >= new_rank ) {
1918
                        $("select[name=rank-request]")
1928
                            $(this).val(current_rank + 1);
1919
                            .not("[disabled]")
1920
                            .not(this_rank)
1921
                            .each(function () {
1922
                                var current_rank = parseInt($(this).val());
1923
                                if (!isNaN(current_rank) && current_rank >= new_rank) {
1924
                                    $(this).val(current_rank + 1);
1925
                                }
1926
                            });
1927
                        prev_rank_request = new_rank;
1928
                        return;
1929
                    }
1930
1931
                    if (isNaN(new_rank)) {
1932
                        if (!isNaN(old_rank)) {
1933
                            $("select[name=rank-request]")
1934
                                .not("[disabled]")
1935
                                .not(this)
1936
                                .each(function () {
1937
                                    var current_rank = parseInt($(this).val());
1938
                                    if (!isNaN(current_rank) && current_rank > old_rank) {
1939
                                        $(this).val(current_rank - 1);
1940
                                    }
1941
                                });
1929
                        }
1942
                        }
1930
                    });
1943
                        prev_rank_request = NaN;
1931
                    prev_rank_request = new_rank;
1944
                        return;
1932
                    return;
1945
                    }
1933
                }
1946
1947
                    //if new rank is old rank, don't continue
1948
                    if (new_rank === old_rank) return;
1934
1949
1935
                if ( isNaN( new_rank ) ) {
1950
                    // Adjust ranks
1936
                    if ( !isNaN( old_rank ) ) {
1951
                    $("select[name=rank-request]")
1937
                        $("select[name=rank-request]").not('[disabled]').not(this).each(function() {
1952
                        .not("[disabled]")
1953
                        .not(this)
1954
                        .each(function () {
1938
                            var current_rank = parseInt($(this).val());
1955
                            var current_rank = parseInt($(this).val());
1939
                            if ( !isNaN(current_rank) && current_rank > old_rank ) {
1956
                            //if current_rank is NaN, bail
1940
                                $(this).val(current_rank - 1);
1957
                            if (isNaN(current_rank)) return;
1958
1959
                            if (old_rank > new_rank) {
1960
                                if (current_rank >= new_rank && current_rank < old_rank) {
1961
                                    $(this).val(current_rank + 1);
1962
                                }
1963
                            } else {
1964
                                if (current_rank > old_rank && current_rank <= new_rank) {
1965
                                    $(this).val(current_rank - 1);
1966
                                }
1941
                            }
1967
                            }
1942
                        });
1968
                        });
1943
                    }
1944
                    prev_rank_request = NaN;
1945
                    return;
1946
                }
1947
1969
1948
                //if new rank is old rank, don't continue
1970
                    prev_rank_request = new_rank;
1949
                if ( new_rank === old_rank ) return;
1950
1951
                // Adjust ranks
1952
                $("select[name=rank-request]").not('[disabled]').not(this).each(function() {
1953
                    var current_rank = parseInt($(this).val());
1954
                    //if current_rank is NaN, bail
1955
                    if ( isNaN( current_rank ) ) return;
1956
1957
                    if ( old_rank > new_rank ) {
1958
                        if ( current_rank >= new_rank && current_rank < old_rank ) {
1959
                            $(this).val(current_rank + 1);
1960
                        }
1961
                    } else {
1962
                        if ( current_rank > old_rank && current_rank <= new_rank ) {
1963
                            $(this).val(current_rank - 1);
1964
                        }
1965
                    }
1966
                });
1971
                });
1967
1972
1968
                prev_rank_request = new_rank;
1973
            $(".clear-date").on("click", function (e) {
1969
            });
1970
1971
            $(".clear-date").on("click",function(e){
1972
                e.preventDefault();
1974
                e.preventDefault();
1973
                var fieldID = this.id.replace("clear-date-","");
1975
                var fieldID = this.id.replace("clear-date-", "");
1974
                $("#" + fieldID).val("");
1976
                $("#" + fieldID).val("");
1975
            });
1977
            });
1976
1978
1977
            if (apply_patron_autocomplete){
1979
            if (apply_patron_autocomplete) {
1978
                patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': url_biblio_params });
1980
                patron_autocomplete($(".search_patron_filter"), { "link-to": "reserve", "url-params": url_biblio_params });
1979
            }
1981
            }
1980
1982
1981
            if (prefs.EnableItemGroupHolds){
1983
            if (prefs.EnableItemGroupHolds) {
1982
                $(':radio[name="item_group_id"]').change(function(){
1984
                $(':radio[name="item_group_id"]').change(function () {
1983
                    $('input[name="checkitem"]').prop('checked', false);
1985
                    $('input[name="checkitem"]').prop("checked", false);
1984
                });
1986
                });
1985
1987
1986
                $('input[name="checkitem"]').change(function(){
1988
                $('input[name="checkitem"]').change(function () {
1987
                    $(':radio[name="item_group_id"]').prop('checked', false);
1989
                    $(':radio[name="item_group_id"]').prop("checked", false);
1988
                });
1990
                });
1989
            }
1991
            }
1990
1992
1991
            $(".hold-arrow").click(function(e) {
1993
            $(".hold-arrow").click(function (e) {
1992
                e.preventDefault();
1994
                e.preventDefault();
1993
                let arrowForm = $("#hold-actions-form").attr({
1995
                let arrowForm = $("#hold-actions-form").attr({
1994
                    action: 'request.pl',
1996
                    action: "request.pl",
1995
                    method: 'post'
1997
                    method: "post",
1996
                });
1998
                });
1997
                let arrow_op = $("<input />").attr({
1999
                let arrow_op = $("<input />").attr({
1998
                    name: 'op',
2000
                    name: "op",
1999
                    type: 'hidden',
2001
                    type: "hidden",
2000
                    value: $(this).data('op')
2002
                    value: $(this).data("op"),
2001
                });
2003
                });
2002
                let arrow_where = $("<input />").attr({
2004
                let arrow_where = $("<input />").attr({
2003
                    name: 'where',
2005
                    name: "where",
2004
                    type: 'hidden',
2006
                    type: "hidden",
2005
                    value: $(this).data('where')
2007
                    value: $(this).data("where"),
2006
                });
2008
                });
2007
                let arrow_fp = $("<input />").attr({
2009
                let arrow_fp = $("<input />").attr({
2008
                    name: 'first_priority',
2010
                    name: "first_priority",
2009
                    type: 'hidden',
2011
                    type: "hidden",
2010
                    value: $(this).data('first_priority')
2012
                    value: $(this).data("first_priority"),
2011
                });
2013
                });
2012
                let arrow_lp = $("<input />").attr({
2014
                let arrow_lp = $("<input />").attr({
2013
                    name: 'last_priority',
2015
                    name: "last_priority",
2014
                    type: 'hidden',
2016
                    type: "hidden",
2015
                    value: $(this).data('last_priority')
2017
                    value: $(this).data("last_priority"),
2016
                });
2018
                });
2017
                let arrow_pp = $("<input />").attr({
2019
                let arrow_pp = $("<input />").attr({
2018
                    name: 'prev_priority',
2020
                    name: "prev_priority",
2019
                    type: 'hidden',
2021
                    type: "hidden",
2020
                    value: $(this).data('prev_priority')
2022
                    value: $(this).data("prev_priority"),
2021
                });
2023
                });
2022
                let arrow_np = $("<input />").attr({
2024
                let arrow_np = $("<input />").attr({
2023
                    name: 'next_priority',
2025
                    name: "next_priority",
2024
                    type: 'hidden',
2026
                    type: "hidden",
2025
                    value: $(this).data('next_priority')
2027
                    value: $(this).data("next_priority"),
2026
                });
2028
                });
2027
                let arrow_bn = $("<input />").attr({
2029
                let arrow_bn = $("<input />").attr({
2028
                    name: 'borrowernumber',
2030
                    name: "borrowernumber",
2029
                    type: 'hidden',
2031
                    type: "hidden",
2030
                    value: $(this).data('borrowernumber')
2032
                    value: $(this).data("borrowernumber"),
2031
                });
2033
                });
2032
                let arrow_bb = $("<input />").attr({
2034
                let arrow_bb = $("<input />").attr({
2033
                    name: 'biblionumber',
2035
                    name: "biblionumber",
2034
                    type: 'hidden',
2036
                    type: "hidden",
2035
                    value: $(this).data('biblionumber')
2037
                    value: $(this).data("biblionumber"),
2036
                });
2038
                });
2037
                let arrow_ri = $("<input />").attr({
2039
                let arrow_ri = $("<input />").attr({
2038
                    name: 'reserve_id',
2040
                    name: "reserve_id",
2039
                    type: 'hidden',
2041
                    type: "hidden",
2040
                    value: $(this).data('reserve_id')
2042
                    value: $(this).data("reserve_id"),
2041
                });
2043
                });
2042
                let arrow_date = $("<input />").attr({
2044
                let arrow_date = $("<input />").attr({
2043
                    name: 'date',
2045
                    name: "date",
2044
                    type: 'hidden',
2046
                    type: "hidden",
2045
                    value: $(this).data('date')
2047
                    value: $(this).data("date"),
2046
                });
2048
                });
2047
                arrowForm.append(arrow_op,arrow_where,arrow_fp,arrow_lp,arrow_pp,arrow_np,arrow_bn,arrow_bb,arrow_ri,arrow_date);
2049
                arrowForm.append(arrow_op, arrow_where, arrow_fp, arrow_lp, arrow_pp, arrow_np, arrow_bn, arrow_bb, arrow_ri, arrow_date);
2048
                $("#hold-actions-form").submit();
2050
                $("#hold-actions-form").submit();
2049
                return true;
2051
                return true;
2050
            })
2052
            });
2051
        });
2053
        });
2052
    </script>
2054
    </script>
2053
    <script>
2055
    <script>
2054
- 

Return to bug 41577