+{{/each}}
diff --git a/frontend/client/src/controllers/admin.js b/frontend/client/src/controllers/admin.js
index 0c4b53114d..dbb6da7209 100644
--- a/frontend/client/src/controllers/admin.js
+++ b/frontend/client/src/controllers/admin.js
@@ -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());
diff --git a/frontend/client/src/models/settings.js b/frontend/client/src/models/settings.js
index 35c2b79bbd..c2ebf2678b 100644
--- a/frontend/client/src/models/settings.js
+++ b/frontend/client/src/models/settings.js
@@ -27,6 +27,10 @@ Espo.define('Models.Settings', 'ModelOffline', function (Dep) {
getDefaultCurrencyOptions: function () {
return this.get('currencyList') || [];
},
+
+ getBaseCurrencyOptions: function () {
+ return this.get('currencyList') || [];
+ },
});
diff --git a/frontend/client/src/views/admin/currency.js b/frontend/client/src/views/admin/currency.js
new file mode 100644
index 0000000000..ba09af2a97
--- /dev/null
+++ b/frontend/client/src/views/admin/currency.js
@@ -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);
+ }
+ },
+
+ });
+
+});
+
diff --git a/frontend/client/src/views/admin/settings.js b/frontend/client/src/views/admin/settings.js
index f397bcf10a..90f6b2a04e 100644
--- a/frontend/client/src/views/admin/settings.js
+++ b/frontend/client/src/views/admin/settings.js
@@ -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));
- }
+
},
});
diff --git a/frontend/client/src/views/settings/fields/currency-rates.js b/frontend/client/src/views/settings/fields/currency-rates.js
new file mode 100644
index 0000000000..6a23981394
--- /dev/null
+++ b/frontend/client/src/views/settings/fields/currency-rates.js
@@ -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;
+ },
+
+ });
+
+});