currency 1
This commit is contained in:
@@ -29,7 +29,8 @@
|
||||
"Field Manager": "Field Manager",
|
||||
"User Interface": "User Interface",
|
||||
"Auth Tokens": "Auth Tokens",
|
||||
"Authentication": "Authentication"
|
||||
"Authentication": "Authentication",
|
||||
"Currency": "Currency"
|
||||
},
|
||||
"layouts": {
|
||||
"list": "List",
|
||||
@@ -113,7 +114,8 @@
|
||||
"fieldManager": "Create new fields or customize existing ones.",
|
||||
"userInterface": "Configure UI.",
|
||||
"authTokens": "Active auth sessions. IP address and last access date.",
|
||||
"authentication": "Authentication settings."
|
||||
"authentication": "Authentication settings.",
|
||||
"currency": "Currency settings and rates."
|
||||
},
|
||||
"options": {
|
||||
"previewSize": {
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
"thousandSeparator": "Thousand Separator",
|
||||
"decimalMark": "Decimal Mark",
|
||||
"defaultCurrency": "Default Currency",
|
||||
"baseCurrency": "Base Currency",
|
||||
"baseCurrency": "Base Currency",
|
||||
"currencyRates": "Rate Values",
|
||||
|
||||
"currencyList": "Currency List",
|
||||
"language": "Language",
|
||||
|
||||
@@ -62,6 +66,8 @@
|
||||
"Locale": "Locale",
|
||||
"SMTP": "SMTP",
|
||||
"Configuration": "Configuration",
|
||||
"Notifications": "Notifications"
|
||||
"Notifications": "Notifications",
|
||||
"Currency Settings": "Currency Settings",
|
||||
"Currency Rtes": "Currency Rates"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"label": "Currency Settings",
|
||||
"rows": [
|
||||
[{"name": "defaultCurrency"}, {"name": "currencyList"}]
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Currency Rates",
|
||||
"rows": [
|
||||
[{"name": "baseCurrency"}],
|
||||
[{"name": "currencyRates"}]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -12,7 +12,6 @@
|
||||
[{"name": "dateFormat"}, {"name": "timeZone"}],
|
||||
[{"name": "timeFormat"}, {"name": "weekStart"}],
|
||||
[{"name": "thousandSeparator"}, {"name": "decimalMark"}],
|
||||
[{"name": "defaultCurrency"}, {"name": "currencyList"}],
|
||||
[{"name": "language"}]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
"label":"Scheduled Jobs",
|
||||
"description":"scheduledJob"
|
||||
},
|
||||
{
|
||||
"url":"#Admin/currency",
|
||||
"label":"Currency",
|
||||
"description":"currency"
|
||||
},
|
||||
{
|
||||
"url":"#Admin/upgrade",
|
||||
"label":"Upgrade",
|
||||
|
||||
@@ -61,6 +61,15 @@
|
||||
"default": "USD",
|
||||
"required": true
|
||||
},
|
||||
"baseCurrency": {
|
||||
"type": "enum",
|
||||
"default": "USD",
|
||||
"required": true
|
||||
},
|
||||
"currencyRates": {
|
||||
"type": "base",
|
||||
"view": "Settings.Fields.CurrencyRates"
|
||||
},
|
||||
"outboundEmailIsShared": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<h3><a href="#Admin">{{translate 'Administration'}}</a> » {{translate 'Currency' scope='Admin'}}</h3>
|
||||
@@ -0,0 +1,6 @@
|
||||
{{#each rateValues}}
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{{@key}}</span>
|
||||
<input class="form-control" type="text" data-currency="{{@key}}" value="{{./this}}">
|
||||
</div>
|
||||
{{/each}}
|
||||
@@ -90,6 +90,22 @@ Espo.define('Controllers.Admin', 'Controller', function (Dep) {
|
||||
model.fetch();
|
||||
},
|
||||
|
||||
currency: function () {
|
||||
var model = this.getSettingsModel();
|
||||
|
||||
model.once('sync', function () {
|
||||
model.id = '1';
|
||||
this.main('Edit', {
|
||||
model: model,
|
||||
views: {
|
||||
header: {template: 'admin.settings.header-currency'},
|
||||
body: {view: 'Admin.Currency'},
|
||||
},
|
||||
});
|
||||
}, this);
|
||||
model.fetch();
|
||||
},
|
||||
|
||||
authTokens: function () {
|
||||
this.collectionFactory.create('AuthToken', function (collection) {
|
||||
var searchManager = new Espo.SearchManager(collection, 'list', this.getStorage(), this.getDateTime());
|
||||
|
||||
@@ -27,6 +27,10 @@ Espo.define('Models.Settings', 'ModelOffline', function (Dep) {
|
||||
getDefaultCurrencyOptions: function () {
|
||||
return this.get('currencyList') || [];
|
||||
},
|
||||
|
||||
getBaseCurrencyOptions: function () {
|
||||
return this.get('currencyList') || [];
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('Views.Admin.Currency', 'Views.Settings.Record.Edit', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
layoutName: 'currency',
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
var currencyListField = this.getFieldView('currencyList');
|
||||
var defaultCurrencyField = this.getFieldView('defaultCurrency');
|
||||
var baseCurrencyField = this.getFieldView('baseCurrency');
|
||||
|
||||
var currencyRatesField = this.getFieldView('currencyRates');
|
||||
|
||||
if (currencyListField) {
|
||||
this.listenTo(currencyListField, 'change', function () {
|
||||
var data = currencyListField.fetch();
|
||||
var options = data.currencyList;
|
||||
if (defaultCurrencyField) {
|
||||
defaultCurrencyField.params.options = options;
|
||||
defaultCurrencyField.render();
|
||||
}
|
||||
if (baseCurrencyField) {
|
||||
baseCurrencyField.params.options = options;
|
||||
baseCurrencyField.render();
|
||||
}
|
||||
if (currencyRatesField) {
|
||||
currencyRatesField.render();
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
if (baseCurrencyField) {
|
||||
this.listenTo(baseCurrencyField, 'change', function () {
|
||||
if (currencyRatesField) {
|
||||
currencyRatesField.render();
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -27,17 +27,7 @@ Espo.define('Views.Admin.Settings', 'Views.Settings.Record.Edit', function (Dep)
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
|
||||
var currencyListField = this.getFieldView('currencyList');
|
||||
var defaultCurrencyField = this.getFieldView('defaultCurrency');
|
||||
if (currencyListField && defaultCurrencyField) {
|
||||
this.listenTo(currencyListField, 'change', function () {
|
||||
var data = currencyListField.fetch();
|
||||
var options = data.currencyList;
|
||||
defaultCurrencyField.params.options = options;
|
||||
defaultCurrencyField.render();
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
Espo.define('Views.Settings.Fields.CurrencyRates', 'Views.Fields.Base', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
editTemplate: 'settings.fields.currency-rates.edit',
|
||||
|
||||
data: function () {
|
||||
var baseCurrency = this.model.get('baseCurrency');
|
||||
var currencyRates = this.model.get('currencyRates') || {};
|
||||
|
||||
var rateValues = {};
|
||||
this.model.get('currencyList').forEach(function (currency) {
|
||||
if (currency != baseCurrency) {
|
||||
rateValues[currency] = currencyRates[currency] || 1.00;
|
||||
}
|
||||
}, this);
|
||||
|
||||
return {
|
||||
rateValues: rateValues
|
||||
};
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
},
|
||||
|
||||
fetch: function () {
|
||||
var data = {};
|
||||
var currencyRates = {};
|
||||
|
||||
var baseCurrency = this.model.get('baseCurrency');
|
||||
|
||||
this.model.get('currencyList').forEach(function (currency) {
|
||||
if (currency != baseCurrency) {
|
||||
currencyRates[currency] = parseFloat(this.$el.find('input[data-currency="'+currency+'"]').val() || 1);
|
||||
}
|
||||
}, this);
|
||||
|
||||
data[this.name] = currencyRates;
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user