diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 9895e195ea..eb2e827248 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -207,16 +207,18 @@ sub SearchAuthorities { # also store main entry MARC tag, to extract it at end of search my $mainentrytag; ##first set the authtype search and may be multiple authorities - my $n=0; - my @authtypecode; - my @auths=split / /,$authtypecode ; - foreach my $auth (@auths){ - $query .=" \@attr 1=authtype \@attr 5=100 ".$auth; ##No truncation on authtype - push @authtypecode ,$auth; - $n++; - } - if ($n>1){ - while ($n>1){$query= "\@or ".$query;$n--;} + if ($authtypecode) { + my $n=0; + my @authtypecode; + my @auths=split / /,$authtypecode ; + foreach my $auth (@auths){ + $query .=" \@attr 1=authtype \@attr 5=100 ".$auth; ##No truncation on authtype + push @authtypecode ,$auth; + $n++; + } + if ($n>1){ + while ($n>1){$query= "\@or ".$query;$n--;} + } } my $dosearch; diff --git a/C4/Context.pm b/C4/Context.pm index 9ce6c74914..4a81dfa4ab 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -1009,7 +1009,7 @@ set_userenv is called in Auth.pm #' sub set_userenv { my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter)= @_; - my $var=$context->{"activeuser"}; + my $var=$context->{"activeuser"} || ''; my $cell = { "number" => $usernum, "id" => $userid, diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 5149f9bff2..50b10cf4a3 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -205,7 +205,7 @@ sub AddImportBatch { my (@fields, @vals); foreach (qw( matcher_id template_id branchcode overlay_action nomatch_action item_action - import_status batch_type file_name comments )) { + import_status batch_type file_name comments record_type )) { if (exists $params->{$_}) { push @fields, $_; push @vals, $params->{$_}; @@ -328,7 +328,7 @@ sub BatchStageMarcRecords { my $branch_code = shift; my $parse_items = shift; my $leave_as_staging = shift; - + # optional callback to monitor status # of job my $progress_interval = 0; @@ -346,6 +346,7 @@ sub BatchStageMarcRecords { batch_type => 'batch', file_name => $file_name, comments => $comments, + record_type => $record_type, } ); if ($parse_items) { SetImportBatchItemAction($batch_id, 'always_add'); @@ -584,7 +585,7 @@ sub BatchCommitRecords { $num_items_errored += $bib_items_errored; } } else { - my $authid = AddAuthority($marc_record, undef, GuessAuthTypeCode($marc_record)); + $recordid = AddAuthority($marc_record, undef, GuessAuthTypeCode($marc_record)); $query = "UPDATE import_auths SET matched_authid = ? WHERE import_record_id = ?"; } my $sth = $dbh->prepare_cached($query); @@ -616,7 +617,7 @@ sub BatchCommitRecords { $num_items_errored += $bib_items_errored; } } else { - my $oldxml = GetAuthorityXML($recordid); + $oldxml = GetAuthorityXML($recordid); ModAuthority($recordid, $marc_record, GuessAuthTypeCode($marc_record)); $query = "UPDATE import_auths SET matched_authid = ? WHERE import_record_id = ?"; @@ -1350,9 +1351,9 @@ sub _add_auth_fields { if ($marc_record->field('001')) { $controlnumber = $marc_record->field('001')->data(); } - my $authorized_heading = GetAuthorizedHeading($marc_record); + my $authorized_heading = GetAuthorizedHeading({ record => $marc_record }); my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("INSERT INTO import_auths (import_record_id, controlnumber, authorized_heading) VALUES (?, ?, ?)"); + my $sth = $dbh->prepare("INSERT INTO import_auths (import_record_id, control_number, authorized_heading) VALUES (?, ?, ?)"); $sth->execute($import_record_id, $controlnumber, $authorized_heading); $sth->finish(); } @@ -1403,8 +1404,7 @@ sub _update_batch_record_counts { num_records = ( SELECT COUNT(*) FROM import_records - WHERE import_batch_id = import_batches.import_batch_id - AND record_type = 'biblio'), + WHERE import_batch_id = import_batches.import_batch_id), num_items = ( SELECT COUNT(*) FROM import_records diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e430d2cf95..53bc692325 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -924,7 +924,7 @@ CREATE TABLE `import_auths` ( `original_source` varchar(25) default NULL, CONSTRAINT `import_auths_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE, - KEY `matched_authid` (`matched_authid`), + KEY `matched_authid` (`matched_authid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt index 2a9deda8cc..8265b50a0f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -1,3 +1,22 @@ +[% BLOCK final_match_link %] + [% IF ( record.record_type == 'biblio' ) %] + [% record.final_match_id %] + [% ELSIF ( record.record_type == 'auth' ) %] + [% record.final_match_id %] + [% END %] +[% END %] +[% BLOCK match_link %] + [% IF ( record_lis.match_id ) %] +