Bug 20287: Move fixup_cardnumber
[koha.git] / opac / opac-authoritiesdetail.pl
index b867012..438ef80 100755 (executable)
@@ -47,6 +47,7 @@ use CGI qw ( -utf8 );
 use MARC::Record;
 use C4::Koha;
 
+use Koha::Authorities;
 use Koha::Authority::Types;
 
 my $query = new CGI;
@@ -75,14 +76,15 @@ if ( ! $record ) {
     exit;
 }
 
-my $authtypecode = $record->authtypecode;
+my $authority = Koha::Authorities->find( $authid );
+my $authtypecode = $authority ? $authority->authtypecode : q{};
 
 if ($display_hierarchy){
     $template->{VARS}->{'displayhierarchy'} = $display_hierarchy;
     $template->{VARS}->{'loophierarchies'} = GenerateHierarchy($authid);
 }
 
-my $count = CountUsage($authid);
+my $count = $authority ? $authority->get_usage_count : 0;
 
 my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
 $template->param(