3 # Script for handling import of MARC data into Koha db
6 # Koha library project www.koha-community.org
8 # Licensed under the GPL
10 # Copyright 2000-2002 Katipo Communications
12 # This file is part of Koha.
14 # Koha is free software; you can redistribute it and/or modify it
15 # under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 3 of the License, or
17 # (at your option) any later version.
19 # Koha is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with Koha; if not, see <http://www.gnu.org/licenses>.
29 # standard or CPAN modules used
32 use MARC::File::USMARC;
37 use C4::Auth qw( get_template_and_user );
38 use C4::Output qw( output_html_with_http_headers );
40 use Koha::UploadedFiles;
41 use C4::MarcModificationTemplates qw( GetModificationTemplates );
43 use Koha::ImportBatches;
44 use Koha::BackgroundJob::StageMARCForImport;
47 my $op = $input->param('op') // q{};
49 my $fileID = $input->param('uploadedfileid');
50 my $matcher_id = $input->param('matcher');
51 my $overlay_action = $input->param('overlay_action');
52 my $nomatch_action = $input->param('nomatch_action');
53 my $parse_items = $input->param('parse_items');
54 my $item_action = $input->param('item_action');
55 my $comments = $input->param('comments');
56 my $record_type = $input->param('record_type');
57 my $encoding = $input->param('encoding') || 'UTF-8';
58 my $format = $input->param('format') || 'ISO2709';
59 my $marc_modification_template = $input->param('marc_modification_template_id');
60 my $basketno = $input->param('basketno');
61 my $booksellerid = $input->param('booksellerid');
62 my $profile_id = $input->param('profile_id');
65 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
67 template_name => "tools/stage-marc-import.tt",
70 flagsrequired => { tools => 'stage_marc_import' },
75 basketno => $basketno,
76 booksellerid => $booksellerid,
79 if ( $op eq 'cud-stage' && $fileID ) {
80 my $upload = Koha::UploadedFiles->find( $fileID );
81 my $filepath = $upload->full_path;
82 my $filename = $upload->filename;
85 record_type => $record_type,
86 encoding => $encoding,
88 filepath => $filepath,
89 filename => $filename,
90 marc_modification_template => $marc_modification_template,
91 comments => $comments,
92 parse_items => $parse_items,
93 matcher_id => $matcher_id,
94 overlay_action => $overlay_action,
95 nomatch_action => $nomatch_action,
96 item_action => $item_action,
97 basket_id => $basketno,
98 vendor_id => $booksellerid,
99 profile_id => $profile_id,
102 my $job_id = Koha::BackgroundJob::StageMARCForImport->new->enqueue( $params );
115 code => 'cannot_enqueue_job',
122 if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
123 $template->param( "UNIMARC" => 1 );
125 my @matchers = C4::Matcher::GetMatcherList();
126 $template->param( available_matchers => \@matchers );
128 my @templates = GetModificationTemplates();
129 $template->param( MarcModificationTemplatesLoop => \@templates );
131 if ( C4::Context->config('enable_plugins') ) {
133 my @plugins = Koha::Plugins->new()->GetPlugins({
136 $template->param( plugins => \@plugins );
140 $template->param( messages => \@messages );
142 output_html_with_http_headers $input, $cookie, $template->output;