From 39eceb95b224033892aa6fb619040028814b45bb Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 6 Mar 2018 14:47:46 +0100 Subject: [PATCH] Bug 20343: Show number of checkouts by itemtype in circulation.pl It is sometimes useful to have the number of checkouts grouped by itemtype (to see if we're approaching the maximum number of checkouts allowed for instance). This patch adds this information above the checkouts table, in circ/circulation.pl Test plan: 1. Check out some items with various item types to a patron 2. In circ/circulation.pl, click on 'Show checkouts' button to display the table 3. Notice the line "Number of checkouts by item type" above the table, click on it 4. See that the list of item types is displayed with a count in front of each one 5. Compare the numbers to the checkouts in the table and verify that the numbers are correct --- koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 15 +++++++++++++++ koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css index 32a614bd70..310e84dd76 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -385,6 +385,21 @@ legend { width: auto; } +details > summary { + cursor: pointer; +} + +details > summary::before { + content: "\f0da"; + display: inline-block; + font-family: FontAwesome; + width: 1em; +} + +details[open] > summary::before { + content: "\f0d7"; +} + #floating-save { background-color: rgba(185, 216, 217, 0.6); bottom: 3%; diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 5167ee12ae..5718bbc8dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -475,7 +475,7 @@ $(document).ready(function() { fnCallback(json) } ); }, - "fnInitComplete": function(oSettings) { + "fnInitComplete": function(oSettings, json) { // Disable rowGrouping plugin after first use // so any sorting on the table doesn't use it var oSettings = issuesTable.fnSettings(); @@ -488,6 +488,23 @@ $(document).ready(function() { } oSettings.aaSortingFixed = null; + + // Build a summary of checkouts grouped by itemtype + var checkoutsByItype = json.aaData.reduce(function (obj, row) { + obj[row.itemtype_description] = (obj[row.itemtype_description] || 0) + 1; + return obj; + }, {}); + var ul = $('