From: Jagadedes Date: Tue, 7 Oct 2014 04:37:40 +0000 (+0530) Subject: #29755 review comments X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0a3819f8bceaed8175f5da4eb3e0fb2257622e3c;p=com.zyxware.civiwci.git #29755 review comments --- 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; }