Bug 20456: Switch routling list tab in staff to use Koha::Object
authorKatrin Fischer <katrin.fischer.83@web.de>
Fri, 16 Mar 2018 08:57:06 +0000 (09:57 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 22 Jun 2018 15:02:46 +0000 (15:02 +0000)
Bug 20400 added a routing list tab to the patron account in the
OPAC using Koha::Object.

This patch switches the routing list tab in the patron account
in intranet over to the new code. It also adds an additional
column showing the position of the patron on the routing list
and fixes the search.

To test:
- Create some subscriptions with routing lists
- Take a look at the patron accounts of several patrons having
  - no entries on routing lists
  - 1 entry on a routing list
  - entries on several routing lists
- Make sure the display works correctly.
- Search for a subscription and make sure search works.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt
members/routing-lists.pl

index 1cbbfa6..c79d3bb 100644 (file)
 
 <!-- Search Bar -->
 <p class="tip">Search subscriptions:</p>
-<form action="/cgi-bin/koha/serials/serials-home.pl" method="get">[% IF ( routing ) %]<input type="hidden" name="routing" value="[% routing %]" />[% END %]<input type="hidden" name="searched" value="1" /> <label for="ISSN_filter">ISSN:</label> <input type="text" size="10" maxlength="11" name="ISSN_filter" id="ISSN_filter" value="[% ISSN_filter %]" /> <label for="title_filter">Title:</label> <input type="text" size="20" maxlength="40" name="title_filter" id="title_filter" value="[% title_filter %]" /><input type="submit" value="Search" class="submit" />
+<form action="/cgi-bin/koha/serials/serials-search.pl" method="get">[% IF ( routing ) %]<input type="hidden" name="routing" value="[% routing %]" />[% END %]<input type="hidden" name="searched" value="1" /> <label for="ISSN_filter">ISSN:</label> <input type="text" size="10" maxlength="11" name="ISSN_filter" id="ISSN_filter" value="[% ISSN_filter %]" /> <label for="title_filter">Title:</label> <input type="text" size="20" maxlength="40" name="title_filter" id="title_filter" value="[% title_filter %]" /><input type="submit" value="Search" class="submit" />
 </form>
 <!-- Search Bar End -->
 
 <h1>
-[% IF ( countSubscrip ) %]
-[% countSubscrip %] Subscription routing list(s)
+[% UNLESS ( routinglists ) %]
+0 subscription routing lists
+[% ELSIF ( routinglists.size() == 1 ) %]
+[% routinglists.size() %] subscription routing list
 [% ELSE %]
-0 Subscription routing lists
+[% routinglists.size() %] subscription routing lists
 [% END %]
 </h1>
 
 <div id="subscriptions">
-[% IF ( subscripLoop ) %]
-<table id="subscriptiont">
-              <thead>
-                <tr>
-                  <th>Subscription title</th>
-                  <th>Routing list</th>
-                </tr>
-              </thead>
-              <tbody>
-[% FOREACH subscripLoop IN subscripLoop %]
-<tr>
-    <td>
-    <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscripLoop.subscriptionid %]"><strong>
-    [% subscripLoop.title %]
-    </strong>
+
+[% SET routinglists = logged_in_user.get_routing_lists %]
+[% IF ( routinglists ) %]
+    <table id="subscriptiont">
+        <thead>
+            <tr>
+                <th>Subscription title</th>
+                <th>Position</th>
+                <th>Routing list</th>
+            </tr>
+        </thead>
+        <tbody>
+        [% FOREACH routinglist IN routinglists %]
+            <tr>
+                <td>
+                    <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% routinglist.subscription.subscriptionid %]">
+                        [% routinglist.subscription.biblio.title %]
                     </a>
-                  </td>
-                  <td>
-                    <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscripLoop.subscriptionid %]"><strong>
-                    Edit routing list
-                      </strong>
+                </td>
+                <td>
+                    [% routinglist.ranking %]
+                </td>
+                <td>
+                    <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% routinglist.subscription.subscriptionid %]">
+                        Edit routing list
                     </a>
-                    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
-                    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
-                  </td>
-                </tr>
-                [% END %]
-                </tbody>
-            </table>
-            </form>
-          [% ELSE %]
-          <p>Patron does not belong to any subscription routing lists.</p>
-          <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
+                    <input type="hidden" name="biblionumber" value="[% routinglist.subscription.biblionumber %]" />
                     <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
-                    [% END %]
+                </td>
+            </tr>
+            [% END %]
+        </tbody>
+    </table>
+[% ELSE %]
+    <p>Patron does not belong to any subscription routing lists.</p>
+    <input type="hidden" name="biblionumber" value="[% routinglist.subscription.biblionumber %]" />
+    <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber %]" />
+[% END %]
 
 </div>
 
 
-
-
 </div>
 </div>
 
index 793317d..c9b514f 100755 (executable)
@@ -51,25 +51,6 @@ my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"
 my $patron         = Koha::Patrons->find( $borrowernumber );
 output_and_exit_if_error( $query, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
 
-my $count;
-my @borrowerSubscriptions;
-($count, @borrowerSubscriptions) = GetSubscriptionsFromBorrower($borrowernumber );
-my @subscripLoop;
-
-foreach my $num_res (@borrowerSubscriptions) {
-    my %getSubscrip;
-    $getSubscrip{subscriptionid} = $num_res->{'subscriptionid'};
-    $getSubscrip{title}          = $num_res->{'title'};
-    $getSubscrip{borrowernumber} = $num_res->{'borrowernumber'};
-    push( @subscripLoop, \%getSubscrip );
-}
-
-$template->param(
-    countSubscrip => scalar @subscripLoop,
-    subscripLoop  => \@subscripLoop,
-    routinglistview => 1
-);
-
 $template->param(
     patron            => $patron,
     findborrower      => $findborrower,