bug 5825: (follow-up) consult item-level_itypes
authorGalen Charlton <gmc@esilibrary.com>
Fri, 16 Aug 2013 15:36:10 +0000 (15:36 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 16 Aug 2013 15:36:10 +0000 (15:36 +0000)
This patch teaches GetHoldsQueueItems to consult
the item-level_itypes system preference and return
the item-level or bib-level item type accordingly.

To test:

- Arrange so that an item that shows up on the holds queue
  report has one item type while its bib has a different one.
- Run the report with item-level_itypes ON.  Verify that
  the item-level item type is displayed.
- Change item-level_itypes to OFF.  Run the report again and
  verify that the bib-level item type is displayed.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/HoldsQueue.pm

index 1242fc5..094fbe7 100755 (executable)
@@ -119,7 +119,7 @@ sub GetHoldsQueueItems {
     my $dbh   = C4::Context->dbh;
 
     my @bind_params = ();
-    my $query = q/SELECT tmp_holdsqueue.*, biblio.author, items.ccode, items.itype, items.location, items.enumchron, items.cn_sort, biblioitems.publishercode,biblio.copyrightdate,biblioitems.publicationyear,biblioitems.pages,biblioitems.size,biblioitems.publicationyear,biblioitems.isbn,items.copynumber
+    my $query = q/SELECT tmp_holdsqueue.*, biblio.author, items.ccode, items.itype, biblioitems.itemtype, items.location, items.enumchron, items.cn_sort, biblioitems.publishercode,biblio.copyrightdate,biblioitems.publicationyear,biblioitems.pages,biblioitems.size,biblioitems.publicationyear,biblioitems.isbn,items.copynumber
                   FROM tmp_holdsqueue
                        JOIN biblio      USING (biblionumber)
                   LEFT JOIN biblioitems USING (biblionumber)
@@ -141,6 +141,13 @@ sub GetHoldsQueueItems {
             $row->{parts} = GetRecordValue('parts',$record,'')->[0]->{subfield};
             $row->{numbers} = GetRecordValue('numbers',$record,'')->[0]->{subfield};
         }
+
+        # return the bib-level or item-level itype per syspref
+        if (!C4::Context->preference('item-level_itypes')) {
+            $row->{itype} = $row->{itemtype};
+        }
+        delete $row->{itemtype};
+
         push @$items, $row;
     }
     return $items;