From 0a3819f8bceaed8175f5da4eb3e0fb2257622e3c Mon Sep 17 00:00:00 2001 From: Jagadedes Date: Tue, 7 Oct 2014 10:07:40 +0530 Subject: [PATCH] #29755 review comments --- CRM/Wci/BAO/ProgressBar.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/CRM/Wci/BAO/ProgressBar.php b/CRM/Wci/BAO/ProgressBar.php index 0c79170..40c251b 100644 --- a/CRM/Wci/BAO/ProgressBar.php +++ b/CRM/Wci/BAO/ProgressBar.php @@ -127,12 +127,19 @@ class CRM_WCI_BAO_ProgressBar extends CRM_WCI_DAO_ProgressBar { } return FALSE; } - + + /** + * Returns percentage value of a progressbar + * + * @param integer progressbar id + * + * @return decimal percentage value + * @access public + */ public static function getProgressbarPercentage($idPB) { $bp = 0; $query = "SELECT * FROM civicrm_wci_progress_bar where id=" . $idPB; $params = array(); - //echo $query."
"; $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_WCI_DAO_ProgressBar'); while ($dao->fetch()) { @@ -140,40 +147,32 @@ class CRM_WCI_BAO_ProgressBar extends CRM_WCI_DAO_ProgressBar { CRM_Core_DAO::storeValues($dao, $con_page[$dao->id]); $con_page[$dao->id]['name']; $sa = $con_page[$dao->id]['starting_amount']; - //echo "stat amount ".$sa.'
'; $ga = $con_page[$dao->id]['goal_amount']; - //echo "goal amt ".$ga.'
'; } $query = "SELECT * FROM civicrm_wci_progress_bar_formula WHERE progress_bar_id =" . $idPB; $params = array(); - //echo $query."
"; $daoPbf = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_WCI_DAO_ProgressBarFormula'); while ($daoPbf->fetch()) { $for_page[$daoPbf->id] = array(); CRM_Core_DAO::storeValues($daoPbf, $for_page[$daoPbf->id]); - //echo "contribution_page_id ".$for_page[$daoPbf->id]['contribution_page_id'].'
'; $px = $for_page[$daoPbf->id]['percentage']; - //echo "percentage ".$px.'
'; $query = "SELECT * FROM civicrm_contribution where contribution_page_id =" . $for_page[$daoPbf->id]['contribution_page_id']; $params = array(); - //echo $query."
"; $daoCon = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_Contribution'); while ($daoCon->fetch()) { $contributions[$daoCon->id] = array(); CRM_Core_DAO::storeValues($daoCon, $contributions[$daoCon->id]); $bx = $contributions[$daoCon->id]['total_amount']; - //echo "total_amount".$bx ."
"; - //echo "status".$contributions[$daoCon->id]['contribution_status_id'] ."
"; + $bp += $bx * $px / 100; } } $perc = (($sa + $bp) / $ga ) * 100; - //echo "percentate " . . "
"; return $perc; } -- 2.25.1