本文整理汇总了PHP中currency_format_number函数的典型用法代码示例。如果您正苦于以下问题:PHP currency_format_number函数的具体用法?PHP currency_format_number怎么用?PHP currency_format_number使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了currency_format_number函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateLineItems
function populateLineItems()
{
global $app_strings, $mod_strings;
$sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Quotes' AND parent_id = '" . $this->bean->id . "' AND deleted = 0";
$result = $this->bean->db->query($sql);
$html = "";
$html .= "<div style='width:1000px;'><table border='0' width='100%' cellpadding='0' cellspacing='0'>";
$html .= "<tr>";
$html .= "<td width='2%' class='tabDetailViewDL' style='text-align: left;'> </td>";
$html .= "<td width='15%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_PRODUCT_NAME'] . "</td>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;'>Asset</td>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_UNIT_PRICE'] . "</td>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;'>Rate</td>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;'>Start Date</td>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;'>Stop Date</td>";
$html .= "<td width='20%' class='tabDetailViewDL' style='text-align: left;'>Notes</td>";
$html .= "</tr>";
$i = 1;
while ($row = $this->bean->db->fetchByAssoc($result)) {
$html .= "<tr>";
$product_note = wordwrap($row['description'], 40, "<br />\n");
$product_note2 = wordwrap($row['description2'], 40, "<br />\n");
$html .= "<td class='tabDetailViewDF'>" . $i++ . "</td>";
$html .= "<td class='tabDetailViewDF'><a href='index.php?module=AOS_Products&action=DetailView&record=" . $row['product_id'] . "' class='tabDetailViewDFLink'>" . $row['name'] . "</a></td>";
$html .= "<td class='tabDetailViewDF'>" . $product_note . "</td>";
$html .= "<td class='tabDetailViewDF'>" . currency_format_number($row['product_unit_price']) . "</td>";
$html .= "<td class='tabDetailViewDF'>" . $row['product_rate'] . "</td>";
$html .= "<td class='tabDetailViewDF'>" . $row['start_date'] . "</td>";
$html .= "<td class='tabDetailViewDF'>" . $row['stop_date'] . "</td>";
$html .= "<td class='tabDetailViewDF'>" . $product_note2 . "</td>";
$html .= "</tr>";
}
$html .= "</table></div>";
$this->ss->assign('LINE_ITEMS', $html);
}
示例2: populateLineItems
function populateLineItems()
{
global $app_strings, $mod_strings;
$sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Invoices' AND parent_id = '" . $this->bean->id . "' AND deleted = 0";
$result = $this->bean->db->query($sql);
$html = "";
$html .= "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
$html .= "<tr>";
$html .= "<td width='10%' class='tabDetailViewDL' style='text-align: left;'> </td>";
$html .= "<td width='10%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_PRODUCT_QUANITY'] . "</td>";
$html .= "<td width='15%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_PRODUCT_NAME'] . "</td>";
$html .= "<td width='15%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_LIST_PRICE'] . "</td>";
$html .= "<td width='15%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_UNIT_PRICE'] . "</td>";
$html .= "<td width='15%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_VAT'] . " %</td>";
$html .= "<td width='15%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
$html .= "<td width='15%' class='tabDetailViewDL' style='text-align: left;'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
$html .= "</tr>";
$i = 1;
while ($row = $this->bean->db->fetchByAssoc($result)) {
$html .= "<tr>";
$product_note = wordwrap($row['description'], 40, "<br />\n");
$html .= "<td class='tabDetailViewDF'>" . $i++ . "</td>";
$html .= "<td class='tabDetailViewDF'>" . number_format($row['product_qty']) . "</td>";
$html .= "<td class='tabDetailViewDF'><a href='index.php?module=AOS_Products&action=DetailView&record=" . $row['product_id'] . "' class='tabDetailViewDFLink'>" . $row['name'] . "</a><br />" . $product_note . "</td>";
$html .= "<td class='tabDetailViewDF'>" . currency_format_number($row['product_list_price']) . "</td>";
$html .= "<td class='tabDetailViewDF'>" . currency_format_number($row['product_unit_price']) . "</td>";
$html .= "<td class='tabDetailViewDF'>" . $row['vat'] . "</td>";
$html .= "<td class='tabDetailViewDF'>" . currency_format_number($row['vat_amt']) . "</td>";
$html .= "<td class='tabDetailViewDF'>" . currency_format_number($row['product_total_price']) . "</td>";
$html .= "</tr>";
}
$html .= "</table>";
$this->ss->assign('LINE_ITEMS', $html);
}
示例3: listViewProcess
function listViewProcess()
{
$this->processSearchForm();
$this->lv->searchColumns = $this->searchForm->searchColumns;
if (!$this->headers) {
return;
}
if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
$this->lv->setup($this->seed, 'modules/Contracts/tpls/ListViewGeneric.tpl', $this->where, $this->params);
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name'];
echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
/**
* added by Hoc Bui
*
* @var OpportunitiesViewList
*/
$filter_fields = array();
$orderBy = "";
$ret_array = $this->seed->create_new_list_query($orderBy, $this->where, $filter_fields, $this->params, 0, '', true, $this->seed, true);
$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
//print_r($ret_array);
//exit;
/*$query = "SELECT amount_usdollar,amount, deleted FROM opportunities " ;
if($this->where)
$query .= "WHERE ".$this->where;*/
global $db;
$result = $db->query($main_query);
$i = 0;
$total = 0;
while (($row = $db->fetchByAssoc($result)) != null) {
if ($row['deleted'] != 1) {
$total += $row['tongtien'];
}
$i++;
}
// $this->lv->ss->assign("total", currency_format_number($GLOBALS['ESCOppAmount'])) ;
$this->lv->ss->assign("total", currency_format_number($total));
/**
* end Hoc Bui
*
* @var OpportunitiesViewList
*/
echo $this->lv->display();
//echo currency_format_number($GLOBALS['ESCOppAmount']);
}
}
示例4: get_list_view_data
function get_list_view_data()
{
global $action;
if (isset($this->currency_id) && ($action == 'DetailView' || $action == "SubPanelViewer")) {
global $locale, $current_language, $current_user, $mod_strings, $app_list_strings, $sugar_config;
$app_strings = return_application_language($current_language);
$params = array();
$temp_array = $this->get_list_view_array();
$params = array('currency_id' => $this->currency_id, 'convert' => true);
foreach ($temp_array as $field => $value) {
$fieldLow = strToLower($field);
if (!empty($this->field_defs[$fieldLow]) && $this->field_defs[$fieldLow]['type'] == 'currency') {
$temp_array[$field] = currency_format_number($this->{$fieldLow}, $params);
}
}
return $temp_array;
} else {
return parent::get_list_view_data();
}
}
示例5: smarty_function_sugar_currency_format
/**
* Smarty {sugar_currency_format} function plugin
*
* Type: function<br>
* Name: sugar_currency_format<br>
* Purpose: formats a number
*
* @author Wayne Pan {wayne at sugarcrm.com}
* @param array
* @param Smarty
*/
function smarty_function_sugar_currency_format($params, &$smarty)
{
if (!isset($params['var']) || $params['var'] == '') {
return '';
}
global $locale;
if (empty($params['currency_id'])) {
$params['currency_id'] = $locale->getPrecedentPreference('currency');
if (!isset($params['convert'])) {
$params['convert'] = true;
}
if (!isset($params['currency_symbol'])) {
$params['currency_symbol'] = $locale->getPrecedentPreference('default_currency_symbol');
}
}
$_contents = currency_format_number($params['var'], $params);
if (!empty($params['assign'])) {
$smarty->assign($params['assign'], $_contents);
} else {
return $_contents;
}
}
示例6: get_discount_string
function get_discount_string($type, $amount, $params, $locale, $sep)
{
if ($amount != '' && $amount != '0.00') {
if ($type == 'Amount') {
return currency_format_number($amount, $params) . "</td>";
} else {
if ($locale->getPrecision()) {
return rtrim(rtrim(format_number($amount), '0'), $sep[1]) . "%";
} else {
return format_number($amount) . "%";
}
}
} else {
return "-";
}
}
示例7: formatResultSetRows
private static function formatResultSetRows($reportId, $dashletId, $resulsetFields, &$rowValues, $userDateFormat, $userDateTimeFormat, $userTZ, $currencyId, $gmtDates, $isGroupedReport, $auditedReport, $auditedAppliedFields, $auditedFieldType, $referenceAlias)
{
global $timedate;
foreach ($resulsetFields as &$fieldDef) {
$isTotal = !$isGroupedReport && $fieldDef['function'] !== '0';
if (!$isTotal) {
$oldType = $fieldDef['type'];
$formatType = !empty($fieldDef['format']['type']) ? $fieldDef['format']['type'] : (!empty($fieldDef['type']) ? $fieldDef['type'] : "");
$currentUnformattedValue = $rowValues[$fieldDef['alias']];
if ($auditedReport && in_array($fieldDef['field'], $auditedAppliedFields)) {
$formatType = $auditedFieldType;
}
if (in_array($formatType, array("enum", "radioenum"))) {
$rowValues[$fieldDef['alias']] = !isset($fieldDef['enumLabels'][$currentUnformattedValue]) ? $currentUnformattedValue : $fieldDef['enumLabels'][$currentUnformattedValue];
} else {
if ($formatType == "multienum") {
$multiEnumValues = explode(',', $currentUnformattedValue);
foreach ($multiEnumValues as &$multiEnumValue) {
$multiEnumValue = trim($multiEnumValue, '^');
$multiEnumValue = !isset($fieldDef['enumLabels'][$multiEnumValue]) ? $multiEnumValue : $fieldDef['enumLabels'][$multiEnumValue];
}
$rowValues[$fieldDef['alias']] = implode(', ', $multiEnumValues);
} else {
if ($formatType == "date") {
if ($currentUnformattedValue != "" && date('Y-m-d H:i:s', strtotime($currentUnformattedValue)) == $currentUnformattedValue) {
if ($gmtDates && in_array($oldType, array("datetime", "datetimecombo"))) {
$currentUnformattedValue = $timedate->handle_offset($currentUnformattedValue, $timedate->get_db_date_time_format(), true, null, $userTZ);
}
$currentUnformattedValue = date('Y-m-d', strtotime($currentUnformattedValue));
}
if ($currentUnformattedValue != "" && date('Y-m-d', strtotime($currentUnformattedValue)) == $currentUnformattedValue) {
$rowValues[$fieldDef['alias']] = $timedate->swap_formats($currentUnformattedValue, $GLOBALS['timedate']->dbDayFormat, $userDateFormat);
}
} else {
if (in_array($formatType, array("datetime", "datetimecombo"))) {
if ($currentUnformattedValue != "" && date('Y-m-d H:i:s', strtotime($currentUnformattedValue)) == $currentUnformattedValue) {
if ($gmtDates) {
$rowValues[$fieldDef['alias']] = $timedate->handle_offset($currentUnformattedValue, $timedate->get_db_date_time_format(), true, null, $userTZ);
}
$rowValues[$fieldDef['alias']] = $timedate->swap_formats($rowValues[$fieldDef['alias']], $timedate->get_db_date_time_format(), $userDateTimeFormat);
}
} else {
if ($formatType == "timestamp") {
if ($currentUnformattedValue != "" && date('Y-m-d H:i:s', strtotime($currentUnformattedValue)) == $currentUnformattedValue) {
$rowValues[$fieldDef['alias']] = $timedate->swap_formats($currentUnformattedValue, $timedate->get_db_date_time_format(), $userDateTimeFormat);
}
} else {
if ($formatType == "int") {
//***********************//
//***AlineaSol Premium***//
//***********************//
$extraParams = array('numericValue' => $currentUnformattedValue, 'extraFormat' => $fieldDef['format']['extra']);
$returnedPremiumNumeric = asol_ReportsUtils::managePremiumFeature("reportPercentFormat", "reportFunctions.php", "getReportNumericField", $extraParams);
$rowValues[$fieldDef['alias']] = $returnedPremiumNumeric !== false ? $returnedPremiumNumeric : $currentUnformattedValue;
//***********************//
//***AlineaSol Premium***//
//***********************//
} else {
if ($formatType == "currency") {
$params = array('currency_id' => $currencyId, 'convert' => false);
$rowValues[$fieldDef['alias']] = currency_format_number($currentUnformattedValue, $params);
} else {
if (in_array($formatType, array("decimal", "double"))) {
if (!empty($currentUnformattedValue)) {
$rowValues[$fieldDef['alias']] = format_number($currentUnformattedValue);
} else {
if ($currentUnformattedValue !== null) {
$rowValues[$fieldDef['alias']] = format_number(0);
} else {
$rowValues[$fieldDef['alias']] = 0;
}
}
//***********************//
//***AlineaSol Premium***//
//***********************//
$extraParams = array('numericValue' => $rowValues[$fieldDef['alias']], 'extraFormat' => $fieldDef['format']['extra']);
$returnedPremiumNumeric = asol_ReportsUtils::managePremiumFeature("reportPercentFormat", "reportFunctions.php", "getReportNumericField", $extraParams);
$rowValues[$fieldDef['alias']] = $returnedPremiumNumeric !== false ? $returnedPremiumNumeric : $rowValues[$fieldDef['alias']];
//***********************//
//***AlineaSol Premium***//
//***********************//
} else {
if ($formatType == "percent") {
$rowValues[$fieldDef['alias']] = !empty($currentUnformattedValue) ? $currentUnformattedValue : 0;
$numericValue = $rowValues[$fieldDef['alias']] * 100;
//***********************//
//***AlineaSol Premium***//
//***********************//
$extraParams = array('numericValue' => $numericValue, 'extraFormat' => $fieldDef['format']['extra']);
$returnedPremiumPercent = asol_ReportsUtils::managePremiumFeature("reportPercentFormat", "reportFunctions.php", "getReportPercentField", $extraParams);
$rowValues[$fieldDef['alias']] = $returnedPremiumPercent !== false ? $returnedPremiumPercent : $numericValue . '%';
//***********************//
//***AlineaSol Premium***//
//***********************//
} else {
if ($formatType == "bool") {
$rowValues[$fieldDef['alias']] = '<input type="checkbox" ' . (!empty($currentUnformattedValue) ? 'checked=""' : '') . ' disabled="true" class="checkbox">';
} else {
if ($formatType == "button") {
//***********************//
//.........这里部分代码省略.........
示例8: get_list_view_data
function get_list_view_data()
{
global $locale, $current_language, $current_user, $mod_strings, $app_list_strings, $sugar_config;
$app_strings = return_application_language($current_language);
require_once 'modules/Currencies/Currency.php';
$temp_array = $this->get_list_view_array();
$temp_array['SALES_STAGE'] = empty($temp_array['SALES_STAGE']) ? '' : $temp_array['SALES_STAGE'];
$temp_array['AMOUNT'] = currency_format_number($this->amount);
$temp_array["ENCODED_NAME"] = $this->name;
return $temp_array;
}
示例9: parse_template_bean
function parse_template_bean($string, $key, &$focus)
{
global $app_strings;
$repl_arr = array();
foreach ($focus->field_defs as $field_def) {
if ($field_def['type'] == 'currency') {
$repl_arr[$key . "_" . $field_def['name']] = currency_format_number($focus->{$field_def}['name'], $params = array('currency_symbol' => false));
} else {
if ($field_def['type'] == 'enum' && isset($field_def['options'])) {
$repl_arr[$key . "_" . $field_def['name']] = translate($field_def['options'], $focus->module_dir, $focus->{$field_def}['name']);
} else {
if ($field_def['type'] == 'multienum' && isset($field_def['options'])) {
$repl_arr[$key . "_" . $field_def['name']] = implode(', ', unencodeMultienum($focus->{$field_def}['name']));
} else {
$repl_arr[$key . "_" . $field_def['name']] = $focus->{$field_def}['name'];
}
}
}
}
// end foreach()
krsort($repl_arr);
reset($repl_arr);
foreach ($repl_arr as $name => $value) {
if (strpos($name, 'product_discount') > 0) {
if ($value != '' && $value != '0.00') {
if ($repl_arr['aos_products_quotes_discount'] == 'Percentage') {
$sep = get_number_seperators();
$value = rtrim(rtrim(format_number($value), '0'), $sep[1]);
//.$app_strings['LBL_PERCENTAGE_SYMBOL'];
} else {
$value = currency_format_number($value, $params = array('currency_symbol' => false));
}
} else {
$value = '';
}
}
if ($name === 'aos_products_product_image') {
$value = '<img src="' . $value . '"width="50" height="50"/>';
}
if ($name === 'aos_products_quotes_product_qty') {
$sep = get_number_seperators();
$value = rtrim(rtrim(format_number($value), '0'), $sep[1]);
}
if ($name === 'aos_products_quotes_vat' || strpos($name, 'pct') > 0 || strpos($name, 'percent') > 0 || strpos($name, 'percentage') > 0) {
$sep = get_number_seperators();
$value = rtrim(rtrim(format_number($value), '0'), $sep[1]) . $app_strings['LBL_PERCENTAGE_SYMBOL'];
}
if (strpos($name, 'date') > 0 || strpos($name, 'expiration') > 0) {
if ($value != '') {
$dt = explode(' ', $value);
$value = $dt[0];
}
}
if ($value != '' && is_string($value)) {
$string = str_replace("\${$name}", $value, $string);
} else {
if (strpos($name, 'address') > 0) {
$string = str_replace("\${$name}<br />", '', $string);
$string = str_replace("\${$name} <br />", '', $string);
$string = str_replace("\${$name}", '', $string);
} else {
$string = str_replace("\${$name}", ' ', $string);
}
}
}
return $string;
}
示例10: gen_xml
//.........这里部分代码省略.........
}
$query = "SELECT lead_source,sales_stage,sum(amount_usdollar/1000) as total,count(*) as opp_count FROM opportunities ";
$query .= "WHERE " . $where . " AND opportunities.deleted=0 ";
$query .= " GROUP BY sales_stage,lead_source ORDER BY lead_source,sales_stage";
//Now do the db queries
//query for opportunity data that matches $datay and $user
$result = $opp->db->query($query) or sugar_die("Error selecting sugarbean: " . mysql_error());
//build pipeline by sales stage data
$total = 0;
$div = 1;
global $sugar_config;
$symbol = $sugar_config['default_currency_symbol'];
$other = $current_module_strings['LBL_LEAD_SOURCE_OTHER'];
$rowTotalArr = array();
$rowTotalArr[] = 0;
global $current_user;
$salesStages = array("Closed Lost" => $app_list_strings['sales_stage_dom']["Closed Lost"], "Closed Won" => $app_list_strings['sales_stage_dom']["Closed Won"], "Other" => $other);
if ($current_user->getPreference('currency')) {
$currency = new Currency();
$currency->retrieve($current_user->getPreference('currency'));
$div = $currency->conversion_rate;
$symbol = $currency->symbol;
}
$fileContents = ' <yData defaultAltText="' . $current_module_strings['LBL_ROLLOVER_DETAILS'] . '">' . "\n";
$leadSourceArr = array();
while ($row = $opp->db->fetchByAssoc($result, -1, false)) {
if ($row['total'] * $div <= 100) {
$sum = round($row['total'] * $div, 2);
} else {
$sum = round($row['total'] * $div);
}
if ($row['lead_source'] == '') {
$row['lead_source'] = $current_module_strings['NTC_NO_LEGENDS'];
}
if ($row['sales_stage'] == 'Closed Won' || $row['sales_stage'] == 'Closed Lost') {
$salesStage = $row['sales_stage'];
$salesStageT = $app_list_strings['sales_stage_dom'][$row['sales_stage']];
} else {
$salesStage = "Other";
$salesStageT = $other;
}
if (!isset($leadSourceArr[$row['lead_source']]['row_total'])) {
$leadSourceArr[$row['lead_source']]['row_total'] = 0;
}
$leadSourceArr[$row['lead_source']][$salesStage]['opp_count'][] = $row['opp_count'];
$leadSourceArr[$row['lead_source']][$salesStage]['total'][] = $sum;
$leadSourceArr[$row['lead_source']]['outcome'][$salesStage] = $salesStageT;
$leadSourceArr[$row['lead_source']]['row_total'] += $sum;
$total += $sum;
}
foreach ($datay as $key => $translation) {
if ($key == '') {
$key = $current_module_strings['NTC_NO_LEGENDS'];
$translation = $current_module_strings['NTC_NO_LEGENDS'];
}
if (!isset($leadSourceArr[$key])) {
$leadSourceArr[$key] = $key;
}
if (isset($leadSourceArr[$key]['row_total'])) {
$rowTotalArr[] = $leadSourceArr[$key]['row_total'];
}
if (isset($leadSourceArr[$key]['row_total']) && $leadSourceArr[$key]['row_total'] > 100) {
$leadSourceArr[$key]['row_total'] = round($leadSourceArr[$key]['row_total']);
}
$fileContents .= ' <dataRow title="' . $translation . '" endLabel="' . currency_format_number($leadSourceArr[$key]['row_total'], array('currency_symbol' => true)) . '">' . "\n";
if (is_array($leadSourceArr[$key]['outcome'])) {
foreach ($leadSourceArr[$key]['outcome'] as $outcome => $outcome_translation) {
$fileContents .= ' <bar id="' . $outcome . '" totalSize="' . array_sum($leadSourceArr[$key][$outcome]['total']) . '" altText="' . format_number(array_sum($leadSourceArr[$key][$outcome]['opp_count']), 0, 0) . ' ' . $current_module_strings['LBL_OPPS_WORTH'] . ' ' . currency_format_number(array_sum($leadSourceArr[$key][$outcome]['total']), array('currency_symbol' => true)) . $current_module_strings['LBL_OPP_THOUSANDS'] . ' ' . $current_module_strings['LBL_OPPS_OUTCOME'] . ' ' . $outcome_translation . '" url="index.php?module=Opportunities&action=index&lead_source=' . $key . '&sales_stage=' . urlencode($outcome) . '&query=true&searchFormTab=advanced_search"/>' . "\n";
}
}
$fileContents .= ' </dataRow>' . "\n";
}
$fileContents .= ' </yData>' . "\n";
$max = get_max($rowTotalArr);
$fileContents .= ' <xData min="0" max="' . $max . '" length="10" kDelim="' . $kDelim . '" prefix="' . $symbol . '" suffix=""/>' . "\n";
$fileContents .= ' <colorLegend status="on">' . "\n";
$i = 0;
foreach ($salesStages as $outcome => $outcome_translation) {
$color = generate_graphcolor($outcome, $i);
$fileContents .= ' <mapping id="' . $outcome . '" name="' . $outcome_translation . '" color="' . $color . '"/>' . "\n";
$i++;
}
$fileContents .= ' </colorLegend>' . "\n";
$fileContents .= ' <graphInfo>' . "\n";
$fileContents .= ' <![CDATA[' . $current_module_strings['LBL_OPP_SIZE'] . ' ' . $symbol . '1' . $current_module_strings['LBL_OPP_THOUSANDS'] . ']]>' . "\n";
$fileContents .= ' </graphInfo>' . "\n";
$fileContents .= ' <chartColors ';
foreach ($barChartColors as $key => $value) {
$fileContents .= ' ' . $key . '=' . '"' . $value . '" ';
}
$fileContents .= ' />' . "\n";
$fileContents .= '</graphData>' . "\n";
$total = round($total, 2);
$title = '<graphData title="' . $current_module_strings['LBL_ALL_OPPORTUNITIES'] . currency_format_number($total, array('currency_symbol' => true)) . $app_strings['LBL_THOUSANDS_SYMBOL'] . '">' . "\n";
$fileContents = $title . $fileContents;
save_xml_file($cache_file_name, $fileContents);
}
$return = create_chart('hBarF', $cache_file_name);
return $return;
}
示例11: unformat_number
*
* Copyright (C) SugarCRM Inc. All rights reserved.
*/
$module = $_REQUEST['save_module'];
$record = $_REQUEST['save_record'];
$field_value = $_REQUEST['save_value'];
$field = $_REQUEST['save_field_name'];
$type = $_REQUEST['type'];
$bean = BeanFactory::getBean($module, $record);
if ($type != 'currency') {
$bean->{$field} = $field_value;
} else {
$bean->{$field} = unformat_number($field_value);
}
$bean->save(false);
$ret_array = array();
$ret_array['id'] = $record;
$ret_array['field'] = $field;
if ($type != 'currency') {
$ret_array['value'] = $bean->{$field};
} else {
global $locale;
$params = array();
$params['currency_id'] = $_REQUEST['currency_id'];
$params['convert'] = false;
$params['currency_symbol'] = $_REQUEST['currency_symbol'];
$ret_array['currency_formatted_value'] = currency_format_number($bean->{$field}, $params);
$ret_array['formatted_value'] = format_number($bean->{$field});
}
$json = getJSONobj();
echo 'result = ' . $json->encode($ret_array);
示例12: gen_xml_pipeline_by_sales_stage
//.........这里部分代码省略.........
$query .= " GROUP BY opportunities.sales_stage,users.user_name,opportunities.assigned_user_id";
$result = $opp->db->query($query, true);
//build pipeline by sales stage data
$total = 0;
$div = 1;
global $sugar_config;
$symbol = $sugar_config['default_currency_symbol'];
global $current_user;
if ($current_user->getPreference('currency')) {
$currency = new Currency();
$currency->retrieve($current_user->getPreference('currency'));
$div = $currency->conversion_rate;
$symbol = $currency->symbol;
}
// cn: adding user-pref date handling
$dateStartDisplay = $timedate->asUserDate($timedate->fromString($date_start));
$dateEndDisplay = $timedate->asUserDate($timedate->fromString($date_end));
$fileContents = ' <yData defaultAltText="' . $current_module_strings['LBL_ROLLOVER_DETAILS'] . '">' . "\n";
$stageArr = array();
$usernameArr = array();
$rowTotalArr = array();
$rowTotalArr[] = 0;
while ($row = $opp->db->fetchByAssoc($result, false)) {
if ($row['total'] * $div <= 100) {
$sum = round($row['total'] * $div, 2);
} else {
$sum = round($row['total'] * $div);
}
if (!isset($stageArr[$row['sales_stage']]['row_total'])) {
$stageArr[$row['sales_stage']]['row_total'] = 0;
}
$stageArr[$row['sales_stage']][$row['assigned_user_id']]['opp_count'] = $row['opp_count'];
$stageArr[$row['sales_stage']][$row['assigned_user_id']]['total'] = $sum;
$stageArr[$row['sales_stage']]['people'][$row['assigned_user_id']] = $row['user_name'];
$stageArr[$row['sales_stage']]['row_total'] += $sum;
$usernameArr[$row['assigned_user_id']] = $row['user_name'];
$total += $sum;
}
foreach ($datax as $key => $translation) {
if (isset($stageArr[$key]['row_total'])) {
$rowTotalArr[] = $stageArr[$key]['row_total'];
}
if (isset($stageArr[$key]['row_total']) && $stageArr[$key]['row_total'] > 100) {
$stageArr[$key]['row_total'] = round($stageArr[$key]['row_total']);
}
$fileContents .= ' <dataRow title="' . $translation . '" endLabel="';
if (isset($stageArr[$key]['row_total'])) {
$fileContents .= $stageArr[$key]['row_total'];
}
$fileContents .= '">' . "\n";
if (isset($stageArr[$key]['people'])) {
asort($stageArr[$key]['people']);
reset($stageArr[$key]['people']);
foreach ($stageArr[$key]['people'] as $nameKey => $nameValue) {
$fileContents .= ' <bar id="' . $nameKey . '" totalSize="' . $stageArr[$key][$nameKey]['total'] . '" altText="' . $nameValue . ': ' . $stageArr[$key][$nameKey]['opp_count'] . ' ' . $current_module_strings['LBL_OPPS_WORTH'] . ' ' . currency_format_number($stageArr[$key][$nameKey]['total'], array('currency_symbol' => true)) . $current_module_strings['LBL_OPP_THOUSANDS'] . ' ' . $current_module_strings['LBL_OPPS_IN_STAGE'] . ' ' . $translation . '" url="index.php?module=Opportunities&action=index&assigned_user_id[]=' . $nameKey . '&sales_stage=' . urlencode($key) . '&date_start=' . $date_start . '&date_closed=' . $date_end . '&query=true&searchFormTab=advanced_search"/>' . "\n";
}
}
$fileContents .= ' </dataRow>' . "\n";
}
$fileContents .= ' </yData>' . "\n";
$max = get_max($rowTotalArr);
if ($chart_size == 'hBarF') {
$length = "10";
} else {
$length = "4";
}
$fileContents .= ' <xData min="0" max="' . $max . '" length="' . $length . '" kDelim="' . $kDelim . '" prefix="' . $symbol . '" suffix=""/>' . "\n";
$fileContents .= ' <colorLegend status="on">' . "\n";
$i = 0;
asort($new_ids);
foreach ($new_ids as $key => $value) {
$color = generate_graphcolor($key, $i);
$fileContents .= ' <mapping id="' . $key . '" name="' . $value . '" color="' . $color . '"/>' . "\n";
$i++;
}
$fileContents .= ' </colorLegend>' . "\n";
$fileContents .= ' <graphInfo>' . "\n";
$fileContents .= ' <![CDATA[' . $current_module_strings['LBL_DATE_RANGE'] . ' ' . $dateStartDisplay . ' ' . $current_module_strings['LBL_DATE_RANGE_TO'] . ' ' . $dateEndDisplay . '<BR/>' . $current_module_strings['LBL_OPP_SIZE'] . ' ' . $symbol . '1' . $current_module_strings['LBL_OPP_THOUSANDS'] . ']]>' . "\n";
$fileContents .= ' </graphInfo>' . "\n";
$fileContents .= ' <chartColors ';
foreach ($barChartColors as $key => $value) {
$fileContents .= ' ' . $key . '=' . '"' . $value . '" ';
}
$fileContents .= ' />' . "\n";
$fileContents .= '</graphData>' . "\n";
$total = $total;
$title = '<graphData title="' . $current_module_strings['LBL_TOTAL_PIPELINE'] . currency_format_number($total, array('currency_symbol' => true)) . $app_strings['LBL_THOUSANDS_SYMBOL'] . '">' . "\n";
$fileContents = $title . $fileContents;
save_xml_file($cache_file_name, $fileContents);
}
if ($chart_size == 'hBarF') {
$width = "800";
$height = "400";
} else {
$width = "350";
$height = "400";
}
$return = create_chart($chart_size, $cache_file_name, $width, $height);
return $return;
}
示例13: formatDisplayValue
function formatDisplayValue($bean, $value, $vardef, $method = "save")
{
global $app_list_strings, $timedate;
//Fake the params so we can pass the values through the sugarwidgets to get the correct display html.
$GLOBALS['focus'] = $bean;
$_REQUEST['record'] = $bean->id;
$vardef['fields']['ID'] = $bean->id;
$vardef['fields'][strtoupper($vardef['name'])] = $value;
// If field is of type email.
if ($vardef['name'] == "email1" && $vardef['group'] == "email1") {
require_once "include/generic/SugarWidgets/SugarWidgetSubPanelEmailLink.php";
$SugarWidgetSubPanelEmailLink = new SugarWidgetSubPanelEmailLink($vardef);
$value = $SugarWidgetSubPanelEmailLink->displayList($vardef);
}
//If field is of type link and name.
if ($vardef['link'] && $vardef['type'] == "name" && $_REQUEST['view'] != "DetailView") {
require_once "include/generic/SugarWidgets/SugarWidgetSubPanelDetailViewLink.php";
$vardef['module'] = $bean->module_dir;
$SugarWidgetSubPanelDetailViewLink = new SugarWidgetSubPanelDetailViewLink($vardef);
$value = "<b>" . $SugarWidgetSubPanelDetailViewLink->displayList($vardef) . "</b>";
}
//If field is of type date time or datetimecombo
if ($vardef['type'] == "datetimecombo" || $vardef['type'] == "datetime") {
if ($method != "save") {
$value = convertDateUserToDB($value);
}
$datetime_format = $timedate->get_date_time_format();
// create utc date (as it's utc in db)
$datetime = DateTime::createFromFormat("Y-m-d H:i:s", $value, new DateTimeZone('UTC'));
// convert it to timezone the user uses
$datetime = $timedate->tzUser($datetime);
$value = $datetime->format($datetime_format);
}
//If field is of type bool, checkbox.
if ($vardef['type'] == "bool") {
require_once "include/generic/LayoutManager.php";
$layoutManager = new LayoutManager();
require_once "include/generic/SugarWidgets/SugarWidgetFieldbool.php";
$SugarWidgetFieldbool = new SugarWidgetFieldbool($layoutManager);
$value = $SugarWidgetFieldbool->displayListPlain($vardef);
}
//if field is of type multienum.
if ($vardef['type'] == "multienum") {
$value = str_replace("^", "", $value);
$array_values = explode(",", $value);
foreach ($array_values as $value) {
$values[] = $app_list_strings[$vardef['options']][$value];
}
$value = implode(", ", $values);
}
//if field is of type radio.
if ($vardef['type'] == "radioenum" || $vardef['type'] == "enum" || $vardef['type'] == "dynamicenum") {
$value = $app_list_strings[$vardef['options']][$value];
}
//if field is of type relate.
if ($vardef['type'] == "relate" || $vardef['type'] == "parent") {
if ($vardef['source'] == "non-db") {
if ($vardef['module'] == "Employees") {
$vardef['ext2'] = "Users";
$vardef['rname'] = "full_name";
}
}
if ($vardef['type'] == "parent") {
$vardef['module'] = $bean->parent_type;
$name = $bean->parent_name;
}
$idName = $vardef['id_name'];
$record = $bean->{$idName};
if ($vardef['name'] != "assigned_user_name") {
$value = "<a class=\"listViewTdLinkS1\" href=\"index.php?action=DetailView&module=" . $vardef['module'] . "&record={$record}\">";
} else {
$value = "";
}
//To fix github bug 880 (the rname was null and was causing a 500 error in the getFieldValueFromModule call to $fieldname
$fieldName = 'name';
//$vardef['name'];
if (!is_null($vardef['rname'])) {
$fieldName = $vardef['rname'];
}
if ($vardef['ext2']) {
$value .= getFieldValueFromModule($fieldName, $vardef['ext2'], $record);
} else {
if (!empty($vardef['rname']) || $vardef['name'] == "related_doc_name") {
$value .= getFieldValueFromModule($fieldName, $vardef['module'], $record);
} else {
$value .= $name;
}
}
if ($vardef['name'] != "assigned_user_name") {
$value .= "</a>";
}
}
if ($vardef['type'] == "url") {
$value = '<a href=' . $value . ' target="_blank">' . $value . '</a>';
}
if ($vardef['type'] == "currency") {
if ($_REQUEST['view'] != "DetailView") {
$value = currency_format_number($value);
} else {
$value = format_number($value);
//.........这里部分代码省略.........
示例14: kcurrencyRenderer
public static function kcurrencyRenderer($fieldid, $record)
{
if ($record[$fieldid] == '' || $record[$fieldid] == 0) {
return '';
}
// 2014-02-25 .. set teh default system currency .. otherwise sugar might take the default users currency
if (empty($record[$fieldid . '_curid'])) {
$record[$fieldid . '_curid'] = '99';
}
return currency_format_number($record[$fieldid], array('currency_id' => $record[$fieldid . '_curid'], 'currency_symbol' => true));
}
示例15: populateLineItems
function populateLineItems()
{
global $app_strings, $mod_strings;
$params = array('currency_id' => $this->bean->currency_id);
$sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Quotes' AND parent_id = '" . $this->bean->id . "' AND product_id != '0' AND deleted = 0 ORDER BY number ASC";
$result = $this->bean->db->query($sql);
$countLine = $this->bean->db->getRowCount($result);
$sep = get_number_seperators();
$html = "";
$html .= "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
if ($countLine != 0) {
$html .= "<tr>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;'> </td>";
$html .= "<td width='10%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_PRODUCT_QUANITY'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_PRODUCT_NAME'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_LIST_PRICE'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_DISCOUNT_AMT'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_UNIT_PRICE'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
$html .= "</tr>";
}
$i = 1;
while ($row = $this->bean->db->fetchByAssoc($result)) {
$html .= "<tr>";
$product_note = wordwrap($row['description'], 40, "<br />\n");
$html .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>" . $i++ . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['product_qty']), '0'), $sep[1]) . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'><a href='index.php?module=AOS_Products&action=DetailView&record=" . $row['product_id'] . "' class='tabDetailViewDFLink'>" . $row['name'] . "</a><br />" . $product_note . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_list_price'], $params) . "</td>";
if ($row['product_discount'] != '' && $row['product_discount'] != '0.00') {
if ($row['discount'] == 'Amount') {
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_discount'], $params) . "</td>";
} else {
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['product_discount']), '0'), $sep[1]) . "%</td>";
}
} else {
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>-</td>";
}
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_unit_price'], $params) . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['vat']), '0'), $sep[1]) . "%</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['vat_amt'], $params) . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_total_price'], $params) . "</td>";
$html .= "</tr>";
}
$sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Quotes' AND parent_id = '" . $this->bean->id . "' AND product_id = '0' AND deleted = 0 ORDER BY number ASC";
$result = $this->bean->db->query($sql);
$countLine = $this->bean->db->getRowCount($result);
if ($i != 1 && $countLine != 0) {
$html .= "<tr>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px; padding-top:12px;'> </td>";
$html .= "<td width='46%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' colspan='4' scope='row'>" . $mod_strings['LBL_SERVICE_NAME'] . "</td>";
$html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_SERVICE_PRICE'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
$html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
$html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
$html .= "</tr>";
} else {
if ($countLine != 0) {
$html .= "<tr>";
$html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;'> </td>";
$html .= "<td width='46%' class='dataLabel' style='text-align: left;padding:2px;' colspan='4' scope='row'>" . $mod_strings['LBL_SERVICE_NAME'] . "</td>";
$html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_SERVICE_PRICE'] . "</td>";
$html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
$html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
$html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
$html .= "</tr>";
}
}
while ($row = $this->bean->db->fetchByAssoc($result)) {
$html .= "<tr>";
$html .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>" . $i++ . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;' colspan='4'>" . $row['name'] . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_unit_price'], $params) . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['vat']), '0'), $sep[1]) . "%</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['vat_amt'], $params) . "</td>";
$html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_total_price'], $params) . "</td>";
$html .= "</tr>";
}
$html .= "</table>";
$this->ss->assign('LINE_ITEMS', $html);
}