From fc7d2a7fc06e86aa74f9a3e41524ae5fb93546ff Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Thu, 3 Aug 2017 11:57:11 +0300 Subject: [PATCH] Bug 19037: Issuing rules test tool - GUI for test tool To test: 1. Go to INTRANET/cgi-bin/koha/admin/smart-rules.pl 2. You should see a button below circulation rules matrix "Circulation and fine rules test tool" 3. Click it 4. You should see options for inputting test patron, item and branch 5. Play with the tester and make sure it returns correct issuing rules (CircControl and HomeOrHoldingBranch system preferences affects the result) --- .../prog/en/modules/admin/smart-rules.tt | 253 +++++++++++++++++++++ 1 file changed, 253 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index 0283d80..ac56e39 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Koha › Administration › Circulation and fine rules @@ -26,6 +27,89 @@ function clear_edit(){ $(edit_row).find("td:last input[name='clear']").remove(); } +function change_tester_input(el) { + $(el).parent().find("span").css("display", "none"); + $(el).parent().find("span").eq($("option:selected", el).index()).css("display", "inline"); +} + +function reset_tester_results() { + $("td[id^='tester_res_']").each(function() { + $(this).html(""); + }); +} + +function tester_submit() { + var url = "/api/v1/issuingrules/effective"; + var query_params = {}; + $.each($("input[name^=tester_input_], select[name^=tester_input_]"), function () { + if ($(this).parent().css("display") === "none") { + return true; + } + var param = $(this).attr("name").replace("tester_input_", ""); + if ($(this).val() || param === 'branchcode' && !$(this).val()) { + query_params[param] = $(this).val(); + } + }); + $.ajax({ + url: "/api/v1/issuingrules/effective?"+$.param(query_params), + method: "GET", + statusCode: { + 200: function(response) { + $("#tester_error").html("").css("display","none"); + $.each(response, function (key,val) { + if (key === "hardduedate") { + var compare; + switch (response.hardduedatecompare) { + case -1: + compare = _("Before"); + break; + case 0: + compare = _("Exactly on"); + break; + case 1: + compare = _("After"); + break; + default: + compare = _("Exactly on"); + break; + } + val = "("+compare+") " + response.hardduedate; + } + if (val === "*") { + val = _("All"); + } + $("#tester_res_"+key).html("" + val); + }); + }, + 400: function(xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 404: function(xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 401: function(xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 403: function(xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 500: function(xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + }, + 503: function(xhr) { + $("#tester_error").html(' ' + xhr.responseJSON.error).css("display", "block"); + reset_tester_results(); + } + }, + dataType: "json" + }); +} + var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); $(document).ready(function() { @@ -105,6 +189,27 @@ $(document).ready(function() { e.preventDefault(); clear_edit(); }); + + $("#issuing-rules-tester-container").css("display", "none"); + $("#toggle-tester").click(function() { + $("#issuing-rules-tester-container").toggle(); + }); + $("#tester_patron").val("cardnumber"); + $("#tester_item").val("barcode"); + $("#tester_branch").val($("#tester_branch option:first").val()); + change_tester_input($("#tester_patron")); + change_tester_input($("#tester_item")); + change_tester_input($("#tester_branch")); + $("select[id^='tester_']").change(function(e) { + change_tester_input(this); + }); + + tester_submit(); + $("#tester_submit").click(function () { + tester_submit(); + }); + + }); //]]> @@ -427,9 +532,157 @@ $(document).ready(function() { +
+ Circulation and fine rules test tool +
+

Circulation and fine rules test tool

+

This test tool lets you search a row of circulation and fine rules for a specific patron, item and library.

+

Dropdown value for Library is determined via system preference CircControl. If the preference is set to item's library, then system preference HomeOrHoldingBranch defines the branch to use. You can test with any library by selecting the last option Library.

+ + + + + + + + + + + + + + + + + +
PatronItemLibraryActions
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LibraryPatron categoryItem typeCurrent checkouts allowedCurrent on-site checkouts allowedLoan periodUnitHard due dateFine amountFine charging intervalWhen to chargeFine grace periodOverdue fines cap (amount)Cap fine at replacement priceSuspension in days (day)Max. suspension duration (day)Renewals allowed (count)Renewal periodNo renewal beforeAutomatic renewalNo automatic renewal afterNo automatic renewal after (hard limit)Holds allowed (count)Holds per record (count)On shelf holds allowedItem level holdsArticle requestsRental discount (%)
+
+
+

Default checkout, hold and return policy[% IF humanbranch %] for [% Branches.GetName( humanbranch ) %][% END %]

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.

+

Current system preference

-- 2.7.4