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
44 use MARC::File::USMARC;
51 open (KC, "/etc/koha.conf");
55 if (/(.*)\s*=\s*(.*)/) {
58 # Clean up white space at beginning and end
63 $configfile{$variable}=$value;
66 my $includes=$configfile{'includes'};
67 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
69 # HTML colors for alternating lines
77 my $userid=$ENV{'REMOTE_USER'};
84 #print $input->header;
86 #print startmenu('acquisitions');
89 # Process input parameters
91 my $file=$input->param('file');
92 my $menu = $input->param('menu');
96 # TODO : parameter decoding and function call is quite dirty.
97 # should be rewritten...
100 if ($input->param('z3950queue')) {
101 AcceptZ3950Queue($dbh,$input);
104 if ($input->param('uploadmarc')) {
105 AcceptMarcUpload($dbh,$input)
108 if ($input->param('insertnewrecord')) {
109 # Add biblio item, and set up menu for adding item copies
110 my ($biblionumber,$biblioitemnumber)=AcceptBiblioitem($dbh,$input);
114 if ($input->param('newitem')) {
116 &AcceptItemCopy($dbh,$input);
122 ProcessFile($dbh,$input);
126 if ($menu eq 'z3950') { z3950menu($dbh,$input); last SWITCH; }
127 if ($menu eq 'uploadmarc') { uploadmarc($dbh); last SWITCH; }
128 if ($menu eq 'manual') { manual(); last SWITCH; }
136 # Process a MARC file : show list of records, of 1 record detail, if numrecord exists
138 # A MARC file has been specified; process it for review form
154 requireDBI($dbh,"ProcessFile");
156 # See if a particular result item was specified
157 my $numrecord = $input->param('numrecord');
159 ProcessRecord($dbh,$input,$numrecord);
161 # No result item specified, list results
162 ListFileRecords($dbh,$input);
166 # show 1 record from the MARC file
168 my ($dbh, $input,$numrecord) = @_;
176 if ($file=~/Z-(\d+)/) {
178 my $resultsid=$input->param('resultsid');
179 my $sth=$dbh->prepare("select results from z3950results where id=$resultsid");
181 ($data) = $sth->fetchrow;
183 my $sth=$dbh->prepare("select marc from uploadedmarc where id=$file");
185 ($data) = $sth->fetchrow;
188 my $file=MARC::File::USMARC->indata ($data);
190 for (my $i==1;$i<$numrecord;$i++) {
191 $record = $file->next;
194 $oldkoha=MARCmarc2koha($dbh,$record);
196 my $templatebase="marcimport/marcimportdetail.tmpl";
197 my $theme=picktemplate($includes, $templatebase);
198 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
199 $oldkoha->{additionalauthors} =~ s/ \| /\n/g;
200 $oldkoha =~ s/\|/\n/g;
201 $template->param($oldkoha);
202 #---- build MARC array for template
204 my $tagmeaning = &MARCgettagslib($dbh,1);
205 my @fields = $record->fields();
208 foreach my $field (@fields) {
209 my @subfields=$field->subfields();
210 foreach my $subfieldcount (0..$#subfields) {
212 if ($lasttag== $field->tag()) {
213 $row_data{tagid} = "";
215 $row_data{tagid} = $field->tag();
217 $row_data{subfield} = $subfields[$subfieldcount][0];
218 $row_data{tagmean} = $tagmeaning->{$field->tag()}->{$subfields[$subfieldcount][0]};
219 $row_data{tagvalue}= $subfields[$subfieldcount][1];
222 $row_data{color} = $lc1;
225 $row_data{color} = $lc2;
227 push(@loop,\%row_data);
228 $lasttag=$field->tag();
231 $template->param(MARC => \@loop);
232 $template->param(numrecord => $numrecord);
233 $template->param(file => $data);
234 print "Content-Type: text/html\n\n", $template->output;
237 # lists all records from the MARC file
238 sub ListFileRecords {
250 $data, # records in MARC file format
260 my ($numrecords,$resultsid,$data,$startdate,$enddate);
262 requireDBI($dbh,"ListFileRecords");
264 my $templatebase="marcimport/ListFileRecords.tmpl";
265 my $theme=picktemplate($includes, $templatebase);
266 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
268 # File can be z3950 search query or uploaded MARC data
271 if (not $file=~/Z-(\d+)/) {
272 # This is a Marc upload
273 $sth=$dbh->prepare("select marc,name from uploadedmarc where id=$file");
275 ($data, $name) = $sth->fetchrow;
276 $template->param(IS_MARC => 1);
277 $template->param(recordsource => $name);
280 if ($file=~/Z-(\d+)/) {
281 # This is a z3950 search
282 $template->param(IS_Z3950 =>1);
283 my $id=$1; # search query id number
285 my $starttimer=time();
288 select z3950results.numrecords,z3950results.id,z3950results.results,
289 z3950results.startdate,z3950results.enddate,server
290 from z3950queue left outer join z3950results
291 on z3950queue.id=z3950results.queryid
292 where z3950queue.id=?
297 # loop through all servers in search results
298 while ( ($numrecords,$resultsid,$data,
299 $startdate,$enddate,$serverstring) = $sth->fetchrow ) {
300 my ($srvid, $server, $database, $auth) = split(/\//, $serverstring, 4);
302 my $srvname=&z3950servername($dbh,$srvid,"$server/$database");
303 $template->parram(srvid => $srvid);
304 $template->param(srvname => $srvname);
306 my $startrecord=$input->param("ST-$srvid");
307 ($startrecord) || ($startrecord='0');
308 my $serverplaceholder='';
309 foreach ($input->param) {
310 (next) unless (/ST-(.+)/);
312 (next) if ($serverid eq $srvid);
313 my $place=$input->param("ST-$serverid");
314 $serverplaceholder.="\&ST-$serverid=$place";
317 $template->param(HAS_NUMRECORDS => 1);
320 if ($startrecord>0) {
321 $previous="<a href=".$ENV{'SCRIPT_NAME'}."?file=Z-$id&menu=z3950$serverplaceholder\&ST-$srvid=".($startrecord-10)."#SERVER-$srvid>Previous</a>";
324 $highest=$startrecord+10;
325 ($highest>$numrecords) && ($highest=$numrecords);
326 if ($numrecords>$startrecord+10) {
327 $next="<a href=".$ENV{'SCRIPT_NAME'}."?file=Z-$id&menu=z3950$serverplaceholder\&ST-$srvid=$highest#SERVER-$srvid>Next</a>";
329 $template->param(startrecord => $startrecord+1);
330 $template->param(highest => $highest);
331 $template->param(numrecords => $numrecords);
332 $template->param(previous => $previous);
333 $template->param(next => $next);
334 my $stj=$dbh->prepare("update z3950results
335 set highestseen=? where id=?");
336 $stj->execute($startrecord+10,$resultsid);
340 $template->param(PENDING => 1);
341 } elsif ($enddate == 0) {
343 my $elapsed=$now-$startdate;
346 $elapsedtime=sprintf "%d minutes",($elapsed/60);
348 $elapsedtime=sprintf "%d seconds",$elapsed;
350 $template->param(elapsedtime => $elapsedtime);
351 } elsif ($numrecords) {
353 my $z3950file=MARC::File::USMARC->indata ($data);
354 while (my $record=$z3950file->next) {
355 my $oldkoha = MARCmarc2koha($dbh,$record);
356 my %row = ResultRecordLink($dbh,$oldkoha,$resultsid);
359 $template->param(LINES => \@loop);
364 my $elapsed=time()-$starttimer;
365 # print "<hr>It took $elapsed seconds to process this page.\n";
367 $template->param(NO_RECORDS =>1);
368 $template->param(id => $id);
373 # This is an uploaded Marc record
376 my $MARCfile = MARC::File::USMARC->indata($data);
378 while (my $record=$MARCfile->next) {
380 my $oldkoha = MARCmarc2koha($dbh,$record);
381 my %row = ResultRecordLink($dbh,$oldkoha,'',$num);
384 $template->param(LINES => \@loop);
385 } # if z3950 or marc upload
386 print "Content-Type: text/html\n\n", $template->output;
387 } # sub ListFileRecords
391 sub ResultRecordLink {
393 my ($dbh,$oldkoha,$resultsid, $num)=@_; # input
396 $bib, # hash ref to named fields
397 $searchfield, $searchvalue,
402 requireDBI($dbh,"PrintResultRecordLink");
404 # $bib=extractmarcfields($record);
406 $sth=$dbh->prepare("select *
408 where (isbn=? and isbn!='') or (issn=? and issn!='') or (lccn=? and lccn!='') ");
409 $sth->execute($oldkoha->{isbn},$oldkoha->{issn},$oldkoha->{lccn});
415 ($oldkoha->{author}) && ($oldkoha->{author}="by $oldkoha->{author}");
418 foreach $fieldname ( "controlnumber", "lccn", "issn", "isbn") {
419 if ( defined $oldkoha->{$fieldname} && $oldkoha->{$fieldname} ) {
420 $searchfield=$fieldname;
421 $searchvalue=$oldkoha->{$fieldname};
422 } # if defined fieldname
424 if ( $searchfield ) {
425 $row{SCRIPT_NAME} = $ENV{'SCRIPT_NAME'};
426 $row{donetext} = $donetext;
428 # $row{resultsid} = $resultsid;
429 # $row{searchfield} = $searchfield;
430 # $row{searchvalue} = $searchvalue;
431 $row{numrecord} = $num;
432 $row{title} = $oldkoha->{title};
433 $row{author} = $oldkoha->{author};
435 $row{title} = "Error: Problem with <br>$bib->{title} $bib->{author}<br>";
438 } # sub PrintResultRecordLink
440 #---------------------------------
456 $resultstatus, $statuscolor,
457 $id, $term, $type, $done,
458 $startdate, $enddate, $servers,
462 requireDBI($dbh,"z3950menu");
464 print "<a href=$ENV{'SCRIPT_NAME'}>Main Menu</a><hr>\n";
465 print "<table border=0><tr><td valign=top>\n";
466 print "<h2>Results of Z39.50 searches</h2>\n";
467 print "<a href=$ENV{'SCRIPT_NAME'}?menu=z3950>Refresh</a><br>\n" .
470 # Check queued queries
471 $sth=$dbh->prepare("select id,term,type,done,
472 startdate,enddate,servers
477 while ( ($id, $term, $type, $done,
478 $startdate, $enddate, $servers) = $sth->fetchrow) {
484 # See if query produced results
485 $sti=$dbh->prepare("select id,server,startdate,enddate,numrecords,results
493 while (my ($r_id,$r_server,$r_startdate,$r_enddate,$r_numrecords,$r_marcdata)
496 # It hasn't finished yet
499 # It finished, see how long it took.
500 if ($r_enddate>$realenddate) {
501 $realenddate=$r_enddate;
503 # Snag any title from the results if there were any
504 if ( ! $title && $r_marcdata ) {
505 ($record)=parsemarcfileformat($r_marcdata);
506 $bib=extractmarcfields($record);
507 if ( $bib->{title} ) { $title=$bib->{title} };
511 $totalrecords+=$r_numrecords;
515 $elapsed=time()-$startdate;
516 $resultstatus="Processing...";
519 $elapsed=$realenddate-$startdate;
520 $resultstatus="Done.";
521 $statuscolor="black";
525 $elapsedtime=sprintf "%d minutes",($elapsed/60);
527 $elapsedtime=sprintf "%d seconds",$elapsed;
530 $totalrecords="$totalrecords found.";
534 print "<li><a href=$ENV{'SCRIPT_NAME'}?file=Z-$id&menu=$menu>".
536 "<font size=-1 color=$statuscolor>$resultstatus $totalrecords " .
537 "($elapsedtime) $title </font><br>\n";
539 print "<li><a href=$ENV{'SCRIPT_NAME'}?file=Z-$id&menu=$menu>
540 $type=$term</a> <font size=-1>Pending</font><br>\n";
543 print "</ul> </td>\n";
544 # End of query listing
546 #------------------------------
548 print "<td valign=top width=30%>\n";
550 my $sth=$dbh->prepare("select id,name,checked
555 while (my ($id, $name, $checked) = $sth->fetchrow) {
556 ($checked) ? ($checked='checked') : ($checked='');
557 $serverlist.="<input type=checkbox name=S-$id $checked> $name<br>\n";
559 $serverlist.="<input type=checkbox name=S-MAN> <input name=manualz3950server size=25 value=otherserver:210/DATABASE>\n";
561 my $rand=rand(1000000000);
563 <form action=$ENV{'SCRIPT_NAME'} method=GET>
564 <input type=hidden name=z3950queue value=1>
565 <input type=hidden name=menu value=$menu>
567 <input type=hidden name=test value=testvalue>
568 <input type=hidden name=rand value=$rand>
569 <table border=1 bgcolor=#dddddd>
570 <tr><th bgcolor=#bbbbbb colspan=2>Search for MARC records</th></tr>
571 <tr><td>Query Term</td><td><input name=query></td></tr>
572 <tr><td colspan=2 align=center>
573 <input type=radio name=type value=isbn checked> ISBN
574 <input type=radio name=type value=lccn > LCCN<br>
575 <input type=radio name=type value=author > Author
576 <input type=radio name=type value=title > Title
577 <input type=radio name=type value=keyword > Keyword</td></tr>
578 <tr><td colspan=2> $serverlist </td></tr>
579 <tr><td colspan=2 align=center> <input type=submit> </td></tr>
584 print "</td></tr></table>\n";
586 #---------------------------------
592 requireDBI($dbh,"uploadmarc");
594 my $templatebase="marcimport/uploadmarc.tmpl";
595 my $theme=picktemplate($includes, $templatebase);
596 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
597 $template->param(SCRIPT_NAME => $ENV{'SCRIPT_NAME'});
598 # print "<a href=$ENV{'SCRIPT_NAME'}>Main Menu</a><hr>\n";
599 my $sth=$dbh->prepare("select id,name from uploadedmarc");
601 # print "<h2>Select a set of MARC records</h2>\n<ul>";
603 while (my ($id, $name) = $sth->fetchrow) {
607 push(@marc_loop, \%row);
608 # print "<li><a href=$ENV{'SCRIPT_NAME'}?file=$id&menu=$menu>$name</a><br>\n";
610 $template->param(marc => \@marc_loop);
611 print "Content-Type: text/html\n\n", $template->output;
620 my $templatebase="marcimport/mainmenu.tmpl";
621 my $theme=picktemplate($includes, $templatebase);
622 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
623 $template->param(SCRIPT_NAME => $ENV{'SCRIPT_NAME'});
624 print "Content-Type: text/html\n\n", $template->output;
627 #----------------------------
628 # Accept form results to add query to z3950 queue
629 sub AcceptZ3950Queue {
641 requireDBI($dbh,"AcceptZ3950Queue");
643 my $query=$input->param('query');
646 if ($input->param('type') eq 'isbn') {
647 $isbngood=checkvalidisbn($query);
650 foreach ($input->param) {
653 if ($server eq 'MAN') {
654 push @serverlist, "MAN/".$input->param('manualz3950server')."//"
657 push @serverlist, $server;
662 $error=addz3950queue($dbh,$input->param('query'), $input->param('type'),
663 $input->param('rand'), @serverlist);
666 <table border=1 cellpadding=5 cellspacing=0 align=center>
667 <tr><td bgcolor=#99cc33 background=/images/background-acq.gif colspan=2><font color=red><b>Error</b></font></td></tr>
671 if ( $error =~ /daemon/i ) {
673 There is a launcher for the Z39.50 client daemon in your intranet installation<br>
674 directory under <b>./scripts/z3950daemon/z3950-daemon-launch.sh</b>. This<br>
675 script should be run as root, and it will start up the program running with the<br>
676 privileges of your apache user. Ideally, this script should be started from a<br>
677 system init directory so that is running after the machine starts up.
690 print "<font color=red size=+1>$query is not a valid ISBN
693 } # sub AcceptZ3950Queue
695 #---------------------------------------------
696 sub AcceptMarcUpload {
703 requireDBI($dbh,"AcceptMarcUpload");
705 my $name=$input->param('name');
706 my $data=$input->param('uploadmarc');
709 ($name) || ($name=$data);
710 if (length($data)>0) {
715 my $q_marcrecord=$dbh->quote($marcrecord);
716 my $q_name=$dbh->quote($name);
717 my $sth=$dbh->prepare("insert into uploadedmarc
719 values ($q_marcrecord, $q_name)");
721 } # sub AcceptMarcUpload
723 #-------------------------------------------
724 sub AcceptBiblioitem {
732 my $biblioitemnumber=0;
736 requireDBI($dbh,"AcceptBiblioitem");
738 # my $isbn=$input->param('isbn');
739 # my $issn=$input->param('issn');
740 # my $lccn=$input->param('lccn');
741 # my $q_origisbn=$dbh->quote($input->param('origisbn'));
742 # my $q_origissn=$dbh->quote($input->param('origissn'));
743 # my $q_origlccn=$dbh->quote($input->param('origlccn'));
744 # my $q_origcontrolnumber=$dbh->quote($input->param('origcontrolnumber'));
745 my $title=$input->param('title');
747 # my $q_isbn=$dbh->quote((($isbn) || ('NIL')));
748 # my $q_issn=$dbh->quote((($issn) || ('NIL')));
749 # my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
750 my $file= MARC::File::USMARC->indata($input->param('file'));
751 my $numrecord = $input->param('numrecord');
753 for (my $i==1;$i<$numrecord;$i++) {
757 print STDERR "Error in marcimport.pl/Acceptbiblioitem : numrecord not defined\n";
758 print "Error in marcimport.pl/Acceptbiblioitem : numrecord not defined : contact administrator\n";
760 my $templatebase="marcimport/AcceptBiblioitem.tmpl";
761 my $theme=picktemplate($includes, $templatebase);
762 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
764 my $oldkoha = MARCmarc2koha($dbh,$record);
765 # See if it already exists
766 my $sth=$dbh->prepare("select biblionumber,biblioitemnumber
768 where isbn=? or issn=? or lccn=?");
769 $sth->execute($oldkoha->{isbn},$oldkoha->{issn},$oldkoha->{lccn});
773 ($biblionumber, $biblioitemnumber) = $sth->fetchrow;
774 $template->param(title => $title);
775 $template->param(biblionumber => $biblionumber);
776 $template->param(biblioitemnumber => $biblioitemnumber);
777 $template->param(BIBLIO_EXISTS => 1);
780 # It doesn't exist; add it.
786 # convert to upper case and split on lines
787 my $subjectheadings=$input->param('subject');
788 my @subjectheadings=split(/[\r\n]+/,$subjectheadings);
790 my $additionalauthors=$input->param('additionalauthors');
791 my @additionalauthors=split(/[\r\n]+|\|/,uc($additionalauthors));
793 # Use individual assignments to hash buckets, in case
794 # any of the input parameters are empty or don't exist
795 $biblio{title} =$input->param('title');
796 $biblio{author} =$input->param('author');
797 $biblio{copyright} =$input->param('copyrightdate');
798 $biblio{seriestitle} =$input->param('seriestitle');
799 $biblio{notes} =$input->param('notes');
800 $biblio{abstract} =$input->param('abstract');
801 $biblio{subtitle} =$input->param('subtitle');
803 $biblioitem{volume} =$input->param('volume');
804 $biblioitem{number} =$input->param('number');
805 $biblioitem{itemtype} =$input->param('itemtype');
806 $biblioitem{isbn} =$input->param('isbn');
807 $biblioitem{issn} =$input->param('issn');
808 $biblioitem{dewey} =$input->param('dewey');
809 $biblioitem{subclass} =$input->param('subclass');
810 $biblioitem{publicationyear} =$input->param('publicationyear');
811 $biblioitem{publishercode} =$input->param('publishercode');
812 $biblioitem{volumedate} =$input->param('volumedate');
813 $biblioitem{volumeddesc} =$input->param('volumeddesc');
814 $biblioitem{illus} =$input->param('illustrator');
815 $biblioitem{pages} =$input->param('pages');
816 $biblioitem{notes} =$input->param('notes');
817 $biblioitem{size} =$input->param('size');
818 $biblioitem{place} =$input->param('place');
819 $biblioitem{lccn} =$input->param('lccn');
820 $biblioitem{marc} =$input->param('marc');
821 # print STDERR $record->as_formatted();
823 ($biblionumber, $biblioitemnumber, $error)=
824 ALLnewbiblio($dbh,$record,\%biblio,\%biblioitem);
826 # newcompletebiblioitem($dbh,
830 # \@additionalauthors
834 print "<H2>Error adding biblio item</H2> $error\n";
836 $template->param(title => $title);
837 $template->param(biblionumber => $biblionumber);
838 $template->param(biblioitemnumber => $biblioitemnumber);
839 $template->param(BIBLIO_CREATE => 1);
844 # Get next barcode, or pick random one if none exist yet
845 $sth=$dbh->prepare("select max(barcode) from items");
847 ($barcode) = $sth->fetchrow;
850 $barcode=int(rand()*1000000);
852 my $branchselect=getkeytableselectoptions(
853 $dbh, 'branches', 'branchcode', 'branchname', 0);
854 $template->param(barcode => $barcode);
855 $template->param(branchselect => $branchselect);
856 print "Content-Type: text/html\n\n", $template->output;
860 #---------------------------------------
861 # Accept form data to add an item copy
864 my ( $dbh, $input )=@_;
866 my $templatebase="marcimport/AcceptItemCopy.tmpl";
867 my $theme=picktemplate($includes, $templatebase);
868 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
872 requireDBI($dbh,"AcceptItemCopy");
874 my $barcode=$input->param('barcode');
875 my $replacementprice=($input->param('replacementprice') || 0);
877 my $sth=$dbh->prepare("select barcode
880 $sth->execute($barcode);
882 $template->param(BARCODE_EXISTS => 1);
883 $template->param(barcode => $barcode);
885 # Insert new item into database
886 $error=&ALLnewitem($dbh,
887 { biblionumber=> $input->param('biblionumber'),
888 biblioitemnumber=> $input->param('biblioitemnumber'),
889 itemnotes=> $input->param('notes'),
890 homebranch=> $input->param('homebranch'),
891 replacementprice=> $replacementprice,
896 $template->param(ITEM_ERROR => 1);
897 $template->param(error => $error);
899 $template->param(ITEM_CREATED => 1);
900 $template->param(barcode => $barcode);
902 } # if barcode exists
903 print "Content-Type: text/html\n\n", $template->output;
904 } # sub AcceptItemCopy
906 #---------------------------------------
912 $fields, # list ref to MARC fields
923 $subfieldcode,$subfieldvalue,
928 #-----------------------------------------
930 $marctext="<table border=0 cellspacing=1>
931 <tr><th colspan=4 background=/images/background-acq.gif>
935 foreach $field ( @$fields ) {
937 # Swap colors on alternating lines
938 ($color eq $lc1) ? ($color=$lc2) : ($color=$lc1);
940 $tag=$field->{'tag'};
941 $label=taglabel($tag);
943 if ( $tag eq 'LDR' ) {
947 print "<pre>Format tag=$tag label=$label</pre>\n" if $debug;
949 $marctext.="<tr><td bgcolor=$color valign=top>$label</td> \n" .
950 "<td bgcolor=$color valign=top>$tag</td> \n";
952 $indicator=$field->{'indicator'};
953 $indicator=~s/ +$//; # drop trailing blanks
955 # Third table column has indicator if it is short.
956 # Fourth column has embedded table of subfields, and indicator
957 # if it is long (leader or fixed-position fields)
959 print "<pre>Format indicator=$indicator" .
960 " length=" . length( $indicator ) . "</pre>\n" if $debug;
961 if ( length( $indicator <= 3 ) ) {
962 $marctext.="<td bgcolor=$color valign=top><pre>" .
963 "$indicator</pre></td>" .
964 "<td bgcolor=$color valign=top>" ;
966 $marctext.="<td bgcolor=$color valign=top></td>" .
967 "<td bgcolor=$color valign=top>" .
972 if ( $field->{'subfields'} ) {
973 # start another table for subfields
974 $marctext.= "<table border=0 cellspacing=2>\n";
975 foreach $subfieldcode ( sort( keys %{ $field->{'subfields'} } )) {
976 $subfieldvalue=$field->{'subfields'}->{$subfieldcode};
977 if (ref($subfieldvalue) eq 'ARRAY' ) {
978 # if it's a pointer to array, get all the values
979 @values=@{$subfieldvalue};
981 # otherwise get the one value
982 @values=( $subfieldvalue );
983 } # if subfield array
984 foreach $value ( @values ) {
985 $marctext.="<tr><td><strong>$subfieldcode</strong></td>" .
986 "<td>$value</td></tr>\n";
989 $marctext.="</table>\n";
991 # End of indicator and subfields column
992 $marctext.="</td>\n";
995 $marctext.="</tr>\n";
999 $marctext.="</table>\n";
1003 } # sub FormatMarcText
1008 # Revision 1.13 2002/08/14 18:12:52 tonnesen
1009 # Added copyright statement to all .pl and .pm files
1011 # Revision 1.12 2002/07/24 16:24:20 tipaul
1012 # Now, the acqui.simple system...
1013 # marcimport.pl has been almost completly rewritten, so LOT OF BUGS TO COME !!! You've been warned. It seems to work, but...
1015 # As with my former messages, nothing seems to have been changed... but ...
1016 # * marcimport now uses HTML::Template.
1017 # * marcimport now uses MARC::Record. that means that when you import a record, the old-DB is populated with the data as in version 1.2, but the MARC-DB part is filled with full MARC::Record.
1020 # to get correct response times, you MUST add an index on isbn, issn and lccn rows in biblioitem table. Note this should be done in 1.2 too...
1024 # acqui.simple manage biblio, biblioitems and items tables quite properly. Normal acquisition system manages biblio, biblioitems BUT NOT items. That will be done in the near future...
1025 # </IMPORTANT NOTE2>
1028 # * bug tracking, of course... Surely a dozen of dozens...
1029 # * LOT of developpments, i'll surely write a mail to koha-devel tomorrow (as it's time for dinner in France, and i plan to play NeverwinterNights after dinner ;-) ...
1031 # Revision 1.6.2.32 2002/06/29 17:33:47 amillar
1032 # Allow DEFAULT as input to addz3950search.
1033 # Check for existence of pid file (cat crashed otherwise).
1034 # Return error messages in addz3950search.
1036 # Revision 1.6.2.31 2002/06/28 18:50:46 tonnesen
1037 # Got rid of white text on black, replaced with black on background-acq.gif
1039 # Revision 1.6.2.30 2002/06/28 18:07:27 tonnesen
1040 # marcimport.pl will print an error message if it can not signal the
1041 # processz3950queue program. The message contains instructions for starting the
1044 # Revision 1.6.2.29 2002/06/27 18:35:01 tonnesen
1045 # $deweyinput was always defined (it's an HTML input field). Check against
1046 # $bib->{dewey} instead.
1048 # Revision 1.6.2.28 2002/06/27 17:41:26 tonnesen
1049 # Applying patch from Matt Kraai to pick F or NF based on presense of a dewey
1050 # number when adding a book via marcimport.pl
1052 # Revision 1.6.2.27 2002/06/26 15:52:55 amillar
1053 # Fix display of marc tag labels and indicators
1055 # Revision 1.6.2.26 2002/06/26 14:28:35 amillar
1056 # Removed subroutines now existing in modules: extractmarcfields,
1057 # parsemarcfileformat, addz3950queue, getkeytableselectoptions