From 0e05e9353adca221446b66a38bab4f200591d666 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Thu, 21 Nov 2019 17:58:01 +0200
Subject: [PATCH] Improve display of electronic items from Alma. (#1509)

---
 module/VuFind/src/VuFind/ILS/Driver/Alma.php  | 23 +++++++++++++++----
 .../RecordTab/holdingsils/electronic.phtml    | 10 ++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/module/VuFind/src/VuFind/ILS/Driver/Alma.php b/module/VuFind/src/VuFind/ILS/Driver/Alma.php
index 6e9f5a4d687..ed1448f4dce 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/Alma.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/Alma.php
@@ -1722,15 +1722,30 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
                         $avail = $this->getMarcSubfield($field, 'e');
                         $item = $tmpl;
                         $item['availability'] = strtolower($avail) === 'available';
-                        $item['location'] = $this->getMarcSubfield($field, 'm');
-                        // Using subfield 't' ('Interface name') as callnumber
+                        // Use the following subfields for location:
+                        // m (Collection name)
+                        // i (Available for library)
+                        // d (Available for library)
+                        // b (Available for library)
+                        $location = [
+                            $this->getMarcSubfield($field, 'm') ?: 'Get full text'
+                        ];
+                        foreach (['i', 'd', 'b'] as $code) {
+                            if ($content = $this->getMarcSubfield($field, $code)) {
+                                $location[] = $content;
+                            }
+                        }
+                        $item['location'] = implode(' - ', $location);
                         $item['callnumber'] = $this->getMarcSubfield($field, 't');
                         $url = $this->getMarcSubfield($field, 'u');
                         if (preg_match('/^https?:\/\//', $url)) {
                             $item['locationhref'] = $url;
                         }
-                        $item['status'] = $this->getMarcSubfield($field, 's');
-                        $item['callnumber'] = $this->getMarcSubfield($field, 'd');
+                        $item['status'] = $this->getMarcSubfield($field, 's')
+                            ?: null;
+                        if ($note = $this->getMarcSubfield($field, 'n')) {
+                            $item['item_notes'] = [$note];
+                        }
                         $status[] = $item;
                     }
                     // Digital
diff --git a/themes/bootstrap3/templates/RecordTab/holdingsils/electronic.phtml b/themes/bootstrap3/templates/RecordTab/holdingsils/electronic.phtml
index 352bdfd1f00..4accf033e60 100644
--- a/themes/bootstrap3/templates/RecordTab/holdingsils/electronic.phtml
+++ b/themes/bootstrap3/templates/RecordTab/holdingsils/electronic.phtml
@@ -18,6 +18,16 @@
         <?php else: ?>
           <span class="text-danger"><?=$this->transEsc($item['status'])?></span>
         <?php endif; ?>
+        <?php if (isset($item['item_notes'])): ?>
+          <div class="item-notes">
+            <b><?=$this->transEsc("Item Notes")?>:</b>
+            <ul>
+              <?php foreach ($item['item_notes'] as $item_note): ?>
+                <li><?=$this->escapeHtml($item_note) ?></li>
+              <?php endforeach; ?>
+            </ul>
+          </div>
+        <?php endif; ?>
       </td>
     </tr>
   <?php endforeach; ?>
-- 
GitLab