From bccd4e0ce5dc965a0922120c9b386fa08ecb531c Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 12 Feb 2015 09:06:30 +0100 Subject: [PATCH] Bug 7957: Fix members/routing-lists.pl page --- C4/Serials.pm | 18 ++---- .../prog/en/modules/members/routing-lists.tt | 75 +++++++++++----------- members/routing-lists.pl | 16 +---- 3 files changed, 45 insertions(+), 64 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index d062167..517de41 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -2259,21 +2259,17 @@ sub GetSubscriptionsFromBorrower { my ($borrowernumber) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( - "SELECT subscription.subscriptionid, biblio.title - FROM subscription + "SELECT subscriptionroutinglist.*, biblio.title AS bibliotitle + FROM subscriptionroutinglist + JOIN subscriptionrouting ON (subscriptionroutinglist.routinglistid = subscriptionrouting.routinglistid) + JOIN subscription ON (subscriptionroutinglist.subscriptionid = subscription.subscriptionid) JOIN biblio ON biblio.biblionumber = subscription.biblionumber - JOIN subscriptionroutinglist USING (subscriptionid) - WHERE subscriptionroutinglist.borrowernumber = ? ORDER BY title ASC + WHERE subscriptionrouting.borrowernumber = ? ORDER BY title ASC " ); $sth->execute($borrowernumber); - my @routinglist; - my $count = 0; - while ( my $line = $sth->fetchrow_hashref ) { - $count++; - push( @routinglist, $line ); - } - return ( $count, @routinglist ); + my $routinglists = $sth->fetchall_arrayref({}); + return $routinglists ? @$routinglists : (); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt index f6f6f92..69e36bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/routing-lists.tt @@ -21,50 +21,47 @@

-[% IF ( countSubscrip ) %] -[% countSubscrip %] Subscription routing list(s) +[% IF ( routinglists.size > 0 ) %] + [% routinglists.size %] Subscription routing list(s) [% ELSE %] -0 Subscription routing lists + 0 Subscription routing lists [% END %]

-[% IF ( subscripLoop ) %] - - - - - - - - -[% FOREACH subscripLoop IN subscripLoop %] - - - - - [% END %] - -
Subscription titleRouting list
- - [% subscripLoop.title %] - - - - - Edit routing list - - - - -
- - [% ELSE %] -

Patron does not belong to any subscription routing lists.

- - - [% END %] - + [% IF ( routinglists.size > 0 ) %] + + + + + + + + + + [% FOREACH routinglist IN routinglists %] + + + + + + [% END %] + +
Subscription titleRouting listActions
+ + + [% routinglist.bibliotitle %] + + + [% routinglist.title %] + + Edit routing list + + +
+ [% ELSE %] +

Patron does not belong to any subscription routing lists.

+ [% END %]
diff --git a/members/routing-lists.pl b/members/routing-lists.pl index efd067e..5cd65b2 100755 --- a/members/routing-lists.pl +++ b/members/routing-lists.pl @@ -76,22 +76,10 @@ if ($borrowernumber) { if ($borrowernumber) { # new op dev - 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 ); - } + my @routinglists = GetSubscriptionsFromBorrower($borrowernumber ); $template->param( - countSubscrip => scalar @subscripLoop, - subscripLoop => \@subscripLoop, + routinglists => \@routinglists, routinglistview => 1 ); -- 1.9.1