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 46-51 use C4::Members::Attributes qw(GetBorrowerAttributes); Link Here
46
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
46
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
47
use Koha::DateUtils;
47
use Koha::DateUtils;
48
use Koha::Database;
48
use Koha::Database;
49
use Koha::CsvProfiles;
49
50
50
use Date::Calc qw(
51
use Date::Calc qw(
51
  Today
52
  Today
Lines 630-637 $template->param( Link Here
630
my ($picture, $dberror) = GetPatronImage($borrower->{'borrowernumber'});
631
my ($picture, $dberror) = GetPatronImage($borrower->{'borrowernumber'});
631
$template->param( picture => 1 ) if $picture;
632
$template->param( picture => 1 ) if $picture;
632
633
633
# get authorised values with type of BOR_NOTES
634
if ( C4::Context->preference("ExportCircHistory") ) {
635
    $template->param(csv_profiles => [ Koha::CsvProfiles->search ]);
636
}
634
637
638
# get authorised values with type of BOR_NOTES
635
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
639
my $canned_notes = GetAuthorisedValues("BOR_NOTES");
636
640
637
$template->param(
641
$template->param(
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc (-2 / +9 lines)
Lines 47-63 Link Here
47
                    [% END %]
47
                    [% END %]
48
                </fieldset>
48
                </fieldset>
49
49
50
                [% IF ( exports_enabled ) %]
50
                [% IF Koha.Preference('ExportCircHistory') %]
51
                    <fieldset>
51
                    <fieldset>
52
                        <label for="output_format"><b>Export checkouts using format:</b></label>
52
                        <label for="output_format"><b>Export checkouts using format:</b></label>
53
                        <select name="output_format" id="output_format">
53
                        <select name="output_format" id="output_format">
54
                            <option value="iso2709_995">ISO2709 with items</option>
54
                            <option value="iso2709_995">ISO2709 with items</option>
55
                            <option value="iso2709">ISO2709 without items</option>
55
                            <option value="iso2709">ISO2709 without items</option>
56
                            [% IF Koha.Preference('ExportWithCsvProfile') %]
56
                            [% IF csv_profiles.size %]
57
                                <option value="csv">CSV</option>
57
                                <option value="csv">CSV</option>
58
                            [% END %]
58
                            [% END %]
59
                        </select>
59
                        </select>
60
60
61
                        [% IF csv_profiles.size %]
62
                            <select name="csv_profile">
63
                                [% FOREACH csv_profile IN csv_profiles %]
64
                                    <option value="[% csv_profile.export_format_id %]">[% csv_profile.profile %]</option>
65
                                [% END %]
66
                            </select>
67
                        [% END %]
61
                       <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" />
68
                       <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" />
62
                        <input type="hidden" name="op" value="export" />
69
                        <input type="hidden" name="op" value="export" />
63
                        <input type="hidden" id="output_format" name="output_format" value="iso2709" />
70
                        <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 && AllowRenewalLimitOverride)? 1: 0 %];
37
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && 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 1-9 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE ColumnsSettings %]
3
[% USE ColumnsSettings %]
4
[% IF Koha.Preference('ExportRemoveFields') OR Koha.Preference('ExportWithCsvProfile') %]
5
   [% SET exports_enabled = 1 %]
6
[% END %]
7
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
8
<title>Koha &rsaquo; Patrons &rsaquo;
5
<title>Koha &rsaquo; Patrons &rsaquo;
9
[% IF ( unknowuser ) %]
6
[% IF ( unknowuser ) %]
Lines 32-38 var interface = "[% interface %]"; Link Here
32
var theme = "[% theme %]";
29
var theme = "[% theme %]";
33
var borrowernumber = "[% borrowernumber %]";
30
var borrowernumber = "[% borrowernumber %]";
34
var branchcode = "[% branch %]";
31
var branchcode = "[% branch %]";
35
var exports_enabled = "[% exports_enabled %]";
32
var exports_enabled = "[% ExportCircHistory %]";
36
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
33
var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 %]
37
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && AllowRenewalLimitOverride)? 1: 0 %];
34
var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && AllowRenewalLimitOverride)? 1: 0 %];
38
var script = "moremember";
35
var script = "moremember";
(-)a/members/moremember.pl (+5 lines)
Lines 61-66 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
61
use DateTime;
61
use DateTime;
62
use Koha::DateUtils;
62
use Koha::DateUtils;
63
use Koha::Database;
63
use Koha::Database;
64
use Koha::CsvProfiles;
64
65
65
use vars qw($debug);
66
use vars qw($debug);
66
67
Lines 328-333 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
328
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
329
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
329
}
330
}
330
331
332
if ( C4::Context->preference("ExportCircHistory") ) {
333
    $template->param(csv_profiles => [ Koha::CsvProfiles->search ]);
334
}
335
331
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
336
# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children) 
332
$template->param( $data->{'categorycode'} => 1 ); 
337
$template->param( $data->{'categorycode'} => 1 ); 
333
$template->param(
338
$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 194-204 if ($deleted_barcodes) { Link Here
194
    }
197
    }
195
}
198
}
196
else {
199
else {
197
    unless ( $csv_profile_id ) {
198
        # FIXME export_format.profile should be a unique key
199
        my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
200
        $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef;
201
    }
202
    Koha::Exporter::Record::export(
200
    Koha::Exporter::Record::export(
203
        {   record_type        => $record_type,
201
        {   record_type        => $record_type,
204
            record_ids         => \@record_ids,
202
            record_ids         => \@record_ids,
Lines 250-256 Print a brief help message. Link Here
250
=item B<--csv_profile_id>
248
=item B<--csv_profile_id>
251
249
252
 --csv_profile_id=ID    Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl)
250
 --csv_profile_id=ID    Generate a CSV file with the given CSV profile id (see tools/csv-profiles.pl)
253
                        Unless provided, the one defined in the system preference 'ExportWithCsvProfile' will be used.
254
                        This can only be used to export biblio records.
251
                        This can only be used to export biblio records.
255
252
256
=item B<--deleted_barcodes>
253
=item B<--deleted_barcodes>
(-)a/tools/export.pl (-7 lines)
Lines 190-201 if ( $op eq "export" ) { Link Here
190
        );
190
        );
191
191
192
        my $csv_profile_id = $query->param('csv_profile_id');
192
        my $csv_profile_id = $query->param('csv_profile_id');
193
        unless ( $csv_profile_id ) {
194
            # FIXME export_format.profile should be a unique key
195
            my $default_csv_profiles = Koha::CsvProfiles->search({ profile => C4::Context->preference('ExportWithCsvProfile') });
196
            $csv_profile_id = $default_csv_profiles->count ? $default_csv_profiles->next->export_format_id : undef;
197
        }
198
199
        Koha::Exporter::Record::export(
193
        Koha::Exporter::Record::export(
200
            {   record_type        => $record_type,
194
            {   record_type        => $record_type,
201
                record_ids         => \@record_ids,
195
                record_ids         => \@record_ids,
202
- 

Return to bug 15498