From 5c63236dccd70af5f33886c2599370d2c1c2709e 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 Signed-off-by: claude Signed-off-by: Jesse Maseto Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 67d905d49f2871c884dc868bd1b50517624dcdbf) Signed-off-by: Fridolin Somers --- .../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 171dbe3e10..76f8056d25 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -377,6 +377,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 1d16823045..7d106cad2a 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 = $('
    '); + Object.keys(checkoutsByItype).sort().forEach(function (itype) { + var li = $('
  • ') + .append($('').html(itype || _("No itemtype"))) + .append(': ' + checkoutsByItype[itype]); + ul.append(li); + }) + $('
    ') + .append($('').html(_("Number of checkouts by item type"))) + .append(ul) + .insertBefore(oSettings.nTableWrapper) }, }, columns_settings).rowGrouping( { -- 2.39.5