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 Cormack <chrisc@catalyst.net.nz>
Mon, 4 Apr 2011 22:04:08 +0000 (10:04 +1200)
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>

suggestion/suggestion.pl

index ea3fbf5..aa8fad0 100755 (executable)
@@ -189,7 +189,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}) ;