Fix issue with negative starting amount in the progressbar
authorVimal Joseph <vimal.joseph@zyxware.com>
Tue, 16 Dec 2014 15:34:46 +0000 (21:04 +0530)
committerVimal Joseph <vimal.joseph@zyxware.com>
Tue, 16 Dec 2014 15:34:46 +0000 (21:04 +0530)
CRM/Wci/BAO/ProgressBar.php

index 9ef635df0b84a8a22613a47a14477873731e5ca8..bff02bc392643767f6eeebaac8cc0850c9aab2e1 100644 (file)
@@ -116,13 +116,8 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
       $amount_collected = CRM_Wci_BAO_ProgressBar::getPBCollectedAmount($pbId);
       $amount_raised = $amount_collected + $pbInfo['starting_amount'];
       $goal = $pbInfo['goal_amount'];
-      $pbData['pb_collected'] = $amount_raised;
-      if ($amount_raised < 0) {
-        $pbData["pb_percentage"] = 0;
-      }
-      else {
-        $pbData["pb_percentage"] = ($amount_raised / $goal) * 100;
-      }
+      $pbData['pb_collected'] = ($amount_raised < 0) ? 0 : $amount_raised;
+      $pbData["pb_percentage"] = ($pbData['pb_collected'] / $goal) * 100;
       $pbData["goal_amount"] = $goal;
       $pbData["no_pb"] = False;
     } else {