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

(-)a/Koha/Exporter/Record.pm (-7 / +3 lines)
Lines 134-145 sub export { Link Here
134
        print MARC::File::XML::footer();
134
        print MARC::File::XML::footer();
135
        print "\n";
135
        print "\n";
136
    } elsif ( $format eq 'csv' ) {
136
    } elsif ( $format eq 'csv' ) {
137
        unless ( $csv_profile_id ) {
137
        die 'There is no valid csv profile defined for this export'
138
            # FIXME export_format.profile should be a unique key
138
            unless Koha::CsvProfiles->find( $csv_profile_id );
139
            my $csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
140
            die "The ExportWithCsvProfile system preference is not defined or does not match a valid csv profile" unless $csv_profiles->count;
141
            $csv_profile_id = $csv_profiles->next->export_format_id;
142
        }
143
        print marc2csv( $record_ids, $csv_profile_id, $itemnumbers );
139
        print marc2csv( $record_ids, $csv_profile_id, $itemnumbers );
144
    }
140
    }
145
141
Lines 199-205 It will displays on STDOUT the generated file. Link Here
199
195
200
=item csv_profile_id
196
=item csv_profile_id
201
197
202
  If the format is csv, a csv_profile_id can be provide to overwrite the default value (syspref ExportWithCsvProfile).
198
  If the format is csv, you have to define a csv_profile_id.
203
199
204
=cut
200
=cut
205
201
(-)a/circ/circulation.pl (-1 / +5 lines)
Lines 49-54 use Koha::DateUtils; Link Here
49
use Koha::Database;
49
use Koha::Database;
50
use Koha::Patron::Messages;
50
use Koha::Patron::Messages;
51
use Koha::Patron::Images;
51
use Koha::Patron::Images;
52
use Koha::CsvProfiles;
52
53
53
use Date::Calc qw(
54
use Date::Calc qw(
54
  Today
55
  Today
Lines 649-656 $template->param( Link Here
649
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
650
my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
650
$template->param( picture => 1 ) if $patron_image;
651
$template->param( picture => 1 ) if $patron_image;
651
652
652
# get authorised values with type of BOR_NOTES
653
if ( C4::Context->preference("ExportCircHistory") ) {
654
    $template->param(csv_profiles => [ Koha::CsvProfiles->search ]);
655
}
653
656
657
# get authorised values with type of BOR_NOTES
654
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
658
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
655
659
656
$template->param(
660
$template->param(
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc (-2 / +9 lines)
Lines 48-64 Link Here
48
                    [% END %]
48
                    [% END %]
49
                </fieldset>
49
                </fieldset>
50
50
51
                [% IF ( exports_enabled ) %]
51
                [% IF Koha.Preference('ExportCircHistory') %]
52
                    <fieldset>
52
                    <fieldset>
53
                        <label for="output_format"><b>Export checkouts using format:</b></label>
53
                        <label for="output_format"><b>Export checkouts using format:</b></label>
54
                        <select name="output_format" id="output_format">
54
                        <select name="output_format" id="output_format">
55
                            <option value="iso2709_995">ISO2709 with items</option>
55
                            <option value="iso2709_995">ISO2709 with items</option>
56
                            <option value="iso2709">ISO2709 without items</option>
56
                            <option value="iso2709">ISO2709 without items</option>
57
                            [% IF Koha.Preference('ExportWithCsvProfile') %]
57
                            [% IF csv_profiles.size %]
58
                                <option value="csv">CSV</option>
58
                                <option value="csv">CSV</option>
59
                            [% END %]
59
                            [% END %]
60
                        </select>
60
                        </select>
61
61
62
                        [% IF csv_profiles.size %]
63
                            <select name="csv_profile">
64
                                [% FOREACH csv_profile IN csv_profiles %]
65
                                    <option value="[% csv_profile.export_format_id %]">[% csv_profile.profile %]</option>
66
                                [% END %]
67
                            </select>
68
                        [% END %]
62
                       <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" />
69
                       <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" />
63
                        <input type="hidden" name="op" value="export" />
70
                        <input type="hidden" name="op" value="export" />
64
                        <input type="hidden" id="output_format" name="output_format" value="iso2709" />
71
                        <input type="hidden" id="output_format" name="output_format" value="iso2709" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/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/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-4 / +1 lines)
Lines 3-11 Link Here
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE ColumnsSettings %]
4
[% USE ColumnsSettings %]
5
[% USE ItemTypes %]
5
[% USE ItemTypes %]
6
[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %]
7
   [% SET exports_enabled = 1 %]
8
[% END %]
9
[% USE AuthorisedValues %]
6
[% USE AuthorisedValues %]
10
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
11
[% SET destination = "circ" %]
8
[% SET destination = "circ" %]
Lines 36-42 var interface = "[% interface %]"; Link Here
36
var theme = "[% theme %]";
33
var theme = "[% theme %]";
37
var borrowernumber = "[% borrowernumber %]";
34
var borrowernumber = "[% borrowernumber %]";
38
var branchcode = "[% branch %]";
35
var branchcode = "[% branch %]";
39
var exports_enabled = "[% exports_enabled %]";
36
var exports_enabled = "[% ExportCircHistory %]";
40
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
37
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
41
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %];
38
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %];
42
var script = "circulation";
39
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 2-10 Link Here
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE AuthorisedValues %]
3
[% USE AuthorisedValues %]
4
[% USE ColumnsSettings %]
4
[% USE ColumnsSettings %]
5
[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %]
6
   [% SET exports_enabled = 1 %]
7
[% END %]
8
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
9
<title>Koha &rsaquo; Patrons &rsaquo;
6
<title>Koha &rsaquo; Patrons &rsaquo;
10
[% IF ( unknowuser ) %]
7
[% IF ( unknowuser ) %]
Lines 33-39 var interface = "[% interface %]"; Link Here
33
var theme = "[% theme %]";
30
var theme = "[% theme %]";
34
var borrowernumber = "[% borrowernumber %]";
31
var borrowernumber = "[% borrowernumber %]";
35
var branchcode = "[% branch %]";
32
var branchcode = "[% branch %]";
36
var exports_enabled = "[% exports_enabled %]";
33
var exports_enabled = "[% ExportCircHistory %]";
37
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
34
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
38
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
35
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 %];
39
var script = "moremember";
36
var script = "moremember";
(-)a/members/moremember.pl (+5 lines)
Lines 62-67 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
62
use DateTime;
62
use DateTime;
63
use Koha::DateUtils;
63
use Koha::DateUtils;
64
use Koha::Database;
64
use Koha::Database;
65
use Koha::CsvProfiles;
65
66
66
use vars qw($debug);
67
use vars qw($debug);
67
68
Lines 317-322 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
317
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
318
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
318
}
319
}
319
320
321
if ( C4::Context->preference("ExportCircHistory") ) {
322
    $template->param(csv_profiles => [ Koha::CsvProfiles->search ]);
323
}
324
320
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
325
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
321
$template->param( $data->{'categorycode'} => 1 ); 
326
$template->param( $data->{'categorycode'} => 1 ); 
322
$template->param(
327
$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 195-205 if ($deleted_barcodes) { Link Here
195
    }
198
    }
196
}
199
}
197
else {
200
else {
198
    unless ( $csv_profile_id ) {
199
        # FIXME export_format.profile should be a unique key
200
        my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
201
        $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef;
202
    }
203
    Koha::Exporter::Record::export(
201
    Koha::Exporter::Record::export(
204
        {   record_type        => $record_type,
202
        {   record_type        => $record_type,
205
            record_ids         => \@record_ids,
203
            record_ids         => \@record_ids,
Lines 251-257 Print a brief help message. Link Here
251
=item B<--csv_profile_id>
249
=item B<--csv_profile_id>
252
250
253
 --csv_profile_id=ID    Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl)
251
 --csv_profile_id=ID    Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl)
254
                        Unless provided, the one defined in the system preference 'ExportWithCsvProfile' will be used.
255
                        This can only be used to export biblio records.
252
                        This can only be used to export biblio records.
256
253
257
=item B<--deleted_barcodes>
254
=item B<--deleted_barcodes>
(-)a/tools/export.pl (-7 lines)
Lines 191-202 if ( $op eq "export" ) { Link Here
191
        );
191
        );
192
192
193
        my $csv_profile_id = $query->param('csv_profile_id');
193
        my $csv_profile_id = $query->param('csv_profile_id');
194
        unless ( $csv_profile_id ) {
195
            # FIXME export_format.profile should be a unique key
196
            my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
197
            $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef;
198
        }
199
200
        Koha::Exporter::Record::export(
194
        Koha::Exporter::Record::export(
201
            {   record_type        => $record_type,
195
            {   record_type        => $record_type,
202
                record_ids         => \@record_ids,
196
                record_ids         => \@record_ids,
203
- 

Return to bug 15498