/** * Load all currencies * * @return array */ public static function getAllCurrencies() { if (self::$completeLoad == false) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('*')->from($db->qn('#__redcore_currency')); $db->setQuery($query); $items = $db->loadObjectList(); foreach ($items as $item) { $item->precision = $item->decimals; self::$currencies[$item->alpha3] = $item; } self::$completeLoad = true; } return self::$currencies; }
/** * Return supported currencies from http://www.currency-iso.org * * @return array */ protected static function get_iso_4217_currency_codes() { if (!self::$codes) { // Xml file was pulled from http://www.currency-iso.org/dam/downloads/table_a1.xml. Should be refreshed sometimes ! $xml = file_get_contents(dirname(__FILE__) . '/currency_iso_4217_table.xml'); $obj = new SimpleXMLElement($xml); $currencies = array(); foreach ($obj->children()->children() as $country) { $code = (string) $country->Ccy; if ($code && !isset($currencies[$code])) { $obj = new stdclass(); $obj->name = (string) $country->CcyNm; $obj->code = (string) $country->Ccy; $obj->number = (string) $country->CcyNbr; $currencies[$code] = $obj; } } self::$codes = $currencies; } return self::$codes; }
/** * Test getOptions * * @return void */ public function testGetOptions() { $options = RHelperCurrency::getCurrencyOptions(); $this->assertTrue(is_array($options) && count($options)); }
</th> <td> <?php echo $this->item->transaction_id; ?> </td> </tr> <tr> <th> <?php echo JText::_('COM_REDCORE_PAYMENT_LOG_AMOUNT'); ?> </th> <td> <?php echo RHelperCurrency::getFormattedPrice($this->item->amount, $this->item->currency); ?> </td> </tr> <tr> <th> <?php echo JText::_('COM_REDCORE_PAYMENT_LOG_COUPON_CODE'); ?> </th> <td> <?php echo $this->item->coupon_code; ?> </td> </tr>
/** * Method to get the options to populate list * * @return array The field option objects. * * @since 1.0 */ protected function getOptions() { $options = array_merge(parent::getOptions(), RHelperCurrency::getCurrencyOptions()); return $options; }
</td> </tr> <tr> <th> <?php echo JText::_('COM_REDCORE_PAYMENT_DASHBOARD_STATISTICS_AVERAGE'); ?> </th> <td> <?php echo $values['sum']['averageCount']; ?> </td> <td> <?php echo RHelperCurrency::getFormattedPrice($values['sum']['averageSum'], $this->paymentData['chart']['currency']); ?> </td> </tr> </table> </div> <?php } ?> </div> <input type="hidden" name="task" value=""> <input type="hidden" name="boxchecked" value="0"> <?php echo JHtml::_('form.token'); ?>
/** * Generate Payment Log depending on the status * * @param array $paymentLog Data for payment log storage * @param bool $updatePaymentStatus Update Payment Status * * @return bool */ public static function saveNewPaymentLog($paymentLog, $updatePaymentStatus = true) { if (empty($paymentLog['payment_id'])) { return false; } // Forcing default set of statuses $paymentLog['status'] = RApiPaymentStatus::getStatus($paymentLog['status']); // Currency should not be numeric if (!empty($paymentLog['currency']) && is_numeric($paymentLog['currency'])) { $paymentLog['currency'] = RHelperCurrency::getIsoCode($paymentLog['currency']); } /** @var RedcoreModelPayment_Log $logModel */ $logModel = RModelAdmin::getAdminInstance('Payment_Log', array(), 'com_redcore'); if ($logModel->save($paymentLog)) { if ($updatePaymentStatus) { self::updatePaymentStatus($paymentLog['payment_id']); } } return true; }
/** * Get the payment amount as an float. * * @param int $amount Amount * @param string $currency Iso 4217 3 letters currency code * * @return float */ public function getAmountToFloat($amount, $currency) { return (double) round($amount / pow(10, RHelperCurrency::getPrecision($currency))); }
echo $item->extension_name; ?> </td> <td> <?php echo $item->owner_name; ?> </td> <td> <?php echo RHelperCurrency::getFormattedPrice($item->amount_total, $item->currency); ?> </td> <td> <?php echo RHelperCurrency::getFormattedPrice($item->amount_paid, $item->currency); ?> </td> <td> <?php echo RApiPaymentStatus::getStatusLabel($item->status); ?> </td> <td> <?php echo JHtml::_('date', $item->modified_date, JText::_('DATE_FORMAT_LC2')); ?> </td> </tr> <?php }