From fb3f7966b41ce8ee9b834c0bfcb3ca9814ac5a7e Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Fri, 20 Nov 2009 19:41:08 +0000 Subject: [PATCH] Cleanup date handling in routing.pl Remove dead code Clarify the loop assigning dates Remove the cause of undef warnings in the log Signed-off-by: Galen Charlton --- serials/routing.pl | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/serials/routing.pl b/serials/routing.pl index 9580dca8d7..3d2c5148d7 100755 --- a/serials/routing.pl +++ b/serials/routing.pl @@ -49,6 +49,7 @@ my $borrowernumber = $query->param('borrowernumber'); my $notes = $query->param('notes'); my $op = $query->param('op') || q{}; my $date_selected = $query->param('date_selected'); +$date_selected ||= q{}; my $dbh = C4::Context->dbh; if($op eq 'delete'){ @@ -68,20 +69,20 @@ if($op eq 'save'){ my ($routing, @routinglist) = getroutinglist($subscriptionid); my $subs = GetSubscription($subscriptionid); my ($count,@serials) = GetSerials($subscriptionid); -my ($serialdates) = GetLatestSerials($subscriptionid,$count); - -my @dates; -my $i=0; -foreach my $dateseq (@$serialdates) { - $dates[$i]->{'planneddate'} = $dateseq->{'planneddate'}; - $dates[$i]->{'serialseq'} = $dateseq->{'serialseq'}; - $dates[$i]->{'serialid'} = $dateseq->{'serialid'}; - if($date_selected eq $dateseq->{'serialid'}){ - $dates[$i]->{'selected'} = ' selected'; - } else { - $dates[$i]->{'selected'} = ''; - } - $i++; +my $serialdates = GetLatestSerials($subscriptionid,$count); + +my $dates = []; +foreach my $dateseq (@{$serialdates}) { + my $d = {}; + $d->{planneddate} = $dateseq->{planneddate}; + $d->{serialseq} = $dateseq->{serialseq}; + $d->{serialid} = $dateseq->{serialid}; + if($date_selected eq $dateseq->{serialid}){ + $d->{selected} = ' selected'; + } else { + $d->{selected} = q{}; + } + push @{$dates}, $d; } my ($template, $loggedinuser, $cookie) @@ -92,19 +93,6 @@ my ($template, $loggedinuser, $cookie) flagsrequired => {serials => 1}, debug => 1, }); -# my $date; -# if($serialseq){ -# for(my $i = 0;$i<@serials; $i++){ -# if($serials[$i]->{'serialseq'} eq $serialseq){ -# $date = $serials[$i]->{'planneddate'} -# } -# } -# } else { -# $serialseq = $serials[0]->{'serialseq'}; -# $date = $serials[0]->{'planneddate'}; -# } - -# my $issue = "$serialseq ($date)"; my @results; my $data; @@ -154,7 +142,7 @@ $template->param( subscriptionid => $subscriptionid, memberloop => \@results, op => $new, - dates => \@dates, + dates => $dates, routingnotes => $serials[0]->{'routingnotes'}, ); -- 2.39.5