From 873b6a40c4329e31ef03c502d1c54389c994fc20 Mon Sep 17 00:00:00 2001
From: Julian Maurice <julian.maurice@biblibre.com>
Date: Wed, 14 Feb 2018 15:52:30 +0100
Subject: [PATCH] Bug 20194: Display ccode and both itemtypes in pending
 reserves table

Test plan:
1. Go to /cgi-bin/koha/circ/pendingreserves.pl (Holds to pull) and
   verify that ccodes and both itemtypes are displayed in the table
---
 circ/pendingreserves.pl                                  |  6 ++++++
 .../prog/en/modules/circ/pendingreserves.tt              | 16 +++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl
index 15873201b1..08f0277349 100755
--- a/circ/pendingreserves.pl
+++ b/circ/pendingreserves.pl
@@ -96,8 +96,11 @@ my $strsth =
                     ORDER BY items.itemnumber SEPARATOR '|') l_holdingbranch,
             reserves.biblionumber,
             reserves.branchcode as l_branch,
+            biblioitems.itemtype,
             GROUP_CONCAT(DISTINCT items.itype 
                     ORDER BY items.itemnumber SEPARATOR '|') l_itype,
+            GROUP_CONCAT(DISTINCT items.ccode
+                    ORDER BY items.itemnumber SEPARATOR '|') l_ccode,
             GROUP_CONCAT(DISTINCT items.location 
                     ORDER BY items.itemnumber SEPARATOR '|') l_location,
             GROUP_CONCAT(DISTINCT items.itemcallnumber 
@@ -115,6 +118,7 @@ my $strsth =
     FROM  reserves
         LEFT JOIN items ON items.biblionumber=reserves.biblionumber 
         LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber
+        LEFT JOIN biblioitems ON reserves.biblionumber = biblioitems.biblionumber
         LEFT JOIN branchtransfers ON items.itemnumber=branchtransfers.itemnumber
         LEFT JOIN issues ON items.itemnumber=issues.itemnumber
         LEFT JOIN borrowers ON reserves.borrowernumber=borrowers.borrowernumber
@@ -165,7 +169,9 @@ while ( my $data = $sth->fetchrow_hashref ) {
             count           => $data->{icount},
             rcount          => $data->{rcount},
             pullcount       => $data->{icount} <= $data->{rcount} ? $data->{icount} : $data->{rcount},
+            itemtype        => $data->{itemtype},
             itypes          => [split('\|', $data->{l_itype})],
+            ccodes          => [split('\|', $data->{l_ccode})],
             locations       => [split('\|', $data->{l_location})],
         }
     );
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
index 200f95c1b0..3d8a48e8f8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
@@ -41,6 +41,7 @@
         <th>Available copy numbers</th>
         <th>Available enumeration</th>
         <th class="string-sort">Available itypes</th>
+        <th class="string-sort">Available ccodes</th>
         <th class="string-sort">Available locations</th>
         <th class="title-string">Earliest hold date</th>
         </tr>
@@ -75,10 +76,16 @@
         <td><p>[% reserveloo.copyno %]</p></td>
         <td><p>[% reserveloo.enumchron %]</p></td>
         <td>
+        [% ItemTypes.GetDescription(reserveloo.itemtype) %]
         [% FOREACH itype IN reserveloo.itypes %]
             [% ItemTypes.GetDescription( itype ) %]
         [% END %]
         </td>
+        <td>
+            [% FOREACH ccode IN reserveloo.ccodes %]
+                [% AuthorisedValues.GetByCode('CCODE', ccode) %]<br>
+            [% END %]
+        </td>
         <td>
         [% FOREACH loc IN reserveloo.locations %]
             [% AuthorisedValues.GetByCode('LOC', loc) %]<br>
@@ -102,6 +109,7 @@
         <td><input type="text" class="filter" data-column_num="7" placeholder="Available copy" style="width:95%"/></td>
         <td><input type="text" class="filter" data-column_num="8" placeholder="Available enumeration" style="width:95%"/></td>
         <td id="itypefilter"></td>
+        <td id="ccodefilter"></td>
         <td id="locationfilter"></td>
         <td></td>
         </tr>
@@ -202,12 +210,18 @@
                   holdst.fnFilter( $(this).val(), 9 );
               });
           });
-          $("#locationfilter").each( function () {
+          $("#ccodefilter").each( function () {
               $(this).html( createSelect( holdst.fnGetColumnData(10) ) );
               $('select', this).change( function () {
                   holdst.fnFilter( $(this).val(), 10 );
               });
           });
+          $("#locationfilter").each( function () {
+              $(this).html( createSelect( holdst.fnGetColumnData(11) ) );
+              $('select', this).change( function () {
+                  holdst.fnFilter( $(this).val(), 11 );
+              });
+          });
         });
     </script>
 [% END %]
-- 
2.14.2