Normalizing s/On loan/Checked out/
[koha_fer] / C4 / XSLT.pm
index 52cb83c..aea933c 100644 (file)
@@ -56,7 +56,12 @@ sub transformMARCXML4XSLT {
     my $biblio = GetBiblioData($biblionumber);
     my $frameworkcode = GetFrameworkCode($biblionumber);
     my $tagslib = &GetMarcStructure(1,$frameworkcode);
-    my @fields = $record->fields();
+    my @fields;
+    # FIXME: wish there was a better way to handle exceptions
+    eval {
+        @fields = $record->fields();
+    };
+    if ($@) { warn "PROBLEM WITH RECORD"; next; }
     my $list_of_authvalues = getAuthorisedValues4MARCSubfields($frameworkcode);
     for my $authvalue (@$list_of_authvalues) {
         for my $field ( $record->field($authvalue->{tagfield}) ) {
@@ -101,13 +106,12 @@ sub getAuthorisedValues4MARCSubfields {
 }
 
 sub XSLTParse4Display {
-    my ($biblionumber,$type) = @_;
+    my ($biblionumber,$xslfile) = @_;
     # grab the XML, run it through our stylesheet, push it out to the browser
     my $record = transformMARCXML4XSLT($biblionumber);
     my $itemsxml  = buildKohaItemsNamespace($biblionumber);
     my $xmlrecord = $record->as_xml();
     $xmlrecord =~ s/\<\/record\>/$itemsxml\<\/record\>/;
-    my $xslfile = C4::Context->config('intranetdir')."/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPAC$type.xsl";
     my $parser = XML::LibXML->new();
     # don't die when you find &, >, etc
     $parser->recover_silently(1);
@@ -128,8 +132,22 @@ sub buildKohaItemsNamespace {
     my $xml;
     for my $item (@items) {
         my $status;
-        if ($item->{onloan}) {
-            $status = "On loan";
+        if ( $item->{notforloan} == -1 || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged}) {
+            if ( $item->{notforloan} == -1) {
+                $status = "On order";
+            }
+            if ($item->{onloan}) {
+                $status = "Checked out";
+            }
+            if ( $item->{wthdrawn}) {
+                $status = "Withdrawn";
+            }
+            if ($item->{itemlost}) {
+                $status = "Lost";
+            }
+            if ($item->{damaged}) {
+                $status = "Damaged"; 
+            }
         } else {
             $status = "available";
         }