|
Lines 34-39
use Koha::CsvProfiles;
Link Here
|
| 34 |
use Koha::Exporter::Record; |
34 |
use Koha::Exporter::Record; |
| 35 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
35 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
| 36 |
use Koha::Reports; |
36 |
use Koha::Reports; |
|
|
37 |
use Koha::File::Transports; |
| 37 |
|
38 |
|
| 38 |
my ( |
39 |
my ( |
| 39 |
$output_format, |
40 |
$output_format, |
|
Lines 62-68
my (
Link Here
|
| 62 |
$report, |
63 |
$report, |
| 63 |
$sql, |
64 |
$sql, |
| 64 |
$params_needed, |
65 |
$params_needed, |
| 65 |
$help |
66 |
$destination_server_id, |
|
|
67 |
$delete_local_after_run, |
| 68 |
$help, |
| 66 |
); |
69 |
); |
| 67 |
|
70 |
|
| 68 |
GetOptions( |
71 |
GetOptions( |
|
Lines 89-95
GetOptions(
Link Here
|
| 89 |
'embed_see_from_headings' => \$embed_see_from_headings, |
92 |
'embed_see_from_headings' => \$embed_see_from_headings, |
| 90 |
'report_id=s' => \$report_id, |
93 |
'report_id=s' => \$report_id, |
| 91 |
'report_param=s' => \@report_params, |
94 |
'report_param=s' => \@report_params, |
| 92 |
'h|help|?' => \$help |
95 |
'destination_server_id=s' => \$destination_server_id, |
|
|
96 |
'delete_local_after_run' => \$delete_local_after_run, |
| 97 |
'h|help|?' => \$help, |
| 93 |
) || pod2usage(1); |
98 |
) || pod2usage(1); |
| 94 |
|
99 |
|
| 95 |
if ($help) { |
100 |
if ($help) { |
|
Lines 119-130
if ( $deleted_barcodes and $record_type ne 'bibs' ) {
Link Here
|
| 119 |
pod2usage(q|--deleted_barcodes can only be used with biblios|); |
124 |
pod2usage(q|--deleted_barcodes can only be used with biblios|); |
| 120 |
} |
125 |
} |
| 121 |
|
126 |
|
|
|
127 |
my $sftp_server; |
| 128 |
if ($destination_server_id) { |
| 129 |
$sftp_server = Koha::File::Transports->find($destination_server_id); |
| 130 |
|
| 131 |
pod2usage( sprintf( "No FTP/SFTP Server (%s) found", $destination_server_id ) ) |
| 132 |
unless $sftp_server; |
| 133 |
} |
| 134 |
|
| 122 |
if ($report_id) { |
135 |
if ($report_id) { |
| 123 |
|
136 |
|
| 124 |
# Check report exists |
137 |
# Check report exists |
| 125 |
$report = Koha::Reports->find($report_id); |
138 |
$report = Koha::Reports->find($report_id); |
| 126 |
unless ($report) { |
139 |
unless ($report) { |
| 127 |
pod2usage( sprintf( "No saved report (%s) found", $report_id ) ); |
140 |
pod2usage( sprintf( "No FTP/SFTP Server (%s) found", $report_id ) ); |
| 128 |
} |
141 |
} |
| 129 |
$sql = $report->savedsql; |
142 |
$sql = $report->savedsql; |
| 130 |
|
143 |
|
|
Lines 340-345
if ($deleted_barcodes) {
Link Here
|
| 340 |
} |
353 |
} |
| 341 |
); |
354 |
); |
| 342 |
} |
355 |
} |
|
|
356 |
|
| 357 |
if ($sftp_server) { |
| 358 |
$sftp_server->connect |
| 359 |
or die pod2usage( sprintf( "Unable to connect server (%s)", $destination_server_id ) ); |
| 360 |
|
| 361 |
my $upload_dir = $sftp_server->upload_directory; |
| 362 |
if ($upload_dir) { |
| 363 |
$sftp_server->change_directory( $upload_dir ) |
| 364 |
or die pod2usage( sprintf( "Unable to change directory on server (%s) to path (%s)", $destination_server_id, $upload_dir ) ); |
| 365 |
} |
| 366 |
|
| 367 |
$sftp_server->upload_file ( $filename, $filename ) |
| 368 |
or die pod2usage( sprintf( "Unable to upload file (%s) to server (%s)", $filename, $destination_server_id ) ); |
| 369 |
} |
| 370 |
|
| 371 |
if ($delete_local_after_run) { |
| 372 |
unlink $filename |
| 373 |
or die pod2usage( sprintf( "Unable to delete local file (%s)", $filename ) ); |
| 374 |
} |
| 375 |
|
| 343 |
exit; |
376 |
exit; |
| 344 |
|
377 |
|
| 345 |
=head1 NAME |
378 |
=head1 NAME |
|
Lines 483-488
Print a brief help message.
Link Here
|
| 483 |
Report params are not combined as on the staff side, so you may |
516 |
Report params are not combined as on the staff side, so you may |
| 484 |
need to repeat params. |
517 |
need to repeat params. |
| 485 |
|
518 |
|
|
|
519 |
=item B<--destination_server_id> |
| 520 |
|
| 521 |
--destination_server_id=ID Provide this option, along with the destination server ID, to |
| 522 |
upload the resultant mrc file to the selected FTP/SFTP Server. |
| 523 |
You can create FTP/SFTP Servers via the Koha Staff client, under |
| 524 |
Koha Administration. |
| 525 |
|
| 526 |
=item B<--delete_local_after_run> |
| 527 |
|
| 528 |
--delete_local_after_run Deletes the local file at the end of the script run. Can be |
| 529 |
useful if, for example, you are uploading the file to an |
| 530 |
FTP/SFTP server. |
| 531 |
|
| 486 |
=back |
532 |
=back |
| 487 |
|
533 |
|
| 488 |
=head1 AUTHOR |
534 |
=head1 AUTHOR |
| 489 |
- |
|
|