5 # Script for handling import of MARC data into Koha db
8 # Koha library project www.koha.org
10 # Licensed under the GPL
13 # Copyright 2000-2002 Katipo Communications
15 # This file is part of Koha.
17 # Koha is free software; you can redistribute it and/or modify it under the
18 # terms of the GNU General Public License as published by the Free Software
19 # Foundation; either version 2 of the License, or (at your option) any later
22 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
23 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
24 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License along with
27 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
28 # Suite 330, Boston, MA 02111-1307 USA
32 # standard or CPAN modules used
39 use C4::Interface::CGI::Output;
42 use MARC::File::USMARC;
51 my $includes = C4::Context->config('includes') ||
52 "/usr/local/www/hdl/htdocs/includes";
54 # HTML colors for alternating lines
62 my $userid=$ENV{'REMOTE_USER'};
65 my $dbh = C4::Context->dbh;
67 my $uploadmarc=$input->param('uploadmarc');
68 my $overwrite_biblio = $input->param('overwrite_biblio');
69 my $filename = $input->param('filename');
70 my $syntax = $input->param('syntax');
71 my ($template, $loggedinuser, $cookie)
72 = get_template_and_user({template_name => "tools/import.tmpl",
76 flagsrequired => {tools => 1},
80 $template->param(SCRIPT_NAME => $ENV{'SCRIPT_NAME'},
81 uploadmarc => $uploadmarc);
82 if ($uploadmarc && length($uploadmarc)>0) {
84 while (<$uploadmarc>) {
87 my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported) = ImportBreeding($marcrecord,$overwrite_biblio,$filename,$syntax,int(rand(99999)));
89 $template->param(imported => $imported,
90 alreadyindb => $alreadyindb,
91 alreadyinfarm => $alreadyinfarm,
92 notmarcrecord => $notmarcrecord,
93 total => $imported+$alreadyindb+$alreadyinfarm+$notmarcrecord,
98 output_html_with_http_headers $input, $cookie, $template->output;
102 # log cleared, as marcimport is (almost) rewritten from scratch.
104 # Revision 1.4 2007/03/09 15:14:47 tipaul
105 # rel_3_0 moved to HEAD
107 # Revision 1.1.2.4 2006/12/22 17:13:49 tipaul
108 # removing "management" permission, that is useless (replaced by tools & admin)
110 # Revision 1.1.2.3 2006/12/18 16:35:20 toins
111 # removing use HTML::Template from *.pl.
113 # Revision 1.1.2.2 2006/10/03 12:27:32 toins
114 # the script was written twice into the file !
116 # Revision 1.1.2.1 2006/09/26 13:42:54 toins
117 # fix wrong link to breeding.tmpl
119 # Revision 1.1 2006/02/24 11:52:38 hdl
120 # Adding tools directory template and scripts
121 # Changing barcodes, export and import and letters directory.
122 # Changing export script name (marc.pl) to export.pl
123 # Changing import script name (breeding.pl) to import.pl
125 # Revision 1.4 2005/05/04 08:52:13 tipaul
126 # synch'ing 2.2 and head
128 # Revision 1.3 2005/03/23 09:57:47 doxulting
129 # Adding a parameter to allow acces to people with management/tools flags