31453 31498 code cleanup
[com.zyxware.civiwci.git] / CRM / Wci / BAO / ProgressBar.php
index 358c80fd75d11dc3e49b524225fddd45d17e8fd9..01fbf8d34db12d1d6b95fe97daf9631a3f395656 100644 (file)
@@ -1,27 +1,24 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM Widget Creation Interface (WCI) Version 1.0                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright Zyxware Technologies (c) 2014                            |
  +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
+ | This file is a part of CiviCRM WCI.                                |
  |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ | CiviCRM WCI is free software; you can copy, modify, and distribute |
+ | it under the terms of the GNU Affero General Public License        |
+ | Version 3, 19 November 2007.                                       |
  |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | CiviCRM WCI is distributed in the hope that it will be useful,     |
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of     |
  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
  | See the GNU Affero General Public License for more details.        |
  |                                                                    |
  | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ | License along with this program; if not, contact Zyxware           |
+ | Technologies at info[AT]zyxware[DOT]com.                           |
  +--------------------------------------------------------------------+
 */
 
@@ -40,12 +37,12 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
    * Fields : id, name, starting_amount, goal_amount
    * @return progressbar array
    * @access public
-   */  
+   */
   public static function getProgressbarList() {
     $query = "SELECT * FROM civicrm_wci_progress_bar";
     $params = array();
     $pbList = array();
-    
+
     $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_ProgressBar');
 
     while ($dao->fetch()) {
@@ -55,13 +52,13 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
 
     return $pbList;
   }
-  
+
   /**
    * Returns percentage value of a progressbar
    * @param integer progressbar id
    * @return decimal percentage value
    * @access public
-   */  
+   */
   public static function getPBCollectedAmount($pbId) {
     $bp = 0;
     $query = "SELECT * FROM civicrm_wci_progress_bar_formula WHERE progress_bar_id =" . $pbId;
@@ -72,7 +69,7 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
         $for_page[$daoPbf->id] = array();
         CRM_Core_DAO::storeValues($daoPbf, $for_page[$daoPbf->id]);
         $px = $for_page[$daoPbf->id]['percentage'];
-        
+
         $query = "SELECT * FROM civicrm_contribution where contribution_page_id =" . $for_page[$daoPbf->id]['contribution_page_id'];
         $params = array();
 
@@ -88,7 +85,7 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
      }
      return floor($bp);
   }
-  
+
   public static function getProgressbarInfo($pbId) {
     $ga = 0;
     $query = "SELECT * FROM civicrm_wci_progress_bar where id=" . $pbId;
@@ -106,6 +103,7 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
 
      return $pbInfo;
   }
+
   public static function getProgressbarPercentage($pbId, &$pbInfo) {
 
     $pbInfo = CRM_Wci_BAO_ProgressBar::getProgressbarInfo($pbId);
@@ -114,18 +112,19 @@ class CRM_Wci_BAO_ProgressBar extends CRM_Wci_DAO_ProgressBar {
       + $pbInfo['starting_amount'];
     (0 == $ga) ? $currAmt = 0: $perc = ($currAmnt / $ga ) * 100;
     if (100 < $perc){
-      $perc = 100; 
+      $perc = 100;
     }
 
-     return floor($perc);  
+     return floor($perc);
   }
+
   public static function getProgressbarData($pbId, &$pbData) {
     if(0 != $pbId) {
-      $pbInfo = array();//CRM_Wci_BAO_ProgressBar::getProgressbarInfo($pbId);
+      $pbInfo = array();
       $pbData["pb_percentage"] = CRM_Wci_BAO_ProgressBar::getProgressbarPercentage($pbId, $pbInfo);
       $pbData["starting_amount"] = floor($pbInfo['starting_amount']);
       $pbData["goal_amount"] = ceil($pbInfo['goal_amount']);
-      
+
       ($pbData["show_pb_perc"]) ? $pbData["pb_caption"] = $pbData["pb_percentage"]
         : $pbData["pb_caption"] = CRM_Wci_BAO_ProgressBar::getPBCollectedAmount($pbId)
         + $pbData["starting_amount"];