1st commit to go to zebra.
[koha-ffzg.git] / ISBDdetail.pl
index 073ffe2..831fe63 100755 (executable)
@@ -53,14 +53,11 @@ my $query=new CGI;
 
 my $dbh=C4::Context->dbh;
 
-my $biblionumber=$query->param('bib');
-my $bibid = $query->param('bibid');
-$bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
-$biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
-my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
+my $biblionumber=$query->param('biblionumber');
+my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
 my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
 
-my $record =MARCgetbiblio($dbh,$bibid);
+my $record =MARCgetbiblio($dbh,$biblionumber);
 # open template
 my ($template, $loggedinuser, $cookie)
                = get_template_and_user({template_name => "catalogue/ISBDdetail.tmpl",
@@ -99,7 +96,7 @@ my $res;
                                        my @subf = $field->subfields;
                                        for my $i (0..$#subf) {
                                                my $subfieldcode = $subf[$i][0];
-                                               my $subfieldvalue = $subf[$i][1];
+                                               my $subfieldvalue = get_authorised_value_desc($tag, $subf[$i][0], $subf[$i][1], '', $dbh);;
                                                my $tagsubf = $tag.$subfieldcode;
                                                $calculated =~ s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
                                        }
@@ -130,3 +127,28 @@ $template->param(ISBD => $res,
 
 output_html_with_http_headers $query, $cookie, $template->output;
 
+sub get_authorised_value_desc ($$$$$) {
+   my($tag, $subfield, $value, $framework, $dbh) = @_;
+
+   #---- branch
+    if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
+       return getbranchname($value);
+    }
+
+   #---- itemtypes
+   if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
+       return ItemType($value);
+    }
+
+   #---- "true" authorized value
+   my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
+
+   if ($category ne "") {
+       my $sth = $dbh->prepare("select lib from authorised_values where category = ? and authorised_value = ?");
+       $sth->execute($category, $value);
+       my $data = $sth->fetchrow_hashref;
+       return $data->{'lib'};
+   } else {
+       return $value; # if nothing is found return the original value
+   }
+}