From 7102fa9865d4fb76feca1eb4b9771efac7048af2 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). Signed-off-by: Katrin Fischer Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer --- .../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 f57ee6a..a0e1490 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt @@ -39,7 +39,17 @@ Clear all | Actions: - Export selected items + [% IF csv_profiles.count %] + Export selected items + Using the following CSV profile: + + [% ELSE %] + Export selected items + [% END %] @@ -180,7 +190,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 { @@ -203,6 +214,9 @@ $("input[name='itemnumber'][type='checkbox']").change(function() { itemSelectionBuildActionLinks(); }); + $("#csv_profile_id").change(function() { + itemSelectionBuildActionLinks(); + }); $(".SelectAll").on("click",function(e){ e.preventDefault(); 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 04fbca8..06d21ce 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 @@ -91,6 +91,7 @@ [% 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 %] @@ -131,7 +132,7 @@