本文整理汇总了PHP中TTi18n::formatNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP TTi18n::formatNumber方法的具体用法?PHP TTi18n::formatNumber怎么用?PHP TTi18n::formatNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTi18n
的用法示例。
在下文中一共展示了TTi18n::formatNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: getPayStub
//.........这里部分代码省略.........
}
$prev_type = $pay_stub_entry_name_obj->getType();
}
//There should always be pay stub entries for a pay stub.
if (!isset($pay_stub_entries)) {
continue;
}
//Debug::Arr($pay_stub_entries, 'Pay Stub Entries...', __FILE__, __LINE__, __METHOD__,10);
//$pay_period_number = $pay_period_schedule_obj->getCurrentPayPeriodNumber( $pay_period_obj->getTransactionDate(), $pay_period_obj->getEndDate() );
$block_adjust_y = 30;
//
//Earnings
//
if (isset($pay_stub_entries[10])) {
//Earnings Header
$pdf->SetFont('', 'B', 10);
$pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell(90, 5, TTi18n::gettext('Earnings'), $border, 0, 'L');
$pdf->Cell(17, 5, TTi18n::gettext('Rate'), $border, 0, 'R');
$pdf->Cell(23, 5, TTi18n::gettext('Hrs/Units'), $border, 0, 'R');
$pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
$pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R');
$block_adjust_y = $block_adjust_y + 5;
$pdf->SetFont('', '', 10);
foreach ($pay_stub_entries[10] as $pay_stub_entry) {
if ($pay_stub_entry['type'] == 10) {
if ($pay_stub_entry['description_subscript'] != '') {
$subscript = '[' . $pay_stub_entry['description_subscript'] . ']';
} else {
$subscript = NULL;
}
$pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell(88, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L');
$pdf->Cell(17, 5, TTi18n::formatNumber($pay_stub_entry['rate'], TRUE), $border, 0, 'R');
$pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R');
$pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
$pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
} else {
//Total
$pdf->SetFont('', 'B', 10);
$pdf->line(Misc::AdjustXY(110, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->line(Misc::AdjustXY(131, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell(90, 5, $pay_stub_entry['name'], $border, 0, 'L');
$pdf->Cell(17, 5, '', $border, 0, 'R');
$pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R');
$pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
$pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
}
$block_adjust_y = $block_adjust_y + 5;
}
}
//
// Deductions
//
if (isset($pay_stub_entries[20])) {
$max_deductions = count($pay_stub_entries[20]);
//Deductions Header
$block_adjust_y = $block_adjust_y + 5;
$pdf->SetFont('', 'B', 10);
if ($max_deductions > 2) {
$pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L');
$pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
$pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R');
示例3: getPayStub
//.........这里部分代码省略.........
//Debug::Arr($pay_stub_entries, 'Pay Stub Entries...', __FILE__, __LINE__, __METHOD__,10);
//Debug::Arr($max_widths, 'Maximum Widths: ', __FILE__, __LINE__, __METHOD__,10);
$block_adjust_y = 30;
//
//Earnings
//
if (isset($pay_stub_entries[10])) {
$column_widths['ytd_amount'] = $max_widths['ytd_amount'] * 2 < 25 ? 25 : $max_widths['ytd_amount'] * 2;
$column_widths['amount'] = $max_widths['amount'] * 2 < 20 ? 20 : $max_widths['amount'] * 2;
$column_widths['rate'] = $max_widths['rate'] * 2 < 5 ? 5 : $max_widths['rate'] * 2;
$column_widths['units'] = $max_widths['units'] * 2 < 17 ? 17 : $max_widths['units'] * 2;
$column_widths['name'] = 175 - ($column_widths['ytd_amount'] + $column_widths['amount'] + $column_widths['rate'] + $column_widths['units']);
//Debug::Arr($column_widths, 'Column Widths: ', __FILE__, __LINE__, __METHOD__,10);
//Earnings Header
$pdf->SetFont('', 'B', 10);
$pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell($column_widths['name'], 5, TTi18n::gettext('Earnings'), $border, 0, 'L', FALSE, '', 1);
$pdf->Cell($column_widths['rate'], 5, TTi18n::gettext('Rate'), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['units'], 5, TTi18n::gettext('Hrs/Units'), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['amount'], 5, TTi18n::gettext('Amount'), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['ytd_amount'], 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R', FALSE, '', 1);
$block_adjust_y = $block_adjust_y + 5;
$pdf->SetFont('', '', 10);
foreach ($pay_stub_entries[10] as $pay_stub_entry) {
if ($pay_stub_entry['type'] == 10) {
if ($pay_stub_entry['description_subscript'] != '') {
$subscript = '[' . $pay_stub_entry['description_subscript'] . ']';
} else {
$subscript = NULL;
}
$pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell($column_widths['name'] - 2, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L', FALSE, '', 1);
//68
$pdf->Cell($column_widths['rate'], 5, TTi18n::formatNumber($pay_stub_entry['rate'], TRUE), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['units'], 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['amount'], 5, TTi18n::formatNumber($pay_stub_entry['amount'], TRUE, $pay_stub_obj->getCurrencyObject()->getRoundDecimalPlaces()), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['ytd_amount'], 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount'], TRUE, $pay_stub_obj->getCurrencyObject()->getRoundDecimalPlaces()), $border, 0, 'R', FALSE, '', 1);
} else {
//Total
$pdf->SetFont('', 'B', 10);
$pdf->line(Misc::AdjustXY(175 - $column_widths['ytd_amount'] - $column_widths['amount'] - $column_widths['units'], $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175 - (1 + $column_widths['ytd_amount']) - $column_widths['amount'], $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
//90
$pdf->line(Misc::AdjustXY(175 - $column_widths['ytd_amount'] - $column_widths['amount'], $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175 - (1 + $column_widths['ytd_amount']), $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
//111
$pdf->line(Misc::AdjustXY(175 - $column_widths['ytd_amount'], $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
//141
$pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
$pdf->Cell($column_widths['name'], 5, $pay_stub_entry['name'], $border, 0, 'L', FALSE, '', 1);
$pdf->Cell($column_widths['rate'], 5, '', $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['units'], 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['amount'], 5, TTi18n::formatNumber($pay_stub_entry['amount'], TRUE, $pay_stub_obj->getCurrencyObject()->getRoundDecimalPlaces()), $border, 0, 'R', FALSE, '', 1);
$pdf->Cell($column_widths['ytd_amount'], 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount'], TRUE, $pay_stub_obj->getCurrencyObject()->getRoundDecimalPlaces()), $border, 0, 'R', FALSE, '', 1);
}
$block_adjust_y = $block_adjust_y + 5;
}
}
//
// Deductions
//
if (isset($pay_stub_entries[20])) {
$max_deductions = count($pay_stub_entries[20]);
$two_column_threshold = 2;
//Deductions Header
$block_adjust_y = $block_adjust_y + 5;
$pdf->SetFont('', 'B', 10);
if ($max_deductions > $two_column_threshold) {