Ejemplo n.º 1
0
 public function setUp()
 {
     global $current_user, $sugar_config;
     SugarTestHelper::setUp('current_user', array(true));
     $current_user->setPreference('dec_sep', ',');
     $current_user->setPreference('num_grp_sep', '.');
     $current_user->setPreference('default_currency_significant_digits', 3);
     SugarTestHelper::setUp('app_list_strings');
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('beanList');
     parent::setUp();
     $this->lm = new LayoutManager();
     $this->lm->setAttribute('reporter', new stdClass());
     $this->currency_51568 = new Currency();
     $this->currency_51568->symbol = 'TT';
     $this->currency_51568->conversion_rate = 0.5;
     $this->currency_51568->save(false);
     $this->currency_system = new Currency();
     $this->currency_system->retrieve(-99);
     $this->backupSymbol = $this->currency_system->symbol;
     $this->currency_system->symbol = '¥';
     $this->currency_system->save(false);
     $sugar_config['default_currency_symbol'] = '¥';
     get_number_seperators(true);
 }
function get_currency()
{
    global $current_user, $global_currency_obj;
    if (empty($global_currency_obj)) {
        $global_currency_obj = new Currency();
        //  $global_currency_symbol = '$';
        if ($current_user->getPreference('currency')) {
            $global_currency_obj->retrieve($current_user->getPreference('currency'));
        } else {
            $global_currency_obj->retrieve('-99');
        }
    }
    return $global_currency_obj;
}
 public function display()
 {
     $currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
     if ($GLOBALS['current_user']->getPreference('currency')) {
         require_once 'modules/Currencies/Currency.php';
         $currency = new Currency();
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $this->chartDefName = $this->which_chart[0];
     //$chartDef = $this->chartDefs[$this->chartDefName];
     $chartDef = array('type' => 'code', 'id' => 'Chart_invoices_by_month', 'label' => 'Invoices by Month', 'chartUnits' => 'Invoice Size in $1K', 'chartType' => 'stacked group by chart', 'groupBy' => array('m', 'state_in_chart'), 'base_url' => array('module' => 'reg_invoices', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search'), 'url_params' => array('state', 'date_closed'));
     require_once 'include/SugarCharts/SugarChartFactory.php';
     // Special chart config for RegInvoices
     $sugarChart = SugarChartFactory::getInstance('Jit', 'RegInvoices');
     $sugarChart->setProperties('', translate('LBL_FACT_SIZE', 'reg_invoices') . ' ' . $currency_symbol . '1' . translate('LBL_OPP_THOUSANDS', 'Charts'), $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->is_currency = true;
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     $sugarChart->getData($this->constructQuery());
     $this->sortData($sugarChart->data_set);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />';
 }
Ejemplo n.º 4
0
 function populateCurrency()
 {
     global $mod_strings;
     require_once 'modules/Currencies/Currency.php';
     $currency = new Currency();
     $currText = '';
     if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) {
         $currency->retrieve($this->bean->currency_id);
         if ($currency->deleted != 1) {
             $currText = $currency->iso4217 . ' ' . $currency->symbol;
         } else {
             $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol();
         }
     } else {
         $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol();
     }
     $javascript = "<script language='javascript'>\n";
     $javascript .= "var CurrencyText = new Array(); \n";
     $javascript .= "CurrencyText['-99'] = '" . $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol() . "';\n";
     $sql = "SELECT id, iso4217, symbol FROM currencies";
     $res = $this->bean->db->query($sql);
     while ($row = $this->bean->db->fetchByAssoc($res)) {
         $javascript .= "CurrencyText['" . $row['id'] . "'] = '" . $row['iso4217'] . ' ' . $row['symbol'] . "';\n";
     }
     $javascript .= "</script>";
     echo $javascript;
     $this->ss->assign('CURRENCY', "<div id =curr_symbol>{$currText}</div>");
     $mod_strings['LBL_LIST_PRICE'] .= " (" . $currText . ")";
     $mod_strings['LBL_UNIT_PRICE'] .= " (" . $currText . ")";
     $mod_strings['LBL_VAT_AMT'] .= " (" . $currText . ")";
     $mod_strings['LBL_TOTAL_PRICE'] .= " (" . $currText . ")";
     $mod_strings['LBL_SERVICE_PRICE'] .= " (" . $currText . ")";
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $current_user, $sugar_config;
     require "modules/Charts/chartdefs.php";
     $chartDef = $chartDefs['lead_source_by_outcome'];
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->is_currency = true;
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if ($current_user->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
     $sugarChart->setProperties('', $subtitle, $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     if (count($this->lsbo_ids) > 0) {
         $sugarChart->url_params['assigned_user_id'] = array_values($this->lsbo_ids);
     }
     $sugarChart->getData($this->constuctQuery());
     $sugarChart->data_set = $sugarChart->sortData($sugarChart->data_set, 'lead_source', true, 'sales_stage', true, true);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }
Ejemplo n.º 6
0
 function display()
 {
     global $app_list_strings;
     $this->ss->assign('APP_LIST', $app_list_strings);
     if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'set_target') {
         require_once 'modules/Campaigns/utils.php';
         //call function to create campaign logs
         $mess = track_campaign_prospects($this->bean);
         $confirm_msg = "var ajax_C_LOG_Status = new SUGAR.ajaxStatusClass(); \n            window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",1000); \n            window.setTimeout('ajax_C_LOG_Status.hideStatus()', 1500); \n            window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",2000); \n            window.setTimeout('ajax_C_LOG_Status.hideStatus()', 5000); ";
         $this->ss->assign("MSG_SCRIPT", $confirm_msg);
     }
     if ($this->bean->campaign_type == 'Email' || $this->bean->campaign_type == 'NewsLetter') {
         $this->ss->assign("ADD_BUTTON_STATE", "submit");
         $this->ss->assign("TARGET_BUTTON_STATE", "hidden");
     } else {
         $this->ss->assign("ADD_BUTTON_STATE", "hidden");
         $this->ss->assign("DISABLE_LINK", "display:none");
         $this->ss->assign("TARGET_BUTTON_STATE", "submit");
     }
     $currency = new Currency();
     if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) {
         $currency->retrieve($this->bean->currency_id);
         if ($currency->deleted != 1) {
             $this->ss->assign('CURRENCY', $currency->iso4217 . ' ' . $currency->symbol);
         } else {
             $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
         }
     } else {
         $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
     }
     parent::display();
     //We want to display subset of available, panels, so we will call subpanel
     //object directly instead of using sugarview.
     $GLOBALS['focus'] = $this->bean;
     require_once 'include/SubPanel/SubPanelTiles.php';
     $subpanel = new SubPanelTiles($this->bean, $this->module);
     //get available list of subpanels
     $alltabs = $subpanel->subpanel_definitions->get_available_tabs();
     if (!empty($alltabs)) {
         //iterate through list, and filter out all but 3 subpanels
         foreach ($alltabs as $key => $name) {
             if ($name != 'prospectlists' && $name != 'emailmarketing' && $name != 'tracked_urls') {
                 //exclude subpanels that are not prospectlists, emailmarketing, or tracked urls
                 $subpanel->subpanel_definitions->exclude_tab($name);
             }
         }
         //only show email marketing subpanel for email/newsletter campaigns
         if ($this->bean->campaign_type != 'Email' && $this->bean->campaign_type != 'NewsLetter') {
             //exclude emailmarketing subpanel if not on an email or newsletter campaign
             $subpanel->subpanel_definitions->exclude_tab('emailmarketing');
             // Bug #49893  - 20120120 - Captivea (ybi) - Remove trackers subpanels if not on an email/newsletter campaign (useless subpannl)
             $subpanel->subpanel_definitions->exclude_tab('tracked_urls');
         }
     }
     //show filtered subpanel list
     echo $subpanel->display();
 }
Ejemplo n.º 7
0
function perform_save(&$focus)
{
    //US DOLLAR
    if (isset($focus->amount) && !number_empty($focus->amount)) {
        $currency = new Currency();
        $currency->retrieve($focus->currency_id);
        $focus->amount_usdollar = $currency->convertToDollar($focus->amount);
    }
}
function perform_save(&$focus)
{
    require_once 'modules/Currencies/Currency.php';
    //US DOLLAR
    if (isset($focus->price) && !number_empty($focus->price)) {
        $currency = new Currency();
        $currency->retrieve($focus->currency_id);
        $focus->price_usdollar = $currency->convertToDollar(unformat_number($focus->price));
    }
}
 /**
  * Overriding display of value of currency because of currencies are not stored in app_list_strings
  *
  * @param array $layout_def
  * @return string for display
  */
 public function &displayListPlain($layout_def)
 {
     static $currencies;
     $value = $this->_get_list_value($layout_def);
     if (empty($currencies[$value])) {
         $currency = new Currency();
         $currency->retrieve($value);
         $currencies[$value] = $currency->symbol . ' ' . $currency->iso4217;
     }
     return $currencies[$value];
 }
function updateAmountByID($id, $curID, $price)
{
    global $db, $currencies;
    if (isset($id) && !empty($id)) {
        $currency = new Currency();
        $currency->retrieve($curID);
        $dollars = $currency->convertToDollar($price);
        $query = "update opportunities set price='{$price}', currency_id='{$curID}', price_usdollar='{$dollars}' where id='{$id}';";
        $db->query($query);
    }
}
Ejemplo n.º 11
0
 function save($check_notify = FALSE)
 {
     //"amount_usdollar" is really amount_basecurrency. We need to save a copy of the amount in the base currency.
     if (isset($this->amount) && !number_empty($this->amount)) {
         if (!number_empty($this->currency_id)) {
             $currency = new Currency();
             $currency->retrieve($this->currency_id);
             $this->amount_usdollar = $currency->convertToDollar($this->amount);
         } else {
             $this->amount_usdollar = $this->amount;
         }
     }
     return parent::save($check_notify);
 }
Ejemplo n.º 12
0
 function populateCurrency()
 {
     require_once 'modules/Currencies/Currency.php';
     $currency = new Currency();
     if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) {
         $currency->retrieve($focus->currency_id);
         if ($currency->deleted != 1) {
             $this->currSymbol = $currency->symbol;
         } else {
             $this->currSymbol = $currency->getDefaultCurrencySymbol();
         }
     } else {
         $this->currSymbol = $currency->getDefaultCurrencySymbol();
     }
 }
Ejemplo n.º 13
0
/**
 * Products, Quotations & Invoices modules.
 * Extensions to SugarCRM
 * @package Advanced OpenSales for SugarCRM
 * @subpackage Products
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <*****@*****.**>
 */
function perform_aos_save($focus)
{
    //US DOLLAR
    foreach ($focus->field_defs as $field) {
        if (isset($focus->field_defs[$field['name'] . '_usdollar'])) {
            $fieldName = $field['name'] . '_usdollar';
            $focus->{$fieldName} = '';
            if (!number_empty($focus->field_defs[$field['name']])) {
                $currency = new Currency();
                $currency->retrieve($focus->currency_id);
                $focus->{$fieldName} = $currency->convertToDollar($focus->{$field}['name']);
            }
        }
    }
}
Ejemplo n.º 14
0
 function display()
 {
     $currency = new Currency();
     if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) {
         $currency->retrieve($this->bean->currency_id);
         if ($currency->deleted != 1) {
             $this->ss->assign('CURRENCY', $currency->iso4217 . ' ' . $currency->symbol);
         } else {
             $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
         }
     } else {
         $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
     }
     parent::display();
 }
Ejemplo n.º 15
0
/**
 * Products, Quotations & Invoices modules.
 * Extensions to SugarCRM
 * @package Advanced OpenSales for SugarCRM
 * @subpackage Products
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <*****@*****.**>
 */
function perform_aos_save($focus)
{
    foreach ($focus->field_defs as $field) {
        $fieldName = $field['name'];
        $fieldNameDollar = $field['name'] . '_usdollar';
        if (isset($focus->field_defs[$fieldNameDollar])) {
            $focus->{$fieldNameDollar} = '';
            if (!number_empty($focus->field_defs[$field['name']])) {
                $currency = new Currency();
                $currency->retrieve($focus->currency_id);
                $focus->{$fieldNameDollar} = $currency->convertToDollar(unformat_number($fieldName));
            }
        }
    }
}
Ejemplo n.º 16
0
 public function display($title, $subTitle, $xmlFile, $chartType, $width = '100%', $height = '480')
 {
     global $current_user, $sugar_config;
     require "modules/Charts/chartdefs.php";
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->is_currency = true;
     $currency_symbol = $sugar_config['default_currency_symbol'];
     $sugarChart->setProperties($title, $subTitle, $chartType);
     if ($current_user->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, $width, $height, false) . '</div>';
 }
Ejemplo n.º 17
0
 public function __construct()
 {
     $this->db =& DBManagerFactory::getInstance();
     $this->ss = new Sugar_Smarty();
     $this->chart_yAxis['yMin'] = 0;
     $this->chart_yAxis['yMax'] = 0;
     if ($GLOBALS['current_user']->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
         $this->div = $currency->conversion_rate;
         $this->currency_symbol = $currency->symbol;
     } else {
         $this->currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
         $this->div = 1;
         $this->is_currency = false;
     }
 }
Ejemplo n.º 18
0
 function pushFeed($bean, $event, $arguments)
 {
     $text = '';
     if (empty($bean->fetched_row)) {
         $currency = new Currency();
         $currency->retrieve($bean->currency_id);
         $text = '{SugarFeed.CREATED_OPPORTUNITY} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.WITH} [Accounts:' . $bean->account_id . ':' . $bean->account_name . '] {SugarFeed.FOR} ' . $currency->symbol . format_number($bean->amount);
     } else {
         if (!empty($bean->fetched_row['sales_stage']) && $bean->fetched_row['sales_stage'] != $bean->sales_stage && $bean->sales_stage == 'Closed Won') {
             $currency = new Currency();
             $currency->retrieve($bean->currency_id);
             $text = '{SugarFeed.WON_OPPORTUNITY} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.WITH} [Accounts:' . $bean->account_id . ':' . $bean->account_name . '] {SugarFeed.FOR} ' . $currency->symbol . format_number($bean->amount);
         }
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
Ejemplo n.º 19
0
 public function __construct()
 {
     $this->db =& DBManagerFactory::getInstance();
     $this->ss = new Sugar_Smarty();
     $this->chart_yAxis['yMin'] = 0;
     $this->chart_yAxis['yMax'] = 0;
     if ($GLOBALS['current_user']->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
         $this->div = $currency->conversion_rate;
         $this->currency_symbol = $currency->symbol;
     } else {
         $this->currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
         $this->div = 1;
         $this->is_currency = false;
     }
     $this->image_export_type = extension_loaded('gd') && function_exists('gd_info') ? "png" : "jpg";
 }
Ejemplo n.º 20
0
 function handleAdd()
 {
     global $current_user;
     if ($current_user->is_admin) {
         if (isset($_POST['edit']) && $_POST['edit'] == 'true' && isset($_POST['name']) && !empty($_POST['name']) && isset($_POST['conversion_rate']) && !empty($_POST['conversion_rate']) && isset($_POST['symbol']) && !empty($_POST['symbol'])) {
             $currency = new Currency();
             if (isset($_POST['record']) && !empty($_POST['record'])) {
                 $currency->retrieve($_POST['record']);
             }
             $currency->name = $_POST['name'];
             $currency->status = $_POST['status'];
             $currency->symbol = $_POST['symbol'];
             $currency->iso4217 = $_POST['iso4217'];
             $currency->conversion_rate = unformat_number($_POST['conversion_rate']);
             $currency->save();
             $this->focus = $currency;
         }
     }
 }
Ejemplo n.º 21
0
 function populateCurrency()
 {
     global $mod_strings;
     require_once 'modules/Currencies/Currency.php';
     $currency = new Currency();
     $currText = '';
     if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) {
         $currency->retrieve($focus->currency_id);
         if ($currency->deleted != 1) {
             $currText = $currency->iso4217 . ' ' . $currency->symbol;
         } else {
             $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol();
         }
     } else {
         $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol();
     }
     $this->ss->assign('CURRENCY', $currText);
     $mod_strings['LBL_LIST_PRICE'] .= " (" . $currText . ")";
     $mod_strings['LBL_UNIT_PRICE'] .= " (" . $currText . ")";
     $mod_strings['LBL_VAT_AMT'] .= " (" . $currText . ")";
     $mod_strings['LBL_TOTAL_PRICE'] .= " (" . $currText . ")";
 }
Ejemplo n.º 22
0
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     $currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
     if ($GLOBALS['current_user']->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     require "modules/Charts/chartdefs.php";
     $chartDef = $chartDefs['outcome_by_month'];
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->setProperties('', translate('LBL_OPP_SIZE', 'Charts') . ' ' . $currency_symbol . '1' . translate('LBL_OPP_THOUSANDS', 'Charts'), $chartDef['chartType']);
     $sugarChart->base_url = $chartDef['base_url'];
     $sugarChart->group_by = $chartDef['groupBy'];
     $sugarChart->url_params = array();
     $sugarChart->getData($this->constructQuery());
     $sugarChart->is_currency = true;
     $sugarChart->data_set = $sugarChart->sortData($sugarChart->data_set, 'm', false, 'sales_stage', true, true);
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('<div align="center"></div>') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }
 /**
  * Creates PIE CHART image of opportunities by lead_source.
  * param $datax- the sales stage data to display in the x-axis
  * param $datay- the sum of opportunity amounts for each opportunity in each sales stage
  * to display in the y-axis
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
  * All Rights Reserved..
  * Contributor(s): ______________________________________..
  */
 function gen_xml($legends = array('foo', 'bar'), $user_id = array('1'), $cache_file_name = 'a_file', $refresh = true, $current_module_strings)
 {
     global $app_strings, $charset, $lang, $pieChartColors, $current_user;
     require_once 'modules/Currencies/Currency.php';
     $kDelim = $current_user->getPreference('num_grp_sep');
     if (!file_exists($cache_file_name) || $refresh == true) {
         $GLOBALS['log']->debug("starting pipeline chart");
         $GLOBALS['log']->debug("legends is:");
         $GLOBALS['log']->debug($legends);
         $GLOBALS['log']->debug("user_id is: ");
         $GLOBALS['log']->debug($user_id);
         $GLOBALS['log']->debug("cache_file_name is: {$cache_file_name}");
         $opp = new Opportunity();
         //Now do the db queries
         //query for opportunity data that matches $legends and $user
         $where = "";
         //build the where clause for the query that matches $user
         $count = count($user_id);
         $id = array();
         if ($count > 0 && !empty($user_id)) {
             foreach ($user_id as $the_id) {
                 $id[] = "'" . $the_id . "'";
             }
             $ids = join(",", $id);
             $where .= "opportunities.assigned_user_id IN ({$ids}) ";
         }
         if (!empty($where)) {
             $where .= 'AND';
         }
         //build the where clause for the query that matches $datax
         $count = count($legends);
         $legendItem = array();
         if ($count > 0 && !empty($legends)) {
             foreach ($legends as $key => $value) {
                 $legendItem[] = "'" . $key . "'";
             }
             $legendItems = join(",", $legendItem);
             $where .= " opportunities.lead_source IN\t({$legendItems}) ";
         }
         $query = "SELECT lead_source,sum(amount_usdollar/1000) as total,count(*) as opp_count FROM opportunities ";
         $query .= "WHERE " . $where . " AND opportunities.deleted=0 ";
         $query .= "GROUP BY lead_source ORDER BY total DESC";
         //build pipeline by lead source 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;
         }
         $subtitle = $current_module_strings['LBL_OPP_SIZE'] . ' ' . $symbol . '1' . $current_module_strings['LBL_OPP_THOUSANDS'];
         $fileContents = '';
         $fileContents .= '     <pie defaultAltText="' . $current_module_strings['LBL_ROLLOVER_WEDGE_DETAILS'] . '" legendStatus="on">' . "\n";
         $result = $opp->db->query($query) or sugar_die("Error selecting sugarbean: " . mysql_error());
         $leadSourceArr = array();
         while ($row = $opp->db->fetchByAssoc($result, -1, false)) {
             if ($row['lead_source'] == '') {
                 $leadSource = $current_module_strings['NTC_NO_LEGENDS'];
             } else {
                 $leadSource = $row['lead_source'];
             }
             if ($row['total'] * $div <= 100) {
                 $sum = round($row['total'] * $div, 2);
             } else {
                 $sum = round($row['total'] * $div);
             }
             $leadSourceArr[$leadSource]['opp_count'] = $row['opp_count'];
             $leadSourceArr[$leadSource]['sum'] = $sum;
         }
         $i = 0;
         foreach ($legends as $lead_source_key => $translation) {
             if ($lead_source_key == '') {
                 $lead_source_key = $current_module_strings['NTC_NO_LEGENDS'];
                 $translation = $current_module_strings['NTC_NO_LEGENDS'];
             }
             if (!isset($leadSourceArr[$lead_source_key])) {
                 $leadSourceArr[$lead_source_key] = $lead_source_key;
                 $leadSourceArr[$lead_source_key]['sum'] = 0;
             }
             $color = generate_graphcolor($lead_source_key, $i);
             $fileContents .= '          <wedge title="' . $translation . '" kDelim="' . $kDelim . '" value="' . $leadSourceArr[$lead_source_key]['sum'] . '" color="' . $color . '" labelText="' . currency_format_number($leadSourceArr[$lead_source_key]['sum'], array('currency_symbol' => true)) . '" url="index.php?module=Opportunities&action=index&lead_source=' . urlencode($lead_source_key) . '&query=true&searchFormTab=advanced_search" altText="' . format_number($leadSourceArr[$lead_source_key]['opp_count'], 0, 0) . ' ' . $current_module_strings['LBL_OPPS_IN_LEAD_SOURCE'] . ' ' . $translation . '"/>' . "\n";
             if (isset($leadSourceArr[$lead_source_key])) {
                 $total += $leadSourceArr[$lead_source_key]['sum'];
             }
             $i++;
         }
         $fileContents .= '     </pie>' . "\n";
         $fileContents .= '     <graphInfo>' . "\n";
         $fileContents .= '          <![CDATA[]]>' . "\n";
         $fileContents .= '     </graphInfo>' . "\n";
         $fileContents .= '     <chartColors ';
         foreach ($pieChartColors as $key => $value) {
             $fileContents .= ' ' . $key . '=' . '"' . $value . '" ';
         }
         $fileContents .= ' />' . "\n";
         $fileContents .= '</graphData>' . "\n";
         $total = round($total, 2);
         $title = $current_module_strings['LBL_TOTAL_PIPELINE'] . currency_format_number($total, array('currency_symbol' => true)) . $app_strings['LBL_THOUSANDS_SYMBOL'];
         $fileContents = '<graphData title="' . $title . '" subtitle="' . $subtitle . '">' . "\n" . $fileContents;
         $GLOBALS['log']->debug("total is: {$total}");
         if ($total == 0) {
             return $current_module_strings['ERR_NO_OPPS'];
         }
         save_xml_file($cache_file_name, $fileContents);
     }
     $return = create_chart('pieF', $cache_file_name);
     return $return;
 }
Ejemplo n.º 24
0
 function action_saveadminwizard()
 {
     global $current_user;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     $focus = new Administration();
     $focus->retrieveSettings();
     $focus->saveConfig();
     $configurator = new Configurator();
     $configurator->populateFromPost();
     $configurator->handleOverride();
     $configurator->parseLoggerSettings();
     $configurator->saveConfig();
     // Bug 37310 - Delete any existing currency that matches the one we've just set the default to during the admin wizard
     $currency = new Currency();
     $currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name']));
     if (!empty($currency->id) && $currency->symbol == $_REQUEST['default_currency_symbol'] && $currency->iso4217 == $_REQUEST['default_currency_iso4217']) {
         $currency->deleted = 1;
         $currency->save();
     }
     SugarApplication::redirect('index.php?module=Users&action=Wizard&skipwelcome=1');
 }
$query_click .= " FROM campaign_log ";
$query_click .= " WHERE campaign_id = '{$campaign_id}' AND activity_type='link' AND related_type='CampaignTrackers' AND archived=0 AND deleted=0";
//if $marketing id is specified, then lets filter the chart by the value
if (!empty($marketing_id)) {
    $query_click .= " AND marketing_id ='{$marketing_id}'";
}
$query_click .= " GROUP BY  activity_type, target_type";
$query_click .= " ORDER BY  activity_type, target_type";
$result = $campaign->db->query($query_click);
$xtpl->assign("OPP_COUNT", $opp_data1['opp_count']);
$xtpl->assign("ACTUAL_COST", $opp_data1['actual_cost']);
$xtpl->assign("PLANNED_BUDGET", $opp_data1['budget']);
$xtpl->assign("EXPECTED_REVENUE", $opp_data1['expected_revenue']);
$currency = new Currency();
if (isset($focus->currency_id) && !empty($focus->currency_id)) {
    $currency->retrieve($focus->currency_id);
    if ($currency->deleted != 1) {
        $xtpl->assign("CURRENCY", $currency->iso4217 . ' ' . $currency->symbol);
    } else {
        $xtpl->assign("CURRENCY", $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
    }
} else {
    $xtpl->assign("CURRENCY", $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol());
}
global $current_user;
if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
    $xtpl->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $_REQUEST['record'] . "'>" . SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', $mod_strings['LBL_EDIT_LAYOUT']) . "</a>");
}
//$detailView->processListNavigation($xtpl, "CAMPAIGN", $offset, $focus->is_AuditEnabled());
// adding custom fields:
//require_once('modules/DynamicFields/templates/Files/DetailView.php');
 /**
  * Creates opportunity pipeline image as a VERTICAL accumlated bar graph for multiple users.
  * param $datax- the month data to display in the x-axis
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
  * All Rights Reserved..
  * Contributor(s): ______________________________________..
  */
 function gen_xml($date_start = '1971-10-15', $date_end = '2010-10-15', $user_id = array('1'), $cache_file_name = 'a_file', $refresh = false, $current_module_strings)
 {
     global $app_strings, $app_list_strings, $charset, $lang, $barChartColors, $current_user;
     $kDelim = $current_user->getPreference('num_grp_sep');
     global $timedate;
     if (!file_exists($cache_file_name) || $refresh == true) {
         Log::debug("date_start is: {$date_start}");
         Log::debug("date_end is: {$date_end}");
         Log::debug("user_id is: ");
         Log::debug($user_id);
         Log::debug("cache_file_name is: {$cache_file_name}");
         $where = "";
         //build the where clause for the query that matches $user
         $count = count($user_id);
         $id = array();
         if ($count > 0) {
             foreach ($user_id as $the_id) {
                 $id[] = "'" . $the_id . "'";
             }
             $ids = join(",", $id);
             $where .= "opportunities.assigned_user_id IN ({$ids}) ";
         }
         // cn: adding user-pref date handling
         $dateStartDisplay = $timedate->asUserDate($timedate->fromString($date_start));
         $dateEndDisplay = $timedate->asUserDate($timedate->fromString($date_end));
         $opp = new Opportunity();
         //build the where clause for the query that matches $date_start and $date_end
         $where .= "AND opportunities.date_closed >= " . db_convert("'" . $date_start . "'", 'date') . " AND opportunities.date_closed <= " . db_convert("'" . $date_end . "'", 'date') . " AND opportunities.deleted=0";
         $query = "SELECT sales_stage," . db_convert('opportunities.date_closed', 'date_format', array("'%Y-%m'"), array("'YYYY-MM'")) . " as m, sum(amount_usdollar/1000) as total, count(*) as opp_count FROM opportunities ";
         $query .= "WHERE " . $where;
         $query .= " GROUP BY sales_stage," . db_convert('opportunities.date_closed', 'date_format', array("'%Y-%m'"), array("'YYYY-MM'")) . "ORDER BY m";
         //Now do the db queries
         //query for opportunity data that matches $datay and $user
         //_pp($query);
         $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'];
         $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;
         }
         $months = array();
         $monthArr = array();
         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 ($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;
             }
             $months[$row['m']] = $row['m'];
             if (!isset($monthArr[$row['m']]['row_total'])) {
                 $monthArr[$row['m']]['row_total'] = 0;
             }
             $monthArr[$row['m']][$salesStage]['opp_count'][] = $row['opp_count'];
             $monthArr[$row['m']][$salesStage]['total'][] = $sum;
             $monthArr[$row['m']]['outcome'][$salesStage] = $salesStageT;
             $monthArr[$row['m']]['row_total'] += $sum;
             $total += $sum;
         }
         $fileContents = '     <xData length="20">' . "\n";
         if (!empty($months)) {
             foreach ($months as $month) {
                 $rowTotalArr[] = $monthArr[$month]['row_total'];
                 if ($monthArr[$month]['row_total'] > 100) {
                     $monthArr[$month]['row_total'] = round($monthArr[$month]['row_total']);
                 }
                 $fileContents .= '          <dataRow title="' . $month . '" endLabel="' . currency_format_number($monthArr[$month]['row_total'], array('currency_symbol' => true)) . '">' . "\n";
                 arsort($salesStages);
                 foreach ($salesStages as $outcome => $outcome_translation) {
                     if (isset($monthArr[$month][$outcome])) {
                         $fileContents .= '               <bar id="' . $outcome . '" totalSize="' . array_sum($monthArr[$month][$outcome]['total']) . '" altText="' . $month . ': ' . format_number(array_sum($monthArr[$month][$outcome]['opp_count']), 0, 0) . ' ' . $current_module_strings['LBL_OPPS_WORTH'] . ' ' . currency_format_number(array_sum($monthArr[$month][$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&date_closed=' . $month . '&sales_stage=' . urlencode($outcome) . '&query=true&searchFormTab=advanced_search"/>' . "\n";
                     }
                 }
                 $fileContents .= '          </dataRow>' . "\n";
             }
         } else {
             $fileContents .= '          <dataRow title="" endLabel="">' . "\n";
             $fileContents .= '               <bar id="" totalSize="0" altText="" url=""/>' . "\n";
             $fileContents .= '          </dataRow>' . "\n";
             $rowTotalArr[] = 1000;
         }
         $fileContents .= '     </xData>' . "\n";
         $max = get_max($rowTotalArr);
         $fileContents .= '     <yData min="0" max="' . $max . '" length="10" prefix="' . $symbol . '" suffix="" kDelim="' . $kDelim . '" defaultAltText="' . $current_module_strings['LBL_ROLLOVER_DETAILS'] . '"/>' . "\n";
         $fileContents .= '     <colorLegend status="on">' . "\n";
         $i = 0;
         asort($salesStages);
         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_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 = round($total, 2);
         $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;
         //echo $fileContents;
         save_xml_file($cache_file_name, $fileContents);
     }
     $return = create_chart('vBarF', $cache_file_name);
     return $return;
 }
Ejemplo n.º 27
0
 /**
  * Log the user into the application
  *
  * @param UserAuth array $user_auth -- Set user_name and password (password needs to be
  *      in the right encoding for the type of authentication the user is setup for.  For Base
  *      sugar validation, password is the MD5 sum of the plain text password.
  * @param String $application -- The name of the application you are logging in from.  (Currently unused).
  * @param array $name_value_list -- Array of name value pair of extra parameters. As of today only 'language' and 'notifyonsave' is supported
  * @return Array - id - String id is the session_id of the session that was created.
  * 				 - module_name - String - module name of user
  * 				 - name_value_list - Array - The name value pair of user_id, user_name, user_language, user_currency_id, user_currency_name,
  *                                         - user_default_team_id, user_is_admin, user_default_dateformat, user_default_timeformat
  * @exception 'SoapFault' -- The SOAP error, if any
  */
 public function login($user_auth, $application, $name_value_list)
 {
     $GLOBALS['log']->info('Begin: SugarWebServiceImpl->login');
     global $sugar_config, $system_config;
     $error = new SoapError();
     $user = new User();
     $success = false;
     if (!empty($user_auth['encryption']) && $user_auth['encryption'] === 'PLAIN') {
         $user_auth['password'] = md5($user_auth['password']);
     }
     //rrs
     $system_config = new Administration();
     $system_config->retrieveSettings('system');
     $authController = new AuthenticationController();
     //rrs
     $isLoginSuccess = $authController->login($user_auth['user_name'], $user_auth['password'], array('passwordEncrypted' => true));
     $usr_id = $user->retrieve_user_id($user_auth['user_name']);
     if ($usr_id) {
         $user->retrieve($usr_id);
     }
     if ($isLoginSuccess) {
         if ($_SESSION['hasExpiredPassword'] == '1') {
             $error->set_error('password_expired');
             $GLOBALS['log']->fatal('password expired for user ' . $user_auth['user_name']);
             LogicHook::initialize();
             $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
             self::$helperObject->setFaultObject($error);
             return;
         }
         if (!empty($user) && !empty($user->id) && !$user->is_group) {
             $success = true;
             global $current_user;
             $current_user = $user;
         }
     } else {
         if ($usr_id && isset($user->user_name) && $user->getPreference('lockout') == '1') {
             $error->set_error('lockout_reached');
             $GLOBALS['log']->fatal('Lockout reached for user ' . $user_auth['user_name']);
             LogicHook::initialize();
             $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
             self::$helperObject->setFaultObject($error);
             return;
         } else {
             if (function_exists('mcrypt_cbc')) {
                 $password = self::$helperObject->decrypt_string($user_auth['password']);
                 if ($authController->login($user_auth['user_name'], $password) && isset($_SESSION['authenticated_user_id'])) {
                     $success = true;
                 }
             }
         }
     }
     if ($success) {
         session_start();
         global $current_user;
         //$current_user = $user;
         self::$helperObject->login_success($name_value_list);
         $current_user->loadPreferences();
         $_SESSION['is_valid_session'] = true;
         $_SESSION['ip_address'] = query_client_ip();
         $_SESSION['user_id'] = $current_user->id;
         $_SESSION['type'] = 'user';
         $_SESSION['avail_modules'] = self::$helperObject->get_user_module_list($current_user);
         $_SESSION['authenticated_user_id'] = $current_user->id;
         $_SESSION['unique_key'] = $sugar_config['unique_key'];
         $current_user->call_custom_logic('after_login');
         $GLOBALS['log']->info('End: SugarWebServiceImpl->login - succesful login');
         $nameValueArray = array();
         global $current_language;
         $nameValueArray['user_id'] = self::$helperObject->get_name_value('user_id', $current_user->id);
         $nameValueArray['user_name'] = self::$helperObject->get_name_value('user_name', $current_user->user_name);
         $nameValueArray['user_language'] = self::$helperObject->get_name_value('user_language', $current_language);
         $cur_id = $current_user->getPreference('currency');
         $nameValueArray['user_currency_id'] = self::$helperObject->get_name_value('user_currency_id', $cur_id);
         $nameValueArray['user_is_admin'] = self::$helperObject->get_name_value('user_is_admin', is_admin($current_user));
         $nameValueArray['user_default_team_id'] = self::$helperObject->get_name_value('user_default_team_id', $current_user->default_team);
         $nameValueArray['user_default_dateformat'] = self::$helperObject->get_name_value('user_default_dateformat', $current_user->getPreference('datef'));
         $nameValueArray['user_default_timeformat'] = self::$helperObject->get_name_value('user_default_timeformat', $current_user->getPreference('timef'));
         $currencyObject = new Currency();
         $currencyObject->retrieve($cur_id);
         $nameValueArray['user_currency_name'] = self::$helperObject->get_name_value('user_currency_name', $currencyObject->name);
         $_SESSION['user_language'] = $current_language;
         return array('id' => session_id(), 'module_name' => 'Users', 'name_value_list' => $nameValueArray);
     }
     LogicHook::initialize();
     $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
     $error->set_error('invalid_login');
     self::$helperObject->setFaultObject($error);
     $GLOBALS['log']->info('End: SugarWebServiceImpl->login - failed login');
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $sugar_config, $current_user;
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->base_url = array('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search');
     $sugarChart->url_params = array('assigned_user_id' => $current_user->id);
     $sugarChart->group_by = $this->constructGroupBy();
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if ($current_user->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $sugarChart->is_currency = true;
     $sugarChart->thousands_symbol = translate('LBL_OPP_THOUSANDS', 'Charts');
     $subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
     $query = $this->constructQuery();
     $dataset = $this->constructCEChartData($this->getChartData($query));
     $sugarChart->setData($dataset);
     $total = format_number($this->getHorizBarTotal($dataset), 0, 0, array('convert' => true));
     $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $sugarChart->currency_symbol . $total . $sugarChart->thousands_symbol;
     $sugarChart->setProperties($pipeline_total_string, $subtitle, 'horizontal bar chart');
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div><br />' . $this->processAutoRefresh();
 }
Ejemplo n.º 29
0
 /**
  * Log the user into the application
  *
  * @param UserAuth array $user_auth -- Set user_name and password (password needs to be
  *      in the right encoding for the type of authentication the user is setup for.  For Base
  *      sugar validation, password is the MD5 sum of the plain text password.
  * @param String $application -- The name of the application you are logging in from.  (Currently unused).
  * @param array $name_value_list -- Array of name value pair of extra parameters. As of today only 'language' and 'notifyonsave' is supported
  * @return Array - id - String id is the session_id of the session that was created.
  * 				 - module_name - String - module name of user
  * 				 - name_value_list - Array - The name value pair of user_id, user_name, user_language, user_currency_id, user_currency_name,
  *                                         - user_default_team_id, user_is_admin, user_default_dateformat, user_default_timeformat
  * @exception 'SoapFault' -- The SOAP error, if any
  */
 public function login($user_auth, $application, $name_value_list = array())
 {
     $GLOBALS['log']->info("Begin: SugarWebServiceImpl->login({$user_auth['user_name']}, {$application}, " . print_r($name_value_list, true) . ")");
     global $sugar_config, $system_config;
     $error = new SoapError();
     $user = new User();
     $success = false;
     //rrs
     $system_config = new Administration();
     $system_config->retrieveSettings('system');
     $authController = new AuthenticationController(!empty($sugar_config['authenticationClass']) ? $sugar_config['authenticationClass'] : 'SugarAuthenticate');
     //rrs
     if (!empty($user_auth['encryption']) && $user_auth['encryption'] === 'PLAIN' && $authController->authController->userAuthenticateClass != "LDAPAuthenticateUser") {
         $user_auth['password'] = md5($user_auth['password']);
     }
     $isLoginSuccess = $authController->login($user_auth['user_name'], $user_auth['password'], array('passwordEncrypted' => true));
     $usr_id = $user->retrieve_user_id($user_auth['user_name']);
     if ($usr_id) {
         $user->retrieve($usr_id);
     }
     if ($isLoginSuccess) {
         if ($_SESSION['hasExpiredPassword'] == '1') {
             $error->set_error('password_expired');
             $GLOBALS['log']->fatal('password expired for user ' . $user_auth['user_name']);
             LogicHook::initialize();
             $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
             self::$helperObject->setFaultObject($error);
             return;
         }
         if (!empty($user) && !empty($user->id) && !$user->is_group) {
             $success = true;
             global $current_user;
             $current_user = $user;
         }
     } else {
         if ($usr_id && isset($user->user_name) && $user->getPreference('lockout') == '1') {
             $error->set_error('lockout_reached');
             $GLOBALS['log']->fatal('Lockout reached for user ' . $user_auth['user_name']);
             LogicHook::initialize();
             $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
             self::$helperObject->setFaultObject($error);
             return;
         } else {
             if (function_exists('mcrypt_cbc') && $authController->authController->userAuthenticateClass == "LDAPAuthenticateUser" && (empty($user_auth['encryption']) || $user_auth['encryption'] !== 'PLAIN')) {
                 $password = self::$helperObject->decrypt_string($user_auth['password']);
                 $authController->loggedIn = false;
                 // reset login attempt to try again with decrypted password
                 if ($authController->login($user_auth['user_name'], $password) && isset($_SESSION['authenticated_user_id'])) {
                     $success = true;
                 }
             } else {
                 if ($authController->authController->userAuthenticateClass == "LDAPAuthenticateUser" && (empty($user_auth['encryption']) || $user_auth['encryption'] == 'PLAIN')) {
                     $authController->loggedIn = false;
                     // reset login attempt to try again with md5 password
                     if ($authController->login($user_auth['user_name'], md5($user_auth['password']), array('passwordEncrypted' => true)) && isset($_SESSION['authenticated_user_id'])) {
                         $success = true;
                     } else {
                         $error->set_error('ldap_error');
                         LogicHook::initialize();
                         $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
                         self::$helperObject->setFaultObject($error);
                         return;
                     }
                 }
             }
         }
     }
     if ($success) {
         session_start();
         global $current_user;
         //$current_user = $user;
         self::$helperObject->login_success($name_value_list);
         $current_user->loadPreferences();
         $_SESSION['is_valid_session'] = true;
         $_SESSION['ip_address'] = query_client_ip();
         $_SESSION['user_id'] = $current_user->id;
         $_SESSION['type'] = 'user';
         $_SESSION['avail_modules'] = self::$helperObject->get_user_module_list($current_user);
         $_SESSION['authenticated_user_id'] = $current_user->id;
         $_SESSION['unique_key'] = $sugar_config['unique_key'];
         $GLOBALS['log']->info('End: SugarWebServiceImpl->login - successful login');
         $current_user->call_custom_logic('after_login');
         $nameValueArray = array();
         global $current_language;
         $nameValueArray['user_id'] = self::$helperObject->get_name_value('user_id', $current_user->id);
         $nameValueArray['user_name'] = self::$helperObject->get_name_value('user_name', $current_user->user_name);
         $nameValueArray['user_language'] = self::$helperObject->get_name_value('user_language', $current_language);
         $cur_id = $current_user->getPreference('currency');
         $nameValueArray['user_currency_id'] = self::$helperObject->get_name_value('user_currency_id', $cur_id);
         $nameValueArray['user_is_admin'] = self::$helperObject->get_name_value('user_is_admin', is_admin($current_user));
         $nameValueArray['user_default_team_id'] = self::$helperObject->get_name_value('user_default_team_id', $current_user->default_team);
         $nameValueArray['user_default_dateformat'] = self::$helperObject->get_name_value('user_default_dateformat', $current_user->getPreference('datef'));
         $nameValueArray['user_default_timeformat'] = self::$helperObject->get_name_value('user_default_timeformat', $current_user->getPreference('timef'));
         $num_grp_sep = $current_user->getPreference('num_grp_sep');
         $dec_sep = $current_user->getPreference('dec_sep');
         $nameValueArray['user_number_seperator'] = self::$helperObject->get_name_value('user_number_seperator', empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep);
         $nameValueArray['user_decimal_seperator'] = self::$helperObject->get_name_value('user_decimal_seperator', empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep);
         $nameValueArray['mobile_max_list_entries'] = self::$helperObject->get_name_value('mobile_max_list_entries', $sugar_config['wl_list_max_entries_per_page']);
         $nameValueArray['mobile_max_subpanel_entries'] = self::$helperObject->get_name_value('mobile_max_subpanel_entries', $sugar_config['wl_list_max_entries_per_subpanel']);
         $currencyObject = new Currency();
         $currencyObject->retrieve($cur_id);
         $nameValueArray['user_currency_name'] = self::$helperObject->get_name_value('user_currency_name', $currencyObject->name);
         $_SESSION['user_language'] = $current_language;
         return array('id' => session_id(), 'module_name' => 'Users', 'name_value_list' => $nameValueArray);
     }
     LogicHook::initialize();
     $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
     $error->set_error('invalid_login');
     self::$helperObject->setFaultObject($error);
     $GLOBALS['log']->error('End: SugarWebServiceImpl->login - failed login');
 }
 /**
  * @see DashletGenericChart::display()
  */
 public function display()
 {
     global $current_user, $sugar_config;
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     $sugarChart->base_url = array('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search');
     //fixing bug #27097: The opportunity list is not correct after drill-down
     //should send to url additional params: start range value and end range value
     $sugarChart->url_params = array('start_range_date_closed' => $this->pbss_date_start, 'end_range_date_closed' => $this->pbss_date_end);
     $sugarChart->group_by = $this->constructGroupBy();
     $sugarChart->setData($this->getChartData($this->constructQuery()));
     $sugarChart->is_currency = true;
     $sugarChart->thousands_symbol = translate('LBL_OPP_THOUSANDS', 'Charts');
     $currency_symbol = $sugar_config['default_currency_symbol'];
     if ($current_user->getPreference('currency')) {
         $currency = new Currency();
         $currency->retrieve($current_user->getPreference('currency'));
         $currency_symbol = $currency->symbol;
     }
     $subtitle = translate('LBL_OPP_SIZE', 'Charts') . " " . $currency_symbol . "1" . translate('LBL_OPP_THOUSANDS', 'Charts');
     $pipeline_total_string = translate('LBL_TOTAL_PIPELINE', 'Charts') . $sugarChart->currency_symbol . format_number($sugarChart->getTotal(), 0, 0, array('convert' => true)) . $sugarChart->thousands_symbol;
     $sugarChart->setProperties($pipeline_total_string, $subtitle, 'funnel chart 3D');
     $xmlFile = $sugarChart->getXMLFileName($this->id);
     $sugarChart->saveXMLFile($xmlFile, $sugarChart->generateXML());
     return $this->getTitle('') . '<div align="center">' . $sugarChart->display($this->id, $xmlFile, '100%', '480', false) . '</div>' . $this->processAutoRefresh();
 }