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

(-)a/C4/Csv.pm (-56 lines)
Lines 1-56 Link Here
1
package C4::Csv;
2
3
# Copyright 2008 BibLibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
#
21
22
#use strict;
23
#use warnings; FIXME - Bug 2505
24
25
use C4::Context;
26
use vars qw($VERSION @ISA @EXPORT);
27
28
# set the version for version checking
29
$VERSION = 3.07.00.049;
30
31
@ISA = qw(Exporter);
32
33
# only export API methods
34
35
@EXPORT = qw(
36
  &GetMarcFieldsForCsv
37
);
38
39
40
# Returns fields to extract for the given csv profile
41
sub GetMarcFieldsForCsv {
42
43
    my ($id) = @_;
44
    my $dbh = C4::Context->dbh;
45
    my $query = "SELECT content FROM export_format WHERE export_format_id=?";
46
47
    $sth = $dbh->prepare($query);
48
    $sth->execute($id);
49
50
    return ($sth->fetchrow_hashref)->{content};
51
    
52
 
53
}
54
55
56
1;
(-)a/C4/Record.pm (-1 lines)
Lines 29-35 use MARC::Crosswalk::DublinCore; # marc2dcxml Link Here
29
use Biblio::EndnoteStyle;
29
use Biblio::EndnoteStyle;
30
use Unicode::Normalize; # _entity_encode
30
use Unicode::Normalize; # _entity_encode
31
use C4::Biblio; #marc2bibtex
31
use C4::Biblio; #marc2bibtex
32
use C4::Csv; #marc2csv
33
use C4::Koha; #marc2csv
32
use C4::Koha; #marc2csv
34
use C4::XSLT ();
33
use C4::XSLT ();
35
use YAML; #marcrecords2csv
34
use YAML; #marcrecords2csv
(-)a/basket/downloadcart.pl (-1 lines)
Lines 28-34 use C4::Items; Link Here
28
use C4::Output;
28
use C4::Output;
29
use C4::Record;
29
use C4::Record;
30
use C4::Ris;
30
use C4::Ris;
31
use C4::Csv;
32
31
33
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
34
33
(-)a/misc/export_records.pl (-1 lines)
Lines 24-30 use Pod::Usage; Link Here
24
24
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Context;
26
use C4::Context;
27
use C4::Csv;
28
use C4::Record;
27
use C4::Record;
29
28
30
use Koha::Biblioitems;
29
use Koha::Biblioitems;
(-)a/opac/opac-downloadcart.pl (-1 lines)
Lines 28-34 use C4::Items; Link Here
28
use C4::Output;
28
use C4::Output;
29
use C4::Record;
29
use C4::Record;
30
use C4::Ris;
30
use C4::Ris;
31
use C4::Csv;
32
31
33
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
34
33
(-)a/opac/opac-downloadshelf.pl (-1 lines)
Lines 28-34 use C4::Items; Link Here
28
use C4::Output;
28
use C4::Output;
29
use C4::Record;
29
use C4::Record;
30
use C4::Ris;
30
use C4::Ris;
31
use C4::Csv;
32
31
33
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
34
use Koha::Virtualshelves;
33
use Koha::Virtualshelves;
(-)a/serials/claims.pl (-1 / +1 lines)
Lines 27-35 use C4::Context; Link Here
27
use C4::Letters;
27
use C4::Letters;
28
use C4::Branch;    # GetBranches GetBranchesLoop
28
use C4::Branch;    # GetBranches GetBranchesLoop
29
use C4::Koha qw( GetAuthorisedValues );
29
use C4::Koha qw( GetAuthorisedValues );
30
30
use Koha::AdditionalField;
31
use Koha::AdditionalField;
31
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
32
use C4::Csv;
33
33
34
my $input = CGI->new;
34
my $input = CGI->new;
35
35
(-)a/serials/lateissues-export.pl (-1 lines)
Lines 22-28 use C4::Serials; Link Here
22
use C4::Acquisition;
22
use C4::Acquisition;
23
use C4::Output;
23
use C4::Output;
24
use C4::Context;
24
use C4::Context;
25
use C4::Csv;
26
25
27
use Koha::CsvProfiles;
26
use Koha::CsvProfiles;
28
27
(-)a/t/db_dependent/Csv.t (-67 lines)
Lines 1-67 Link Here
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
6
use Test::More tests => 10;
7
use Test::Deep;
8
9
use C4::Context;
10
BEGIN {
11
    use_ok('C4::Csv');
12
}
13
14
my $dbh = C4::Context->dbh;
15
$dbh->{AutoCommit} = 0;
16
$dbh->{RaiseError} = 1;
17
18
$dbh->do('DELETE FROM export_format');
19
20
my $sth = $dbh->prepare(q{
21
    INSERT INTO export_format (profile, description, content, type)
22
    VALUES (?, ?, ?, ?)
23
});
24
$sth->execute('MARC', 'MARC profile', '245$a',          'marc');
25
$sth->execute('SQL',  'SQL profile',  'borrowers.surname', 'sql');
26
27
my $all_profiles = C4::Csv::GetCsvProfiles();
28
is(@$all_profiles, 2, 'test getting all CSV profiles');
29
30
my $sql_profiles = C4::Csv::GetCsvProfiles('sql');
31
is(@$sql_profiles, 1, 'test getting SQL CSV profiles');
32
is($sql_profiles->[0]->{profile}, 'SQL', '... and got the right one');
33
my $marc_profiles = C4::Csv::GetCsvProfiles('marc');
34
is(@$marc_profiles, 1, 'test getting MARC CSV profiles');
35
is($marc_profiles->[0]->{profile}, 'MARC', '... and got the right one');
36
37
my $id = C4::Csv::GetCsvProfileId('MARC');
38
my $profile = C4::Csv::GetCsvProfile($id);
39
is($profile->{profile}, 'MARC', 'retrieved profile by ID');
40
41
is(C4::Csv::GetCsvProfile(), undef, 'test getting CSV profile but not supplying ID');
42
43
cmp_deeply(
44
    C4::Csv::GetCsvProfilesLoop(),
45
    [
46
        {
47
            export_format_id   => ignore(),
48
            profile            => 'MARC',
49
        },
50
        {
51
            export_format_id   => ignore(),
52
            profile            => 'SQL',
53
        },
54
    ],
55
    'test getting profile loop'
56
);
57
58
cmp_deeply(
59
    C4::Csv::GetCsvProfilesLoop('marc'),
60
    [
61
        {
62
            export_format_id   => ignore(),
63
            profile            => 'MARC',
64
        },
65
    ],
66
    'test getting profile loop for one type'
67
);
(-)a/tools/export.pl (-1 lines)
Lines 22-28 use MARC::File::XML; Link Here
22
use List::MoreUtils qw(uniq);
22
use List::MoreUtils qw(uniq);
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch;             # GetBranches
24
use C4::Branch;             # GetBranches
25
use C4::Csv;
26
use C4::Koha;               # GetItemTypes
25
use C4::Koha;               # GetItemTypes
27
use C4::Output;
26
use C4::Output;
28
27
(-)a/virtualshelves/downloadshelf.pl (-1 lines)
Lines 28-34 use C4::Items; Link Here
28
use C4::Output;
28
use C4::Output;
29
use C4::Record;
29
use C4::Record;
30
use C4::Ris;
30
use C4::Ris;
31
use C4::Csv;
32
31
33
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
34
use Koha::Virtualshelves;
33
use Koha::Virtualshelves;
(-)a/virtualshelves/shelves.pl (-2 lines)
Lines 21-27 use Modern::Perl; Link Here
21
use CGI qw ( -utf8 );
21
use CGI qw ( -utf8 );
22
use C4::Auth;
22
use C4::Auth;
23
use C4::Biblio;
23
use C4::Biblio;
24
use C4::Csv;
25
use C4::Koha;
24
use C4::Koha;
26
use C4::Items;
25
use C4::Items;
27
use C4::Members;
26
use C4::Members;
28
- 

Return to bug 15451