Bugzilla – Attachment 169039 Details for
Bug 19037
Circulation and fine rules test tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19037: Move test tool to includes
Bug-19037-Move-test-tool-to-includes.patch (text/plain), 29.73 KB, created by
Martin Renvoize (ashimema)
on 2024-07-16 06:24:22 UTC
(
hide
)
Description:
Bug 19037: Move test tool to includes
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-07-16 06:24:22 UTC
Size:
29.73 KB
patch
obsolete
>From 10e671c0ac5c5bf30c60c6b300b8b9ae2fd2feb7 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 16 Jul 2024 07:11:46 +0100 >Subject: [PATCH] Bug 19037: Move test tool to includes > >--- > .../prog/en/includes/circ-rule-tool.inc | 144 ++++++++++ > .../prog/en/modules/admin/smart-rules.tt | 250 +----------------- > .../intranet-tmpl/prog/js/circ-rule-tool.js | 99 +++++++ > 3 files changed, 245 insertions(+), 248 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc >new file mode 100644 >index 00000000000..e34d2352d4a >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-rule-tool.inc >@@ -0,0 +1,144 @@ >+<div id="issuing-rules-tester" class="page-section"> >+ <h3>Circulation and fine rules test tool</h3> >+ <p>This test tool lets you search a row of circulation and fine rules for a specific patron, item and library.</p> >+ <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> >+ <table> >+ <thead> >+ <tr> >+ <th>Patron</th> >+ <th>Item</th> >+ <th>Library</th> >+ <th>Actions</th> >+ </tr> >+ </thead> >+ <tbody> >+ <tr> >+ <td> >+ <select id="tester_patron" name="tester_patron"> >+ <option value="cardnumber">Card number</option> >+ <option value="borrowernumber">Borrowernumber</option> >+ <option value="categorycode">Categorycode</option> >+ </select> >+ <span><input type="text" name="tester_input_cardnumber" placeholder="Card number" /></span> >+ <span><input type="text" name="tester_input_borrowernumber" placeholder="Borrowernumber" /></span> >+ <span> >+ <select name="tester_input_patron_category_id" id="tester_categorycode"> >+ <option value="">All</option> >+ [% FOREACH patron_category IN patron_categories%] >+ <option value="[% patron_category.categorycode %]">[% patron_category.description %]</option> >+ [% END %] >+ </select> >+ </span> >+ </td> >+ <td> >+ <select id="tester_item" name="tester_item"> >+ <option value="barcode">Barcode</option> >+ <option value="itemnumber">Itemnumber</option> >+ <option value="itemtype">Item type</option> >+ </select> >+ <span><input type="text" name="tester_input_barcode" placeholder="Barcode" /></span> >+ <span><input type="text" name="tester_input_itemnumber" placeholder="Itemnumber" /></span> >+ <span> >+ <select name="tester_input_item_type_id" id="tester_itemtype"> >+ <option value="">All</option> >+ [% FOREACH itemtypeloo IN itemtypeloop %] >+ <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option> >+ [% END %] >+ </select> >+ </span> >+ </td> >+ <td> >+ <select id="tester_branch" name="tester_branch"> >+ [% IF Koha.Preference('CircControl') == 'PatronLibrary' %] >+ <option value="patronlibrary">Patron's home library</option> >+ [% ELSIF Koha.Preference('CircControl') == 'ItemHomeLibrary' %] >+ [% IF Koha.Preference('HomeOrHoldingBranch') == 'homebranch' %] >+ <option value="itemhomelibrary">Item's home library</option> >+ [% ELSE %] >+ <option value="itemholdinglibrary">Item's holding library</option> >+ [% END %] >+ [% ELSE %] >+ <option value="pickuplibrary">Current library ([% LoginBranchname %])</option> >+ [% END %] >+ <option value="library">Library</option> >+ </select> >+ <span></span> >+ <span> >+ <select name="tester_input_library_id" id="tester_branchcode"> >+ <option value="">All</option> >+ [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %] >+ </select> >+ </span> >+ </td> >+ <td><button type="submit" id="tester_submit" class="btn btn-default btn-xs"><i class="fa fa-search"></i> Find</button></td> >+ </tr> >+ </tbody> >+ </table> >+ <table> >+ <thead> >+ <tr> >+ <th>Library</th> >+ <th>Patron category</th> >+ <th>Item type</th> >+ <th>Current checkouts allowed</th> >+ <th>Current on-site checkouts allowed</th> >+ <th>Loan period</th> >+ <th>Unit</th> >+ <th>Hard due date</th> >+ <th>Fine amount</th> >+ <th>Fine charging interval</th> >+ <th>When to charge</th> >+ <th>Fine grace period</th> >+ <th>Overdue fines cap (amount)</th> >+ <th>Cap fine at replacement price</th> >+ <th>Suspension in days (day)</th> >+ <th>Max. suspension duration (day)</th> >+ <th>Renewals allowed (count)</th> >+ <th>Renewal period</th> >+ <th>No renewal before</th> >+ <th>Automatic renewal</th> >+ <th>No automatic renewal after</th> >+ <th>No automatic renewal after (hard limit)</th> >+ <th>Holds allowed (count)</th> >+ <th>Holds per record (count)</th> >+ <th>On shelf holds allowed</th> >+ <th>Item level holds</th> >+ <th>Article requests</th> >+ <th>Rental discount (%)</th> >+ </tr> >+ </thead> >+ <tbody> >+ <tr id="tester_res_results"> >+ <td id="tester_res_branchcode"></td> >+ <td id="tester_res_categorycode"></td> >+ <td id="tester_res_itemtype"></td> >+ <td id="tester_res_maxissueqty"></td> >+ <td id="tester_res_maxonsiteissueqty"></td> >+ <td id="tester_res_issuelength"></td> >+ <td id="tester_res_lengthunit"></td> >+ <td id="tester_res_hardduedate"></td> >+ <td id="tester_res_fine"></td> >+ <td id="tester_res_chargeperiod"></td> >+ <td id="tester_res_chargeperiod_charge_at"></td> >+ <td id="tester_res_firstremind"></td> >+ <td id="tester_res_overduefinescap"></td> >+ <td id="tester_res_cap_fine_to_replacement_price"></td> >+ <td id="tester_res_finedays"></td> >+ <td id="tester_res_maxsuspensiondays"></td> >+ <td id="tester_res_renewalsallowed"></td> >+ <td id="tester_res_renewalperiod"></td> >+ <td id="tester_res_norenewalbefore"></td> >+ <td id="tester_res_auto_renew"></td> >+ <td id="tester_res_no_auto_renewal_after"></td> >+ <td id="tester_res_no_auto_renewal_after_hard_limit"></td> >+ <td id="tester_res_reservesallowed"></td> >+ <td id="tester_res_holds_per_record"></td> >+ <td id="tester_res_onshelfholds"></td> >+ <td id="tester_res_opacitemholds"></td> >+ <td id="tester_res_article_requests"></td> >+ <td id="tester_res_rentaldiscount"></td> >+ </tr> >+ </tbody> >+ </table> >+ <div id="tester_error" class="alert alert-danger"></div> >+</div> >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 f8382873772..9243ca88f59 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 >@@ -73,153 +73,7 @@ > <p>The circulation and fine rules are applied based on the CircControl system preference which is set to <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CircControl">[% Koha.Preference('CircControl') | html %]</a> and the HomeOrHoldingBranch system preference which is set to <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=HomeOrHoldingBranch">[% Koha.Preference('HomeOrHoldingBranch') | html %]</a>.</p> > </div> > >- <div id="issuing-rules-tester" class="page-section"> >- <a id="toggle-tester" class="btn btn-default btn-sm">Circulation and fine rules test tool</a> >- <div id="issuing-rules-tester-container"> >- <h3>Circulation and fine rules test tool</h3> >- <p>This test tool lets you search a row of circulation and fine rules for a specific patron, item and library.</p> >- <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> >- <table> >- <thead> >- <tr> >- <th>Patron</th> >- <th>Item</th> >- <th>Library</th> >- <th>Actions</th> >- </tr> >- </thead> >- <tbody> >- <tr> >- <td> >- <select id="tester_patron" name="tester_patron"> >- <option value="cardnumber">Card number</option> >- <option value="borrowernumber">Borrowernumber</option> >- <option value="categorycode">Categorycode</option> >- </select> >- <span><input type="text" name="tester_input_cardnumber" placeholder="Card number" /></span> >- <span><input type="text" name="tester_input_borrowernumber" placeholder="Borrowernumber" /></span> >- <span> >- <select name="tester_input_patron_category_id" id="tester_categorycode"> >- <option value="">All</option> >- [% FOREACH patron_category IN patron_categories%] >- <option value="[% patron_category.categorycode %]">[% patron_category.description %]</option> >- [% END %] >- </select> >- </span> >- </td> >- <td> >- <select id="tester_item" name="tester_item"> >- <option value="barcode">Barcode</option> >- <option value="itemnumber">Itemnumber</option> >- <option value="itemtype">Item type</option> >- </select> >- <span><input type="text" name="tester_input_barcode" placeholder="Barcode" /></span> >- <span><input type="text" name="tester_input_itemnumber" placeholder="Itemnumber" /></span> >- <span> >- <select name="tester_input_item_type_id" id="tester_itemtype"> >- <option value="">All</option> >- [% FOREACH itemtypeloo IN itemtypeloop %] >- <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option> >- [% END %] >- </select> >- </span> >- </td> >- <td> >- <select id="tester_branch" name="tester_branch"> >- [% IF Koha.Preference('CircControl') == 'PatronLibrary' %] >- <option value="patronlibrary">Patron's home library</option> >- [% ELSIF Koha.Preference('CircControl') == 'ItemHomeLibrary' %] >- [% IF Koha.Preference('HomeOrHoldingBranch') == 'homebranch' %] >- <option value="itemhomelibrary">Item's home library</option> >- [% ELSE %] >- <option value="itemholdinglibrary">Item's holding library</option> >- [% END %] >- [% ELSE %] >- <option value="pickuplibrary">Current library ([% LoginBranchname %])</option> >- [% END %] >- <option value="library">Library</option> >- </select> >- <span></span> >- <span> >- <select name="tester_input_library_id" id="tester_branchcode"> >- <option value="">All</option> >- [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %] >- </select> >- </span> >- </td> >- <td><button type="submit" id="tester_submit" class="btn btn-default btn-xs"><i class="fa fa-search"></i> Find</button></td> >- </tr> >- </tbody> >- </table> >- <table> >- <thead> >- <tr> >- <th>Library</th> >- <th>Patron category</th> >- <th>Item type</th> >- <th>Current checkouts allowed</th> >- <th>Current on-site checkouts allowed</th> >- <th>Loan period</th> >- <th>Unit</th> >- <th>Hard due date</th> >- <th>Fine amount</th> >- <th>Fine charging interval</th> >- <th>When to charge</th> >- <th>Fine grace period</th> >- <th>Overdue fines cap (amount)</th> >- <th>Cap fine at replacement price</th> >- <th>Suspension in days (day)</th> >- <th>Max. suspension duration (day)</th> >- <th>Renewals allowed (count)</th> >- <th>Renewal period</th> >- <th>No renewal before</th> >- <th>Automatic renewal</th> >- <th>No automatic renewal after</th> >- <th>No automatic renewal after (hard limit)</th> >- <th>Holds allowed (count)</th> >- <th>Holds per record (count)</th> >- <th>On shelf holds allowed</th> >- <th>Item level holds</th> >- <th>Article requests</th> >- <th>Rental discount (%)</th> >- </tr> >- </thead> >- <tbody> >- <tr id="tester_res_results"> >- <td id="tester_res_branchcode"></td> >- <td id="tester_res_categorycode"></td> >- <td id="tester_res_itemtype"></td> >- <td id="tester_res_maxissueqty"></td> >- <td id="tester_res_maxonsiteissueqty"></td> >- <td id="tester_res_issuelength"></td> >- <td id="tester_res_lengthunit"></td> >- <td id="tester_res_hardduedate"></td> >- <td id="tester_res_fine"></td> >- <td id="tester_res_chargeperiod"></td> >- <td id="tester_res_chargeperiod_charge_at"></td> >- <td id="tester_res_firstremind"></td> >- <td id="tester_res_overduefinescap"></td> >- <td id="tester_res_cap_fine_to_replacement_price"></td> >- <td id="tester_res_finedays"></td> >- <td id="tester_res_maxsuspensiondays"></td> >- <td id="tester_res_renewalsallowed"></td> >- <td id="tester_res_renewalperiod"></td> >- <td id="tester_res_norenewalbefore"></td> >- <td id="tester_res_auto_renew"></td> >- <td id="tester_res_no_auto_renewal_after"></td> >- <td id="tester_res_no_auto_renewal_after_hard_limit"></td> >- <td id="tester_res_reservesallowed"></td> >- <td id="tester_res_holds_per_record"></td> >- <td id="tester_res_onshelfholds"></td> >- <td id="tester_res_opacitemholds"></td> >- <td id="tester_res_article_requests"></td> >- <td id="tester_res_rentaldiscount"></td> >- </tr> >- </tbody> >- </table> >- <div id="tester_error" class="alert alert-danger"></div> >- </div> >- </div> >+ [% INCLUDE 'circ-rule-tool.inc' %] > > <div class="page-section"> > [% UNLESS restricted_to_own_library %] >@@ -1580,6 +1434,7 @@ > > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/admin-menu.js") | $raw %] >+ [% Asset.js("js/circ-rule-tool.js") | $raw %] > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'columns_settings.inc' %] >@@ -1617,88 +1472,6 @@ > $(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 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/circulation_rules?"+$.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('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >- reset_tester_results(); >- }, >- 404: function(xhr) { >- $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >- reset_tester_results(); >- }, >- 401: function(xhr) { >- $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >- reset_tester_results(); >- }, >- 403: function(xhr) { >- $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >- reset_tester_results(); >- }, >- 500: function(xhr) { >- $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >- reset_tester_results(); >- }, >- 503: function(xhr) { >- $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + 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() { >@@ -1908,25 +1681,6 @@ > f.find("[name='branch']").val($(this).data('branch')); > return f.submit(); > }); >- >- $("#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(); >- }); > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js b/koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js >new file mode 100644 >index 00000000000..59e291ccd12 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/circ-rule-tool.js >@@ -0,0 +1,99 @@ >+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 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/circulation_rules?" + $.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('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >+ reset_tester_results(); >+ }, >+ 404: function (xhr) { >+ $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >+ reset_tester_results(); >+ }, >+ 401: function (xhr) { >+ $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >+ reset_tester_results(); >+ }, >+ 403: function (xhr) { >+ $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >+ reset_tester_results(); >+ }, >+ 500: function (xhr) { >+ $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >+ reset_tester_results(); >+ }, >+ 503: function (xhr) { >+ $("#tester_error").html('<i class="fa fa-exclamation-triangle"></i> ' + xhr.responseJSON.error).css("display", "block"); >+ reset_tester_results(); >+ } >+ }, >+ dataType: "json" >+ }); >+} >+ >+$(document).ready(function () { >+ $("#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(); >+ }); >+}); >+ >-- >2.45.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19037
:
65497
|
65523
|
65524
|
65525
|
65526
|
168450
|
168451
|
169037
|
169038
| 169039 |
169040