init
This commit is contained in:
659
modules/Currencies/Currency.php
Executable file
659
modules/Currencies/Currency.php
Executable file
@@ -0,0 +1,659 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Currency.php
|
||||
* This class encapsulates the handling of currency conversions and
|
||||
* formatting in the SugarCRM application.
|
||||
*
|
||||
*/
|
||||
class Currency extends SugarBean
|
||||
{
|
||||
// Stored fields
|
||||
var $id;
|
||||
var $iso4217;
|
||||
var $name;
|
||||
var $status;
|
||||
var $conversion_rate;
|
||||
var $deleted;
|
||||
var $date_entered;
|
||||
var $date_modified;
|
||||
var $symbol;
|
||||
var $hide = '';
|
||||
var $unhide = '';
|
||||
var $field_name_map;
|
||||
|
||||
var $table_name = "currencies";
|
||||
var $object_name = "Currency";
|
||||
var $module_dir = "Currencies";
|
||||
var $new_schema = true;
|
||||
|
||||
var $disable_num_format = true;
|
||||
|
||||
|
||||
function Currency()
|
||||
{
|
||||
parent::SugarBean();
|
||||
global $app_strings, $current_user, $sugar_config, $locale;
|
||||
$this->field_defs['hide'] = array('name'=>'hide', 'source'=>'non-db', 'type'=>'varchar','len'=>25);
|
||||
$this->field_defs['unhide'] = array('name'=>'unhide', 'source'=>'non-db', 'type'=>'varchar','len'=>25);
|
||||
$this->disable_row_level_security =true;
|
||||
}
|
||||
|
||||
/**
|
||||
* convertToDollar
|
||||
* This method accepts a currency amount and converts it to the US Dollar amount
|
||||
*
|
||||
* @param $amount The currency amount to convert to US Dollars
|
||||
* @param $precision The rounding precision scale
|
||||
* @return currency value in US Dollars from conversion
|
||||
*/
|
||||
function convertToDollar($amount, $precision = 6) {
|
||||
return round(($amount / $this->conversion_rate), $precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* convertFromCollar
|
||||
* This method accepts a US Dollar amount and returns a currency amount
|
||||
* with the conversion rate applied to it.
|
||||
*
|
||||
* @param $amount The currency amount in US Dollars
|
||||
* @param $precision The rounding precision scale
|
||||
* @return currency value from US Dollar conversion
|
||||
*/
|
||||
function convertFromDollar($amount, $precision = 6){
|
||||
return round(($amount * $this->conversion_rate), $precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* getDefaultCurrencyName
|
||||
*
|
||||
* Returns the default currency name as defined in application
|
||||
* @return String value of default currency name
|
||||
*/
|
||||
function getDefaultCurrencyName(){
|
||||
global $sugar_config;
|
||||
return $sugar_config['default_currency_name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* getDefaultCurrencySymbol
|
||||
*
|
||||
* Returns the default currency symobol in application
|
||||
* @return String value of default currency symbol(e.g. $)
|
||||
*/
|
||||
function getDefaultCurrencySymbol(){
|
||||
global $sugar_config;
|
||||
return $sugar_config['default_currency_symbol'];
|
||||
}
|
||||
|
||||
/**
|
||||
* getDefaultISO4217
|
||||
*
|
||||
* Returns the default ISO 4217 standard currency code value
|
||||
* @return String value for the ISO 4217 standard code(e.g. EUR)
|
||||
*/
|
||||
function getDefaultISO4217(){
|
||||
global $sugar_config;
|
||||
return $sugar_config['default_currency_iso4217'];
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieveIDBySmbol
|
||||
*
|
||||
* Returns the id value for given currency symbol in Currencies table
|
||||
* and currency entry for symbol is not set to deleted.
|
||||
*
|
||||
* @param $symbol Symbol value
|
||||
* @return String id value for symbol defined in Currencies table, blank String value
|
||||
* if none found
|
||||
*/
|
||||
function retrieveIDBySymbol($symbol) {
|
||||
$query = "SELECT id FROM currencies WHERE symbol='$symbol' AND deleted=0;";
|
||||
$result = $this->db->query($query);
|
||||
if($result){
|
||||
$row = $this->db->fetchByAssoc($result);
|
||||
if($row){
|
||||
return $row['id'];
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function list_view_parse_additional_sections(&$list_form) {
|
||||
global $isMerge;
|
||||
|
||||
if(isset($isMerge) && $isMerge && $this->id != '-99'){
|
||||
$list_form->assign('PREROW', '<input name="mergecur[]" type="checkbox" value="'.$this->id.'">');
|
||||
}
|
||||
return $list_form;
|
||||
}
|
||||
|
||||
function retrieve_id_by_name($name) {
|
||||
$query = "select id from currencies where name='$name' and deleted=0;";
|
||||
$result = $this->db->query($query);
|
||||
if($result){
|
||||
$row = $this->db->fetchByAssoc($result);
|
||||
if($row){
|
||||
return $row['id'];
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function retrieve($id, $encode = true){
|
||||
if($id == '-99'){
|
||||
$this->name = $this->getDefaultCurrencyName();
|
||||
$this->symbol = $this->getDefaultCurrencySymbol();
|
||||
$this->id = '-99';
|
||||
$this->conversion_rate = 1;
|
||||
$this->iso4217 = $this->getDefaultISO4217();
|
||||
$this->deleted = 0;
|
||||
$this->status = 'Active';
|
||||
$this->hide = '<!--';
|
||||
$this->unhide = '-->';
|
||||
}else{
|
||||
parent::retrieve($id, $encode);
|
||||
}
|
||||
if(!isset($this->name) || $this->deleted == 1){
|
||||
$this->name = $this->getDefaultCurrencyName();
|
||||
$this->symbol = $this->getDefaultCurrencySymbol();
|
||||
$this->conversion_rate = 1;
|
||||
$this->iso4217 = $this->getDefaultISO4217();
|
||||
$this->id = '-99';
|
||||
$this->deleted = 0;
|
||||
$this->status = 'Active';
|
||||
$this->hide = '<!--';
|
||||
$this->unhide = '-->';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for returning the currency symbol, must return chr(2) for the € symbol
|
||||
* to display correctly in pdfs
|
||||
* Parameters:
|
||||
* none
|
||||
* Returns:
|
||||
* $symbol otherwise chr(2) for euro symbol
|
||||
*/
|
||||
function getPdfCurrencySymbol() {
|
||||
if($this->symbol == '€' || $this->symbol == '€')
|
||||
return chr(2);
|
||||
return $this->symbol;
|
||||
}
|
||||
function get_list_view_data() {
|
||||
$this->conversion_rate = format_number($this->conversion_rate, 10, 10);
|
||||
$data = parent::get_list_view_data();
|
||||
return $data;
|
||||
}
|
||||
function save($check_notify = FALSE) {
|
||||
sugar_cache_clear('currency_list');
|
||||
return parent::save($check_notify);
|
||||
}
|
||||
} // end currency class
|
||||
|
||||
/**
|
||||
* currency_format_number
|
||||
*
|
||||
* This method is a wrapper designed exclusively for formatting currency values
|
||||
* with the assumption that the method caller wants a currency formatted value
|
||||
* matching his/her user preferences(if set) or the system configuration defaults
|
||||
*(if user preferences are not defined).
|
||||
*
|
||||
* @param $amount The amount to be formatted
|
||||
* @param $params Optional parameters(see @format_number)
|
||||
* @return String representation of amount with formatting applied
|
||||
*/
|
||||
function currency_format_number($amount, $params = array()) {
|
||||
global $locale;
|
||||
if(isset($params['round']) && is_int($params['round'])){
|
||||
$real_round = $params['round'];
|
||||
}else{
|
||||
$real_round = $locale->getPrecedentPreference('default_currency_significant_digits');
|
||||
}
|
||||
if(isset($params['decimals']) && is_int($params['decimals'])){
|
||||
$real_decimals = $params['decimals'];
|
||||
}else{
|
||||
$real_decimals = $locale->getPrecedentPreference('default_currency_significant_digits');
|
||||
}
|
||||
$real_round = $real_round == '' ? 0 : $real_round;
|
||||
$real_decimals = $real_decimals == '' ? 0 : $real_decimals;
|
||||
|
||||
$showCurrencySymbol = $locale->getPrecedentPreference('default_currency_symbol') != '' ? true : false;
|
||||
if($showCurrencySymbol && !isset($params['currency_symbol'])) {
|
||||
$params["currency_symbol"] = true;
|
||||
}
|
||||
return format_number($amount, $real_round, $real_decimals, $params);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* format_number(deprecated)
|
||||
*
|
||||
* This method accepts an amount and formats it given the user's preferences.
|
||||
* Should the values set in the user preferences be invalid then it will
|
||||
* apply the system wide Sugar configuration values. Calls to
|
||||
* getPrecendentPreference() method in Localization.php are made that
|
||||
* handle this logic.
|
||||
*
|
||||
* Going forward with Sugar 4.5.0e+ implementations, users of this class should
|
||||
* simple call this function with $amount parameter and leave it to the
|
||||
* class to locate and apply the appropriate formatting.
|
||||
*
|
||||
* One of the problems is that there is considerable legacy code that is using
|
||||
* this method for non currency formatting. In other words, the format_number
|
||||
* method may be called to just display a number like 1,000 formatted appropriately.
|
||||
*
|
||||
* Also, issues about responsibilities arise. Currently the callers of this function
|
||||
* are responsible for passing in the appropriate decimal and number rounding digits
|
||||
* as well as parameters to control displaying the currency symbol or not.
|
||||
*
|
||||
* @param $amount The currency amount to apply formatting to
|
||||
* @param $round Integer value for number of places to round to
|
||||
* @param $decimals Integer value for number of decimals to round to
|
||||
* @param $params Array of additional parameter values
|
||||
*
|
||||
*
|
||||
* The following are passed in as an array of params:
|
||||
* boolean $params['currency_symbol'] - true to display currency symbol
|
||||
* boolean $params['convert'] - true to convert from USD dollar
|
||||
* boolean $params['percentage'] - true to display % sign
|
||||
* boolean $params['symbol_space'] - true to have space between currency symbol and amount
|
||||
* String $params['symbol_override'] - string to over default currency symbol
|
||||
* String $params['type'] - pass in 'pdf' for pdf currency symbol conversion
|
||||
* String $params['currency_id'] - currency_id to retreive, defaults to current user
|
||||
* String $params['human'] - formatting that truncates the first thousands and appends "k"
|
||||
* @return String formatted currency value
|
||||
* @see include/Localization/Localization.php
|
||||
*/
|
||||
function format_number($amount, $round = null, $decimals = null, $params = array(), $zeros = null) {
|
||||
|
||||
global $app_strings, $current_user, $sugar_config, $locale;
|
||||
static $current_users_currency = null;
|
||||
static $last_override_currency = null;
|
||||
static $override_currency_id = null;
|
||||
static $currency;
|
||||
|
||||
$seps = get_number_seperators();
|
||||
$num_grp_sep = $seps[0];
|
||||
$dec_sep = $seps[1];
|
||||
|
||||
// cn: bug 8522 - sig digits not honored in pdfs
|
||||
if(is_null($decimals)) {
|
||||
$decimals = $locale->getPrecision();
|
||||
}
|
||||
if(is_null($round)) {
|
||||
$round = $locale->getPrecision();
|
||||
}
|
||||
|
||||
// only create a currency object if we need it
|
||||
if((!empty($params['currency_symbol']) && $params['currency_symbol']) ||
|
||||
(!empty($params['convert']) && $params['convert']) ||
|
||||
(!empty($params['currency_id']))) {
|
||||
// if we have an override currency_id
|
||||
if(!empty($params['currency_id'])) {
|
||||
if($override_currency_id != $params['currency_id']) {
|
||||
$override_currency_id = $params['currency_id'];
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($override_currency_id);
|
||||
$last_override_currency = $currency;
|
||||
} else {
|
||||
$currency = $last_override_currency;
|
||||
}
|
||||
|
||||
} elseif(!isset($current_users_currency)) { // else use current user's
|
||||
$current_users_currency = new Currency();
|
||||
if($current_user->getPreference('currency')) $current_users_currency->retrieve($current_user->getPreference('currency'));
|
||||
else $current_users_currency->retrieve('-99'); // use default if none set
|
||||
$currency = $current_users_currency;
|
||||
}
|
||||
}
|
||||
if(!empty($params['convert']) && $params['convert']) {
|
||||
$amount = $currency->convertFromDollar($amount, 6);
|
||||
}
|
||||
|
||||
if(!empty($params['currency_symbol']) && $params['currency_symbol']) {
|
||||
if(!empty($params['symbol_override'])) {
|
||||
$symbol = $params['symbol_override'];
|
||||
}
|
||||
elseif(!empty($params['type']) && $params['type'] == 'pdf') {
|
||||
$symbol = $currency->getPdfCurrencySymbol();
|
||||
$symbol_space = false;
|
||||
} else {
|
||||
if(empty($currency->symbol))
|
||||
$symbol = $currency->getDefaultCurrencySymbol();
|
||||
else
|
||||
$symbol = $currency->symbol;
|
||||
$symbol_space = true;
|
||||
}
|
||||
} else {
|
||||
$symbol = '';
|
||||
}
|
||||
|
||||
if(isset($params['charset_convert'])) {
|
||||
$symbol = $locale->translateCharset($symbol, 'UTF-8', $locale->getExportCharset());
|
||||
}
|
||||
|
||||
|
||||
if(empty($params['human'])) {
|
||||
|
||||
|
||||
$amount = number_format(round($amount, $round), $decimals, $dec_sep, $num_grp_sep);
|
||||
$amount = format_place_symbol($amount, $symbol,(empty($params['symbol_space']) ? false : true));
|
||||
|
||||
//mz remove zeros
|
||||
if (isset($zeros)) {
|
||||
|
||||
//return $zeros;
|
||||
|
||||
$tmp = explode($dec_sep, $amount);
|
||||
if ($tmp[1]) {
|
||||
if (strlen($tmp[1])>$zeros) {
|
||||
$cut = strlen($tmp[1]);
|
||||
for ($i = strlen($tmp[1])-1; $i>$zeros-1;$i--) {
|
||||
if ($tmp[1][$i]=='0') $cut--; else break;
|
||||
}
|
||||
$tmp[1] = substr($tmp[1],0,$cut);
|
||||
}
|
||||
if ($zeros==0) $dec_sep='';
|
||||
$amount = implode($dec_sep, $tmp);
|
||||
}
|
||||
}
|
||||
//end mz
|
||||
}
|
||||
else {
|
||||
// If amount is more greater than a thousand(postiive or negative)
|
||||
if(strpos($amount, '.') > 0) {
|
||||
$checkAmount = strlen(substr($amount, 0, strpos($amount, '.')));
|
||||
}
|
||||
|
||||
if($checkAmount >= 1000 || $checkAmount <= -1000) {
|
||||
$amount = round(($amount / 1000), 0);
|
||||
$amount = $amount . 'k';
|
||||
$amount = format_place_symbol($amount, $symbol,(empty($params['symbol_space']) ? false : true));
|
||||
} else {
|
||||
$amount = format_place_symbol($amount, $symbol,(empty($params['symbol_space']) ? false : true));
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($params['percentage']) && $params['percentage']) $amount .= $app_strings['LBL_PERCENTAGE_SYMBOL'];
|
||||
|
||||
return $amount;
|
||||
|
||||
} //end function format_number
|
||||
|
||||
|
||||
|
||||
function format_place_symbol($amount, $symbol, $symbol_space) {
|
||||
if($symbol != '') {
|
||||
if($symbol_space == true) {
|
||||
$amount = $symbol . ' ' . $amount;
|
||||
} else {
|
||||
$amount = $symbol . $amount;
|
||||
}
|
||||
}
|
||||
return $amount;
|
||||
}
|
||||
|
||||
function unformat_number($string) {
|
||||
// Just in case someone passes an already unformatted number through.
|
||||
if ( !is_string($string) ) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
static $currency = null;
|
||||
if(!isset($currency)) {
|
||||
global $current_user;
|
||||
$currency = new Currency();
|
||||
if(!empty($current_user->id)){
|
||||
if($current_user->getPreference('currency')){
|
||||
$currency->retrieve($current_user->getPreference('currency'));
|
||||
}
|
||||
else{
|
||||
$currency->retrieve('-99'); // use default if none set
|
||||
}
|
||||
}else{
|
||||
$currency->retrieve('-99'); // use default if none set
|
||||
}
|
||||
}
|
||||
|
||||
$seps = get_number_seperators();
|
||||
// remove num_grp_sep and replace decimal seperater with decimal
|
||||
$string = trim(str_replace(array($seps[0], $seps[1], $currency->symbol), array('', '.', ''), $string));
|
||||
if(preg_match('/^[+-]?\d(\.\d+)?[Ee]([+-]?\d+)?$/', $string)) $string = sprintf("%.0f", $string);//for scientific number format. After round(), we may get this number type.
|
||||
preg_match('/[\-\+]?[0-9\.]*/', $string, $string);
|
||||
|
||||
$out_number = trim($string[0]);
|
||||
if ( $out_number == '' ) {
|
||||
return '';
|
||||
} else {
|
||||
return (float)$out_number;
|
||||
}
|
||||
}
|
||||
|
||||
// deprecated use format_number() above
|
||||
function format_money($amount, $for_display = TRUE) {
|
||||
// This function formats an amount for display.
|
||||
// Later on, this should be converted to use proper thousand and decimal seperators
|
||||
// Currently, it stays closer to the existing format, and just rounds to two decimal points
|
||||
if(isset($amount)) {
|
||||
if($for_display) {
|
||||
return sprintf("%0.02f",$amount);
|
||||
} else {
|
||||
// If it's an editable field, don't use a thousand seperator.
|
||||
// Or perhaps we will want to, but it doesn't matter right now.
|
||||
return sprintf("%0.02f",$amount);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns user/system preference for number grouping separator character(default ",") and the decimal separator
|
||||
*(default "."). Special case: when num_grp_sep is ".", it will return NULL as the num_grp_sep.
|
||||
* @return array Two element array, first item is num_grp_sep, 2nd item is dec_sep
|
||||
*/
|
||||
function get_number_seperators($reset_sep = false) {
|
||||
//mz
|
||||
//nope!
|
||||
return array(".", ",");
|
||||
|
||||
global $current_user, $sugar_config;
|
||||
|
||||
static $dec_sep = null;
|
||||
static $num_grp_sep = null;
|
||||
|
||||
if ( $reset_sep ) {
|
||||
// This is typically only used during unit-tests
|
||||
$dec_sep = $num_grp_sep = null;
|
||||
}
|
||||
|
||||
if($dec_sep == null) {
|
||||
$dec_sep = $sugar_config['default_decimal_seperator'];
|
||||
if(!empty($current_user->id)){
|
||||
$user_dec_sep = $current_user->getPreference('dec_sep');
|
||||
$dec_sep =(empty($user_dec_sep) ? $sugar_config['default_decimal_seperator'] : $user_dec_sep);
|
||||
}
|
||||
}
|
||||
if($num_grp_sep == null) {
|
||||
$num_grp_sep = $sugar_config['default_number_grouping_seperator'];
|
||||
if(!empty($current_user->id)){
|
||||
$user_num_grp_sep = $current_user->getPreference('num_grp_sep');
|
||||
$num_grp_sep =(empty($user_num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $user_num_grp_sep);
|
||||
}
|
||||
}
|
||||
|
||||
return array(".", ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* toString
|
||||
*
|
||||
* Utility function to print out some information about Currency instance.
|
||||
*/
|
||||
function toString($echo = true) {
|
||||
$s = "\$m_currency_round=$m_currency_round \n" .
|
||||
"\$m_currency_decimal=$m_currency_decimal \n" .
|
||||
"\$m_currency_symbol=$m_currency_symbol \n" .
|
||||
"\$m_currency_iso=$m_currency_iso \n" .
|
||||
"\$m_currency_name=$m_currency_name \n";
|
||||
|
||||
if($echo) {
|
||||
echo $s;
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
function getCurrencyDropDown($focus, $field='currency_id', $value='', $view='DetailView'){
|
||||
$view = ucfirst($view);
|
||||
if($view == 'EditView' || $view == 'MassUpdate' || $view == 'QuickCreate'){
|
||||
if ( isset($_REQUEST[$field]) && !empty($_REQUEST[$field]) ) {
|
||||
$value = $_REQUEST[$field];
|
||||
} elseif ( empty($focus->id) ) {
|
||||
$value = $GLOBALS['current_user']->getPreference('currency');
|
||||
if ( empty($value) ) {
|
||||
// -99 is the system default currency
|
||||
$value = -99;
|
||||
}
|
||||
}
|
||||
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();
|
||||
$selectCurrency = $currency->getSelectOptions($value);
|
||||
|
||||
$currency->setCurrencyFields($currency_fields);
|
||||
$html = '<select name="'. $field. '" ';
|
||||
if($view != 'MassUpdate')
|
||||
$html .= 'onchange="CurrencyConvertAll();"';
|
||||
$html .= '>'. $selectCurrency . '</select>';
|
||||
if($view != 'MassUpdate')
|
||||
$html .= $currency->getJavascript();
|
||||
return $html;
|
||||
}else{
|
||||
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($value);
|
||||
return $currency->name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getCurrencyNameDropDown($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->name] = $item->name;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
53
modules/Currencies/EditCurrency.php
Executable file
53
modules/Currencies/EditCurrency.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
/*********************************************************************************
|
||||
|
||||
********************************************************************************/
|
||||
|
||||
if($current_user->is_admin){
|
||||
require_once('modules/Currencies/ListCurrency.php');
|
||||
$lc = new ListCurrency();
|
||||
$lc->handleDelete();
|
||||
$lc->handleAdd();
|
||||
$lc->handleUpdate();
|
||||
echo $lc->getTable();
|
||||
}else{
|
||||
echo 'Admin\'s Only';
|
||||
}
|
||||
|
||||
?>
|
||||
38
modules/Currencies/EditView.js
Normal file
38
modules/Currencies/EditView.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
function isoUpdate(formElem){if(typeof(js_iso4217[formElem.value])=='undefined'){return false;}
|
||||
var thisForm=formElem.form;var thisCurr=js_iso4217[formElem.value];if(thisForm.name.value==''){thisForm.name.value=thisCurr.name;}
|
||||
if(thisForm.symbol.value==''){thisForm.symbol.value='';for(var i=0;i<thisCurr.unicode.length;i++){thisForm.symbol.value=thisForm.symbol.value+String.fromCharCode(thisCurr.unicode[i]);}}
|
||||
return true;}
|
||||
80
modules/Currencies/EditView.tpl
Executable file
80
modules/Currencies/EditView.tpl
Executable file
@@ -0,0 +1,80 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
********************************************************************************/
|
||||
*}
|
||||
|
||||
<script type="text/javascript">
|
||||
js_iso4217 = {$JS_ISO4217};
|
||||
</script>
|
||||
<script type="text/javascript" src="modules/Currencies/EditView.js"></script>
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="edit view">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="15%" scope="row" nowrap><slot>{$MOD.LBL_LIST_NAME}: <span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span></slot></td>
|
||||
<td width="35%"><slot><input name='name' tabindex='1' size='30' maxlength='50' type="text" value="{$NAME}"></slot></td>
|
||||
<td width="15%" scope="row" nowrap><slot>{$MOD.LBL_LIST_ISO4217}: {sugar_help text=$MOD.LBL_LIST_ISO4217_HELP}</slot></td>
|
||||
<td width="35%"><slot><input name='iso4217' tabindex='1' size='3'
|
||||
maxlength='3' type="text" value="{$ISO4217}" onKeyUp='isoUpdate(this);'></slot></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="15%" scope="row" nowrap><slot> {$MOD.LBL_LIST_RATE}: <span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span></slot></td>
|
||||
<td width="35%"><slot><input name='conversion_rate' tabindex='1' size='30' maxlength='50' type="text" value="{$CONVERSION_RATE}">
|
||||
<img border="0" src="index.php?entryPoint=getImage&themeName={$THEME}&imageName=helpInline.gif" onmouseover="return overlib('{$MOD.LBL_LIST_RATE_HELP}', FGCLASS, 'olFgClass', CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass', WIDTH, -1, NOFOLLOW, 'ol_nofollow' );" onmouseout="return nd();"/>
|
||||
</slot></td>
|
||||
<td width="15%" scope="row" nowrap><slot>{$MOD.LBL_LIST_SYMBOL}: <span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span></slot></td>
|
||||
<td width="35%"><slot><input name='symbol' tabindex='1' size='3' maxlength='50' type="text" value="{$SYMBOL}"></slot></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td scope="row"><slot>{$MOD.LBL_LIST_STATUS}:</slot></td>
|
||||
<td><slot><select name='status' tabindex='1'>{$STATUS_OPTIONS}</select> <em>{$MOD.NTC_STATUS}</em></slot></td>
|
||||
</tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type='hidden' name='record' value='{$ID}'>
|
||||
</form>
|
||||
{$JAVASCRIPT}
|
||||
65
modules/Currencies/Forms.php
Executable file
65
modules/Currencies/Forms.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Contains a variety of utility functions used to display UI
|
||||
* components such as form headers and footers. Intended to be modified on a per
|
||||
* theme basis.
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* Create javascript to validate the data entered into a record.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
*/
|
||||
function get_validate_record_js () {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create HTML form to enter a new record with the minimum necessary fields.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
*/
|
||||
function get_new_record_form () {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
243
modules/Currencies/ListCurrency.php
Executable file
243
modules/Currencies/ListCurrency.php
Executable file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
class ListCurrency{
|
||||
var $focus = null;
|
||||
var $list = null;
|
||||
var $javascript = '<script>';
|
||||
function lookupCurrencies(){
|
||||
|
||||
|
||||
$this->focus = new Currency();
|
||||
$this->list = $this->focus->get_full_list('name');
|
||||
$this->focus->retrieve('-99');
|
||||
if(is_array($this->list)){
|
||||
$this->list = array_merge(Array($this->focus), $this->list);
|
||||
}else{
|
||||
$this->list = Array($this->focus);
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function handleUpdate(){
|
||||
global $current_user;
|
||||
if($current_user->is_admin){
|
||||
if(isset($_POST['id']) && !empty($_POST['id'])&&isset($_POST['name']) && !empty($_POST['name']) && isset($_POST['rate']) && !empty($_POST['rate']) && isset($_POST['symbol']) && !empty($_POST['symbol'])){
|
||||
$ids = $_POST['id'];
|
||||
$names= $_POST['name'];
|
||||
$symbols= $_POST['symbol'];
|
||||
$rates = $_POST['rate'];
|
||||
$isos = $_POST['iso'];
|
||||
$size = sizeof($ids);
|
||||
if($size != sizeof($names)|| $size != sizeof($isos) || $size != sizeof($symbols) || $size != sizeof($rates)){
|
||||
return;
|
||||
}
|
||||
|
||||
$temp = new Currency();
|
||||
for($i = 0; $i < $size; $i++){
|
||||
$temp->id = $ids[$i];
|
||||
$temp->name = $names[$i];
|
||||
$temp->symbol = $symbols[$i];
|
||||
$temp->iso4217 = $isos[$i];
|
||||
$temp->conversion_rate = $rates[$i];
|
||||
$temp->save();
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
function getJavascript(){
|
||||
// wp: DO NOT add formatting and unformatting numbers in here, add them prior to calling these to avoid double calling
|
||||
// of unformat number
|
||||
return $this->javascript . <<<EOQ
|
||||
function get_rate(id){
|
||||
return ConversionRates[id];
|
||||
}
|
||||
function ConvertToDollar(amount, rate){
|
||||
return amount / rate;
|
||||
}
|
||||
function ConvertFromDollar(amount, rate){
|
||||
return amount * rate;
|
||||
}
|
||||
function ConvertRate(id,fields){
|
||||
for(var i = 0; i < fields.length; i++){
|
||||
fields[i].value = toDecimal(ConvertFromDollar(toDecimal(ConvertToDollar(toDecimal(fields[i].value), lastRate)), ConversionRates[id]));
|
||||
}
|
||||
lastRate = ConversionRates[id];
|
||||
}
|
||||
function ConvertRateSingle(id,field){
|
||||
var temp = field.innerHTML.substring(1, field.innerHTML.length);
|
||||
unformattedNumber = unformatNumber(temp, num_grp_sep, dec_sep);
|
||||
|
||||
field.innerHTML = CurrencySymbols[id] + formatNumber(toDecimal(ConvertFromDollar(ConvertToDollar(unformattedNumber, lastRate), ConversionRates[id])), num_grp_sep, dec_sep, 2, 2);
|
||||
lastRate = ConversionRates[id];
|
||||
}
|
||||
function CurrencyConvertAll(){
|
||||
try {
|
||||
var id = document.EditView.currency_id.options[document.EditView.currency_id.selectedIndex].value;
|
||||
var fields = new Array();
|
||||
|
||||
for(i in currencyFields){
|
||||
var field = currencyFields[i];
|
||||
if(typeof(document.EditView[field]) != 'undefined'){
|
||||
document.EditView[field].value = unformatNumber(document.EditView[field].value, num_grp_sep, dec_sep);
|
||||
fields.push(document.EditView[field]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ConvertRate(id, fields);
|
||||
for(i in fields){
|
||||
fields[i].value = formatNumber(fields[i].value, num_grp_sep, dec_sep);
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
// Do nothing, if we can't find the currency_id field we will just not attempt to convert currencies
|
||||
// This typically only happens in lead conversion and quick creates, where the currency_id field may be named somethnig else or hidden deep inside a sub-form.
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
EOQ;
|
||||
}
|
||||
|
||||
|
||||
function getSelectOptions($id = ''){
|
||||
global $current_user;
|
||||
$this->javascript .="var ConversionRates = new Array(); \n";
|
||||
$this->javascript .="var CurrencySymbols = new Array(); \n";
|
||||
$options = '';
|
||||
$this->lookupCurrencies();
|
||||
$setLastRate = false;
|
||||
if(isset($this->list ) && !empty($this->list )){
|
||||
foreach ($this->list as $data){
|
||||
if($data->status == 'Active'){
|
||||
if($id == $data->id){
|
||||
$options .= '<option value="'. $data->id . '" selected>';
|
||||
$setLastRate = true;
|
||||
$this->javascript .= 'var lastRate = "' . $data->conversion_rate . '";';
|
||||
|
||||
}else{
|
||||
$options .= '<option value="'. $data->id . '">' ;
|
||||
}
|
||||
$options .= $data->name . ' : ' . $data->symbol;
|
||||
$this->javascript .=" ConversionRates['".$data->id."'] = '".$data->conversion_rate."';\n";
|
||||
$this->javascript .=" CurrencySymbols['".$data->id."'] = '".$data->symbol."';\n";
|
||||
}}
|
||||
if(!$setLastRate){
|
||||
$this->javascript .= 'var lastRate = "1";';
|
||||
}
|
||||
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
function getTable(){
|
||||
$this->lookupCurrencies();
|
||||
$usdollar = translate('LBL_US_DOLLAR');
|
||||
$currency = translate('LBL_CURRENCY');
|
||||
$currency_sym = $sugar_config['default_currency_symbol'];
|
||||
$conv_rate = translate('LBL_CONVERSION_RATE');
|
||||
$add = translate('LBL_ADD');
|
||||
$delete = translate('LBL_DELETE');
|
||||
$update = translate('LBL_UPDATE');
|
||||
|
||||
$form = $html = "<br><table cellpadding='0' cellspacing='0' border='0' class='tabForm'><tr><td><tableborder='0' cellspacing='0' cellpadding='0'>";
|
||||
$form .= <<<EOQ
|
||||
<form name='DeleteCurrency' action='index.php' method='post'><input type='hidden' name='action' value='{$_REQUEST['action']}'>
|
||||
<input type='hidden' name='module' value='{$_REQUEST['module']}'><input type='hidden' name='deleteCur' value=''></form>
|
||||
|
||||
<tr><td><B>$currency</B></td><td><B>ISO 4217</B> </td><td><B>$currency_sym</B></td><td colspan='2'><B>$conv_rate</B></td></tr>
|
||||
<tr><td>$usdollar</td><td>USD</td><td>$</td><td colspan='2'>1</td></tr>
|
||||
<form name="UpdateCurrency" action="index.php" method="post"><input type='hidden' name='action' value='{$_REQUEST['action']}'>
|
||||
<input type='hidden' name='module' value='{$_REQUEST['module']}'>
|
||||
EOQ;
|
||||
if(isset($this->list ) && !empty($this->list )){
|
||||
foreach ($this->list as $data){
|
||||
|
||||
$form .= '<tr><td>'.$data->iso4217. '<input type="hidden" name="iso[]" value="'.$data->iso4217.'"></td><td><input type="hidden" name="id[]" value="'.$data->id.'">'.$data->name. '<input type="hidden" name="name[]" value="'.$data->name.'"></td><td>'.$data->symbol. '<input type="hidden" name="symbol[]" value="'.$data->symbol.'"></td><td>'.$data->conversion_rate.' </td><td><input type="text" name="rate[]" value="'.$data->conversion_rate.'"><td> <input type="button" name="delete" class="button" value="'.$delete.'" onclick="document.forms[\'DeleteCurrency\'].deleteCur.value=\''.$data->id.'\';document.forms[\'DeleteCurrency\'].submit();"> </td></tr>';
|
||||
}
|
||||
}
|
||||
$form .= <<<EOQ
|
||||
<tr><td></td><td></td><td></td><td></td><td></td><td> <input type='submit' name='Update' value='$update' class='button'></TD></form> </td></tr>
|
||||
<tr><td colspan='3'><br></td></tr>
|
||||
<form name="AddCurrency" action="index.php" method="post">
|
||||
<input type='hidden' name='action' value='{$_REQUEST['action']}'>
|
||||
<input type='hidden' name='module' value='{$_REQUEST['module']}'>
|
||||
<tr><td><input type = 'text' name='addname' value=''> </td><td><input type = 'text' name='addiso' size='3' maxlength='3' value=''> </td><td><input type = 'text' name='addsymbol' value=''></td><td colspan='2'> <input type ='text' name='addrate'></td><td> <input type='submit' name='Add' value='$add' class='button'></td></tr>
|
||||
</form></table></td></tr></table>
|
||||
EOQ;
|
||||
return $form;
|
||||
|
||||
}
|
||||
|
||||
function setCurrencyFields($fields){
|
||||
$json = getJSONobj();
|
||||
$this->javascript .= 'var currencyFields = ' . $json->encode($fields) . ";\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//$lc = new ListCurrency();
|
||||
//$lc->handleDelete();
|
||||
//$lc->handleAdd();
|
||||
//$lc->handleUpdate();
|
||||
//echo '<select>'. $lc->getSelectOptions() . '</select>';
|
||||
//echo $lc->getTable();
|
||||
|
||||
?>
|
||||
71
modules/Currencies/ListView.html
Executable file
71
modules/Currencies/ListView.html
Executable file
@@ -0,0 +1,71 @@
|
||||
<!--
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
********************************************************************************/
|
||||
-->
|
||||
|
||||
<!-- BEGIN: main -->
|
||||
{PRETABLE}
|
||||
<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view">
|
||||
|
||||
<tr height="20">
|
||||
<td scope="col" width="1%" >{CHECKALL}</td>
|
||||
<td scope="col" width="20%" nowrap><slot>{MOD.LBL_LIST_NAME}</slot></td>
|
||||
<td scope="col" width="10%" nowrap><slot>{MOD.LBL_LIST_ISO4217}</slot></td>
|
||||
<td scope="col" width="10%" nowrap><slot>{MOD.LBL_LIST_SYMBOL}</slot></td>
|
||||
<td scope="col" width="10%" nowrap><slot>{MOD.LBL_LIST_RATE}</slot></td>
|
||||
<td scope="col" width="10%" nowrap><slot>{MOD.LBL_LIST_STATUS}</slot></td>
|
||||
<td scope="col" width="8%" ><slot> </slot></td>
|
||||
</tr>
|
||||
|
||||
<!-- BEGIN: row -->
|
||||
<tr height="20" class="{ROW_COLOR}S1">
|
||||
<td >{PREROW} </td>
|
||||
<td scope='row' valign=TOP><slot>{CURRENCY.HIDE}<a href="{URL_PREFIX}index.php?action=index&module=Currencies&record={CURRENCY.ID}" >{CURRENCY.UNHIDE}{CURRENCY.NAME}{CURRENCY.HIDE}</a>{CURRENCY.UNHIDE}</slot></td>
|
||||
<td valign=TOP><slot>{CURRENCY.ISO4217}</slot></td>
|
||||
<td valign=TOP><slot>{CURRENCY.SYMBOL}</slot></td>
|
||||
<td valign=TOP><slot>{CURRENCY.CONVERSION_RATE}</slot></td>
|
||||
<td valign=TOP><slot>{CURRENCY.STATUS}</slot></td>
|
||||
<td nowrap align="center" valign=TOP><slot>{CURRENCY.HIDE}<a class="listViewTdToolsS1" onclick="return confirm('{MOD.NTC_DELETE_CONFIRMATION}')" href="{URL_PREFIX}index.php?action=Delete&module=Currencies&record={CURRENCY.ID}&return_module=Currencies&return_action=index&return_id=">{DELETE_INLINE_PNG} {APP.LNK_DELETE}</a>{CURRENCY.UNHIDE}</slot></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<!-- END: row -->
|
||||
|
||||
</table>
|
||||
{POSTTABLE}
|
||||
<!-- END: main -->
|
||||
49
modules/Currencies/Menu.php
Executable file
49
modules/Currencies/Menu.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: TODO To be written.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
global $mod_strings;
|
||||
$module_menu = Array(
|
||||
);
|
||||
|
||||
?>
|
||||
56
modules/Currencies/field_arrays.php
Executable file
56
modules/Currencies/field_arrays.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Contains field arrays that are used for caching
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
$fields_array['Currency'] = array ('column_fields' => Array("id"
|
||||
,"name"
|
||||
,"conversion_rate"
|
||||
,"iso4217"
|
||||
,"symbol"
|
||||
,'status'
|
||||
,"deleted"
|
||||
,"date_entered"
|
||||
,"date_modified"
|
||||
),
|
||||
'required_fields' => array('name'=>1, 'symbol'=>2, 'conversion_rate'=>3, 'iso4217'=>4 , 'status'=>5),
|
||||
);
|
||||
?>
|
||||
8
modules/Currencies/getCurrencyValue.php
Normal file
8
modules/Currencies/getCurrencyValue.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
if (!$_REQUEST['currency_id']) {echo '0'; return;}
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$c = new Currency();
|
||||
$c->retrieve($_REQUEST['currency_id']);
|
||||
echo format_number($c->conversion_rate,4,4);
|
||||
return;
|
||||
?>
|
||||
27
modules/Currencies/getNBPCurrencyExchange.php
Normal file
27
modules/Currencies/getNBPCurrencyExchange.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
$c_id = $_REQUEST['c_id'];
|
||||
$d = $_REQUEST['date'];
|
||||
|
||||
|
||||
if (!$c_id || !$d) {echo '-1'; return;}
|
||||
global $timedate;
|
||||
$d = explode('-',reset(explode(" ",$timedate->to_db($d))));
|
||||
$date = date("Y-m-d",@mktime(0,0,0,$d[1],$d[2],$d[0])+3600*24);
|
||||
|
||||
//what day is it?
|
||||
$dn = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT DAYNAME('$date') as dayname"));
|
||||
|
||||
|
||||
if ($dn['dayname'] == 'Sunday') //- 2 days
|
||||
$q = "SELECT value FROM currency_nbp_archive WHERE currency_id='$c_id' AND date = DATE_ADD('$date', INTERVAL -2 DAY)";
|
||||
elseif ($dn['dayname'] == 'Saturday') //- 1 day
|
||||
$q = "SELECT value FROM currency_nbp_archive WHERE currency_id='$c_id' AND date = DATE_ADD('$date', INTERVAL -1 DAY)";
|
||||
else //any other day - just get exchange
|
||||
$q = "SELECT value FROM currency_nbp_archive WHERE currency_id='$c_id' AND date='$date'";
|
||||
|
||||
$w = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query($q));
|
||||
|
||||
echo $w['value']; return;
|
||||
|
||||
|
||||
?>
|
||||
177
modules/Currencies/index.php
Executable file
177
modules/Currencies/index.php
Executable file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
global $theme;
|
||||
global $mod_strings;
|
||||
global $app_list_strings;
|
||||
global $app_strings;
|
||||
global $current_user, $focus;
|
||||
|
||||
echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'], true);
|
||||
|
||||
if($current_user->is_admin){
|
||||
require_once('modules/Currencies/ListCurrency.php');
|
||||
|
||||
$focus = new Currency();
|
||||
$lc = new ListCurrency();
|
||||
$lc->handleAdd();
|
||||
|
||||
if(isset($_REQUEST['merge']) && $_REQUEST['merge'] == 'true'){
|
||||
$isMerge = true;
|
||||
|
||||
}
|
||||
if(isset($_REQUEST['domerge'])){
|
||||
$currencies = $_REQUEST['mergecur'];
|
||||
|
||||
|
||||
$opp = new Opportunity();
|
||||
$opp->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'].'" accessKey="'.$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
|
||||
<form name= "MERGE" method="POST" action="index.php">
|
||||
<input type="hidden" name="module" value="Currencies">
|
||||
|
||||
<input type="hidden" name="action" value="index">
|
||||
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="edit view">
|
||||
<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
|
||||
<td>{$mod_strings['LBL_MERGE_TXT']}</td><td width='20%'><select name='mergeTo'>{$listoptions}</select></td>
|
||||
</tr>
|
||||
<tr><td></td><td><input title="{$mod_strings['LBL_MERGE']}" accessKey="{$mod_strings['LBL_MERGE']}" class="button" type="submit" name="domerge" value="{$mod_strings['LBL_MERGE']}" >
|
||||
<input title="{$app_strings['LBL_CANCEL_BUTTON_TITLE']}" accessKey="{$app_strings['LBL_CANCEL_BUTTON_KEY']}" class="button" type="submit" name="button" value="{$app_strings['LBL_CANCEL_BUTTON_LABEL']}" > </td></tr>
|
||||
</table></td></tr></table><br>
|
||||
EOQ;
|
||||
|
||||
|
||||
}
|
||||
$edit_botton = '<form name="EditView" method="POST" action="index.php" >';
|
||||
$edit_botton .= '<input type="hidden" name="module" value="Currencies">';
|
||||
$edit_botton .= '<input type="hidden" name="record" value="'.$focus_id.'">';
|
||||
$edit_botton .= '<input type="hidden" name="action">';
|
||||
$edit_botton .= '<input type="hidden" name="edit">';
|
||||
$edit_botton .= '<input type="hidden" name="return_module" value="Currencies">';
|
||||
$edit_botton .= '<input type="hidden" name="return_action" value="index">';
|
||||
$edit_botton .= '<input type="hidden" name="return_id" value="">';
|
||||
$edit_botton .= '<input title="'.$app_strings['LBL_SAVE_BUTTON_TITLE'].'" accessKey="'.$app_strings['LBL_SAVE_BUTTON_KEY'].'" class="button" onclick="this.form.edit.value=\'true\';this.form.action.value=\'index\';return check_form(\'EditView\');" type="submit" name="button" value="'.$app_strings['LBL_SAVE_BUTTON_LABEL'].'" > ';
|
||||
$edit_botton .= '<input title="'.$app_strings['LBL_CLEAR_BUTTON_TITLE'].'" accessKey="'.$app_strings['LBL_CLEAR_BUTTON_KEY'].'" class="button" onclick="this.form.edit.value=\'false\';this.form.action.value=\'index\';" type="submit" name="button" value="'.$app_strings['LBL_CLEAR_BUTTON_LABEL'].'" > ';
|
||||
$header_text = '';
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$header_text = " <a href='index.php?action=index&module=DynamicLayout&from_action=ListView&from_module=".$_REQUEST['module'] ."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>";
|
||||
}
|
||||
$ListView = new ListView();
|
||||
$ListView->initNewXTemplate( 'modules/Currencies/ListView.html',$mod_strings);
|
||||
$ListView->xTemplateAssign('PRETABLE', $pretable);
|
||||
$ListView->xTemplateAssign('POSTTABLE', '</form>');
|
||||
$ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" alt="'.$app_strings['LNK_DELETE'].'" border="0"'));
|
||||
$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']. $header_text );
|
||||
$ListView->setHeaderText($merge_button);
|
||||
|
||||
$ListView->processListView($lc->list, "main", "CURRENCY");
|
||||
|
||||
if(isset($_GET['record']) && !empty($_GET['record']) && !isset($_POST['edit'])) {
|
||||
$focus->retrieve($_GET['record']);
|
||||
$focus->conversion_rate = format_number($focus->conversion_rate, 10, 10);
|
||||
}
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$header_text = " <a href='index.php?action=index&module=DynamicLayout&from_action=EditView&from_module=".$_REQUEST['module'] ."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>";
|
||||
}
|
||||
echo get_form_header($mod_strings['LBL_CURRENCY']." ".$focus->name . $header_text,$edit_botton , false);
|
||||
|
||||
$sugar_smarty = new Sugar_Smarty();
|
||||
|
||||
$sugar_smarty->assign("MOD", $mod_strings);
|
||||
$sugar_smarty->assign("APP", $app_strings);
|
||||
|
||||
// Load in the full ISO 4217 list, so we can dynamically populate the currency strings
|
||||
require_once('modules/Currencies/iso4217.php');
|
||||
$json = getJSONobj();
|
||||
$js_iso4217 = $json->encode($fullIsoList);
|
||||
$sugar_smarty->assign('JS_ISO4217',$js_iso4217);
|
||||
|
||||
if (isset($_REQUEST['return_module'])) $sugar_smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
|
||||
if (isset($_REQUEST['return_action'])) $sugar_smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
|
||||
if (isset($_REQUEST['return_id'])) $sugar_smarty->assign("RETURN_ID", $_REQUEST['return_id']);
|
||||
|
||||
$sugar_smarty->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
|
||||
$sugar_smarty->assign("JAVASCRIPT", get_set_focus_js());
|
||||
$sugar_smarty->assign("THEME", SugarThemeRegistry::current()->__toString());
|
||||
$sugar_smarty->assign("ID", $focus->id);
|
||||
$sugar_smarty->assign('NAME', $focus->name);
|
||||
$sugar_smarty->assign('STATUS', $focus->status);
|
||||
$sugar_smarty->assign('ISO4217', $focus->iso4217);
|
||||
$sugar_smarty->assign('CONVERSION_RATE', $focus->conversion_rate);
|
||||
$sugar_smarty->assign('SYMBOL', $focus->symbol);
|
||||
$sugar_smarty->assign('STATUS_OPTIONS', get_select_options_with_id($mod_strings['currency_status_dom'], $focus->status));
|
||||
|
||||
//if (empty($focus->list_order)) $xtpl->assign('LIST_ORDER', count($focus->get_manufacturers(false,'All'))+1);
|
||||
//else $xtpl->assign('LIST_ORDER', $focus->list_order);
|
||||
|
||||
$sugar_smarty->display("modules/Currencies/EditView.tpl");
|
||||
|
||||
$javascript = new javascript();
|
||||
$javascript->setFormName('EditView');
|
||||
$javascript->setSugarBean($focus);
|
||||
$javascript->addAllFields('',array('iso4217'=>'iso4217'));
|
||||
echo $javascript->getScript();
|
||||
echo("<script type='text/javascript'>addToValidateMoreThan('EditView','conversion_rate','float',true,'".$mod_strings['LBL_BELOW_MIN']."',0.000001);</script>");
|
||||
}else{
|
||||
echo 'Admin\'s Only';
|
||||
}
|
||||
|
||||
?>
|
||||
1849
modules/Currencies/iso4217.php
Executable file
1849
modules/Currencies/iso4217.php
Executable file
File diff suppressed because it is too large
Load Diff
81
modules/Currencies/language/en_us.lang.php
Executable file
81
modules/Currencies/language/en_us.lang.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Defines the English language pack for the base application.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array (
|
||||
'LBL_MODULE_NAME' => 'Currencies',
|
||||
'LBL_LIST_FORM_TITLE' => 'Currencies',
|
||||
'LBL_CURRENCY' => 'Currency',
|
||||
'LBL_ADD' => 'Add',
|
||||
'LBL_MERGE' => 'Merge',
|
||||
'LBL_MERGE_TXT' => 'Please select the currencies you would like to map to the selected currency. This will delete all the currencies with a checkmark and reassign any value associated with them to the selected currency.',
|
||||
'LBL_US_DOLLAR' => 'U.S. Dollar',
|
||||
'LBL_DELETE' => 'Delete',
|
||||
'LBL_LIST_SYMBOL' => 'Currency Symbol',
|
||||
'LBL_LIST_NAME' => 'Currency Name',
|
||||
'LBL_LIST_ISO4217' => 'ISO 4217 Code',
|
||||
'LBL_LIST_ISO4217_HELP' => 'Enter a three-letter ISO 4217 code that defines the currency name and currency symbol.',
|
||||
'LBL_UPDATE' => 'Update',
|
||||
'LBL_LIST_RATE' => 'Conversion Rate',
|
||||
'LBL_LIST_RATE_HELP' => 'A Conversion Rate of 0.5 for Euro means that 10 USD = 5 Euro.',
|
||||
'LBL_LIST_STATUS' => 'Status',
|
||||
'LNK_NEW_CONTACT' => 'New Contact',
|
||||
'LNK_NEW_ACCOUNT' => 'New Account',
|
||||
'LNK_NEW_OPPORTUNITY' => 'New Opportunity',
|
||||
'LNK_NEW_CASE' => 'New Case',
|
||||
'LNK_NEW_NOTE' => 'Create Note or Attachment',
|
||||
'LNK_NEW_CALL' => 'New Call',
|
||||
'LNK_NEW_EMAIL' => 'New Email',
|
||||
'LNK_NEW_MEETING' => 'New Meeting',
|
||||
'LNK_NEW_TASK' => 'Create Task',
|
||||
'NTC_DELETE_CONFIRMATION' => 'Are you sure you want to delete this record? Any record using this currency will be converted to the system default currency when they are accessed. It may be better to set the status to inactive.',
|
||||
'LBL_BELOW_MIN' => 'Conversion rate has to be above 0',
|
||||
'currency_status_dom' =>
|
||||
array (
|
||||
'Active' => 'Active',
|
||||
'Inactive' => 'Inactive',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
67
modules/Currencies/language/pl_pl.lang.php
Executable file
67
modules/Currencies/language/pl_pl.lang.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Public License Version
|
||||
* 1.1.3 ("License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* All copies of the Covered Code must include on each user interface screen:
|
||||
* (i) the "Powered by SugarCRM" logo and
|
||||
* (ii) the SugarCRM copyright notice
|
||||
* in the same form as they appear in the distribution. See full license for
|
||||
* requirements.
|
||||
*
|
||||
* The Original Code is: SugarCRM Open Source
|
||||
* The Initial Developer of the Original Code is SugarCRM, Inc.
|
||||
* Portions created by SugarCRM are Copyright (C) 2004-2005 SugarCRM, Inc.;
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
********************************************************************************/
|
||||
|
||||
/*********************************************************************************
|
||||
* pl_pl.lang.ext.php,v for SugarCRM 4.5 -->>
|
||||
* Translator: Krzysztof Morawski
|
||||
* All Rights Reserved.
|
||||
* Any bugs report welcome: krzysiek<at>mojsklepik<dot>net
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array (
|
||||
'LBL_MODULE_NAME' => 'Waluty',
|
||||
'LBL_LIST_FORM_TITLE' => 'Waluty',
|
||||
'LBL_CURRENCY' => 'Dodaj walutę',
|
||||
'LBL_ADD' => 'Dodaj',
|
||||
'LBL_MERGE' => 'Scal',
|
||||
'LBL_MERGE_TXT' => 'Zaznacz waluty, które chcesz przeliczać do obecnej waluty. Spodowuje to odłaczenie, a następnie przeliczenie walut według nowego przelicznika.',
|
||||
'LBL_US_DOLLAR' => 'U.S. Dollar',
|
||||
'LBL_DELETE' => 'Usuń',
|
||||
'LBL_LIST_SYMBOL' => 'Symbol waluty',
|
||||
'LBL_LIST_NAME' => 'Nazwa waluty',
|
||||
'LBL_LIST_ISO4217' => 'Kod ISO 4217',
|
||||
'LBL_UPDATE' => 'Uaktualnij',
|
||||
'LBL_LIST_RATE' => 'Wspólczynnik wymiany',
|
||||
'LBL_LIST_RATE_HELP' => 'Współczynnik wymiany dla 0,5 dla Euro znaczy, że 10 USD = 5 Euro.',
|
||||
'LBL_LIST_STATUS' => 'Status',
|
||||
'LNK_NEW_CONTACT' => 'Nowy kontakt',
|
||||
'LNK_NEW_ACCOUNT' => 'Nowy klient',
|
||||
'LNK_NEW_OPPORTUNITY' => 'Nowy temat',
|
||||
'LNK_NEW_CASE' => 'Nowe zdarzenie',
|
||||
'LNK_NEW_NOTE' => 'Utwórz notatkę lub załącznik',
|
||||
'LNK_NEW_CALL' => 'Nowa rozmowa telefoniczna',
|
||||
'LNK_NEW_EMAIL' => 'Nowy email',
|
||||
'LNK_NEW_MEETING' => 'Nowe spotkanie',
|
||||
'LNK_NEW_TASK' => 'Utwórz zadania',
|
||||
'NTC_DELETE_CONFIRMATION' => 'Czy na pewno chcesz usunąć ten rekord? Lepiej byłoby ustawić jego status jako nieaktywny. Inaczej wszyskie rekordy używające tej waluty zostaną przekonwertowane do Dolarów Amerykańskich.',
|
||||
'currency_status_dom' =>
|
||||
array (
|
||||
'Active' => 'Aktywny',
|
||||
'Inactive' => 'Nieaktywny',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
73
modules/Currencies/save_nbp_currencies.php
Normal file
73
modules/Currencies/save_nbp_currencies.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
//crontab job - save currencies
|
||||
set_time_limit(9999999999);
|
||||
require_once("./../../config.php");
|
||||
$sql1=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
|
||||
//get xml file name from dir.txt
|
||||
$today=date('ymd');
|
||||
//$today="120127";
|
||||
$connect = fopen("http://www.nbp.pl/kursy/xml/dir.txt", "r") or die("Błąd przy łączeniu");
|
||||
while (!feof ($connect)) {
|
||||
$buffer = fgets($connect, 4096) or die("Błąd przy odczycie
|
||||
");
|
||||
if ((substr($buffer,0,1)=='a') && (substr($buffer,5,6))==$today)
|
||||
{
|
||||
$xml_file = $buffer;
|
||||
break;
|
||||
}
|
||||
if (substr($buffer,0,1)=='a') $xml_file = $buffer; //get last "a" if file when "today" not exists
|
||||
};
|
||||
fclose($connect);
|
||||
|
||||
//download xml
|
||||
$connect = fopen("http://www.nbp.pl/kursy/xml/".trim($xml_file).".xml", "r") or die("Błąd przy łączeniu");
|
||||
$download = fopen("./currencies.xml", "w") or die("Błąd przy łączeniu");
|
||||
while (!feof ($connect)) {
|
||||
$buffer = fgets($connect, 4096);//or die("Błąd przy odczyciee");
|
||||
fwrite($download, $buffer);// or die("Błąd przy zapisie");
|
||||
}
|
||||
fclose($connect);
|
||||
fclose($download);
|
||||
|
||||
|
||||
|
||||
//load currencies
|
||||
$currencies = array();
|
||||
$result = mysql_query("select id, iso4217 from currencies where deleted='0'");
|
||||
while ($r=mysql_fetch_array($result)) {
|
||||
$currencies[$r['iso4217']] = array();
|
||||
$currencies[$r['iso4217']]['id']=$r['id'];
|
||||
}
|
||||
|
||||
//read xml
|
||||
$doc = new DOMDocument();
|
||||
$doc->load( 'currencies.xml' );
|
||||
$tmp = $doc->getElementsByTagName("data_publikacji");
|
||||
$cur_date = $tmp->item(0)->nodeValue;
|
||||
$tmp = $doc->getElementsByTagName("numer_tabeli");
|
||||
$table_name = $tmp->item(0)->nodeValue;
|
||||
$poz = $doc->getElementsByTagName("pozycja");
|
||||
foreach ($poz as $p) {
|
||||
$kod_waluty=$p->getElementsByTagName("kod_waluty");
|
||||
$kod = $kod_waluty->item(0)->nodeValue;
|
||||
if (isset($currencies[$kod])) {
|
||||
$kurs_sredni=$p->getElementsByTagName("kurs_sredni");
|
||||
$kurs = $kurs_sredni->item(0)->nodeValue;
|
||||
$currencies[$kod]['kurs']=$kurs;
|
||||
}
|
||||
}
|
||||
var_dump($currencies);
|
||||
//save values into db
|
||||
foreach ($currencies as $key=>$value) {
|
||||
mysql_query("INSERT INTO currency_nbp_archive VALUES ('".$cur_date."', '".$value['id']."', '".$key."', ".str_replace(",",".",$value['kurs']).",'".$table_name."')");
|
||||
|
||||
//update nbp_conversion_rate in Currencies
|
||||
mysql_query("UPDATE currencies SET nbp_conversion_rate='".str_replace(",",".",$value['kurs'])."' WHERE id='".$value['id']."'");
|
||||
}
|
||||
|
||||
//delete xls
|
||||
unlink("./currencies.xml");
|
||||
|
||||
?>
|
||||
142
modules/Currencies/vardefs.php
Executable file
142
modules/Currencies/vardefs.php
Executable file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* 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 Affero 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.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$dictionary['Currency'] = array('table' => 'currencies',
|
||||
'comment' => 'Currencies allow Sugar to store and display monetary values in various denominations'
|
||||
,'fields' => array (
|
||||
'id' =>
|
||||
array (
|
||||
'name' => 'id',
|
||||
'vname' => 'LBL_NAME',
|
||||
'type' => 'id',
|
||||
'required' => true,
|
||||
'reportable'=>false,
|
||||
'comment' => 'Unique identifer'
|
||||
),
|
||||
'name' =>
|
||||
array (
|
||||
'name' => 'name',
|
||||
'vname' => 'LBL_LIST_NAME',
|
||||
'type' => 'varchar',
|
||||
'len' => '36',
|
||||
'required' => true,
|
||||
'comment' => 'Name of the currency',
|
||||
'importable' => 'required',
|
||||
),
|
||||
'symbol' =>
|
||||
array (
|
||||
'name' => 'symbol',
|
||||
'vname' => 'LBL_LIST_SYMBOL',
|
||||
'type' => 'varchar',
|
||||
'len' => '36',
|
||||
'required' => true,
|
||||
'comment' => 'Symbol representing the currency',
|
||||
'importable' => 'required',
|
||||
),
|
||||
'iso4217' =>
|
||||
array (
|
||||
'name' => 'iso4217',
|
||||
'vname' => 'LBL_LIST_ISO4217',
|
||||
'type' => 'varchar',
|
||||
'len' => '3',
|
||||
'comment' => '3-letter identifier specified by ISO 4217 (ex: USD)',
|
||||
),
|
||||
'conversion_rate' =>
|
||||
array (
|
||||
'name' => 'conversion_rate',
|
||||
'vname' => 'LBL_LIST_RATE',
|
||||
'type' => 'float',
|
||||
'dbType' => 'double',
|
||||
'default' => '0',
|
||||
'required' => true,
|
||||
'comment' => 'Conversion rate factor (relative to stored value)',
|
||||
'importable' => 'required',
|
||||
),
|
||||
'status' =>
|
||||
array (
|
||||
'name' => 'status',
|
||||
'vname' => 'LBL_STATUS',
|
||||
'type' => 'enum',
|
||||
'dbType'=>'varchar',
|
||||
'options' => 'currency_status_dom',
|
||||
'len' => '25',
|
||||
'comment' => 'Currency status',
|
||||
'importable' => 'required',
|
||||
),
|
||||
'deleted' =>
|
||||
array (
|
||||
'name' => 'deleted',
|
||||
'vname' => 'LBL_DELETED',
|
||||
'type' => 'bool',
|
||||
'required' => false,
|
||||
'reportable'=>false,
|
||||
'comment' => 'Record deletion indicator'
|
||||
),
|
||||
'date_entered' =>
|
||||
array (
|
||||
'name' => 'date_entered',
|
||||
'vname' => 'LBL_DATE_ENTERED',
|
||||
'type' => 'datetime',
|
||||
'required' => true,
|
||||
'comment' => 'Date record created'
|
||||
|
||||
),
|
||||
'date_modified' =>
|
||||
array (
|
||||
'name' => 'date_modified',
|
||||
'vname' => 'LBL_DATE_MODIFIED',
|
||||
'type' => 'datetime',
|
||||
'required' => true,
|
||||
'comment' => 'Date record last modified'
|
||||
),
|
||||
'created_by' =>
|
||||
array (
|
||||
'name' => 'created_by',
|
||||
'reportable' => false,
|
||||
'vname' => 'LBL_CREATED_BY',
|
||||
'type' => 'id',
|
||||
'len' => '36',
|
||||
'required' => true,
|
||||
'comment' => 'User ID who created record'
|
||||
),
|
||||
)
|
||||
, 'indices' => array (
|
||||
array('name' =>'currenciespk', 'type' =>'primary', 'fields'=>array('id')),
|
||||
array('name' =>'idx_currency_name', 'type' =>'index', 'fields'=>array('name','deleted'))
|
||||
)
|
||||
|
||||
);
|
||||
?>
|
||||
Reference in New Issue
Block a user