Exemple #1
0
 public static function currency($value)
 {
     $cn = new CNumberFormatter(Yii::app()->locale->id);
     $fmt = $cn->formatCurrency($value, 'USD');
     if (strpos($fmt, '(') !== false) {
         $fmt = '<span class="negative">-' . str_replace(array('(', ')'), '', $fmt) . '</span>';
     }
     return $fmt;
 }
Exemple #2
0
 /**
  * Formats a number using the currency format defined in the locale.
  *
  * @param mixed  $value
  * @param string $currency
  * @param bool   $stripZeroCents
  *
  * @return string The formatted result.
  */
 public function formatCurrency($value, $currency, $stripZeroCents = false)
 {
     $result = parent::formatCurrency($value, $currency);
     if ($stripZeroCents) {
         $decimal = $this->_locale->getNumberSymbol('decimal');
         $result = preg_replace('/\\' . $decimal . '0{1,}$/', '', $result);
     }
     return $result;
 }
        echo CHtml::link($item->getTitle(), $item->getUrl());
        ?>
</td>
		<td><?php 
        echo $position['price'] . ' р.';
        ?>
</td>
		<td><?php 
        echo $position['quantity'] . ' шт.';
        ?>
</td>
		<td><?php 
        echo $position['quantity'] * $position['price'] . ' р.';
        ?>
</td>
	</tr>
<?php 
        $total += $position['quantity'] * $position['price'];
    }
    ?>
	<tr>
		<th>Итого</th>
		<th colspan=3><?php 
    $nf = new CNumberFormatter(Yii::app()->language);
    echo $nf->formatCurrency($total, 'RUB');
    ?>
</th>
	</tr>
</table>
<?php 
}
 public static function Currency($number)
 {
     $numberFormatter = new CNumberFormatter("pt_BR");
     return $numberFormatter->formatCurrency($number, 'BRL');
 }