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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +249 lines)
Lines 612-617 Link Here
612
                    </form>
612
                    </form>
613
                </div><!-- ./page-section -->
613
                </div><!-- ./page-section -->
614
614
615
                <div id="issuing-rules-tester" class="container" style="width:auto;">
616
                    <a id="toggle-tester" class="btn btn-default btn-sm">Circulation and fine rules test tool</a>
617
                    <div id="issuing-rules-tester-container">
618
                    <h3>Circulation and fine rules test tool</h3>
619
                        <p>This test tool lets you search a row of circulation and fine rules for a specific patron, item and library.</p>
620
                        <p>Dropdown value for <strong>Library</strong> is determined via system preference <strong>CircControl</strong>. If the preference is set to item's library, then system preference <strong>HomeOrHoldingBranch</strong> defines the branch to use. You can test with any library by selecting the last option <i>Library</i>.</p>
621
                        <table>
622
                            <thead>
623
                            <tr>
624
                                <th>Patron</th>
625
                                <th>Item</th>
626
                                <th>Library</th>
627
                                <th>Actions</th>
628
                            </tr>
629
                            </thead>
630
                            <tbody>
631
                                <tr>
632
                                <td>
633
                                    <select id="tester_patron" name="tester_patron">
634
                                        <option value="cardnumber">Card number</option>
635
                                        <option value="borrowernumber">Borrowernumber</option>
636
                                        <option value="categorycode">Categorycode</option>
637
                                    </select>
638
                                    <span><input type="text" name="tester_input_cardnumber" placeholder="Card number" /></span>
639
                                    <span><input type="text" name="tester_input_borrowernumber" placeholder="Borrowernumber" /></span>
640
                                    <span>
641
                                        <select name="tester_input_categorycode" id="tester_categorycode">
642
                                            <option value="">All</option>
643
                                        [% FOREACH patron_category IN patron_categories%]
644
                                            <option value="[% patron_category.categorycode %]">[% patron_category.description %]</option>
645
                                        [% END %]
646
                                        </select>
647
                                    </span>
648
                                </td>
649
                                <td>
650
                                    <select id="tester_item" name="tester_item">
651
                                        <option value="barcode">Barcode</option>
652
                                        <option value="itemnumber">Itemnumber</option>
653
                                        <option value="itemtype">Item type</option>
654
                                    </select>
655
                                    <span><input type="text" name="tester_input_barcode" placeholder="Barcode" /></span>
656
                                    <span><input type="text" name="tester_input_itemnumber" placeholder="Itemnumber" /></span>
657
                                    <span>
658
                                        <select name="tester_input_itemtype" id="tester_itemtype">
659
                                            <option value="">All</option>
660
                                        [% FOREACH itemtypeloo IN itemtypeloop %]
661
                                            <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option>
662
                                        [% END %]
663
                                        </select>
664
                                    </span>
665
                                </td>
666
                                <td>
667
                                    <select id="tester_branch" name="tester_branch">
668
                                    [% IF Koha.Preference('CircControl') == 'PatronLibrary' %]
669
                                        <option value="patronlibrary">Patron's home library</option>
670
                                    [% ELSIF Koha.Preference('CircControl') == 'ItemHomeLibrary' %]
671
                                        [% IF Koha.Preference('HomeOrHoldingBranch') == 'homebranch' %]
672
                                        <option value="itemhomelibrary">Item's home library</option>
673
                                        [% ELSE %]
674
                                        <option value="itemholdinglibrary">Item's holding library</option>
675
                                        [% END %]
676
                                    [% ELSE %]
677
                                        <option value="pickuplibrary">Current library ([% LoginBranchname %])</option>
678
                                    [% END %]
679
                                        <option value="library">Library</option>
680
                                    </select>
681
                                    <span></span>
682
                                    <span>
683
                                        <select name="tester_input_branchcode" id="tester_branchcode">
684
                                            <option value="">All</option>
685
                                            [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
686
                                        </select>
687
                                    </span>
688
                                </td>
689
                                <td><button type="submit" id="tester_submit" class="btn btn-default btn-xs"><i class="fa fa-search"></i> Find</button></td>
690
                                </tr>
691
                            </tbody>
692
                        </table>
693
                        <table>
694
                            <thead>
695
                            <tr>
696
                                <th>Library</th>
697
                                <th>Patron category</th>
698
                                <th>Item type</th>
699
                                <th>Current checkouts allowed</th>
700
                                <th>Current on-site checkouts allowed</th>
701
                                <th>Loan period</th>
702
                                <th>Unit</th>
703
                                <th>Hard due date</th>
704
                                <th>Fine amount</th>
705
                                <th>Fine charging interval</th>
706
                                <th>When to charge</th>
707
                                <th>Fine grace period</th>
708
                                <th>Overdue fines cap (amount)</th>
709
                                <th>Cap fine at replacement price</th>
710
                                <th>Suspension in days (day)</th>
711
                                <th>Max. suspension duration (day)</th>
712
                                <th>Renewals allowed (count)</th>
713
                                <th>Renewal period</th>
714
                                <th>No renewal before</th>
715
                                <th>Automatic renewal</th>
716
                                <th>No automatic renewal after</th>
717
                                <th>No automatic renewal after (hard limit)</th>
718
                                <th>Holds allowed (count)</th>
719
                                <th>Holds per record (count)</th>
720
                                <th>On shelf holds allowed</th>
721
                                <th>Item level holds</th>
722
                                <th>Article requests</th>
723
                                <th>Rental discount (%)</th>
724
                            </tr>
725
                            </thead>
726
                            <tbody>
727
                            <tr id="tester_res_results">
728
                                <td id="tester_res_branchcode"></td>
729
                                <td id="tester_res_categorycode"></td>
730
                                <td id="tester_res_itemtype"></td>
731
                                <td id="tester_res_maxissueqty"></td>
732
                                <td id="tester_res_maxonsiteissueqty"></td>
733
                                <td id="tester_res_issuelength"></td>
734
                                <td id="tester_res_lengthunit"></td>
735
                                <td id="tester_res_hardduedate"></td>
736
                                <td id="tester_res_fine"></td>
737
                                <td id="tester_res_chargeperiod"></td>
738
                                <td id="tester_res_chargeperiod_charge_at"></td>
739
                                <td id="tester_res_firstremind"></td>
740
                                <td id="tester_res_overduefinescap"></td>
741
                                <td id="tester_res_cap_fine_to_replacement_price"></td>
742
                                <td id="tester_res_finedays"></td>
743
                                <td id="tester_res_maxsuspensiondays"></td>
744
                                <td id="tester_res_renewalsallowed"></td>
745
                                <td id="tester_res_renewalperiod"></td>
746
                                <td id="tester_res_norenewalbefore"></td>
747
                                <td id="tester_res_auto_renew"></td>
748
                                <td id="tester_res_no_auto_renewal_after"></td>
749
                                <td id="tester_res_no_auto_renewal_after_hard_limit"></td>
750
                                <td id="tester_res_reservesallowed"></td>
751
                                <td id="tester_res_holds_per_record"></td>
752
                                <td id="tester_res_onshelfholds"></td>
753
                                <td id="tester_res_opacitemholds"></td>
754
                                <td id="tester_res_article_requests"></td>
755
                                <td id="tester_res_rentaldiscount"></td>
756
                            </tr>
757
                            </tbody>
758
                        </table>
759
                        <div id="tester_error" class="alert alert-danger"></div>
760
                    </div>
761
                    </div>
762
615
                <div id="defaults-for-this-library" class="page-section">
763
                <div id="defaults-for-this-library" class="page-section">
616
                    <h2>Default checkout, hold and return policy[% IF humanbranch %] for [% Branches.GetName( humanbranch ) | html %][% END %]</h2>
764
                    <h2>Default checkout, hold and return policy[% IF humanbranch %] for [% Branches.GetName( humanbranch ) | html %][% END %]</h2>
617
                    <p>You can set a default maximum number of checkouts, hold policy and return policy that will be used if none is defined below for a particular item type or category.</p>
765
                    <p>You can set a default maximum number of checkouts, hold policy and return policy that will be used if none is defined below for a particular item type or category.</p>
Lines 1468-1473 Link Here
1468
            $(edit_row).find("td:last input[name='clear']").remove();
1616
            $(edit_row).find("td:last input[name='clear']").remove();
1469
        }
1617
        }
1470
1618
1619
        function change_tester_input(el) {
1620
            $(el).parent().find("span").css("display", "none");
1621
            $(el).parent().find("span").eq($("option:selected", el).index()).css("display", "inline");
1622
        }
1623
        
1624
        function reset_tester_results() {
1625
            $("td[id^='tester_res_']").each(function() {
1626
                $(this).html("");
1627
            });
1628
        }
1629
        
1630
        function tester_submit() {
1631
            var url = "/api/v1/issuingrules/effective";
1632
            var query_params = {};
1633
            $.each($("input[name^=tester_input_], select[name^=tester_input_]"), function () {
1634
                if ($(this).parent().css("display") === "none") {
1635
                    return true;
1636
                }
1637
                var param = $(this).attr("name").replace("tester_input_", "");
1638
                if ($(this).val() || param === 'branchcode' && !$(this).val()) {
1639
                    query_params[param] = $(this).val();
1640
                }
1641
            });
1642
            $.ajax({
1643
                url: "/api/v1/issuingrules/effective?"+$.param(query_params),
1644
                method: "GET",
1645
                statusCode: {
1646
                    200: function(response) {
1647
                        $("#tester_error").html("").css("display","none");
1648
                        $.each(response, function (key,val) {
1649
                            if (key === "hardduedate") {
1650
                                var compare;
1651
                                switch (response.hardduedatecompare) {
1652
                                    case -1:
1653
                                        compare = _("Before");
1654
                                        break;
1655
                                    case 0:
1656
                                        compare = _("Exactly on");
1657
                                        break;
1658
                                    case 1:
1659
                                        compare = _("After");
1660
                                        break;
1661
                                    default:
1662
                                        compare = _("Exactly on");
1663
                                        break;
1664
                                }
1665
                                val = "("+compare+") " + response.hardduedate;
1666
                            }
1667
                            if (val === "*") {
1668
                                val = _("All");
1669
                            }
1670
                            $("#tester_res_"+key).html("" + val);
1671
                        });
1672
                    },
1673
                    400: function(xhr) {
1674
                        $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block");
1675
                        reset_tester_results();
1676
                    },
1677
                    404: function(xhr) {
1678
                        $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block");
1679
                        reset_tester_results();
1680
                    },
1681
                    401: function(xhr) {
1682
                        $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block");
1683
                        reset_tester_results();
1684
                    },
1685
                    403: function(xhr) {
1686
                        $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block");
1687
                        reset_tester_results();
1688
                    },
1689
                    500: function(xhr) {
1690
                        $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block");
1691
                        reset_tester_results();
1692
                    },
1693
                    503: function(xhr) {
1694
                        $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block");
1695
                        reset_tester_results();
1696
                    }
1697
                },
1698
                dataType: "json"
1699
            });
1700
        }
1701
        
1471
        var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
1702
        var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
1472
1703
1473
        $(document).ready(function() {
1704
        $(document).ready(function() {
Lines 1678-1683 Link Here
1678
                return f.submit();
1909
                return f.submit();
1679
            });
1910
            });
1680
1911
1912
            $("#issuing-rules-tester-container").css("display", "none");
1913
            $("#toggle-tester").click(function() {
1914
                $("#issuing-rules-tester-container").toggle();
1915
            });
1916
            $("#tester_patron").val("cardnumber");
1917
            $("#tester_item").val("barcode");
1918
            $("#tester_branch").val($("#tester_branch option:first").val());
1919
            change_tester_input($("#tester_patron"));
1920
            change_tester_input($("#tester_item"));
1921
            change_tester_input($("#tester_branch"));
1922
            $("select[id^='tester_']").change(function(e) {
1923
                change_tester_input(this);
1924
            });
1925
     
1926
            tester_submit();
1927
            $("#tester_submit").click(function () {
1928
                tester_submit();
1929
            });
1681
        });
1930
        });
1682
    </script>
1931
    </script>
1683
[% END %]
1932
[% END %]
1684
- 

Return to bug 19037