function configureCurrencyVariables(&$focus) { $currency = new ListCurrency(); global $current_user; $currency->javascript .= "var oqc_ConversionRates = new Array(); \n"; $currency->javascript .= "var oqc_CurrencySymbols = new Array(); \n"; $currency->javascript .= "var oqc_CurrencyNames = new Array(); \n"; $currency->lookupCurrencies(); if (isset($currency->list) && !empty($currency->list)) { foreach ($currency->list as $data) { if ($data->status == 'Active') { $currency->javascript .= " oqc_ConversionRates['" . $data->id . "'] = '" . $data->conversion_rate . "';\n"; $currency->javascript .= " oqc_CurrencySymbols['" . $data->id . "'] = '" . $data->symbol . "';\n"; $currency->javascript .= " oqc_CurrencyNames['" . $data->id . "'] = '" . $data->name . "';\n"; } } //2.2RC1 Some legacy code to determine focus->currency_id foreach ($currency->list as $data) { // $focus_currency_id = ''; if ($data->status == 'Active') { if ($data->name == $focus->currency_id) { $focus->currency_id = $data->id; break; } } } } $currency->javascript .= '</script>'; return $currency->javascript; }
function option_configureCurrencyVariables() { $currency = new ListCurrency(); global $current_user; $currency->javascript .= "var oqc_optionConversionRates = new Array(); \n"; $currency->javascript .= "var oqc_optionCurrencySymbols = new Array(); \n"; $currency->javascript .= "var oqc_optionCurrencyNames = new Array(); \n"; $currency->lookupCurrencies(); if (isset($currency->list) && !empty($currency->list)) { foreach ($currency->list as $data) { if ($data->status == 'Active') { $currency->javascript .= " oqc_optionConversionRates['" . $data->id . "'] = '" . $data->conversion_rate . "';\n"; $currency->javascript .= " oqc_optionCurrencySymbols['" . $data->id . "'] = '" . $data->symbol . "';\n"; $currency->javascript .= " oqc_optionCurrencyNames['" . $data->id . "'] = '" . $data->name . "';\n"; } } } $currency->javascript .= '</script>'; return $currency->javascript; }
/** * Gets currencies * @return array */ public function getSystemCurrencies() { $currencies = array(); require_once 'modules/Currencies/ListCurrency.php'; $lcurrency = new ListCurrency(); $lcurrency->lookupCurrencies(true); if (!empty($lcurrency->list)) { foreach ($lcurrency->list as $current) { $currency = array(); $currency['name'] = $current->name; $currency['iso4217'] = $current->iso4217; $currency['status'] = $current->status; $currency['symbol'] = $current->symbol; $currency['conversion_rate'] = $current->conversion_rate; $currency['name'] = $current->name; $currency['date_entered'] = $current->date_entered; $currency['date_modified'] = $current->date_modified; $currencies[$current->id] = $currency; } } return $currencies; }
function getCurrencySymbolDropDown($focus, $field = 'currency_name', $value = '', $view = 'DetailView') { if ($view == 'EditView' || $view == 'MassUpdate' || $view == 'QuickCreate') { require_once 'modules/Currencies/ListCurrency.php'; $currency_fields = array(); //Bug 18276 - Fix for php 5.1.6 $defs = $focus->field_defs; // foreach ($defs as $name => $key) { if ($key['type'] == 'currency') { $currency_fields[] = $name; } } $currency = new ListCurrency(); $currency->lookupCurrencies(); $listitems = array(); foreach ($currency->list as $item) { $listitems[$item->symbol] = $item->symbol; } return '<select name="' . $field . '" id="' . $field . '" />' . get_select_options_with_id($listitems, $value) . '</select>'; } else { $currency = new Currency(); if (isset($focus->currency_id)) { $currency_id = $focus->currency_id; } else { $currency_id = -99; } $currency->retrieve($currency_id); return $currency->name; } }
} if (isset($_REQUEST['domerge'])) { $currencies = $_REQUEST['mergecur']; $opp = BeanFactory::getBean('Opportunities'); $opp->update_currency_id($currencies, $_REQUEST['mergeTo']); $product = BeanFactory::getBean('ProductTemplates'); $product->update_currency_id($currencies, $_REQUEST['mergeTo']); $quote = BeanFactory::getBean('Quotes'); $quote->update_currency_id($currencies, $_REQUEST['mergeTo']); foreach ($currencies as $cur) { if ($cur != $_REQUEST['mergeTo']) { $focus->mark_deleted($cur); } } } $lc->lookupCurrencies(); if (isset($focus->id)) { $focus_id = $focus->id; } else { $focus_id = ''; } $merge_button = ''; $pretable = ''; if (isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'merge' || isset($isMerge) && !$isMerge) { $merge_button = '<form name= "MERGE" method="POST" action="index.php"><input type="hidden" name="module" value="Currencies"><input type="hidden" name="record" value="' . $focus_id . '"><input type="hidden" name="action" value="index"><input type="hidden" name="merge" value="true"><input title="' . $mod_strings['LBL_MERGE'] . '" class="button" type="submit" name="button" value="' . $mod_strings['LBL_MERGE'] . '" ></form>'; } if (isset($isMerge) && $isMerge) { $currencyList = new ListCurrency(); $listoptions = $currencyList->getSelectOptions(); $pretable = <<<EOQ t<form name= "MERGE" method="POST" action="index.php">
/** * Return a list of currency ids with their associated symbols attached * * This is used for the currency_symbol vardefs via the API * * @return array */ public static function getCurrencySymbols() { require_once 'modules/Currencies/ListCurrency.php'; $currency = new ListCurrency(); $currency->lookupCurrencies(); $currencyList = array(); foreach ($currency->list as $item) { $currencyList[$item->id] = $item->symbol; } return $currencyList; }
function fill_in_additional_list_fields() { parent::fill_in_additional_list_fields(); // $GLOBALS['log']->error("Contract currency_1:". $this->currency_id); if (isset($this->currency_id) && $this->currency_id != '') { $currency = new Currency(); // $test = $currency->retrieve($this->currency_id); // $GLOBALS['log']->error("Currency retrieve:". var_export($test, true)); $currency->retrieve($this->currency_id); if ($currency->id != $this->currency_id || $currency->deleted == 1) { //2.2RC1 Some legacy code to determine currency_id $currencyList = new ListCurrency(); $currencyList->lookupCurrencies(); $legacy = false; if (isset($currencyList->list) && !empty($currencyList->list)) { foreach ($currencyList->list as $data) { if ($data->status == 'Active') { if ($data->name == $this->currency_id) { $this->currency_id = $data->id; $legacy = true; break; } } } } if (!$legacy) { $this->currency_id = $currency->id; } // $GLOBALS['log']->error("Contract currency_2:". $this->currency_id . ' ' .$currency->id); } } else { $this->currency_id = '-99'; // $GLOBALS['log']->error("Contract currency_3:". $this->currency_id); } $this->grand_total = $this->total_cost + $this->grand_total_vat; // $GLOBALS['log']->error("Contract currency_4:". $this->currency_id); if ($this->force_load_details == true) { $this->fill_in_additional_detail_fields(); } }