Lines 6-11
use Koha::Exporter::Record;
Link Here
|
6 |
use C4::Biblio qw//; |
6 |
use C4::Biblio qw//; |
7 |
use Encode; |
7 |
use Encode; |
8 |
use Carp; |
8 |
use Carp; |
|
|
9 |
use List::MoreUtils qw(uniq); |
9 |
|
10 |
|
10 |
use Koha::ItemTypes; |
11 |
use Koha::ItemTypes; |
11 |
use Koha::Authority::Types; |
12 |
use Koha::Authority::Types; |
Lines 77-84
sub _getbackupfilelist {
Link Here
|
77 |
} |
78 |
} |
78 |
closedir($dir); |
79 |
closedir($dir); |
79 |
} |
80 |
} |
80 |
use Data::Dumper; |
|
|
81 |
warn Dumper(\@files); |
82 |
return \@files; |
81 |
return \@files; |
83 |
} |
82 |
} |
84 |
|
83 |
|
Lines 88-101
sub download {
Link Here
|
88 |
my ($flags,$loggedinuser) = $c->staff_authorize({ flagsrequired => { 'tools' => 'export_catalog' } }); |
87 |
my ($flags,$loggedinuser) = $c->staff_authorize({ flagsrequired => { 'tools' => 'export_catalog' } }); |
89 |
|
88 |
|
90 |
my $record_type = $c->param('record_type') || 'bibs'; #FIXME: Remove bibs? |
89 |
my $record_type = $c->param('record_type') || 'bibs'; #FIXME: Remove bibs? |
91 |
my $backupdir = C4::Context->config('backupdir'); |
|
|
92 |
|
93 |
if ( $record_type eq 'bibs' or $record_type eq 'auths' ){ |
90 |
if ( $record_type eq 'bibs' or $record_type eq 'auths' ){ |
|
|
91 |
my $output_format = $c->param('output_format') || 'iso2709'; |
92 |
my $filename = $c->param('filename') || ( $output_format eq 'csv' ? 'koha.csv' : 'koha.mrc' ); |
93 |
my $csv_profile_id = $c->param('csv_profile_id'); |
94 |
my $export_remove_fields = $c->param('export_remove_fields') || q(); |
95 |
my $dont_export_items = $c->param('dont_export_item') || 0; #FIXME: Shouldn't this be bibs specific? |
96 |
my $itemnumbers = $c->every_param('itemnumbers'); #FIXME: Shouldn't this be bibs specific? |
97 |
|
98 |
my $branch = $c->every_param('branch'); |
99 |
my $strip_items_not_from_libraries = $c->param('strip_items_not_from_libraries'); |
100 |
my $only_export_items_for_branches = $strip_items_not_from_libraries ? $branch : undef; |
101 |
|
102 |
my $record_ids = (); |
103 |
if ($record_type eq 'bibs'){ |
104 |
my $biblionumbers = $c->every_param('biblionumbers'); |
105 |
|
106 |
$record_ids = $biblionumbers; |
107 |
} |
108 |
|
109 |
#FIXME: Move this to module |
110 |
#NOTE: Ensure record IDs are unique |
111 |
#@record_ids = uniq @record_ids; |
112 |
|
113 |
#FIXME: Add "id_list_file" filter... |
114 |
|
115 |
my $content_type = 'application/octet-stream'; |
116 |
$c->res->headers->content_type($content_type); |
117 |
$c->res->headers->content_disposition("attachment; filename=$filename;"); |
118 |
|
119 |
my $exporter = Koha::Exporter::Record->new({ |
120 |
record_type => $record_type, |
121 |
record_ids => $record_ids, |
122 |
format => $output_format, |
123 |
filename => $filename, |
124 |
itemnumbers => $itemnumbers, |
125 |
dont_export_fields => $export_remove_fields, |
126 |
csv_profile_id => $csv_profile_id, |
127 |
export_items => (not $dont_export_items), |
128 |
only_export_items_for_branches => $only_export_items_for_branches, |
129 |
}); |
130 |
my $drain; |
131 |
$drain = sub { |
132 |
my $c = shift; |
133 |
if ( $exporter->has_next() ){ |
134 |
my $record = $exporter->next; |
135 |
$c->write($record,$drain); |
136 |
} |
137 |
else { |
138 |
$c->write(''); |
139 |
} |
140 |
}; |
141 |
$c->$drain; |
142 |
|
94 |
#TODO: Refactor code from export.pl |
143 |
#TODO: Refactor code from export.pl |
95 |
$c->render( text => 'TODO: I need to rewrite the handler for this but it is coming.' ); |
144 |
#$c->render( text => 'TODO: I need to rewrite the handler for this but it is coming.' ); |
96 |
} |
145 |
} |
97 |
elsif ( $record_type eq 'db' or $record_type eq 'conf' ){ |
146 |
elsif ( $record_type eq 'db' or $record_type eq 'conf' ){ |
98 |
#TODO: Most of this code should go in a model module |
147 |
#TODO: Most of this code should go in a model module |
|
|
148 |
my $backupdir = C4::Context->config('backupdir'); |
99 |
if ( $flags->{superlibrarian} |
149 |
if ( $flags->{superlibrarian} |
100 |
and ( |
150 |
and ( |
101 |
$record_type eq 'db' and C4::Context->config('backup_db_via_tools') |
151 |
$record_type eq 'db' and C4::Context->config('backup_db_via_tools') |