Bugzilla – Attachment 60372 Details for
Bug 15498
Replace ExportWithCsvProfile with ExportCircHistory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15498: Let the user choose the CSV profile to export circ history
Bug-15498-Let-the-user-choose-the-CSV-profile-to-e.patch (text/plain), 13.97 KB, created by
Marcel de Rooy
on 2017-02-17 07:57:56 UTC
(
hide
)
Description:
Bug 15498: Let the user choose the CSV profile to export circ history
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-02-17 07:57:56 UTC
Size:
13.97 KB
patch
obsolete
>From 14dc1af415495a8c296f9800ce034e587dbae835 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 2 Nov 2016 08:28:01 +0000 >Subject: [PATCH] Bug 15498: Let the user choose the CSV profile to export circ > history >Content-Type: text/plain; charset=utf-8 > >The way the export options are displayed at the bottom of the checkouts table >was not consistent. >Prior to this patch set, they are display if ExportRemoveFields or >ExportWithCsvProfile is set. >It does not make any sense, the user could want to export the checkouts in >iso2709 format without having to define a csv profile and fill the pref. > >Moreover the behavior of this pref did not match its description: it's used as >a default CSV profile when exporting records from the export tools or the >command line. > >This patch set adds a new pref ExportCircHistory and remove >ExportWithCsvProfile. The new pref is set if ExportWithCsvProfile or >ExportRemoveFields were set. >A new dropdown list with the CSV profile list will be displayed in the >export area, at the bottom of the checkouts table. > >Note that now --csv_profile_id is mandatory for the export command line >(misc/export_records.pl) if the export format is csv. > >Test plan: >0/ Do not execute the DB entry >1/ Clear both ExportWithCsvProfile and ExportRemoveFields prefs >2/ Execute the DB entry >3/ ExportCircHistory should not be set and the export options should not >be displayed at the bottom of the checkouts table. >4/ Remove the pref > DELETE FROM systempreferences WHERE variable='ExportCircHistory'; >and reinsert the previous one, with a value: > INSERT INTO systempreferences (variable, value) VALUES > ('ExportWithCsvProfile', 'something'); >Execute the DB entry again >=> The now pref should be now set >5/ Export some checkouts using the CSV entry >6/ Note that the export tool and commandline script still work using the >csv format. You have to provide a --csv_profile_id option to make it >work. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/Exporter/Record.pm | 10 +++------- > circ/circulation.pl | 5 +++++ > koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc | 11 +++++++++-- > koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 5 +---- > .../intranet-tmpl/prog/en/modules/help/circ/circulation.tt | 2 +- > koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt | 5 +---- > koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 10 ++++++++++ > members/moremember.pl | 7 ++++++- > misc/export_records.pl | 9 +++------ > tools/export.pl | 6 ------ > 10 files changed, 39 insertions(+), 31 deletions(-) > >diff --git a/Koha/Exporter/Record.pm b/Koha/Exporter/Record.pm >index aa805e2..193f87e 100644 >--- a/Koha/Exporter/Record.pm >+++ b/Koha/Exporter/Record.pm >@@ -143,12 +143,8 @@ sub export { > print MARC::File::XML::footer(); > print "\n"; > } elsif ( $format eq 'csv' ) { >- unless ( $csv_profile_id ) { >- # FIXME export_format.profile should be a unique key >- my $csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); >- die "The ExportWithCsvProfile system preference is not defined or does not match a valid csv profile" unless $csv_profiles->count; >- $csv_profile_id = $csv_profiles->next->export_format_id; >- } >+ die 'There is no valid csv profile defined for this export' >+ unless Koha::CsvProfiles->find( $csv_profile_id ); > print marc2csv( $record_ids, $csv_profile_id, $itemnumbers ); > } > >@@ -208,7 +204,7 @@ It will displays on STDOUT the generated file. > > =item csv_profile_id > >- If the format is csv, a csv_profile_id can be provide to overwrite the default value (syspref ExportWithCsvProfile). >+ If the format is csv, you have to define a csv_profile_id. > > =cut > >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 5db1001..75580f6 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -43,6 +43,7 @@ use C4::Context; > use CGI::Session; > use C4::Members::Attributes qw(GetBorrowerAttributes); > use Koha::AuthorisedValues; >+use Koha::CsvProfiles; > use Koha::Patron; > use Koha::Patron::Debarments qw(GetDebarments); > use Koha::DateUtils; >@@ -646,6 +647,10 @@ $template->param( > my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber}); > $template->param( picture => 1 ) if $patron_image; > >+if ( C4::Context->preference("ExportCircHistory") ) { >+ $template->param(csv_profiles => [ Koha::CsvProfiles->search ]); >+} >+ > my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count; > $template->param( > debt_confirmed => $debt_confirmed, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc >index 98a6a22..8c2e5bf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc >@@ -49,17 +49,24 @@ > [% END %] > </fieldset> > >- [% IF ( exports_enabled ) %] >+ [% IF Koha.Preference('ExportCircHistory') %] > <fieldset> > <label for="issues-table-output-format"><b>Export checkouts using format:</b></label> > <select name="issues-table-output-format" id="issues-table-output-format"> > <option value="iso2709_995">ISO2709 with items</option> > <option value="iso2709">ISO2709 without items</option> >- [% IF Koha.Preference('ExportWithCsvProfile') %] >+ [% IF csv_profiles.size %] > <option value="csv">CSV</option> > [% END %] > </select> > >+ [% IF csv_profiles.size %] >+ <select name="csv_profile_id"> >+ [% FOREACH csv_profile IN csv_profiles %] >+ <option value="[% csv_profile.export_format_id %]">[% csv_profile.profile %]</option> >+ [% END %] >+ </select> >+ [% END %] > <label for="export_remove_fields">Don't export fields:</label> <input type="text" id="export_remove_fields" name="export_remove_fields" value="[% export_remove_fields %]" title="Use for iso2709 exports" /> > <input type="hidden" name="op" value="export" /> > <input type="hidden" id="output_format" name="output_format" value="iso2709" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index d6608d7..3736a5e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -5,9 +5,6 @@ > [% USE ColumnsSettings %] > [% USE ItemTypes %] > [% USE Price %] >-[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %] >- [% SET exports_enabled = 1 %] >-[% END %] > [% USE AuthorisedValues %] > [% INCLUDE 'doc-head-open.inc' %] > [% SET destination = "circ" %] >@@ -38,7 +35,7 @@ var interface = "[% interface %]"; > var theme = "[% theme %]"; > var borrowernumber = "[% borrowernumber %]"; > var branchcode = "[% branch %]"; >-var exports_enabled = "[% exports_enabled %]"; >+var exports_enabled = "[% Koha.Preference('ExportCircHistory') %]"; > var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %]; > var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]; > var script = "circulation"; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/help/circ/circulation.tt >index ec54f40..643d3cf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/circ/circulation.tt >@@ -32,7 +32,7 @@ > > <p>If you checked out an item for on site use you will see that highlighted in red in the checkout summary.</p> > >-<p>If you have set your ExportWithCsvProfile preference, you will also see the option to export the patron's current checkout information using a CSV Profile or ISO2709 (MARC21) format.</p> >+<p>If you have set your ExportCircHistory preference, you will also see the option to export the patron's current checkout information using a CSV Profile or ISO2709 (MARC21) format.</p> > > <p>Also at the bottom of the page is the list of items the patron has on hold</p> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 271b30b..d5f61d7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -3,9 +3,6 @@ > [% USE KohaDates %] > [% USE AuthorisedValues %] > [% USE ColumnsSettings %] >-[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %] >- [% SET exports_enabled = 1 %] >-[% END %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Patrons › > [% IF ( unknowuser ) %] >@@ -34,7 +31,7 @@ var interface = "[% interface %]"; > var theme = "[% theme %]"; > var borrowernumber = "[% borrowernumber %]"; > var branchcode = "[% Branches.GetLoggedInBranchcode() %]"; >-var exports_enabled = "[% exports_enabled %]"; >+var exports_enabled = "[% Koha.Preference('ExportCircHistory') %]"; > var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %] > var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %]; > var script = "moremember"; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >index f12743f..38bb3c1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >@@ -36,6 +36,16 @@ $(document).ready(function() { > } > }); > >+ $("#output_format > option:first-child").attr("selected", "selected"); >+ $("select[name='csv_profile']").hide(); >+ $(document).on("change", '#output_format', function(){ >+ if ( $(this).val() == 'csv' ) { >+ $("select[name='csv_profile']").show(); >+ } else { >+ $("select[name='csv_profile']").hide(); >+ } >+ }); >+ > // Clicking the table cell checks the checkbox inside it > $(document).on("click", 'td', function(e){ > if(e.target.tagName.toLowerCase() == 'td'){ >diff --git a/members/moremember.pl b/members/moremember.pl >index 7330cb9..8d34ea9 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -53,6 +53,7 @@ use C4::Form::MessagingPreferences; > use List::MoreUtils qw/uniq/; > use C4::Members::Attributes qw(GetBorrowerAttributes); > use Koha::AuthorisedValues; >+use Koha::CsvProfiles; > use Koha::Patron::Debarments qw(GetDebarments); > use Koha::Patron::Images; > use Module::Load; >@@ -326,7 +327,11 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) { > $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification")); > } > >-# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) >+if ( C4::Context->preference("ExportCircHistory") ) { >+ $template->param(csv_profiles => [ Koha::CsvProfiles->search ]); >+} >+ >+# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) > $template->param( $data->{'categorycode'} => 1 ); > $template->param( > patron => $patron, >diff --git a/misc/export_records.pl b/misc/export_records.pl >index 2bb553d..23cc9f1 100755 >--- a/misc/export_records.pl >+++ b/misc/export_records.pl >@@ -71,6 +71,9 @@ if ( $output_format eq 'csv' and $record_type eq 'auths' ) { > pod2usage(q|CSV output is only available for biblio records|); > } > >+if ( $output_format eq 'csv' and not $csv_profile_id ) { >+ pod2usage(q|Define a csv profile to export in CSV|); >+} > > if ( $timestamp and $record_type ne 'bibs' ) { > pod2usage(q|--timestamp can only be used with biblios|); >@@ -193,11 +196,6 @@ if ($deleted_barcodes) { > } > } > else { >- unless ( $csv_profile_id ) { >- # FIXME export_format.profile should be a unique key >- my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); >- $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef; >- } > Koha::Exporter::Record::export( > { record_type => $record_type, > record_ids => \@record_ids, >@@ -249,7 +247,6 @@ Print a brief help message. > =item B<--csv_profile_id> > > --csv_profile_id=ID Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl) >- Unless provided, the one defined in the system preference 'ExportWithCsvProfile' will be used. > This can only be used to export biblio records. > > =item B<--deleted_barcodes> >diff --git a/tools/export.pl b/tools/export.pl >index b1ce09c..0e6b20f 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -187,12 +187,6 @@ if ( $op eq "export" ) { > ); > > my $csv_profile_id = $query->param('csv_profile_id'); >- unless ( $csv_profile_id ) { >- # FIXME export_format.profile should be a unique key >- my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') }); >- $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef; >- } >- > Koha::Exporter::Record::export( > { record_type => $record_type, > record_ids => \@record_ids, >-- >2.1.4
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 15498
:
46338
|
46339
|
50257
|
50258
|
57064
|
57065
|
57066
|
57070
|
57072
|
57073
|
57074
|
57075
|
60372
|
60373
|
60374
|
60375
|
60376
|
60385
|
60386
|
60387
|
60388
|
60389
|
60390
|
60411
|
60412
|
60413
|
60414
|
60415
|
60416