本文整理汇总了PHP中CakeNumber::currency方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeNumber::currency方法的具体用法?PHP CakeNumber::currency怎么用?PHP CakeNumber::currency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeNumber
的用法示例。
在下文中一共展示了CakeNumber::currency方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: numberCurrency
/**
* Number format by market with currency code
*
* @param $market_id
* @param $number
* @param bool $no_symbol
* @return string
*/
public function numberCurrency($market_id, $number, $no_symbol = false)
{
if ($market_id == 5) {
$currency = 'GBP';
} elseif ($market_id == 7 || $market_id == 8 || $market_id == 9) {
$currency = 'EUR';
} else {
$currency = 'USD';
}
if ($no_symbol) {
$options = ['before' => false, 'after' => false, 'places' => 2];
} else {
$options = ['places' => 2];
}
return CakeNumber::currency($number, $currency, $options);
}
示例2: word
//.........这里部分代码省略.........
<p> Singapore 758301 </p>
<div class="invoice_address_blog">
<div class="invoice_add">
<h5>ATTN </h5>
<span>:</span><abbr>' . $contact . '</abbr></div>
<div class="invoice_add">
<h5>TEL </h5>
<span>:</span><abbr> ' . $phone . ' </abbr></div>
<div class="invoice_add">
<h5>FAX </h5>
<span>:</span><abbr>' . $fax . '</abbr></div>
<div class="invoice_add">
<h5>EMAIL </h5>
<span>:</span><abbr>' . $email . '</abbr></div>
</div>
</div>
<div class="address_box">
<h2 class=""> ' . $id . ' </h2>
<div class="invoice_address_blog f_left">
<div class="invoice_add f_left">
<h5> TRACK ID </h5>
<span>:</span><abbr>' . $our_ref_no . '</abbr></div>
<div class="invoice_add f_left">
<h5>PURCHASE ORDER NUMBER </h5>
<span>:</span><abbr>' . $ref_no . '</abbr></div>
<div class="invoice_add f_left">
<h5>DATE </h5>
<span>:</span><abbr>' . $reg_date . '</abbr></div>
<div class="invoice_add f_left">
<h5> PAYMENT TERMS </h5>
<span>:</span><abbr>' . $payment_term . '</abbr></div>
</div>
</div>
<div class="services_details f_left">
<p>Being provided calibration service of the following(s) :</p>
<h4 class="f_left"><abbr>SALES ORDER NO</abbr><span> ' . $salesorderno . '</span></h4>
</div>
<div class="invoice_table f_left">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>Instrument</th>
<th>Brand</th>
<th>Model</th>
<th>Serial No</th>
<th>Quantity</th>
<th>Unit Price $(SGD)</th>
<th>Total Price $(SGD)</th>
</tr>
</thead>
<tbody>';
$subtotal = 0;
foreach ($device_name as $device) {
$html .= '
<tr>
<td class="instrument"><h4>' . $device['Instrument']['name'] . '</h4>
<span>Faulty</span> <span>(9~10)/mm</span></td>
<td>' . $device['Instrument']['InstrumentBrand']['Brand']['brandname'] . '</td>
<td>' . $device['model_no'] . '</td>
<td>53254324</td>
<td>1</td>
<td> $' . $device['sales_unitprice'] . '</td>
<td> $' . $device['sales_unitprice'] . '</td>
</tr>';
$subtotal = $subtotal + $device['sales_unitprice'];
}
$gst = $subtotal * 0.07000000000000001;
//setlocale(LC_MONETARY, 'en_SG');
//$subtotal = money_format('%i', $subtotal);
//$gst = money_format('%i', $gst);
$total_due = $gst + $subtotal;
App::uses('CakeNumber', 'Utility');
$currency = 'USD';
$total_due = CakeNumber::currency($total_due, $currency);
$gst = CakeNumber::currency($gst, $currency);
$subtotal = CakeNumber::currency($subtotal, $currency);
//$total_due = $this->Number->currency($total_due, $currency);
//$total_due = money_format('%i', $total_due);
//echo $a;
//exit;
$html .= '<tr>
<td colspan="6">SUBTOTAL</td>
<td>' . $subtotal . '</td>
</tr>
<tr>
<td colspan="6">GST ( 7.00% )</td>
<td>' . $gst . '</td>
</tr>
<tr>
<td colspan="6"><h4>TOTAL DUE</h4></td>
<td><h4>' . $total_due . '</h4></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>';
$this->export_report_all_format($file_type, $filename, $html);
}
示例3: currency
/**
* Correct the default for European countries
*
* @param mixed $number
* @param string $currency
* @param array $formatOptions
* @return string
*/
public static function currency($number, $currency = null, $formatOptions = [])
{
if ($currency === null) {
$currency = static::$_currency;
}
$defaults = [];
if ($currency !== 'EUR' && isset(static::$_currencies[$currency])) {
$defaults = static::$_currencies[$currency];
} elseif ($currency !== 'EUR' && is_string($currency)) {
$defaults['wholeSymbol'] = $currency;
$defaults['wholePosition'] = 'before';
$defaults['spacer'] = true;
}
$defaults += ['wholeSymbol' => '€', 'wholePosition' => 'after', 'negative' => '-', 'positive' => '+', 'escape' => true, 'decimals' => ',', 'thousands' => '.', 'spacer' => $currency === 'EUR' ? true : false];
$options = $formatOptions + $defaults;
if (!empty($options['spacer'])) {
$spacer = is_string($options['spacer']) ? $options['spacer'] : ' ';
if ($options['wholePosition'] === 'after') {
$options['wholeSymbol'] = $spacer . $options['wholeSymbol'];
} elseif ($options['wholePosition'] === 'before') {
$options['wholeSymbol'] .= $spacer;
}
}
$sign = '';
if ($number > 0 && !empty($options['signed'])) {
$sign = $options['positive'];
}
$options['signed'] = false;
return $sign . parent::currency($number, null, $options);
}
示例4: currency
/**
* Formats a number into a currency format.
*
* @param float $number Number to format.
* @param string $currency Shortcut to default options. Valid values are 'USD', 'EUR', 'GBP', otherwise
* set at least 'before' and 'after' options.
* 'USD' is the default currency, use CakeNumber::defaultCurrency() to change this default.
* @param array $options Options list.
* @return string Number formatted as a currency.
* @see CakeNumber::currency()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency
*/
public function currency($number, $currency = null, $options = array())
{
return $this->_engine->currency($number, $currency, $options);
}
示例5: currency
function currency($number, $currency = null, $options = array()) {
// App::uses('BakewellNumber', 'Utility');
// return BakewellNumber::currency($number, $currency, $options);
App::uses('CakeNumber', 'Utility');
return CakeNumber::currency($number, $currency, $options);
}
示例6: currency
/**
* Correct the default for European countries
* 2012-04-08 ms
*/
public static function currency($number, $currency = null, $formatOptions = array())
{
if ($currency === null) {
$currency = self::$_currency;
}
$options = array('wholeSymbol' => self::$_symbolRight, 'wholePosition' => 'after', 'negative' => '-', 'positive' => '+', 'escape' => true);
$options = am($options, $formatOptions);
if (!empty($options['wholeSymbol'])) {
if ($options['wholePosition'] == 'after') {
$options['wholeSymbol'] = ' ' . self::$_symbolRight;
} elseif ($options['wholePosition'] == 'before') {
$options['wholeSymbol'] = self::$_symbolLeft . ' ';
}
}
$sign = '';
if ($number > 0 && !empty($options['signed'])) {
$sign = $options['positive'];
}
return $sign . parent::currency($number, $currency, $options);
}
示例7: exportToExcel
public function exportToExcel($data = array(), $filename = null)
{
/*
* Export to excel - php
*/
//http://w3lessons.info/2015/07/13/export-html-table-to-excel-csv-json-pdf-png-using-jquery/
//html contain export in excel(upper link)
// http://www.codexworld.com/export-data-to-excel-in-php/
$preparedArray = array();
if (!empty($data)) {
$payment_total = 0;
$receipt_total = 0;
foreach ($data as $signleTransaction) {
$recordArray = array();
if ($signleTransaction["Transaction"]["transaction_type"] == "Payment") {
$amount = $signleTransaction["Transaction"]["amount"];
$recordArray["Payment Amount"] = CakeNumber::currency($amount, "");
$recordArray["Payment Particulars"] = $this->getParticulars($signleTransaction);
$payment_total += $amount;
} else {
$recordArray["Payment Amount"] = null;
$recordArray["Payment Particulars"] = null;
}
if ($signleTransaction["Transaction"]["transaction_type"] == "Receipt") {
$amount = $signleTransaction["Transaction"]["amount"];
$recordArray["Receipt Amount"] = CakeNumber::currency($amount, "");
$recordArray["Receipt Particulars"] = $this->getParticulars($signleTransaction);
$receipt_total += $amount;
} else {
$recordArray["Receipt Amount"] = null;
$recordArray["Receipt Particulars"] = null;
}
$preparedArray[] = $recordArray;
}
$recordArray = array();
$recordArray["Payment Amount"] = null;
$recordArray["Payment Particulars"] = null;
$recordArray["Receipt Amount"] = null;
$recordArray["Receipt Particulars"] = null;
$preparedArray[] = $recordArray;
$recordArray = array();
$recordArray["Payment Amount"] = "Total Payment";
$recordArray["Payment Particulars"] = null;
$recordArray["Receipt Amount"] = "Total Receipt";
$recordArray["Receipt Particulars"] = null;
$preparedArray[] = $recordArray;
$recordArray["Payment Amount"] = CakeNumber::currency($payment_total, "");
$recordArray["Payment Particulars"] = null;
$recordArray["Receipt Amount"] = CakeNumber::currency($receipt_total, "");
$recordArray["Receipt Particulars"] = null;
$preparedArray[] = $recordArray;
}
// $preparedArray = array();
// if (!empty($data)) {
// foreach ($data as $signleTransaction) {
// $recordArray = array();
// $recordArray["Amount"] = $signleTransaction["Transaction"]["amount"];
// $recordArray["Transaction Type"] = $signleTransaction["Transaction"]["transaction_type"];
// $recordArray["Is Interest Entry"] = $signleTransaction["Transaction"]["is_interest"];
// $recordArray["Remarks"] = $signleTransaction["Transaction"]["remarks"];
// $recordArray["Transaction Date"] = $signleTransaction["Transaction"]["transaction_date"];
// $recordArray["Created Date"] = $signleTransaction["Transaction"]["created"];
// $recordArray["Modified Date"] = $signleTransaction["Transaction"]["modified"];
// $preparedArray[] = $recordArray;
// }
// }
if (empty($filename)) {
// file name for download
$filename = "export_data" . date('Ymd') . ".xls";
}
$columnHeadings = array("Amount", "Particulars(Payment)", "Amount", "Particulars(Receipt)");
// headers for download
header("Content-Disposition: attachment; filename=\"{$filename}\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
foreach ($preparedArray as $row) {
if (!$flag) {
// display column names as first row
//echo implode("\t", array_keys($row)) . "\n";
echo implode("\t", $columnHeadings) . "\n";
$flag = true;
}
// filter data
array_walk($row, array($this, 'filterData'));
echo implode("\t", array_values($row)) . "\n";
}
exit;
}
示例8: _replaceCurrency
/**
* Replace by formatted currency string.
*
* Examples:
* - [currency]50[/currency]
* - [currency zero="$0.00"]0[/currency]
*
* @param string $str String to check and modify.
* @return string Modified string.
*/
protected function _replaceCurrency($str)
{
if (!preg_match_all('/\\[currency(.*?)\\](.*)\\[\\/currency\\]/i', $str, $matches)) {
// Fallback regex for when no options are passed.
if (!preg_match_all('/\\[currency(.*?)\\](.[^\\[]*)\\[\\/currency\\]/i', $str, $matches)) {
return $str;
}
}
foreach ($matches[0] as $i => $find) {
$opts = $this->_extractAttributes(trim($matches[1][$i]));
$currency = CakeNumber::defaultCurrency();
if (isset($opts['currency'])) {
$currency = $opts['currency'];
unset($opts['currency']);
}
$replace = empty($matches[2][$i]) || !is_numeric($matches[2][$i]) ? '' : CakeNumber::currency($matches[2][$i], $currency, $opts);
$str = str_replace($find, $replace, $str);
}
return $str;
}
示例9: processItems
/**
* Add product names from drupal for items
*
* @param $items
* @param $market_id
* @return array
*/
private function processItems($items, $market_id)
{
$ret = [];
$parents = [];
$children = [];
foreach ($items as $i) {
$name = '';
/**
* Optionally add variant master name
*/
if (!empty($i['Item']['ParentItems']) && $i['Item']['ParentItems'][0]['item_type_id'] == 2) {
$name = $this->drupalName($i['Item']['ParentItems'][0]) . ' - ';
$variant = true;
} else {
$variant = false;
}
$name .= $this->drupalName($i);
$child = !empty($i['parent_id']);
$cur = $this->currencyByMarket($market_id);
$dec = ['places' => 2];
if ($child) {
$price = CakeNumber::currency($i['price'], $cur, $dec);
$suppl = CakeNumber::currency($i['price'], $cur, $dec);
} else {
if ($variant == true) {
$price = CakeNumber::currency($i['Item']['ParentItems'][0]['ItemPrice']['price'], $cur, $dec);
$suppl = CakeNumber::currency($i['Item']['ParentItems'][0]['ItemPrice']['price_supplement'], $cur, $dec);
} else {
$price = CakeNumber::currency($i['Item']['ItemPrice']['price'], $cur, $dec);
$suppl = CakeNumber::currency($i['Item']['ItemPrice']['price_supplement'], $cur, $dec);
}
}
$sub = CakeNumber::currency($i['price'] * $i['quantity'], $cur, $dec);
$total = CakeNumber::currency($i['extended_price'], $cur, $dec);
$status = $i['order_item_hold_code_id'];
if (!$child) {
$class = 'success';
} else {
$class = 'warning';
}
if ($status == 1) {
$class = 'danger';
}
$object = ['id' => $i['id'], 'item_id' => $i['Item']['id'], 'shipment_id' => $i['order_shipment_id'], 'hold_code' => $i['order_item_hold_code_id'], 'ns_warehouse_id' => $i['ns_warehouse_id'], 'parent_id' => $i['parent_id'], 'sku' => $i['Item']['sku'], 'display_name' => $name, 'quantity' => $i['quantity'], 'price' => $price, 'price_supplement' => $suppl, 'total' => $total, 'subtotal' => $sub, 'backorder' => $status == 1, 'class' => $class];
if (!empty($i['OrderItemRestock'])) {
$object['restock_date'] = $i['OrderItemRestock'][0]['restock_date'];
}
if ($child) {
$children[$i['parent_id']][] = $object;
} else {
$parents[] = $object;
}
}
foreach ($parents as $obj) {
$ret[] = $obj;
$child_items = $children[$obj['id']];
if (!empty($child_items)) {
foreach ($child_items as $c) {
$ret[] = $c;
}
}
}
return $ret;
}