View | Details | Raw Unified | Return to bug 15498
Collapse All | Expand All

(-)a/Koha/Exporter/Record.pm (-7 / +3 lines)
Lines 143-154 sub export { Link Here
143
        print MARC::File::XML::footer();
143
        print MARC::File::XML::footer();
144
        print "\n";
144
        print "\n";
145
    } elsif ( $format eq 'csv' ) {
145
    } elsif ( $format eq 'csv' ) {
146
        unless ( $csv_profile_id ) {
146
        die 'There is no valid csv profile defined for this export'
147
            # FIXME export_format.profile should be a unique key
147
            unless Koha::CsvProfiles->find( $csv_profile_id );
148
            my $csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
149
            die "The ExportWithCsvProfile system preference is not defined or does not match a valid csv profile" unless $csv_profiles->count;
150
            $csv_profile_id = $csv_profiles->next->export_format_id;
151
        }
152
        print marc2csv( $record_ids, $csv_profile_id, $itemnumbers );
148
        print marc2csv( $record_ids, $csv_profile_id, $itemnumbers );
153
    }
149
    }
154
150
Lines 208-214 It will displays on STDOUT the generated file. Link Here
208
204
209
=item csv_profile_id
205
=item csv_profile_id
210
206
211
  If the format is csv, a csv_profile_id can be provide to overwrite the default value (syspref ExportWithCsvProfile).
207
  If the format is csv, you have to define a csv_profile_id.
212
208
213
=cut
209
=cut
214
210
(-)a/circ/circulation.pl (+5 lines)
Lines 43-48 use C4::Context; Link Here
43
use CGI::Session;
43
use CGI::Session;
44
use C4::Members::Attributes qw(GetBorrowerAttributes);
44
use C4::Members::Attributes qw(GetBorrowerAttributes);
45
use Koha::AuthorisedValues;
45
use Koha::AuthorisedValues;
46
use Koha::CsvProfiles;
46
use Koha::Patron;
47
use Koha::Patron;
47
use Koha::Patron::Debarments qw(GetDebarments);
48
use Koha::Patron::Debarments qw(GetDebarments);
48
use Koha::DateUtils;
49
use Koha::DateUtils;
Lines 646-651 $template->param( Link Here
646
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
647
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
647
$template->param( picture => 1 ) if $patron_image;
648
$template->param( picture => 1 ) if $patron_image;
648
649
650
if ( C4::Context->preference("ExportCircHistory") ) {
651
    $template->param(csv_profiles => [ Koha::CsvProfiles->search ]);
652
}
653
649
my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count;
654
my $has_modifications = Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->count;
650
$template->param(
655
$template->param(
651
    debt_confirmed            => $debt_confirmed,
656
    debt_confirmed            => $debt_confirmed,
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc (-2 / +9 lines)
Lines 49-65 Link Here
49
                    [% END %]
49
                    [% END %]
50
                </fieldset>
50
                </fieldset>
51
51
52
                [% IF ( exports_enabled ) %]
52
                [% IF Koha.Preference('ExportCircHistory') %]
53
                    <fieldset>
53
                    <fieldset>
54
                        <label for="issues-table-output-format"><b>Export checkouts using format:</b></label>
54
                        <label for="issues-table-output-format"><b>Export checkouts using format:</b></label>
55
                        <select name="issues-table-output-format" id="issues-table-output-format">
55
                        <select name="issues-table-output-format" id="issues-table-output-format">
56
                            <option value="iso2709_995">ISO2709 with items</option>
56
                            <option value="iso2709_995">ISO2709 with items</option>
57
                            <option value="iso2709">ISO2709 without items</option>
57
                            <option value="iso2709">ISO2709 without items</option>
58
                            [% IF Koha.Preference('ExportWithCsvProfile') %]
58
                            [% IF csv_profiles.size %]
59
                                <option value="csv">CSV</option>
59
                                <option value="csv">CSV</option>
60
                            [% END %]
60
                            [% END %]
61
                        </select>
61
                        </select>
62
62
63
                        [% IF csv_profiles.size %]
64
                            <select name="csv_profile_id">
65
                                [% FOREACH csv_profile IN csv_profiles %]
66
                                    <option value="[% csv_profile.export_format_id %]">[% csv_profile.profile %]</option>
67
                                [% END %]
68
                            </select>
69
                        [% END %]
63
                       <label for="export_remove_fields">Don't export fields:</label> <input type="text" id="export_remove_fields" name="export_remove_fields" value="[% Koha.Preference('ExportRemoveFields') %]" title="Use for iso2709 exports" />
70
                       <label for="export_remove_fields">Don't export fields:</label> <input type="text" id="export_remove_fields" name="export_remove_fields" value="[% Koha.Preference('ExportRemoveFields') %]" title="Use for iso2709 exports" />
64
                        <input type="hidden" name="op" value="export" />
71
                        <input type="hidden" name="op" value="export" />
65
                        <input type="hidden" id="output_format" name="output_format" value="iso2709" />
72
                        <input type="hidden" id="output_format" name="output_format" value="iso2709" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-4 / +1 lines)
Lines 5-13 Link Here
5
[% USE ColumnsSettings %]
5
[% USE ColumnsSettings %]
6
[% USE ItemTypes %]
6
[% USE ItemTypes %]
7
[% USE Price %]
7
[% USE Price %]
8
[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %]
9
   [% SET exports_enabled = 1 %]
10
[% END %]
11
[% USE AuthorisedValues %]
8
[% USE AuthorisedValues %]
12
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
13
[% SET destination = "circ" %]
10
[% SET destination = "circ" %]
Lines 38-44 var interface = "[% interface %]"; Link Here
38
var theme = "[% theme %]";
35
var theme = "[% theme %]";
39
var borrowernumber = "[% borrowernumber %]";
36
var borrowernumber = "[% borrowernumber %]";
40
var branchcode = "[% branch %]";
37
var branchcode = "[% branch %]";
41
var exports_enabled = "[% exports_enabled %]";
38
var exports_enabled = "[% Koha.Preference('ExportCircHistory') %]";
42
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
39
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
43
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %];
40
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %];
44
var script = "circulation";
41
var script = "circulation";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/help/circ/circulation.tt (-1 / +1 lines)
Lines 32-38 Link Here
32
32
33
<p>If you checked out an item for on site use you will see that highlighted in red in the checkout summary.</p>
33
<p>If you checked out an item for on site use you will see that highlighted in red in the checkout summary.</p>
34
34
35
<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>
35
<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>
36
36
37
<p>Also at the bottom of the page is the list of items the patron has on hold</p>
37
<p>Also at the bottom of the page is the list of items the patron has on hold</p>
38
38
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-4 / +1 lines)
Lines 3-11 Link Here
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE AuthorisedValues %]
4
[% USE AuthorisedValues %]
5
[% USE ColumnsSettings %]
5
[% USE ColumnsSettings %]
6
[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %]
7
   [% SET exports_enabled = 1 %]
8
[% END %]
9
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
10
<title>Koha &rsaquo; Patrons &rsaquo;
7
<title>Koha &rsaquo; Patrons &rsaquo;
11
[% IF ( unknowuser ) %]
8
[% IF ( unknowuser ) %]
Lines 34-40 var interface = "[% interface %]"; Link Here
34
var theme = "[% theme %]";
31
var theme = "[% theme %]";
35
var borrowernumber = "[% borrowernumber %]";
32
var borrowernumber = "[% borrowernumber %]";
36
var branchcode = "[% Branches.GetLoggedInBranchcode() %]";
33
var branchcode = "[% Branches.GetLoggedInBranchcode() %]";
37
var exports_enabled = "[% exports_enabled %]";
34
var exports_enabled = "[% Koha.Preference('ExportCircHistory') %]";
38
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
35
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
39
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
36
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
40
var script = "moremember";
37
var script = "moremember";
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (+10 lines)
Lines 36-41 $(document).ready(function() { Link Here
36
        }
36
        }
37
    });
37
    });
38
38
39
    $("#output_format > option:first-child").attr("selected", "selected");
40
    $("select[name='csv_profile']").hide();
41
    $(document).on("change", '#output_format', function(){
42
        if ( $(this).val() == 'csv' ) {
43
            $("select[name='csv_profile']").show();
44
        } else {
45
            $("select[name='csv_profile']").hide();
46
        }
47
    });
48
39
    // Clicking the table cell checks the checkbox inside it
49
    // Clicking the table cell checks the checkbox inside it
40
    $(document).on("click", 'td', function(e){
50
    $(document).on("click", 'td', function(e){
41
        if(e.target.tagName.toLowerCase() == 'td'){
51
        if(e.target.tagName.toLowerCase() == 'td'){
(-)a/members/moremember.pl (+5 lines)
Lines 53-58 use C4::Form::MessagingPreferences; Link Here
53
use List::MoreUtils qw/uniq/;
53
use List::MoreUtils qw/uniq/;
54
use C4::Members::Attributes qw(GetBorrowerAttributes);
54
use C4::Members::Attributes qw(GetBorrowerAttributes);
55
use Koha::AuthorisedValues;
55
use Koha::AuthorisedValues;
56
use Koha::CsvProfiles;
56
use Koha::Patron::Debarments qw(GetDebarments);
57
use Koha::Patron::Debarments qw(GetDebarments);
57
use Koha::Patron::Images;
58
use Koha::Patron::Images;
58
use Module::Load;
59
use Module::Load;
Lines 326-331 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
326
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
327
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
327
}
328
}
328
329
330
if ( C4::Context->preference("ExportCircHistory") ) {
331
    $template->param(csv_profiles => [ Koha::CsvProfiles->search ]);
332
}
333
329
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children)
334
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children)
330
$template->param( $data->{'categorycode'} => 1 );
335
$template->param( $data->{'categorycode'} => 1 );
331
$template->param(
336
$template->param(
(-)a/misc/export_records.pl (-6 / +3 lines)
Lines 71-76 if ( $output_format eq 'csv' and $record_type eq 'auths' ) { Link Here
71
    pod2usage(q|CSV output is only available for biblio records|);
71
    pod2usage(q|CSV output is only available for biblio records|);
72
}
72
}
73
73
74
if ( $output_format eq 'csv' and not $csv_profile_id ) {
75
    pod2usage(q|Define a csv profile to export in CSV|);
76
}
74
77
75
if ( $timestamp and $record_type ne 'bibs' ) {
78
if ( $timestamp and $record_type ne 'bibs' ) {
76
    pod2usage(q|--timestamp can only be used with biblios|);
79
    pod2usage(q|--timestamp can only be used with biblios|);
Lines 193-203 if ($deleted_barcodes) { Link Here
193
    }
196
    }
194
}
197
}
195
else {
198
else {
196
    unless ( $csv_profile_id ) {
197
        # FIXME export_format.profile should be a unique key
198
        my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
199
        $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef;
200
    }
201
    Koha::Exporter::Record::export(
199
    Koha::Exporter::Record::export(
202
        {   record_type        => $record_type,
200
        {   record_type        => $record_type,
203
            record_ids         => \@record_ids,
201
            record_ids         => \@record_ids,
Lines 249-255 Print a brief help message. Link Here
249
=item B<--csv_profile_id>
247
=item B<--csv_profile_id>
250
248
251
 --csv_profile_id=ID    Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl)
249
 --csv_profile_id=ID    Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl)
252
                        Unless provided, the one defined in the system preference 'ExportWithCsvProfile' will be used.
253
                        This can only be used to export biblio records.
250
                        This can only be used to export biblio records.
254
251
255
=item B<--deleted_barcodes>
252
=item B<--deleted_barcodes>
(-)a/tools/export.pl (-7 lines)
Lines 187-198 if ( $op eq "export" ) { Link Here
187
        );
187
        );
188
188
189
        my $csv_profile_id = $query->param('csv_profile_id');
189
        my $csv_profile_id = $query->param('csv_profile_id');
190
        unless ( $csv_profile_id ) {
191
            # FIXME export_format.profile should be a unique key
192
            my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
193
            $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef;
194
        }
195
196
        Koha::Exporter::Record::export(
190
        Koha::Exporter::Record::export(
197
            {   record_type        => $record_type,
191
            {   record_type        => $record_type,
198
                record_ids         => \@record_ids,
192
                record_ids         => \@record_ids,
199
- 

Return to bug 15498