@@ -, +, @@ history DELETE FROM systempreferences WHERE variable='ExportCircHistory'; INSERT INTO systempreferences (variable, value) VALUES ('ExportWithCsvProfile', 'something'); --- 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 | 5 +++++ misc/export_records.pl | 9 +++------ tools/export.pl | 6 ------ 10 files changed, 38 insertions(+), 30 deletions(-) --- a/Koha/Exporter/Record.pm +++ a/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 --- a/circ/circulation.pl +++ a/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, --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -49,17 +49,24 @@ [% END %] - [% IF ( exports_enabled ) %] + [% IF Koha.Preference('ExportCircHistory') %]
+ [% IF csv_profiles.size %] + + [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/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"; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/help/circ/circulation.tt @@ -32,7 +32,7 @@

If you checked out an item for on site use you will see that highlighted in red in the checkout summary.

-

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.

+

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.

Also at the bottom of the page is the list of items the patron has on hold

--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ a/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' %] 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"; --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ a/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'){ --- a/members/moremember.pl +++ a/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,6 +327,10 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) { $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification")); } +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( --- a/misc/export_records.pl +++ a/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> --- a/tools/export.pl +++ a/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, --