Fix progressbar when amount raised is negative
authorVimal Joseph <vimal.joseph@zyxware.com>
Tue, 16 Dec 2014 15:27:25 +0000 (20:57 +0530)
committerVimal Joseph <vimal.joseph@zyxware.com>
Tue, 16 Dec 2014 15:27:25 +0000 (20:57 +0530)
CRM/Wci/BAO/ProgressBar.php
templates/CRM/Wci/Page/WCIWidget.tpl

index 00964505713d68afb9be51cbb39f894725880dc5..9ef635df0b84a8a22613a47a14477873731e5ca8 100644 (file)
@@ -117,7 +117,12 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
       $amount_raised = $amount_collected + $pbInfo['starting_amount'];
       $goal = $pbInfo['goal_amount'];
       $pbData['pb_collected'] = $amount_raised;
-      $pbData["pb_percentage"] = ($amount_raised / $goal) * 100;
+      if ($amount_raised < 0) {
+        $pbData["pb_percentage"] = 0;
+      }
+      else {
+        $pbData["pb_percentage"] = ($amount_raised / $goal) * 100;
+      }
       $pbData["goal_amount"] = $goal;
       $pbData["no_pb"] = False;
     } else {
index f43550e0f431a0af887141b87efa03e9942e2635..6ea49f49e4bb03fd2c6fdcfd1540b069748138ef 100644 (file)
@@ -91,6 +91,8 @@
         {/literal}
         {if $wciform.pb_percentage > 100}
           width:100%
+        {elseif $wciform.pb_percentage < 0}
+          width:0%
         {else}
           width:{$wciform.pb_percentage}%
         {/if}