[Vtigercrm-commits] [vtiger-commits] r9350 - in /vtigercrm/trunk: include/utils/CommonUtils.php modules/Potentials/Charts.php modules/Users/User.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Sep 7 06:52:06 EDT 2006
Author: saraj
Date: Thu Sep 7 04:51:59 2006
New Revision: 9350
Log:
changes made to show currency in conversion rate and symbol in dashboard
Modified:
vtigercrm/trunk/include/utils/CommonUtils.php
vtigercrm/trunk/modules/Potentials/Charts.php
vtigercrm/trunk/modules/Users/User.php
Modified: vtigercrm/trunk/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/CommonUtils.php (original)
+++ vtigercrm/trunk/include/utils/CommonUtils.php Thu Sep 7 04:51:59 2006
@@ -779,6 +779,17 @@
* param $crate - conversion rate.
*/
function convertFromDollar($amount,$crate){
+ global $log;
+ $log->debug("Entering convertFromDollar(".$amount.",".$crate.") method ...");
+ $log->debug("Exiting convertFromDollar method ...");
+ return $amount * $crate;
+}
+
+/** This function returns the amount converted from master currency.
+ * param $amount - amount to be converted.
+ * param $crate - conversion rate.
+ */
+function convertFromMasterCurrency($amount,$crate){
global $log;
$log->debug("Entering convertFromDollar(".$amount.",".$crate.") method ...");
$log->debug("Exiting convertFromDollar method ...");
Modified: vtigercrm/trunk/modules/Potentials/Charts.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/Charts.php (original)
+++ vtigercrm/trunk/modules/Potentials/Charts.php Thu Sep 7 04:51:59 2006
@@ -127,7 +127,7 @@
}
if (isset($record->column_fields['amount'])) {
// Strip all non numbers from this string.
- $amount = ereg_replace('[^0-9]', '', floor($record->column_fields['amount']));
+ $amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
$sum[$month][$sales_stage] = $sum[$month][$sales_stage] + $amount;
if (isset($count[$month][$sales_stage])) {
$count[$month][$sales_stage]++;
@@ -261,8 +261,8 @@
$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', '#E5E5E5')));
// Setup title
- $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$curr_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
- //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$curr_symbol.$total;
+ $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+ //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
$title->setText($titlestr);
@@ -298,7 +298,7 @@
$yaxis->setAxisIntersection('max');
// Then fix the tick marks
- $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $curr_symbol."%d");
+ $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
$yaxis->setFontSize(8);
$yaxis->setDataPreprocessor($valueproc);
// Arrange Y-Axis tick marks inside
@@ -323,7 +323,7 @@
$marker->setFontSize(8);
$gbplot->setMarker($marker);
- $subtitle .= $current_module_strings['LBL_OPP_SIZE'].$curr_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
+ $subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
$footer->setText($subtitle);
$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
@@ -363,7 +363,7 @@
* Contributor(s): ______________________________________..
*/
function lead_source_by_outcome($datay=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
- global $log;
+ global $log,$current_user;
$log->debug("Entering lead_source_by_outcome(".$datay.",".$user_id.",".$cache_file_name.",".$refresh.") method ...");
global $app_strings,$lang_crm, $current_module_strings,$charset, $tmp_dir;
global $theme;
@@ -471,7 +471,7 @@
}
if (isset($record->column_fields['amount'])) {
// Strip all non numbers from this string.
- $amount = ereg_replace('[^0-9]', '', floor($record->column_fields['amount']));
+ $amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
$sum[$lead_source][$sales_stage] = $sum[$lead_source][$sales_stage] + $amount;
if (isset($count[$lead_source][$sales_stage])) {
$count[$lead_source][$sales_stage]++;
@@ -602,8 +602,8 @@
$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
// Setup title
- $titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$curr_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
- //$titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$curr_symbol.$total;
+ $titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+ //$titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total;
$title->setText($titlestr);
// Create the xaxis labels
@@ -635,7 +635,7 @@
// Then fix the tick marks
$yaxis->setFontSize(8);
$yaxis->setAxisIntersection('max');
- $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $curr_symbol."%d");
+ $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
$yaxis->setDataPreprocessor($valueproc);
$yaxis->setLabelInterval($ticks[0]);
$yaxis->setTickOptions(-5,0);
@@ -655,7 +655,7 @@
$gbplot->setMarker($marker);
// Finally setup the title
- $subtitle = $current_module_strings['LBL_OPP_SIZE'].$curr_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
+ $subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
$footer->setText($subtitle);
$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
@@ -690,7 +690,7 @@
* Contributor(s): ______________________________________..
*/
function pipeline_by_sales_stage($datax=array('foo','bar'), $date_start='2071-10-15', $date_end='2071-10-15', $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
- global $log;
+ global $log,$current_user;
$log->debug("Entering pipeline_by_sales_stage(".$datax.",".$date_start.",".$date_end.",".$user_id.",".$cache_file_name.",".$refresh.") method ...");
global $app_strings,$lang_crm, $current_module_strings, $charset, $tmp_dir;
global $theme;
@@ -793,7 +793,7 @@
}
if (isset($record->column_fields['amount'])) {
// Strip all non numbers from this string.
- $amount = ereg_replace('[^0-9]', '', floor($record->column_fields['amount']));
+ $amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
$sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = $sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] + $amount;
if (isset($count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']])) {
$count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']]++;
@@ -915,8 +915,8 @@
$font->setColor($font_color);
// Setup title
- $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$curr_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
- //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$curr_symbol.$total;
+ $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+ //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
$title->setText($titlestr);
// Create the xaxis labels
@@ -951,7 +951,7 @@
$gridY->setLineColor('#E5E5E5 at 0.5');
// First make the labels look right
- $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $curr_symbol."%d");
+ $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
$yaxis->setDataPreprocessor($valueproc);
$yaxis->setLabelInterval($ticks[0]);
$yaxis->setTickOptions(-5,0);
@@ -972,7 +972,7 @@
// Finally setup the title
- $subtitle .= $current_module_strings['LBL_OPP_SIZE'].$curr_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
+ $subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
$footer->setText($subtitle);
$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
@@ -1009,7 +1009,7 @@
* Contributor(s): ______________________________________..
*/
function pipeline_by_lead_source($legends=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=true,$width=900,$height=500){
- global $log;
+ global $log,$current_user;
$log->debug("Entering pipeline_by_lead_source(".$legends.") method ...");
global $app_strings,$lang_crm, $current_module_strings, $log, $charset, $tmp_dir;
global $theme;
@@ -1069,7 +1069,7 @@
if (!isset($sum[$record->column_fields['leadsource']])) $sum[$record->column_fields['leadsource']] = 0;
if (isset($record->column_fields['amount']) && isset($record->column_fields['leadsource'])) {
// Strip all non numbers from this string.
- $amount = ereg_replace('[^0-9]', '', floor($record->column_fields['amount']));
+ $amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
$sum[$record->column_fields['leadsource']] = $sum[$record->column_fields['leadsource']] + ($amount/1000);
if (isset($count[$record->column_fields['leadsource']])) $count[$record->column_fields['leadsource']]++;
else $count[$record->column_fields['leadsource']] = 1;
@@ -1174,13 +1174,13 @@
$gbplot->setFillStyle($fills);
// Setup title
- $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$curr_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
- //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$curr_symbol.$total;
+ $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+ //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
$title->setText($titlestr);
// format the data values
- $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $curr_symbol."%d");
+ $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
// set markers
$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
@@ -1198,7 +1198,7 @@
$legend_box->setFillColor('#F5F5F5');
$legend_box->showShadow();
- $subtitle = $current_module_strings['LBL_OPP_SIZE'].$curr_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
+ $subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
$footer->setText($subtitle);
$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_LEFT);
Modified: vtigercrm/trunk/modules/Users/User.php
==============================================================================
--- vtigercrm/trunk/modules/Users/User.php (original)
+++ vtigercrm/trunk/modules/Users/User.php Thu Sep 7 04:51:59 2006
@@ -63,6 +63,10 @@
'activity_view' =>'',
'lead_view' =>'',
'currency_id' =>'',
+ 'currency_name' =>'',
+ 'currency_code' =>'',
+ 'currency_symbol' =>'',
+ 'conv_rate' =>'',
'hour_format' =>'',
'end_hour' =>'',
'start_hour' =>'',
@@ -839,6 +843,22 @@
$this->column_fields["record_id"] = $record;
$this->column_fields["record_module"] = $module;
+ $currency_query = "select * from vtiger_currency_info where id=".$this->column_fields["currency_id"]." and currency_status='Active'";
+ $currency_result = $adb->query($currency_query);
+ if($adb->num_rows($currency_result) == 0)
+ {
+ $currency_query = "select * from vtiger_currency_info where id =1";
+ $currency_result = $adb->query($currency_query);
+ }
+ $currency_array = array("$"=>"$","$"=>"$","€"=>"€","£"=>"£","¥"=>"¥","Rs"=>"₨");
+ $ui_curr = $currency_array[$adb->query_result($currency_result,0,"currency_symbol")];
+ if($ui_curr == "")
+ $ui_curr = $adb->query_result($currency_result,0,"currency_symbol");
+ $this->column_fields["currency_name"]= $this->currency_name = $adb->query_result($currency_result,0,"currency_name");
+ $this->column_fields["currency_code"]= $this->currency_code = $adb->query_result($currency_result,0,"currency_code");
+ $this->column_fields["currency_symbol"]= $this->currency_symbol = $ui_curr;
+ $this->column_fields["conv_rate"]= $this->conv_rate = $adb->query_result($currency_result,0,"conversion_rate");
+
$this->id = $record;
$log->debug("Exit from retrieve_entity_info($record, $module) method.");
More information about the vtigercrm-commits
mailing list