本文整理匯總了PHP中CCurrencyLang::enableUseHideZero方法的典型用法代碼示例。如果您正苦於以下問題:PHP CCurrencyLang::enableUseHideZero方法的具體用法?PHP CCurrencyLang::enableUseHideZero怎麽用?PHP CCurrencyLang::enableUseHideZero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CCurrencyLang
的用法示例。
在下文中一共展示了CCurrencyLang::enableUseHideZero方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: foreach
CCurrencyLang::disableUseHideZero();
$orderId = (int) $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ID"];
if ($orderId) {
/** @var \Bitrix\Sale\Order $order */
$order = \Bitrix\Sale\Order::load($orderId);
if ($order) {
/** @var \Bitrix\Sale\PaymentCollection $paymentCollection */
$paymentCollection = $order->getPaymentCollection();
if ($paymentCollection) {
/** @var \Bitrix\Sale\Payment $payment */
foreach ($paymentCollection as $payment) {
if (!$payment->isInner()) {
break;
}
}
if ($payment) {
$context = \Bitrix\Main\Application::getInstance()->getContext();
$service = \Bitrix\Sale\PaySystem\Manager::getObjectById($payment->getPaymentSystemId());
if ($_REQUEST['pdf'] && $_REQUEST['GET_CONTENT'] == 'Y') {
$result = $service->initiatePay($payment, $context->getRequest(), \Bitrix\Sale\PaySystem\BaseServiceHandler::STRING);
if ($result->isSuccess()) {
return $result->getTemplate();
}
}
$result = $service->initiatePay($payment, $context->getRequest());
}
CCurrencyLang::enableUseHideZero();
}
}
}
示例2: MoneyToString
public static function MoneyToString($sum, $currencyID, $formatStr = '')
{
if (!CModule::IncludeModule('currency')) {
return number_format($sum, 2, '.', '');
}
$formatInfo = CCurrencyLang::GetCurrencyFormat($currencyID);
$formatInfo['DECIMALS'] = isset($formatInfo['DECIMALS']) ? intval($formatInfo['DECIMALS']) : 2;
if (!isset($formatInfo['DEC_POINT'])) {
$formatInfo['DEC_POINT'] = '.';
}
if (!empty($formatInfo['THOUSANDS_VARIANT'])) {
$thousands = $formatInfo['THOUSANDS_VARIANT'];
if ($thousands === 'N') {
$formatInfo['THOUSANDS_SEP'] = '';
} elseif ($thousands === 'D') {
$formatInfo['THOUSANDS_SEP'] = '.';
} elseif ($thousands === 'C') {
$formatInfo['THOUSANDS_SEP'] = ',';
} elseif ($thousands === 'S' || $thousands === 'B') {
$formatInfo['THOUSANDS_SEP'] = chr(32);
}
}
if (!isset($formatInfo['THOUSANDS_SEP'])) {
$formatInfo['THOUSANDS_SEP'] = '';
}
if (is_integer($sum) || is_float($sum)) {
// Stansard format for float
CCurrencyLang::enableUseHideZero();
return CCurrencyLang::CurrencyFormat($sum, $currencyID, $formatStr !== '#');
} else {
// Do not convert to float to avoid data lost caused by overflow (9 999 999 999 999 999.99 ->10 000 000 000 000 000.00)
$triadSep = strval($formatInfo['THOUSANDS_SEP']);
$decPoint = strval($formatInfo['DEC_POINT']);
$dec = intval($formatInfo['DECIMALS']);
$sum = str_replace(',', '.', strval($sum));
list($i, $d) = explode('.', $sum, 2);
$len = strlen($i);
$leadLen = $len % 3;
if ($leadLen === 0) {
$leadLen = 3;
//take a first triad
}
$lead = substr($i, 0, $leadLen);
if (!is_string($lead)) {
$lead = '';
}
$triads = substr($i, $leadLen);
if (!is_string($triads)) {
$triads = '';
}
$s = $triads !== '' ? $lead . preg_replace('/(\\d{3})/', $triadSep . '\\1', $triads) : ($lead !== '' ? $lead : '0');
$s .= $decPoint . str_pad(substr($d, 0, $dec), $dec, '0', STR_PAD_RIGHT);
}
if (!empty($formatInfo['THOUSANDS_VARIANT']) && $formatInfo['THOUSANDS_VARIANT'] === 'B') {
$s = str_replace(' ', ' ', $s);
}
$formatStr = strval($formatStr);
if ($formatStr === '' && $formatInfo['FORMAT_STRING'] !== '') {
$formatStr = $formatInfo['FORMAT_STRING'];
}
if ($formatStr === '' || $formatStr === '#') {
return strip_tags($s);
}
//Skip HTML entities
return strip_tags(preg_replace('/(^|[^&])#/', '${1}' . $s, $formatStr));
}