本文整理汇总了PHP中TTi18n::formatCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP TTi18n::formatCurrency方法的具体用法?PHP TTi18n::formatCurrency怎么用?PHP TTi18n::formatCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTi18n
的用法示例。
在下文中一共展示了TTi18n::formatCurrency方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_formatCurrency
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
function smarty_function_formatCurrency($params, &$smarty)
{
$amount = $params['amount'];
$currency_code = $params['currency_code'];
$show_code = $params['show_code'];
return TTi18n::formatCurrency($amount, $currency_code, $show_code);
}
示例2: _pdf_Header
function _pdf_Header()
{
if ($this->pdf->getPage() == 1) {
//Draw separate table at the top showing the summarized data specifically for the form.
$column_options = array('cpp_total' => TTi18n::getText('CPP Contributions'), 'ei_total' => TTi18n::getText('EI Premiums'), 'tax_total' => TTi18n::getText('Tax Deductions'), 'total' => TTi18n::getText('This Payment'), 'gross_payroll' => TTi18n::getText('Gross Payroll'), 'employees' => TTi18n::getText('Total Employees'), 'end_remitting_period' => TTi18n::getText('End of Period'), 'due_date' => TTi18n::getText('Due Date'));
$columns = array('cpp_total' => TRUE, 'ei_total' => TRUE, 'tax_total' => TRUE, 'total' => TRUE, 'gross_payroll' => TRUE, 'employees' => TRUE, 'end_remitting_period' => TRUE, 'due_date' => TRUE);
$header_layout = $this->config['other']['layout']['header'];
$margins = $this->pdf->getMargins();
//Draw report information
if ($this->pdf->getPage() > 1) {
$this->_pdf_drawLine(0.75);
//Slightly smaller than first/last lines.
}
if (is_array($columns) and count($columns) > 0) {
$this->pdf->SetFont($this->config['other']['default_font'], 'B', $this->_pdf_fontSize($this->config['other']['table_header_font_size']));
$this->pdf->setTextColor(0);
$this->pdf->setDrawColor(0);
$this->pdf->setFillColor(240);
//Grayscale only.
$column_widths = $this->_pdf_getTableColumnWidths($this->getLargestColumnData(array_intersect_key($column_options, (array) $columns)), $this->config['other']['layout']['header']);
//Table largest column data;
$cell_height = $this->_pdf_getMaximumHeightFromArray($columns, $column_options, $column_widths, $this->config['other']['table_header_word_wrap'], $this->_pdf_fontSize($header_layout['height']));
foreach ($columns as $column => $tmp) {
if (isset($column_options[$column]) and isset($column_widths[$column])) {
$cell_width = $column_widths[$column];
if ($this->pdf->getX() + $cell_width > $this->pdf->getPageWidth()) {
Debug::Text(' Page not wide enough, it should be at least: ' . ($this->pdf->getX() + $cell_width) . ' Page Width: ' . $this->pdf->getPageWidth(), __FILE__, __LINE__, __METHOD__, 10);
$this->pdf->Ln();
}
$this->pdf->Cell($cell_width, $this->_pdf_fontSize($header_layout['height']), $column_options[$column], $header_layout['border'], 0, $header_layout['align'], $header_layout['fill'], '', $header_layout['stretch']);
//Wrapping shouldn't be needed as the cell widths should expand to at least fit the header. Wrapping may be needed on regular rows though.
//$this->pdf->MultiCell( $cell_width, $cell_height, $column_options[$column], 0, $header_layout['align'], $header_layout['fill'], 0 );
} else {
Debug::Text(' Invalid Column: ' . $column, __FILE__, __LINE__, __METHOD__, 10);
}
}
$this->pdf->Ln();
$this->_pdf_drawLine(0.75);
//Slightly smaller than first/last lines.
//Reset all styles/fills after page break.
$this->pdf->SetFont($this->config['other']['default_font'], '', $this->_pdf_fontSize($this->config['other']['table_row_font_size']));
$this->pdf->SetTextColor(0);
$this->pdf->SetDrawColor(0);
$this->pdf->setFillColor(255);
//Draw data
$border = 0;
$row_layout = array('max_width' => 30, 'cell_padding' => 2, 'height' => 5, 'align' => 'R', 'border' => 0, 'fill' => 1, 'stretch' => 1);
//Get the earliest transaction date of all pay periods.
$this->form_data['pay_period'] = array_unique((array) $this->form_data['pay_period']);
ksort($this->form_data['pay_period']);
$transaction_date = current((array) $this->form_data['pay_period']);
Debug::Text('Transaction Date: ' . TTDate::getDate('DATE', $transaction_date) . '(' . $transaction_date . ')', __FILE__, __LINE__, __METHOD__, 10);
$summary_table_data = $this->total_row;
$summary_table_data['cpp_total'] = TTi18n::formatCurrency(isset($summary_table_data['cpp_total']) ? $summary_table_data['cpp_total'] : 0);
$summary_table_data['ei_total'] = TTi18n::formatCurrency(isset($summary_table_data['ei_total']) ? $summary_table_data['ei_total'] : 0);
$summary_table_data['tax_total'] = TTi18n::formatCurrency(isset($summary_table_data['tax_total']) ? $summary_table_data['tax_total'] : 0);
$summary_table_data['total'] = TTi18n::formatCurrency(isset($summary_table_data['total']) ? $summary_table_data['total'] : 0);
$summary_table_data['gross_payroll'] = TTi18n::formatCurrency(isset($summary_table_data['gross_payroll']) ? $summary_table_data['gross_payroll'] : 0);
$summary_table_data['employees'] = count($this->user_ids);
$remittance_due_date = Wage::getRemittanceDueDate($transaction_date, isset($summary_table_data['total']) ? $summary_table_data['total'] : 0);
$summary_table_data['due_date'] = $remittance_due_date > 0 ? TTDate::getDate('DATE', $remittance_due_date) : TTi18n::getText("N/A");
$summary_table_data['end_remitting_period'] = $transaction_date > 0 ? date('Y-m', $transaction_date) : TTi18n::getText("N/A");
foreach ($columns as $column => $tmp) {
$value = $summary_table_data[$column];
$cell_width = isset($column_widths[$column]) ? $column_widths[$column] : 30;
$this->pdf->Cell($cell_width, $this->_pdf_fontSize($row_layout['height']), $value, $border, 0, $row_layout['align'], $row_layout['fill'], '', $row_layout['stretch']);
}
$this->pdf->Ln();
$this->_pdf_drawLine(0.75);
//Slightly smaller than first/last lines.
$this->pdf->Ln();
$this->_pdf_drawLine(0.75);
//Slightly smaller than first/last lines.
}
}
parent::_pdf_Header();
return TRUE;
}
示例3: columnFormatter
function columnFormatter($type, $column, $value, $format = NULL)
{
if (is_array($value) and isset($value['display'])) {
//Found sorting array, use display column.
return $value['display'];
} else {
$retval = $value;
if ($format == 'csv' or $format == 'raw') {
//Force specific field formats for exporting to CSV format.
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
case 'percent':
case 'numeric':
//Don't format above types.
break;
case 'time_unit':
$retval = TTDate::getHours($value);
//Force to hours always.
break;
case 'date_stamp':
$retval = TTDate::getDate('DATE', $value);
break;
case 'time':
$retval = TTDate::getDate('TIME', $value);
break;
case 'time_stamp':
$retval = TTDate::getDate('DATE+TIME', $value);
break;
case 'boolean':
if ($value == TRUE) {
$retval = TTi18n::getText('Yes');
} else {
$retval = TTi18n::getText('No');
}
default:
break;
}
} elseif ($format == 'xml') {
//Use standard XML formats whenever possible.
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
case 'percent':
case 'numeric':
//Don't format above types.
break;
case 'time_unit':
$retval = TTDate::getHours($value);
//Force to hours always.
break;
case 'date_stamp':
$retval = date('Y-m-d', $value);
////type="xs:date"
break;
case 'time':
$retval = date('H:i:s', $value);
//type="xs:time"
break;
case 'time_stamp':
$retval = date('c', $value);
//type="xs:dateTime"
break;
case 'boolean':
if ($value == TRUE) {
$retval = TTi18n::getText('Yes');
} else {
$retval = TTi18n::getText('No');
}
default:
break;
}
} else {
switch ($type) {
case 'report_date':
$column = strpos($column, 'custom_column') === FALSE ? $column : $column . '-' . 'date_stamp';
$retval = TTDate::getReportDates($column, $value, TRUE, $this->getUserObject());
break;
case 'currency':
if (is_object($this->getCurrencyObject())) {
//Set MIN decimals to 2 and max to the currency rounding.
$retval = $this->getCurrencyObject()->getSymbol() . TTi18n::formatNumber($value, TRUE, 2, $this->getCurrencyObject()->getRoundDecimalPlaces());
} else {
$retval = TTi18n::formatCurrency($value);
}
break;
case 'percent':
$retval = TTi18n::formatNumber($value, TRUE) . '%';
break;
case 'numeric':
$retval = TTi18n::formatNumber($value, TRUE);
break;
case 'time_unit':
$retval = TTDate::getTimeUnit($value);
//.........这里部分代码省略.........