Bug 12648: Fix conflict with bug 8096
[koha.git] / authorities / authorities-list.pl
blob2b15856dcfaf4b371a7c2c732799613f7ff64006
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) ];
9 my $dbh=C4::Context->dbh;
10 my $datatypes_query = $dbh->prepare(<<ENDSQL);
11 SELECT authtypecode,authtypetext,auth_tag_to_report from auth_types;
12 ENDSQL
13 $datatypes_query->execute;
14 my $datatypes=$datatypes_query->fetchall_arrayref({});
15 my %authtypes;
16 map { $authtypes{$_->{'authtypecode'}}={"tag"=> $_->{'auth_tag_to_report'}, "lib"=> $_->{'authtypetext'}};} @$datatypes;
17 my $data_query = $dbh->prepare(<<ENDSQL);
18 SELECT authid, authtypecode from auth_header
19 ENDSQL
20 $data_query->execute;
21 my $dataauthorities=$data_query->fetchall_arrayref({});
22 foreach my $authority (@$dataauthorities){
23 my $marcauthority=GetAuthority($authority->{'authid'});
24 my $query;
25 $query= "an=".$authority->{'authid'};
26 # search for biblios mapped
27 my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
28 if (defined $err) {
29 $used = 0;
31 if ($marcauthority && $marcauthority->field($authtypes{$authority->{'authtypecode'}}->{'tag'})){
32 print qq("),$marcauthority->field($authtypes{$authority->{'authtypecode'}}->{"tag"})->as_string(),qq(";),qq($authority->{'authid'};"),$authtypes{$authority->{'authtypecode'}}->{'lib'},qq(";$used\n);