/** * Smarty {localize} function plugin * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {ratio p1='25' p2='35'} * </pre> * @author Andrej Harsani, Michal Bebjak * @param array * @param Smarty * @return string */ function smarty_function_ratio($params, &$smarty) { if ($params['p2']!=0) { return round($params['p1']/$params['p2'],Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); } else { echo ''; } }
/** * Smarty {localize} function plugin * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {ratioPercentage p1='25' p2='35'} * </pre> * @author Andrej Harsani, Michal Bebjak * @param array * @param Smarty * @return string */ function smarty_function_ratioPercentage($params, &$smarty) { if ($params['p2']!=0) { $number = round($params['p1']/$params['p2']*100,Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); return Gpf_Common_NumberUtils::toStandardNumberFormat($number, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()) . ' %'; } else { return '0'; } }
protected function setVariableValues() { $this->setVariable('currency', Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getSymbol()); $this->setVariable('payaffiliateslist', $this->payAffiliatesList->getHtml()); $this->setVariable('amounttopay', $this->payAffiliatesList->getAmountToPay()); $this->setVariable('approvedcommissions', $this->payAffiliatesList->getApprovedCommissions()); $this->setVariable('pendingcommissions', $this->payAffiliatesList->getPendingCommissions()); $this->setVariable('declinedcommissions', $this->payAffiliatesList->getDeclinedCommissions()); }
protected function setVariableValues() { $this->setVariable('currency', Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getSymbol()); $this->setStatsVariables(); $this->setVariableRaw('commissionsList', new Pap_Mail_Reports_List($this->createTransactionList($this->statsParams))); $this->setVariableRaw('salesList', new Pap_Mail_Reports_List($this->getSalesList())); $this->setVariableRaw('actionsList', new Pap_Mail_Reports_List($this->getActionsList())); }
/** * Smarty |currency_span modifier * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {$allCommission|currency_span} * </pre> * @author Michal Bebjak * @param string * @return string */ function smarty_modifier_currency_span($number) { $cssClass = 'CurrencyData'; if ($number < 0) { $cssClass .= ' CurrencyData-negative'; } $number = number_format($number, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision(), Gpf_Settings_Regional::getInstance()->getDecimalSeparator(), Gpf_Settings_Regional::getInstance()->getThousandsSeparator()); return '<span class="'.$cssClass.'">'.Pap_Common_Utils_CurrencyUtils::stringToCurrencyFormat($number).'</span>'; }
/** * * @service affiliate_invoice read * @param $fields */ public function previewInvoice(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $user = new Pap_Affiliates_User(); $applyVat = $form->getFieldValue('applyVat'); $payoutInvoice = $form->getFieldValue('payoutInvoice'); $user->setId($form->getFieldValue('userid')); try { $user->load(); } catch (Gpf_Exception $e) { $this->invoiceHtml = $this->_("You have to select user"); return $this; } $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency(); $payout = new Pap_Common_Payout($user, $currency, 1, 123456); $payout->setApplyVat($applyVat); $payout->generateInvoice($payoutInvoice); $this->invoiceHtml = $payout->getInvoice(); return $this; }
private function round($value) { return round($value, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); }
/** * 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; }
/** * @service pay_affiliate write * @return Gpf_Rpc_Form */ public function payAffiliates(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $this->saveNotificationSettings($form); $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency(); $payoutHistory = $this->createPayoutHistoryItem($form); foreach ($this->getAffiliatesToPaySelect()->getAllRowsIterator() as $row) { $user = new Pap_Common_User(); $user->fillFromRecord($row); $payout = new Pap_Common_Payout($user, $currency, $row->get('amountRaw'), $this->generateInvoiceNumber()); $payout->setPayoutHistory($payoutHistory); $payout->generateInvoice(); try { $payout->save(); } catch (Gpf_DbEngine_Row_ConstraintException $e) { $form->setErrorMessage($this->_('Failed to pay affiliates %s', $e->getMessage())); continue; } $this->markTransactionsAsPaid($payout); $this->sendEmails($payout); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.Pap_Merchants_Payout_PayAffiliatesForm.payAffiliates', $user); } $form->setInfoMessage($this->_('Affiliates successfully paid')); return $form; }
private function toCurency($value){ return (string)Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($value); }
/** * Get default currency symbol */ private function getDefaultCurrencySymbol() { $defaultCurrency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency(); return $defaultCurrency->getSymbol(); }
/** * formats the value to the standard currency format according to the default currency settings * For example 2.0001 will be transformed to $ 2.0001. Does not round the number. * * @param string $value * @return string */ public static function stringToCurrencyFormat($value) { if ($value == null || $value == '') { return $value; } $defaultCurrency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency(); if($defaultCurrency == NULL) { return $value; } $currencySymbol = $defaultCurrency->getSymbol(); $currencyWhereDisplay = $defaultCurrency->getWhereDisplay(); if ($currencyWhereDisplay == Pap_Common_Utils_CurrencyUtils::WHEREDISPLAY_LEFT) { return $currencySymbol.' '.$value; } return $value.' '.$currencySymbol; }
private function createList() { $salesTemplate = new Gpf_Templates_Template('sales_list.tpl', 'merchants'); $salesTemplate->assignByRef('sales', $this->iterator); $salesTemplate->assignByRef('currency', Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getSymbol()); return $salesTemplate->getHTML(); }
/** * Smarty |currency modifier * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {$allCommission|currency} * </pre> * @author Michal Bebjak * @param string * @return string */ function smarty_modifier_currency($number) { $number = number_format($number, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision(), Gpf_Settings_Regional::getInstance()->getDecimalSeparator(), Gpf_Settings_Regional::getInstance()->getThousandsSeparator()); return Pap_Common_Utils_CurrencyUtils::stringToCurrencyFormat($number); }
/** * @param Gpf_Data_Row $row */ private function addVATData(Gpf_Data_Row $row) { try { $user = new Pap_Common_User(); $user->setId($row->get('userid')); $user->load(); } catch (Gpf_Exception $e) { $row->add('vat', $this->_('N/A')); $row->add('amounttopay', $this->_('N/A')); return; } $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency(); $payout = new Pap_Common_Payout($user, $currency, $row->get(Pap_Db_Table_Transactions::COMMISSION), null); if (!$payout->getApplyVat()) { $row->add('vat', $this->_('N/A')); $row->add('amounttopay', $row->get(Pap_Db_Table_Transactions::COMMISSION)); return; } $row->add('vat', $payout->getVatPercentage() . ' %'); $row->add('amounttopay', $payout->getAmountWithVat()); }
/** * 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; }
public function getTooltip() { if ($this->dataType == Pap_Stats_Computer_Graph_Transactions::COUNT) { return parent::getTooltip(); } return '#x_label#<br>'.$this->getName().': '.Pap_Common_Utils_CurrencyUtils::stringToCurrencyFormat('#val#'); }
public function getAmountAsText() { return round($this->getAmount(), Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); }
protected function getFormattedBonusValue() { return Pap_Common_Utils_CurrencyUtils::toStandardCurrencyFormat($this->rule->getBonusValue(), $this->rule->getBonusType()); }