From 1ddf1d240abf0e81ad4a532cebdef5e0ed4ad6aa Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 18 Jun 2012 13:02:42 +1000 Subject: [PATCH] Bug 8260 Correction: Routing List Ranking Re-order Content-Type: text/plain; charset="utf-8" --- C4/Serials.pm | 25 +++++++++++++++++++++++++ serials/routing.pl | 2 ++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 8e5bbcb..bb74a6c 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -50,6 +50,7 @@ BEGIN { &GetDistributedTo &SetDistributedTo &getroutinglist &delroutingmember &addroutingmember &reorder_members + &reorder_member_ranking &check_routing &updateClaim &removeMissingIssue &CountIssues HasItems @@ -2000,6 +2001,30 @@ sub reorder_members { return; } +=head2 reorder_member_ranking + +reorder_member_ranking($subscriptionid) + +this function is used to reorder the routing list without adding or deleting any members, which is necessary when the ranking goes out of sync due to the cascading delete of a borrower + +=cut + +sub reorder_member_ranking { + my ( $subscriptionid, $routingid, $rank ) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( "SELECT * FROM subscriptionroutinglist WHERE subscriptionid = ? ORDER BY ranking ASC" ); + $sth->execute($subscriptionid); + my @result; + while ( my $line = $sth->fetchrow_hashref ) { + push( @result, $line->{'routingid'} ); + } + + for ( my $j = 0 ; $j < @result ; $j++ ) { + my $sth = $dbh->prepare( "UPDATE subscriptionroutinglist SET ranking = '" . ( $j + 1 ) . "' WHERE routingid = '" . $result[$j] . "'" ); + $sth->execute; + } +} + =head2 delroutingmember delroutingmember($routingid,$subscriptionid) diff --git a/serials/routing.pl b/serials/routing.pl index a95631b..0c5ac9f 100755 --- a/serials/routing.pl +++ b/serials/routing.pl @@ -66,6 +66,8 @@ if($op eq 'save'){ print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate"); } +reorder_member_ranking($subscriptionid); + my @routinglist = getroutinglist($subscriptionid); my $subs = GetSubscription($subscriptionid); my ($count,@serials) = GetSerials($subscriptionid); -- 1.7.7.4