Minor Fix : IndependentBranchPatron misspelling
[koha.git] / authorities / detail.pl
index e2849ba..9096d1c 100755 (executable)
@@ -39,7 +39,7 @@ parameters tables.
 
 
 use strict;
-require Exporter;
+
 use C4::AuthoritiesMarc;
 use C4::Auth;
 use C4::Context;
@@ -51,41 +51,6 @@ use C4::Koha;
 # use C4::Catalogue;
 
 our ($tagslib);
-=item find_value
-
-    ($indicators, $value) = find_value($tag, $subfield, $record,$encoding);
-
-Find the given $subfield in the given $tag in the given
-MARC::Record $record.  If the subfield is found, returns
-the (indicators, value) pair; otherwise, (undef, undef) is
-returned.
-
-=cut
-
-sub find_value {
-  my ($tagfield,$insubfield,$record,$encoding) = @_;
-  my @result;
-  my $indicator;
-  if ($tagfield <10) {
-    if ($record->field($tagfield)) {
-      push @result, $record->field($tagfield)->data();
-    } else {
-      push @result,"";
-    }
-  } else {
-    foreach my $field ($record->field($tagfield)) {
-      my @subfields = $field->subfields();
-      foreach my $subfield (@subfields) {
-        if (@$subfield[0] eq $insubfield) {
-        push @result,@$subfield[1];
-              $indicator = $field->indicator(1).$field->indicator(2);
-        }
-      }
-    }
-  }
-  return($indicator,@result);
-}
-
 
 =item build_authorized_values_list
 
@@ -236,7 +201,7 @@ sub create_input {
         # opening plugin. Just check wether we are on a developper computer on a production one
         # (the cgidir differs)
         my $cgidir = C4::Context->intranetdir . "/cgi-bin/cataloguing/value_builder";
-        unless ( opendir( DIR, "$cgidir" ) ) {
+        unless (-r $cgidir and -d $cgidir) {
             $cgidir = C4::Context->intranetdir . "/cataloguing/value_builder";
         }
         my $plugin = $cgidir . "/" . $tagslib->{$tag}->{$subfield}->{'value_builder'};
@@ -370,7 +335,7 @@ sub build_tabs ($$$$$) {
                     @fields = $record->field($tag);
                 }
                 else {
-                  push @fields, $record->leader(); # if tag == 000
+                  push @fields, MARC::Field->new('000', $record->leader()); # if tag == 000
                 }
                 # loop through each field
                 foreach my $field (@fields) {
@@ -419,7 +384,10 @@ sub build_tabs ($$$$$) {
                     }
                     if ($#subfields_data>=0) {
                       my %tag_data;
-                      $tag_data{tag}=$field->tag().' - '. $tagslib->{$field->tag()}->{lib};
+                      $tag_data{tag}=$field->tag(). ' '  
+                                     . C4::Koha::display_marc_indicators($field) 
+                                     . ' - '
+                                     . $tagslib->{$field->tag()}->{lib};
                       $tag_data{subfield} = \@subfields_data;
                       push (@loop_data, \%tag_data);
                     }
@@ -427,7 +395,6 @@ sub build_tabs ($$$$$) {
               }
             }
             if ( $#loop_data >= 0 ) {
-                warn "pushing : $tabloop = ".Data::Dumper::Dumper(@loop_data);
                 push @BIG_LOOP, {
                     number    => $tabloop,
                     innerloop => \@loop_data,
@@ -509,7 +476,7 @@ my $tag;
 
 my $authtypes = getauthtypes;
 my @authtypesloop;
-foreach my $thisauthtype (keys %$authtypes) {
+foreach my $thisauthtype (sort { $authtypes->{$b} cmp $authtypes->{$a} } keys %$authtypes) {
        my $selected = 1 if $thisauthtype eq $authtypecode;
        my %row =(value => $thisauthtype,
                                selected => $selected,