本文整理匯總了PHP中NumberFormatter::getSymbol方法的典型用法代碼示例。如果您正苦於以下問題:PHP NumberFormatter::getSymbol方法的具體用法?PHP NumberFormatter::getSymbol怎麽用?PHP NumberFormatter::getSymbol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NumberFormatter
的用法示例。
在下文中一共展示了NumberFormatter::getSymbol方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildView
/**
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$dataType = self::DATA_INTEGER;
if (isset($options['data_type'])) {
$dataType = $options['data_type'];
}
$formatterOptions = array();
switch ($dataType) {
case self::PERCENT:
$formatterOptions['decimals'] = 2;
$formatterOptions['grouping'] = false;
$formatterOptions['percent'] = true;
break;
case self::DATA_DECIMAL:
$formatterOptions['decimals'] = 2;
$formatterOptions['grouping'] = true;
break;
case self::DATA_INTEGER:
default:
$formatterOptions['decimals'] = 0;
$formatterOptions['grouping'] = false;
}
$formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
$formatterOptions['orderSeparator'] = $formatterOptions['grouping'] ? $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL) : '';
$formatterOptions['decimalSeparator'] = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
$view->vars['formatter_options'] = array_merge($formatterOptions, $options['formatter_options']);
}
示例2: render
/**
* \copydoc ::Erebot::Styling::VariableInterface::render()
*
* \note
* If no currency was passed to this class' constructor,
* the currency associated with the translator's locale
* is used.
*/
public function render(\Erebot\IntlInterface $translator)
{
$locale = $translator->getLocale(\Erebot\IntlInterface::LC_MONETARY);
$formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
$currency = $this->currency !== null ? $this->currency : $formatter->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL);
return (string) $formatter->formatCurrency($this->value, $currency);
}
示例3: currencySymbolFunction
public function currencySymbolFunction($locale)
{
$locale = $locale == null ? \Locale::getDefault() : $locale;
$formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
$symbol = $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
return $symbol;
}
示例4: currency_symbol
public function currency_symbol($config = array())
{
$config = new KObjectConfig($config);
$config->append(array('currency_code' => 'USD', 'locale' => 'en_US'));
if (class_exists('NumberFormatter')) {
$formatter = new \NumberFormatter($config->locale . '@currency=' . $config->currency_code, \NumberFormatter::CURRENCY);
$result = $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
} else {
$result = $config->currency_code;
}
return $result;
}
示例5: check_number_locale
public function check_number_locale()
{
$number_locale = $this->input->post('number_locale');
$fmt = new \NumberFormatter($number_locale, \NumberFormatter::CURRENCY);
$currency_symbol = empty($this->input->post('currency_symbol')) ? $fmt->getSymbol(\NumberFormatter::CURRENCY_SYMBOL) : $this->input->post('currency_symbol');
if ($this->input->post('thousands_separator') == "false") {
$fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
}
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $currency_symbol);
$number_local_example = $fmt->format(1234567890.123);
echo json_encode(array('success' => $number_local_example != FALSE, 'number_locale_example' => $number_local_example, 'currency_symbol' => $currency_symbol, 'thousands_separator' => $fmt->getAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL) != ''));
}
示例6: format
private function format()
{
$numberFormatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::CURRENCY);
$result = $numberFormatter->format($this->getValue());
if ($this->format !== null || self::$globalFormat !== null) {
// need a special format?
if ($this->format === null) {
// if the local format was not setted, the global format is used
$this->format = self::$globalFormat;
}
$symbol = $numberFormatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
$number = trim(str_replace($symbol, '', $result));
$result = str_replace('{symbol}', $symbol, $this->format);
$result = str_replace('{number}', $number, $result);
}
return $result;
}
示例7: format
/**
* Locale-aware number and monetary formatting.
* Due to issues with the operating system functions on some platforms intl extension is used if available
*
* // In English, "1,200.05"
* // In Spanish, "1200,05"
* // In Portuguese, "1 200,05"
* echo Num::format(1200.05, 2);
*
* // In English, "1,200.05"
* // In Spanish, "1.200,05"
* // In Portuguese, "1.200.05"
* echo Num::format(1200.05, 2, true);
*
* @param float $number number to format
* @param integer $places decimal places
* @param boolean $monetary monetary formatting?
* @return string
*/
public static function format($number, $places, $monetary = false)
{
if (extension_loaded('intl')) {
$mode = $monetary ? \NumberFormatter::CURRENCY : \NumberFormatter::DECIMAL;
$formatter = new \NumberFormatter(\Locale::getDefault(), $mode);
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $places);
$result = $formatter->format($number);
return $monetary ? str_replace($formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL), '', $result) : $result;
}
$info = localeconv();
if ($monetary) {
$decimal = $info['mon_decimal_point'];
$thousands = $info['mon_thousands_sep'];
} else {
$decimal = $info['decimal_point'];
$thousands = $info['thousands_sep'];
}
return number_format($number, $places, $decimal, $thousands);
}
示例8: format
private function format()
{
$locale = $this->locale === null ? \Locale::getDefault() : $this->locale;
$numberFormatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
$result = $numberFormatter->format($this->getValue());
if ($this->format !== null || self::$globalFormat !== null) {
// need a special format?
if ($this->format === null) {
// if the local format was not setted, the global format is used
$this->format = self::$globalFormat;
}
// remove the parenthesis indicating negative value, it will be placed afterwards
$result = trim($result, '()');
$symbol = $numberFormatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
$number = trim(str_replace($symbol, '', $result));
$result = str_replace('{symbol}', $symbol, $this->format);
$result = str_replace('{number}', $number, $result);
}
return $result;
}
示例9: validate
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
{
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value)) {
throw new UnexpectedTypeException($value, 'string');
}
$formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::ROUNDING_MODE, \NumberFormatter::ROUND_DOWN);
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, 0);
$formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 0);
$formatter->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, 0);
$decimalSeparator = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
$position = 0;
$formatter->parse($value, PHP_INT_SIZE == 8 ? $formatter::TYPE_INT64 : $formatter::TYPE_INT32, $position);
if (intl_is_failure($formatter->getErrorCode()) || strpos($value, $decimalSeparator) !== false || $position < strlen($value)) {
/** @var Integer $constraint */
$this->context->addViolation($constraint->message, ['{{ value }}' => $this->formatValue($value)]);
}
}
示例10: cetakRestitusiAction
/**
* Cetak kwitansi restitusi.
*
* @Route("/cetak-restitusi/{rid}", name="pembayaran_pendaftaran__cetak_restitusi")
*/
public function cetakRestitusiAction($sid, $rid)
{
$sekolah = $this->getSekolah();
$em = $this->getDoctrine()->getManager();
$siswa = $em->getRepository('LanggasSisdikBundle:Siswa')->find($sid);
if (!(is_object($siswa) && $siswa instanceof Siswa)) {
throw $this->createNotFoundException('Entity Siswa tak ditemukan.');
}
if ($this->get('security.authorization_checker')->isGranted('view', $siswa) === false) {
throw new AccessDeniedException($this->get('translator')->trans('akses.ditolak'));
}
$pembayaranPendaftaran = $em->getRepository('LanggasSisdikBundle:PembayaranPendaftaran')->findBy(['siswa' => $siswa]);
$restitusi = $em->getRepository('LanggasSisdikBundle:RestitusiPendaftaran')->find($rid);
if (!$restitusi instanceof RestitusiPendaftaran) {
throw $this->createNotFoundException('Entity RestitusiPendaftaran tak ditemukan.');
}
$restitusiPendaftaran = $em->getRepository('LanggasSisdikBundle:RestitusiPendaftaran')->findBy(['sekolah' => $sekolah, 'siswa' => $siswa], ['waktuSimpan' => 'ASC']);
$counterRestitusi = 0;
$nomorRestitusi = 1;
$totalRestitusi = 0;
foreach ($restitusiPendaftaran as $r) {
if ($r instanceof RestitusiPendaftaran) {
$counterRestitusi++;
$totalRestitusi += $r->getNominalRestitusi();
if ($r->getId() == $rid) {
$nomorRestitusi = $counterRestitusi;
}
}
}
$jumlahRestitusi = $em->createQueryBuilder()->select('COUNT(restitusi.id)')->from('LanggasSisdikBundle:RestitusiPendaftaran', 'restitusi')->where('restitusi.sekolah = :sekolah')->andWhere('restitusi.siswa = :siswa')->setParameter('sekolah', $sekolah)->setParameter('siswa', $siswa)->getQuery()->getSingleScalarResult();
$totalBayar = $em->createQueryBuilder()->select('SUM(transaksi.nominalPembayaran) AS jumlah')->from('LanggasSisdikBundle:TransaksiPembayaranPendaftaran', 'transaksi')->leftJoin('transaksi.pembayaranPendaftaran', 'pembayaran')->where('transaksi.sekolah = :sekolah')->andWhere('pembayaran.siswa = :siswa')->setParameter('sekolah', $sekolah)->setParameter('siswa', $siswa)->getQuery()->getSingleScalarResult();
$totalPotongan = $em->createQueryBuilder()->select('SUM(pembayaran.persenPotonganDinominalkan + pembayaran.nominalPotongan) AS jumlah')->from('LanggasSisdikBundle:PembayaranPendaftaran', 'pembayaran')->where('pembayaran.siswa = :siswa')->setParameter('siswa', $siswa)->getQuery()->getSingleScalarResult();
$qbDaftarBiaya = $em->createQueryBuilder()->select('daftar')->from('LanggasSisdikBundle:DaftarBiayaPendaftaran', 'daftar')->leftJoin('daftar.biayaPendaftaran', 'biaya')->leftJoin('daftar.pembayaranPendaftaran', 'pembayaran')->where('pembayaran.siswa = :siswa')->orderBy('biaya.urutan', 'ASC')->setParameter('siswa', $siswa);
$daftarBiaya = $qbDaftarBiaya->getQuery()->getResult();
$itemBiayaTersimpan = [];
foreach ($daftarBiaya as $daftar) {
if ($daftar instanceof DaftarBiayaPendaftaran) {
$itemBiayaTersimpan[] = $daftar->getBiayaPendaftaran()->getId();
}
}
/* @var $pembayaran PembayaranPendaftaran */
/* @var $biaya BiayaPendaftaran */
$totalBiayaMasuk = 0;
foreach ($pembayaranPendaftaran as $pembayaran) {
foreach ($pembayaran->getDaftarBiayaPendaftaran() as $biaya) {
$totalBiayaMasuk += $biaya->getNominal();
}
}
$totalBiayaSisa = 0;
if (count($itemBiayaTersimpan) != 0) {
if ($siswa->getPenjurusan() instanceof Penjurusan) {
$response = $this->forward('LanggasSisdikBundle:BiayaPendaftaran:getFeeInfoRemain', ['tahun' => $siswa->getTahun()->getId(), 'gelombang' => $siswa->getGelombang()->getId(), 'usedfee' => implode(',', $itemBiayaTersimpan), 'penjurusan' => $siswa->getPenjurusan()->getId()]);
} else {
$response = $this->forward('LanggasSisdikBundle:BiayaPendaftaran:getFeeInfoRemain', ['tahun' => $siswa->getTahun()->getId(), 'gelombang' => $siswa->getGelombang()->getId(), 'usedfee' => implode(',', $itemBiayaTersimpan)]);
}
$totalBiayaSisa = $response->getContent();
} else {
if ($siswa->getPenjurusan() instanceof Penjurusan) {
$response = $this->forward('LanggasSisdikBundle:BiayaPendaftaran:getFeeInfoTotal', ['tahun' => $siswa->getTahun()->getId(), 'gelombang' => $siswa->getGelombang()->getId(), 'penjurusan' => $siswa->getPenjurusan()->getId()]);
} else {
$response = $this->forward('LanggasSisdikBundle:BiayaPendaftaran:getFeeInfoTotal', ['tahun' => $siswa->getTahun()->getId(), 'gelombang' => $siswa->getGelombang()->getId()]);
}
$totalBiayaSisa = $response->getContent();
}
$totalBiaya = $totalBiayaSisa + ($totalBiayaMasuk - $totalPotongan);
$tahun = $restitusi->getWaktuSimpan()->format('Y');
$bulan = $restitusi->getWaktuSimpan()->format('m');
$translator = $this->get('translator');
$formatter = new \NumberFormatter($this->container->getParameter('locale'), \NumberFormatter::CURRENCY);
$symbol = $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
$output = 'pdf';
$pilihanCetak = $em->getRepository('LanggasSisdikBundle:PilihanCetakKwitansi')->findOneBy(['sekolah' => $sekolah]);
if ($pilihanCetak instanceof PilihanCetakKwitansi) {
$output = $pilihanCetak->getOutput();
}
$fs = new Filesystem();
$dirKwitansiSekolah = $this->get('kernel')->getRootDir() . self::RECEIPTS_DIR . $sekolah->getId();
if (!$fs->exists($dirKwitansiSekolah . DIRECTORY_SEPARATOR . $tahun . DIRECTORY_SEPARATOR . $bulan)) {
$fs->mkdir($dirKwitansiSekolah . DIRECTORY_SEPARATOR . $tahun . DIRECTORY_SEPARATOR . $bulan);
}
if ($output == 'esc_p') {
$filetarget = $restitusi->getNomorTransaksi() . ".sisdik.direct";
$documenttarget = $dirKwitansiSekolah . DIRECTORY_SEPARATOR . $tahun . DIRECTORY_SEPARATOR . $bulan . DIRECTORY_SEPARATOR . $filetarget;
$commands = new EscapeCommand();
$commands->addLineSpacing_1_6();
$commands->addPageLength33Lines();
$commands->addMarginBottom5Lines();
$commands->addMaster10CPI();
$commands->addMasterCondensed();
$commands->addModeDraft();
// max 137 characters
$maxwidth = 137;
$labelwidth1 = 20;
$labelwidth2 = 15;
$marginBadan = 7;
//.........這裏部分代碼省略.........
示例11: normalize
/**
* @param String $number
* @return String
*/
private function normalize($number)
{
$numberFormatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
$decPoint = $numberFormatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
$thousandPoint = $numberFormatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
if (strstr($number, $decPoint)) {
$number = str_replace($thousandPoint, '', $number);
$number = str_replace($decPoint, '.', $number);
}
return $number;
}
示例12: getCurrencySymbol
/**
* @param Currency $currency
* @param string|null $locale
* @return string
*/
public static function getCurrencySymbol(Currency $currency, $locale = null)
{
$locale = null === $locale ? \Yii::$app->language : $locale;
$result = '';
try {
$fake = $locale . '@currency=' . $currency->iso_code;
$fmt = new \NumberFormatter($fake, \NumberFormatter::CURRENCY);
$result = $fmt->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
} catch (\Exception $e) {
$result = preg_replace('%[\\d\\s,]%i', '', $currency->format(0));
}
return $result;
}
示例13: setDecimalSeparator
/**
* @param string $uiLocale
*
* @return string
*/
public function setDecimalSeparator($uiLocale)
{
$number = new \NumberFormatter($uiLocale, \NumberFormatter::DECIMAL);
$this->decimalSeparator = $number->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
}
示例14: currencyForCountryCode
/**
* Returns the code of the currency that is default for a specified country/region code.
*
* @param string $code The two-letter ISO 3166 (or ISO 639) country/region code (case-insensitive).
*
* @return CUStringObject The three-letter currency code for the country/region code.
*/
public static function currencyForCountryCode($code)
{
assert('is_cstring($code)', vs(isset($this), get_defined_vars()));
$code = CString::toUpperCase($code);
$locale = self::fromCountryCode($code);
if (!$locale->hasRegionCode()) {
return self::DEFAULT_CURRENCY;
}
$numberFormatter = new NumberFormatter($locale->m_name, NumberFormatter::CURRENCY);
return $numberFormatter->getSymbol(NumberFormatter::INTL_CURRENCY_SYMBOL);
}
示例15: updateAction
//.........這裏部分代碼省略.........
$layanan = $em->getRepository('LanggasSisdikBundle:LayananSms')->findOneBy(['sekolah' => $sekolah, 'jenisLayanan' => 'za-biaya-sekali-bayar']);
if ($layanan instanceof LayananSms) {
$tekstemplate = $layanan->getTemplatesms()->getTeks();
$namaOrtuWali = "";
$ponselOrtuWali = "";
$orangtuaWaliAktif = $siswa->getOrangtuaWaliAktif();
if ($orangtuaWaliAktif instanceof OrangtuaWali) {
$namaOrtuWali = $orangtuaWaliAktif->getNama();
$ponselOrtuWali = $orangtuaWaliAktif->getPonsel();
}
$tekstemplate = str_replace("%nama-ortuwali%", $namaOrtuWali, $tekstemplate);
$tekstemplate = str_replace("%nama-siswa%", $siswa->getNamaLengkap(), $tekstemplate);
$nomorTransaksi = "";
$em->refresh($entity);
foreach ($entity->getTransaksiPembayaranSekali() as $transaksi) {
if ($transaksi instanceof TransaksiPembayaranSekali) {
$em->refresh($transaksi);
$nomorTransaksi = $transaksi->getNomorTransaksi();
}
}
$tekstemplate = str_replace("%nomor-kwitansi%", $nomorTransaksi, $tekstemplate);
$counter = 1;
$daftarBiayaDibayar = [];
foreach ($entity->getDaftarBiayaSekali() as $biaya) {
if ($counter > 3) {
$daftarBiayaDibayar[] = $this->get('translator')->trans('dll');
break;
}
$daftarBiayaDibayar[] = $biaya->getNama();
$counter++;
}
$tekstemplate = str_replace("%daftar-biaya%", implode(", ", $daftarBiayaDibayar), $tekstemplate);
$formatter = new \NumberFormatter($this->container->getParameter('locale'), \NumberFormatter::CURRENCY);
$symbol = $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
$tekstemplate = str_replace("%besar-pembayaran%", $symbol . ". " . number_format($currentPaymentAmount, 0, ',', '.'), $tekstemplate);
if ($ponselOrtuWali != "") {
$nomorponsel = preg_split("/[\\s,\\/]+/", $ponselOrtuWali);
foreach ($nomorponsel as $ponsel) {
$messenger = $this->get('sisdik.messenger');
if ($messenger instanceof Messenger) {
if ($vendorSekolah instanceof VendorSekolah) {
if ($vendorSekolah->getJenis() == 'khusus') {
$messenger->setUseVendor(true);
$messenger->setVendorURL($vendorSekolah->getUrlPengirimPesan());
}
}
$messenger->setPhoneNumber($ponsel);
$messenger->setMessage($tekstemplate);
$messenger->sendMessage($sekolah);
}
}
}
}
}
}
if ($siswa->isLunasBiayaSekali()) {
$pilihanLayananSms = $em->getRepository('LanggasSisdikBundle:PilihanLayananSms')->findOneBy(['sekolah' => $sekolah, 'jenisLayanan' => 'zb-biaya-sekali-bayar-lunas', 'status' => true]);
if ($pilihanLayananSms instanceof PilihanLayananSms) {
if ($pilihanLayananSms->getStatus()) {
$layanan = $em->getRepository('LanggasSisdikBundle:LayananSms')->findOneBy(['sekolah' => $sekolah, 'jenisLayanan' => 'zb-biaya-sekali-bayar-lunas']);
if ($layanan instanceof LayananSms) {
$tekstemplate = $layanan->getTemplatesms()->getTeks();
$namaOrtuWali = "";
$ponselOrtuWali = "";
$orangtuaWaliAktif = $siswa->getOrangtuaWaliAktif();
if ($orangtuaWaliAktif instanceof OrangtuaWali) {