Changed the position of the progress bar caption. Now it is just beneath the progressbar.
Removed starting amount from the template.
Now negative amounts are allowed for starting amount.
Formated the amount raised and goal amount.
public static function getProgressbarData($pbId, &$pbData) {
if(0 != $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"];
-
+ $pbInfo = CRM_Wci_BAO_ProgressBar::getProgressbarInfo($pbId);
+ $amount_collected = CRM_Wci_BAO_ProgressBar::getPBCollectedAmount($pbId);
+ $amount_raised = $amount_collected + $pbInfo['starting_amount'];
+ $goal = $pbInfo['goal_amount'];
+ $pbData['pb_collected'] = $amount_raised;
+ $pbData["pb_percentage"] = ($amount_raised / $goal) * 100;
+ $pbData["goal_amount"] = $goal;
$pbData["no_pb"] = False;
} else {
$pbData["no_pb"] = True;
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_ProgressBar');
- while ($dao->fetch()) {
- $con_page[$dao->id] = array();
- CRM_Core_DAO::storeValues($dao, $con_page[$dao->id]);
+ if ($dao->fetch()) {
$this->setDefaults(array(
- 'progressbar_name' => $con_page[$dao->id]['name']));
+ 'progressbar_name' => $dao->name));
$this->setDefaults(array(
- 'starting_amount' => $con_page[$dao->id]['starting_amount']));
+ 'starting_amount' => $dao->starting_amount));
$this->setDefaults(array(
- 'goal_amount' => $con_page[$dao->id]['goal_amount']));
+ 'goal_amount' => $dao->goal_amount));
}
$query = "SELECT * FROM civicrm_wci_progress_bar_formula WHERE progress_bar_id =%1";
return TRUE;
}
+ public function upgrade_1003() {
+ $this->ctx->log->info('Applying update to allow -ve values to sarting amount');
+ CRM_Core_DAO::executeQuery('
+ ALTER TABLE `civicrm_wci_progress_bar`
+ CHANGE `starting_amount` `starting_amount` FLOAT NULL DEFAULT NULL
+ COMMENT "Arbitrary starting amount for progress bar."'
+ );
+ return TRUE;
+ }
}
CREATE TABLE IF NOT EXISTS civicrm_wci_progress_bar (
id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Custom Progress bar Id.',
name varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Name of progress bar.',
- starting_amount float unsigned NULL COMMENT 'Arbitrary starting amount for progress bar.',
+ starting_amount float NULL COMMENT 'Arbitrary starting amount for progress bar.',
goal_amount float unsigned NULL COMMENT 'Goal amount for progress bar.',
PRIMARY KEY (`id`),
UNIQUE KEY `unique_wci_name` (`name`)
-khtml-border-radius: 4px;
border-radius: 4px;
margin-top:.8em;
- margin-bottom:.8em;
/*text-align:left;*/
margin-left: auto;
margin-right: auto;
-khtml-border-radius: 4px;
border-radius: 4px;
text-align:left;
- width: {/literal}{$wciform.pb_percentage}{literal}%; /* progress bar percentage */
+ {/literal}
+ {if $wciform.pb_percentage > 100}
+ width:100%
+ {else}
+ width:{$wciform.pb_percentage}%
+ {/if}
+ {literal}
}
.crm-amount-raised-wrapper {
margin-bottom:.8em;
</div>
{/if}
{if false == $wciform.no_pb}
- {if (false == $wciform.hide_pbcap)}
+ <div class="crm-amount-bar">
+ <div class="crm-amount-fill" id="crm_wid_{$wciform.widgetId}_amt_fill"></div>
+ </div>
+ {if (false == $wciform.hide_pbcap)}
<div class="crm-amounts">
- <div id="crm_wid_{$wciform.widgetId}_amt_hi" class="crm-amount-high">${$wciform.goal_amount}</div>
- <div id="crm_wid_{$wciform.widgetId}_amt_low" class="crm-amount-low">${$wciform.starting_amount}</div>
+ <div id="crm_wid_{$wciform.widgetId}_amt_hi" class="crm-amount-high">Goal: ${$wciform.goal_amount|number_format}</div>
{if (true == $wciform.show_pb_perc)}
- <div id="crm_wid_{$wciform.widgetId}_percentage" class="crm-percentage">{$wciform.pb_caption}%</div>
+ <div id="crm_wid_{$wciform.widgetId}_low" class="crm-amount-low">{$wciform.pb_percentage}% raised</div>
{else}
- <div id="crm_wid_{$wciform.widgetId}_percentage" class="crm-percentage">${$wciform.pb_caption}</div>
+ <div id="crm_wid_{$wciform.widgetId}_low" class="crm-amount-low">${$wciform.pb_collected|number_format} raised</div>
{/if}
</div>
{/if}
- <div class="crm-amount-bar">
- <div class="crm-amount-fill" id="crm_wid_{$wciform.widgetId}_amt_fill"></div>
- </div>
<div id="crm_wid_{$wciform.widgetId}_donors" class="crm-donors">
</div>
{/if}