From 76a8cca21a38ad2f23712c97766e8a30b6e55268 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 5 Oct 2017 17:38:34 -0300 Subject: [PATCH] Bug 9573: Lost items report - Add the CSV export ability Finally we add the ability to export the list of lost items. The items will be export in CSV format using a CSV profile defined. Test plan: 0/ Apply all the patches from this patch set 1/ Define a CSV profile (type=SQL, Usage=Export lost items in report) Try something like that to get the same columns as the default table: Title=biblio.title |Author=biblio.author |Lost status=items.itemlost |Lost on=items.itemlost_on |Barcode=items.barcode |Call number=items.itemcallnumber |Date last seen=items.datelastseen |Price=items.price |Rep. price=items.replacementprice |Library=items.homebranch |item type=items.itype |Current location=items.holdingbranch |Location=items.location |Not for loan status=items.notforloan |Notes=items.itemnotes 2/ Use the filters and select items to export 3/ Export the list of items you want and make sure the CSV is correctly formatted and contains the items you selected QA Notes: - I think we should add default CSV profiles for the different "usage", but I would consider it as a separate enhancement since none of them is defined yet - Most of the code to export CSV is no reusable. We should make Koha::Exporter::Record support CSV export for type=SQL (it only supports MARC type so far). --- .../prog/en/modules/reports/itemslost.tt | 18 ++++++- .../prog/en/modules/tools/csv-profiles.tt | 3 +- reports/itemslost.pl | 62 +++++++++++++++++++++- 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt index 1d24ddaf07..cc33a2d13a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt @@ -33,7 +33,8 @@ itemnumbers.push($(this).val()); }); if (itemnumbers.length > 0) { - var url = '/cgi-bin/koha/tools/batchMod.pl?op=show'; + var csv_profile_id = $("#csv_profile_id option:selected").val(); + var url = '/cgi-bin/koha/reports/itemslost.pl?op=export&csv_profile_id='+csv_profile_id; url += '&itemnumber=' + itemnumbers.join('&itemnumber='); $('a.itemselection_action_export').attr('href', url); } else { @@ -56,6 +57,9 @@ $("input[name='itemnumber'][type='checkbox']").change(function() { itemSelectionBuildActionLinks(); }); + $("#csv_profile_id").change(function() { + itemSelectionBuildActionLinks(); + }); $(".SelectAll").on("click",function(e){ e.preventDefault(); @@ -104,7 +108,17 @@ Clear all | Actions: - Export selected items + [% IF csv_profiles.count %] + Export selected items + Using the following CSV profile: + + [% ELSE %] + Export selected items + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt index cdbaab9fe5..8b36112538 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/csv-profiles.tt @@ -112,6 +112,7 @@ function reloadPage(p) { [% IF used_for_code == 'export_records' %] Export records [% ELSIF used_for_code == 'late_issues' %] Late serial issues claims [% ELSIF used_for_code == 'export_basket' %] Basket export in acquisition + [% ELSIF used_for_code == 'export_lost_items' %] Export lost items in report [% ELSE %] Unknown usage [% END %] [% END %] @@ -152,7 +153,7 @@ function reloadPage(p) {