/**
  * Render totals in a product portlet view
  */
 protected function renderTotalBarDetails()
 {
     $persistantProductConfigItemValue = ProductsPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($this->params['portletId'], 'filteredByStage');
     $relationModelClassName = get_class($this->params["relationModel"]);
     $relationModelId = $this->params["relationModel"]->id;
     $relationModel = $relationModelClassName::getById($relationModelId);
     $models = $relationModel->products;
     $oneTimeTotal = 0;
     $monthlyTotal = 0;
     $annualTotal = 0;
     foreach ($models as $model) {
         if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($model, Permission::READ)) {
             if ($persistantProductConfigItemValue === null) {
                 $persistantProductConfigItemValue = ProductsConfigurationForm::FILTERED_BY_ALL_STAGES;
             }
             if ($persistantProductConfigItemValue != ProductsConfigurationForm::FILTERED_BY_ALL_STAGES) {
                 if ($model->stage->value != $persistantProductConfigItemValue) {
                     continue;
                 }
             }
             if ($model->priceFrequency == ProductTemplate::PRICE_FREQUENCY_ONE_TIME) {
                 $oneTimeTotal += $this->getAdjustedTotalByCurrency($model);
             }
             if ($model->priceFrequency == ProductTemplate::PRICE_FREQUENCY_MONTHLY) {
                 $monthlyTotal += $this->getAdjustedTotalByCurrency($model);
             }
             if ($model->priceFrequency == ProductTemplate::PRICE_FREQUENCY_ANNUALLY) {
                 $annualTotal += $this->getAdjustedTotalByCurrency($model);
             }
         }
     }
     $content = Zurmo::t("Core", "Total: ");
     $contentArray = array();
     if ($oneTimeTotal > 0) {
         $contentArray[] = Yii::app()->numberFormatter->formatCurrency($oneTimeTotal, Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay()) . Zurmo::t("Core", " One Time");
     }
     if ($monthlyTotal > 0) {
         $contentArray[] = Yii::app()->numberFormatter->formatCurrency($monthlyTotal, Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay()) . Zurmo::t("Core", " Monthly");
     }
     if ($annualTotal > 0) {
         $contentArray[] = Yii::app()->numberFormatter->formatCurrency($annualTotal, Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay()) . Zurmo::t("Core", " Annually");
     }
     if (empty($contentArray)) {
         $content = '';
     } else {
         $content .= implode(', ', $contentArray);
     }
     echo $content;
 }
 /**
  * @param ProductsConfigurationForm $productsConfigurationForm
  * @param string $excludeFromRestore
  * @return ProductsConfigurationForm
  */
 protected function restoreUserSettingsToConfigFrom(&$productsConfigurationForm, $excludeFromRestore)
 {
     foreach (static::$persistantProductPortletConfigs as $persistantProductConfigItem) {
         if (in_array($persistantProductConfigItem, $excludeFromRestore)) {
             continue;
         }
         $persistantProductConfigItemValue = ProductsPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($this->params['portletId'], $persistantProductConfigItem);
         if (isset($persistantProductConfigItemValue)) {
             $productsConfigurationForm->{$persistantProductConfigItem} = $persistantProductConfigItemValue;
         }
     }
     return $productsConfigurationForm;
 }