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;
48 my $fileID = $input->param('uploadedfileid');
49 my $matcher_id = $input->param('matcher');
50 my $overlay_action = $input->param('overlay_action');
51 my $nomatch_action = $input->param('nomatch_action');
52 my $parse_items = $input->param('parse_items');
53 my $item_action = $input->param('item_action');
54 my $comments = $input->param('comments');
55 my $record_type = $input->param('record_type');
56 my $encoding = $input->param('encoding') || 'UTF-8';
57 my $format = $input->param('format') || 'ISO2709';
58 my $marc_modification_template = $input->param('marc_modification_template_id');
59 my $basketno = $input->param('basketno');
60 my $booksellerid = $input->param('booksellerid');
61 my $profile_id = $input->param('profile_id');
64 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
66 template_name => "tools/stage-marc-import.tt",
69 flagsrequired => { tools => 'stage_marc_import' },
74 basketno => $basketno,
75 booksellerid => $booksellerid,
79 my $upload = Koha::UploadedFiles->find( $fileID );
80 my $filepath = $upload->full_path;
81 my $filename = $upload->filename;
84 record_type => $record_type,
85 encoding => $encoding,
87 filepath => $filepath,
88 filename => $filename,
89 marc_modification_template => $marc_modification_template,
90 comments => $comments,
91 parse_items => $parse_items,
92 matcher_id => $matcher_id,
93 overlay_action => $overlay_action,
94 nomatch_action => $nomatch_action,
95 item_action => $item_action,
96 basket_id => $basketno,
97 vendor_id => $booksellerid,
100 my $job_id = Koha::BackgroundJob::StageMARCForImport->new->enqueue( $params );
113 code => 'cannot_enqueue_job',
120 if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
121 $template->param( "UNIMARC" => 1 );
123 my @matchers = C4::Matcher::GetMatcherList();
124 $template->param( available_matchers => \@matchers );
126 my @templates = GetModificationTemplates();
127 $template->param( MarcModificationTemplatesLoop => \@templates );
129 if ( C4::Context->config('enable_plugins') ) {
131 my @plugins = Koha::Plugins->new()->GetPlugins({
134 $template->param( plugins => \@plugins );
138 $template->param( messages => \@messages );
140 output_html_with_http_headers $input, $cookie, $template->output;