|
Lines 1-37
Link Here
|
| 1 |
#!/usr/bin/perl |
|
|
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use C4::Context; |
| 5 |
use C4::AuthoritiesMarc; |
| 6 |
use utf8; |
| 7 |
use open qw[ :std :encoding(utf8) ]; |
| 8 |
use Koha::SearchEngine; |
| 9 |
use Koha::SearchEngine::Search; |
| 10 |
|
| 11 |
my $dbh=C4::Context->dbh; |
| 12 |
my $datatypes_query = $dbh->prepare(<<ENDSQL); |
| 13 |
SELECT authtypecode,authtypetext,auth_tag_to_report from auth_types; |
| 14 |
ENDSQL |
| 15 |
$datatypes_query->execute; |
| 16 |
my $datatypes=$datatypes_query->fetchall_arrayref({}); |
| 17 |
my %authtypes; |
| 18 |
map { $authtypes{$_->{'authtypecode'}}={"tag"=> $_->{'auth_tag_to_report'}, "lib"=> $_->{'authtypetext'}};} @$datatypes; |
| 19 |
my $data_query = $dbh->prepare(<<ENDSQL); |
| 20 |
SELECT authid, authtypecode from auth_header |
| 21 |
ENDSQL |
| 22 |
$data_query->execute; |
| 23 |
my $dataauthorities=$data_query->fetchall_arrayref({}); |
| 24 |
foreach my $authority (@$dataauthorities){ |
| 25 |
my $marcauthority=GetAuthority($authority->{'authid'}); |
| 26 |
my $query; |
| 27 |
$query= "an=".$authority->{'authid'}; |
| 28 |
# search for biblios mapped |
| 29 |
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); |
| 30 |
my ($err,undef,$used) = $searcher->simple_search_compat($query,0,1); |
| 31 |
if (defined $err) { |
| 32 |
$used = 0; |
| 33 |
} |
| 34 |
if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){ |
| 35 |
print qq("),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";),qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";$used\n); |
| 36 |
} |
| 37 |
} |
| 38 |
- |