private function toCurency($value){
		return (string)Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($value);
	}
Esempio n. 2
0
    /**
     * returns text description about campaign commissions
     *
     * @param string $campaignId
     * @param Gpf_Data_RecordSet $rsCommissions
     * @return string
     */
    private function getCommissionsDescription($campaignId, Gpf_Data_RecordSet $rsCommissions) {
    	if($rsCommissions->getSize() == 0) {
    		return $this->_('none active');
    	}
    	
    	$commissions = array();
    	$maxTiers = 1;
    	foreach($rsCommissions as $record) {
    		if($campaignId != $record->get("campaignid")) {
    			continue;
    		}
    		
    		$rType = $record->get('rtype');
    		$tier = $record->get('tier');
    		if($tier > $maxTiers) {
    			$maxTiers = $tier;
    		}
    		$commissions[$rType][$tier]['commtype'] = $record->get(Pap_Db_Table_Commissions::TYPE);
    		$commissions[$rType][$tier]['value'] = $record->get(Pap_Db_Table_Commissions::VALUE);
    	}

    	$description = '';

    	for($i=1; $i<=$maxTiers; $i++) {
    		if(isset($commissions[Pap_Common_Constants::TYPE_CPM][$i])) {
    			$description .= ($description != '' ? ', ' : '');
    			$description .= $this->_('CPM').': '.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commissions[Pap_Common_Constants::TYPE_CPM][$i]['value']);
    		}
    		if(isset($commissions[Pap_Common_Constants::TYPE_CLICK][$i])) {
    			$description .= ($description != '' ? ', ' : '');
    			$description .= $this->_('per click').': '.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commissions[Pap_Common_Constants::TYPE_CLICK][$i]['value']);
    		}
    		if(isset($commissions[Pap_Common_Constants::TYPE_SALE][$i])) {
    			$description .= ($description != '' ? ', ' : '');

    			$description .= $this->_('per sale').': '.
    			Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commissions[Pap_Common_Constants::TYPE_SALE][$i]['value'],
    			$commissions[Pap_Common_Constants::TYPE_SALE][$i]['commtype']);
    		}

    	}
    	if($description == '') {
    		$description = $this->_('none active');
    	}
    	
    	return $description;
    }
	/**
	 * returns text description about campaign commissions
	 *
	 * @param string $campaignId
	 * @param Gpf_Data_RecordSet $rsCommissions
	 * @return string
	 */
	public function getCommissionsDescription($campaignId, Gpf_Data_RecordSet $rsCommissions, $commissionGroupId = null, $extendedFormatting = false) {
		if ($rsCommissions->getSize() == 0) {
			return $this->_('none active !');
		}

		if ($commissionGroupId == null) {
			try {
				$commissionGroupId = $this->getDefaultCommissionGroup($campaignId);
			} catch (Gpf_Exception $e) {
				return $this->_('none active');
			}
		}

		$commissions = array();
		foreach ($rsCommissions as $record) {
			if ($campaignId != $record->get("campaignid") ||
			($commissionGroupId != '' && $commissionGroupId != $record->get("commissiongroupid"))) {
				continue;
			}

			$rType = $record->get('rtype');
			$commissions[$rType]['commtype'] = $record->get(Pap_Db_Table_Commissions::TYPE);
			$commissions[$rType]['value'] = $record->get(Pap_Db_Table_Commissions::VALUE);
			switch ($rType) {
				case Pap_Common_Constants::TYPE_CPM:
					$commissionTypeName = $this->_('CPM');
					break;
				case Pap_Common_Constants::TYPE_CLICK:
					$commissionTypeName = $this->_('per click');
					break;
				case Pap_Common_Constants::TYPE_SALE:
					$commissionTypeName = $this->_('per sale / lead');
					break;
				default:
					$commissionTypeName = $record->get('commissionTypeName');
					break;
			}
			$commissions[$rType]['name'] = $commissionTypeName;
		}

		$description = '';
		if ($extendedFormatting) {
			foreach ($commissions as $rtype => $commission) {
				$description .= ($description != '' ? '<br>' : '');
				$description .= $commission['name'].': <strong>'.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commission['value'], $commission['commtype']).'</strong>';
			}
		} else {
			foreach ($commissions as $rtype => $commission) {
				$description .= ($description != '' ? ', ' : '');
				$description .= $commission['name'].': '.Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($commission['value'], $commission['commtype']);
			}
		}
		if($description == '') {
			$description = $this->_('none active');
		}

		return $description;
	}
 protected function getFormattedBonusValue() {
     return Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($this->rule->getBonusValue(), $this->rule->getBonusType());
 }