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

Return to bug 41577