Corrects an error when showing a suggestion linked to a deleted budget.
authorFrédérick Capovilla <frederick.capovilla@sys-tech.net>
Wed, 30 Mar 2011 16:12:19 +0000 (12:12 -0400)
committerChris Nighswonger <chris.nighswonger@gmail.com>
Mon, 11 Apr 2011 19:44:36 +0000 (15:44 -0400)
If a suggestion is associated to a budget that was deleted, an error was
returned because we try to get the name of a budget that doesn't exist.
With this fix, the page is shown without errors.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit 0a43ba114d0fee9a478def455b926121442a0814)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
suggestion/suggestion.pl

index 3a6dd20..d55d5fd 100755 (executable)
@@ -177,7 +177,10 @@ if ($op=~/else/) {
     
         my $suggestions = &SearchSuggestion($suggestion_ref);
         foreach my $suggestion (@$suggestions){
-            $suggestion->{budget_name}=GetBudget($suggestion->{budgetid})->{budget_name} if $suggestion->{budgetid};
+            if($suggestion->{budgetid}) {
+                my $budget = GetBudget($suggestion->{budgetid});
+                $suggestion->{budget_name}=$budget->{budget_name} if $budget;
+            }
             foreach my $date qw(suggesteddate manageddate accepteddate){
                 if ($suggestion->{$date} ne "0000-00-00" && $suggestion->{$date} ne "" ){
                 $suggestion->{$date}=format_date($suggestion->{$date}) ;