diff --git a/.phive/phars.xml b/.phive/phars.xml index 5bfa092bfad10dad9d23240281a5a2041acb815b..4ff573d4258efaa06e5ed882cef81b58ca6fddb3 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <phive xmlns="https://phar.io/phive"> - <phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/> + <phar name="phpstan" version="^2.0.4" installed="2.0.4" location="./tools/phpstan" copy="false"/> <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/> <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/> <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/> diff --git a/bin/Currency.js b/bin/Currency.js index e8a5c8f62b3afc63ee71ae96fb84d51b7676a448..c01dfe88a084e29723f7928f7b749b30b464d10a 100644 --- a/bin/Currency.js +++ b/bin/Currency.js @@ -11,7 +11,7 @@ define('package/quiqqer/currency/bin/Currency', [ 'Ajax', 'package/quiqqer/currency/bin/classes/BulkConverting' -], function(QUI, QUIDOM, QUIAjax, BulkConverting) { +], function (QUI, QUIDOM, QUIAjax, BulkConverting) { 'use strict'; let Converter = null; @@ -19,7 +19,6 @@ define('package/quiqqer/currency/bin/Currency', [ let SYSTEM_CURRENCY = ''; let getCurrenciesFetch = false; - // package_quiqqer_currency_ajax_setUserCurrency if (typeof window.DEFAULT_CURRENCY !== 'undefined') { def = window.DEFAULT_CURRENCY; @@ -36,7 +35,7 @@ define('package/quiqqer/currency/bin/Currency', [ Extends: QUIDOM, Type: 'package/quiqqer/currency/bin/Currency', - initialize: function(options) { + initialize: function (options) { this.parent(options); this.$currency = def; @@ -56,9 +55,9 @@ define('package/quiqqer/currency/bin/Currency', [ * * @param {String} currencyCode */ - setCurrency: function(currencyCode) { - this.getCurrencies().then(function(currencies) { - const found = currencies.find(function(Currency) { + setCurrency: function (currencyCode) { + this.getCurrencies().then(function (currencies) { + const found = currencies.find(function (Currency) { return Currency.code === currencyCode; }); @@ -79,7 +78,7 @@ define('package/quiqqer/currency/bin/Currency', [ * @param {Boolean} [refresh] - Refresh data from database * @return {Promise} */ - getCurrency: function(currencyCode, refresh) { + getCurrency: function (currencyCode, refresh) { currencyCode = currencyCode || this.$currency; refresh = refresh || false; @@ -108,12 +107,13 @@ define('package/quiqqer/currency/bin/Currency', [ }); }, + /** * Return all available currencies * * @returns {Promise} */ - getCurrencies: function() { + getCurrencies: function () { if (Object.getLength(this.$currencies)) { return Promise.resolve(this.$currencies); } @@ -142,12 +142,33 @@ define('package/quiqqer/currency/bin/Currency', [ }); }, + /** + * Return default currency + * + * @returns {Promise} + */ + getDefaultCurrency: function () { + if (SYSTEM_CURRENCY !== '') { + return Promise.resolve(SYSTEM_CURRENCY); + } + + return new Promise((resolve, reject) => { + QUIAjax.get('package_quiqqer_currency_ajax_getDefault', (result) => { + SYSTEM_CURRENCY = result.code; + resolve(result.code); + }, { + 'package': 'quiqqer/currency', + onError: reject + }); + }); + }, + /** * Return all available currency types. * * @returns {Promise<Array>} */ - getCurrencyTypes: function() { + getCurrencyTypes: function () { if (this.$currencyTypes.length) { return Promise.resolve(this.$currencyTypes); } @@ -171,7 +192,7 @@ define('package/quiqqer/currency/bin/Currency', [ * @param {String} currencyTo * @returns {Promise} */ - convert: function(amount, currencyFrom, currencyTo) { + convert: function (amount, currencyFrom, currencyTo) { currencyTo = currencyTo || this.$currency; currencyFrom = currencyFrom || this.$currency; @@ -193,7 +214,7 @@ define('package/quiqqer/currency/bin/Currency', [ * @param {String} currencyTo * @returns {Promise} */ - convertWithSign: function(amount, currencyFrom, currencyTo) { + convertWithSign: function (amount, currencyFrom, currencyTo) { currencyTo = currencyTo || this.$currency; currencyFrom = currencyFrom || this.$currency; diff --git a/bin/controls/Select.js b/bin/controls/Select.js index df4a1bd1a7e626f37d0b3c7b3f7cfa590c96a140..475a2850a460ea0b065f9eba15434cae952966fe 100644 --- a/bin/controls/Select.js +++ b/bin/controls/Select.js @@ -13,7 +13,7 @@ define('package/quiqqer/currency/bin/controls/Select', [ 'package/quiqqer/currency/bin/Currency', 'Locale' -], function(QUI, QUIElementSelect, Currencies, QUILocale) { +], function (QUI, QUIElementSelect, Currencies, QUILocale) { 'use strict'; const lg = 'quiqqer/currency'; @@ -36,7 +36,7 @@ define('package/quiqqer/currency/bin/controls/Select', [ options: {}, - initialize: function(options) { + initialize: function (options) { this.parent(options); this.setAttribute('Search', this.currencySearch); @@ -62,7 +62,7 @@ define('package/quiqqer/currency/bin/controls/Select', [ * @param {String} value * @returns {Promise} */ - currencySearch: function(value) { + currencySearch: function (value) { return new Promise((resolve) => { require(['package/quiqqer/currency/bin/settings/AllowedCurrencies'], (AllowedCurrencies) => { let GetCurrencies; @@ -84,7 +84,7 @@ define('package/quiqqer/currency/bin/controls/Select', [ } data = list[currency]; - + if (data.text.toLowerCase().indexOf(value) !== -1) { result.push({ icon: 'fa fa-money', @@ -106,15 +106,15 @@ define('package/quiqqer/currency/bin/controls/Select', [ * @param self * @param Btn */ - $onSearchButtonClick: function(self, Btn) { + $onSearchButtonClick: function (self, Btn) { Btn.setAttribute('icon', 'fa fa-spinner fa-spin'); require([ 'package/quiqqer/currency/bin/controls/search/Window' - ], function(Search) { + ], function (Search) { new Search({ events: { - onSubmit: function(Win, values) { + onSubmit: function (Win, values) { for (let i = 0, len = values.length; i < len; i++) { self.addItem(values[i]); } diff --git a/bin/controls/SelectItem.js b/bin/controls/SelectItem.js index 59f9827dc662e06bfd135274f4abbaaa420750ab..83aefe1df6a32518b97328ad8b5e2531bc22e34c 100644 --- a/bin/controls/SelectItem.js +++ b/bin/controls/SelectItem.js @@ -9,7 +9,7 @@ define('package/quiqqer/currency/bin/controls/SelectItem', [ 'css!package/quiqqer/currency/bin/controls/SelectItem.css' -], function(QUIControl, Currencies) { +], function (QUIControl, Currencies) { 'use strict'; return new Class({ @@ -25,7 +25,7 @@ define('package/quiqqer/currency/bin/controls/SelectItem', [ id: false }, - initialize: function(options) { + initialize: function (options) { this.parent(options); this.$Icon = null; @@ -42,7 +42,7 @@ define('package/quiqqer/currency/bin/controls/SelectItem', [ * * @returns {HTMLElement} */ - create: function() { + create: function () { const self = this, Elm = this.parent(); @@ -57,7 +57,7 @@ define('package/quiqqer/currency/bin/controls/SelectItem', [ this.$Text = Elm.getElement('.quiqqer-currency-selectItem-text'); this.$Destroy = Elm.getElement('.quiqqer-currency-selectItem-destroy'); - this.$Destroy.addEvent('click', function() { + this.$Destroy.addEvent('click', function () { self.destroy(); }); @@ -67,7 +67,7 @@ define('package/quiqqer/currency/bin/controls/SelectItem', [ /** * event : on inject */ - $onInject: function() { + $onInject: function () { this.$Text.set({ html: '<span class="fa fa-spinner fa-spin"></span>' }); diff --git a/bin/controls/search/Search.js b/bin/controls/search/Search.js index 2e609873a1ec970054c65e6151d9f200b2fabf34..5786ff78d71c428f4f3414fcc889e0ac88ecf22d 100644 --- a/bin/controls/search/Search.js +++ b/bin/controls/search/Search.js @@ -14,7 +14,7 @@ define('package/quiqqer/currency/bin/controls/search/Search', [ 'css!package/quiqqer/currency/bin/controls/search/Search.css' -], function(QUIControl, Currencies, QUIButton, QUISwitch, QUILocale, QUIAjax, Grid) { +], function (QUIControl, Currencies, QUIButton, QUISwitch, QUILocale, QUIAjax, Grid) { 'use strict'; const lg = 'quiqqer/currency'; @@ -35,7 +35,7 @@ define('package/quiqqer/currency/bin/controls/search/Search', [ onlyAllowed: true }, - initialize: function(options) { + initialize: function (options) { this.parent(options); this.$Container = null; @@ -48,7 +48,7 @@ define('package/quiqqer/currency/bin/controls/search/Search', [ * * @returns {HTMLElement} */ - create: function() { + create: function () { this.$Elm = new Element('div', { 'class': 'quiqqer-currency-search', html: '', @@ -129,7 +129,7 @@ define('package/quiqqer/currency/bin/controls/search/Search', [ * * @return {Promise} */ - resize: function() { + resize: function () { const size = this.$Elm.getSize(); return Promise.all([ @@ -141,7 +141,7 @@ define('package/quiqqer/currency/bin/controls/search/Search', [ /** * execute the search */ - search: function() { + search: function () { this.fireEvent('searchBegin', [this]); return new Promise((resolve, reject) => { @@ -187,7 +187,7 @@ define('package/quiqqer/currency/bin/controls/search/Search', [ * * @return {Array} */ - getSelectedData: function() { + getSelectedData: function () { return this.$Grid.getSelectedData(); } }); diff --git a/bin/controls/search/Window.js b/bin/controls/search/Window.js index 2cb14cb1ce5a4c47cca637192a54025d52e47f6e..01f16cea42ca1c6a6654f3edb1d8f228e904c5af 100644 --- a/bin/controls/search/Window.js +++ b/bin/controls/search/Window.js @@ -11,7 +11,7 @@ define('package/quiqqer/currency/bin/controls/search/Window', [ 'package/quiqqer/currency/bin/controls/search/Search', 'Locale' -], function(QUI, QUIControl, QUIButton, QUIConfirm, Search, QUILocale) { +], function (QUI, QUIControl, QUIButton, QUIConfirm, Search, QUILocale) { 'use strict'; return new Class({ @@ -38,7 +38,7 @@ define('package/quiqqer/currency/bin/controls/search/Window', [ multiple: false }, - initialize: function(options) { + initialize: function (options) { this.parent(options); this.$Search = null; @@ -53,7 +53,7 @@ define('package/quiqqer/currency/bin/controls/search/Window', [ * * @return {Promise} */ - $onResize: function() { + $onResize: function () { return this.$Search.resize(); }, @@ -62,7 +62,7 @@ define('package/quiqqer/currency/bin/controls/search/Window', [ * * @returns {HTMLDivElement} */ - $onOpen: function(Win) { + $onOpen: function (Win) { const self = this, Content = Win.getContent(); @@ -71,15 +71,15 @@ define('package/quiqqer/currency/bin/controls/search/Window', [ this.$Search = new Search({ searchbutton: false, events: { - onDblClick: function() { + onDblClick: function () { self.submit(); }, - onSearchBegin: function() { + onSearchBegin: function () { self.Loader.show(); }, - onSearchEnd: function() { + onSearchEnd: function () { self.Loader.hide(); } } @@ -91,7 +91,7 @@ define('package/quiqqer/currency/bin/controls/search/Window', [ /** * Execute the search */ - search: function() { + search: function () { this.$Search.search(); }, @@ -100,7 +100,7 @@ define('package/quiqqer/currency/bin/controls/search/Window', [ * * @fires onSubmit */ - submit: function() { + submit: function () { let selected = this.$Search.getSelectedData(); if (!selected.length) { diff --git a/bin/settings/AccountingCurrencyDiffers.js b/bin/settings/AccountingCurrencyDiffers.js index c769aa9e5079743d84ea120c6048c440f69a99ab..57cf9479987bc3d46d9ba61df33824e3828d658c 100644 --- a/bin/settings/AccountingCurrencyDiffers.js +++ b/bin/settings/AccountingCurrencyDiffers.js @@ -13,7 +13,7 @@ define('package/quiqqer/currency/bin/settings/AccountingCurrencyDiffers', [ return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/currency/bin/settings/AccountingCurrencyDiffers', + Type: 'package/quiqqer/currency/bin/settings/AccountingCurrencyDiffers', Binds: [ '$onImport' @@ -30,7 +30,7 @@ define('package/quiqqer/currency/bin/settings/AccountingCurrencyDiffers', [ }, $onImport: function () { - var self = this, + var self = this, Table = this.getElm().getParent('table'); this.getElm().addEvent('change', function () { diff --git a/bin/settings/AllowedCurrencies.js b/bin/settings/AllowedCurrencies.js index 8d434cd11407cb8c73a7a6cb699f44af9f2c1298..2d38c324bde9d6552b27a4946d2b487665696e9c 100644 --- a/bin/settings/AllowedCurrencies.js +++ b/bin/settings/AllowedCurrencies.js @@ -19,7 +19,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ 'css!package/quiqqer/currency/bin/settings/AllowedCurrencies.css' -], function(QUI, QUIControl, QUISwitch, QUIConfirm, QUIPrompt, QUIAjax, QUILocale, Grid, CurrencyWindow) { +], function (QUI, QUIControl, QUISwitch, QUIConfirm, QUIPrompt, QUIAjax, QUILocale, Grid, CurrencyWindow) { 'use strict'; const lg = 'quiqqer/currency'; @@ -43,7 +43,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ values: {} }, - initialize: function(options) { + initialize: function (options) { this.parent(options); this.$Input = null; @@ -59,7 +59,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ /** * event : on import */ - $onImport: function() { + $onImport: function () { this.$Input = this.getElm(); this.$Input.type = 'hidden'; @@ -164,7 +164,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ textimage: 'fa fa-edit', disabled: true, events: { - onClick: function() { + onClick: function () { self.openUpdateDialog(self.$Grid.getSelectedData()[0].code); } } @@ -178,8 +178,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ textimage: 'fa fa-trash', disabled: true, events: { - onClick: function() { - const currencies = self.$Grid.getSelectedData().map(function(C) { + onClick: function () { + const currencies = self.$Grid.getSelectedData().map(function (C) { return C.code; }); @@ -193,15 +193,15 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ this.$Grid.setWidth(width); this.$Grid.addEvents({ - onClick: function() { + onClick: function () { const selected = self.$Grid.getSelectedIndices(), buttons = self.$Grid.getButtons(); - const Edit = buttons.filter(function(Btn) { + const Edit = buttons.filter(function (Btn) { return Btn.getAttribute('name') === 'edit'; })[0]; - const Delete = buttons.filter(function(Btn) { + const Delete = buttons.filter(function (Btn) { return Btn.getAttribute('name') === 'delete'; })[0]; @@ -216,7 +216,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ } }, - onDblClick: function() { + onDblClick: function () { self.openUpdateDialog(self.$Grid.getSelectedData()[0].code); }, @@ -246,7 +246,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ /** * refresh the currency list */ - refresh: function() { + refresh: function () { this.$Grid.showLoader(); return this.getCurrencies().then((list) => { @@ -268,7 +268,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ data = data.splice(start, perPage); - data.each(function(entry, i) { + data.each(function (entry, i) { data[i].allowed = new QUISwitch({ status: (typeof values[entry.code] !== 'undefined'), currency: entry.code, @@ -294,11 +294,11 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ const buttons = this.$Grid.getButtons(); - const Edit = buttons.filter(function(Btn) { + const Edit = buttons.filter(function (Btn) { return Btn.getAttribute('name') === 'edit'; })[0]; - const Delete = buttons.filter(function(Btn) { + const Delete = buttons.filter(function (Btn) { return Btn.getAttribute('name') === 'delete'; })[0]; @@ -313,7 +313,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ /** * update values to the input field */ - update: function() { + update: function () { const allowed = [], values = this.getAttribute('values'); @@ -336,8 +336,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * Return all available currencies * @returns {Promise} */ - getCurrencies: function() { - return new Promise(function(resolve, reject) { + getCurrencies: function () { + return new Promise(function (resolve, reject) { QUIAjax.get('package_quiqqer_currency_ajax_getCurrencies', resolve, { 'package': 'quiqqer/currency', onError: reject @@ -350,7 +350,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * * @returns {Promise} */ - getAllowedCurrencies: function() { + getAllowedCurrencies: function () { return new Promise((resolve, reject) => { QUIAjax.get('package_quiqqer_currency_ajax_getAllowedCurrencies', resolve, { 'package': 'quiqqer/currency', @@ -365,12 +365,12 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * @param {Array|String} currencies * @returns {Promise} */ - deleteCurrency: function(currencies) { + deleteCurrency: function (currencies) { if (typeOf(currencies) === 'string') { currencies = [currencies]; } - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { QUIAjax.post('package_quiqqer_currency_ajax_delete', resolve, { 'package': 'quiqqer/currency', currencies: JSON.encode(currencies), @@ -385,8 +385,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * @param {String} currency * @returns {Promise} */ - createCurrency: function(currency) { - return new Promise(function(resolve, reject) { + createCurrency: function (currency) { + return new Promise(function (resolve, reject) { QUIAjax.post('package_quiqqer_currency_ajax_create', resolve, { 'package': 'quiqqer/currency', currency: currency, @@ -400,7 +400,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * * @param {Object} Switch */ - $onCurrencyStatusChange: function(Switch) { + $onCurrencyStatusChange: function (Switch) { const currency = Switch.getAttribute('currency'); const values = this.getAttribute('values'); @@ -435,7 +435,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * * @param {Event} event */ - $switchCurrencyStatus: function(event) { + $switchCurrencyStatus: function (event) { const Target = event.target; const SwitchContainer = Target.getParent().getElement('.qui-switch'); @@ -452,8 +452,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * @param {Object} Switch * @return {Promise} */ - $changeAutoUpdate: function(Switch) { - return new Promise(function(resolve, reject) { + $changeAutoUpdate: function (Switch) { + return new Promise(function (resolve, reject) { QUIAjax.post('package_quiqqer_currency_ajax_setAutoupdate', resolve, { 'package': 'quiqqer/currency', currency: Switch.getAttribute('currency'), @@ -468,8 +468,8 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * * @returns {Promise} */ - $importFromECB: function() { - return new Promise(function(resolve, reject) { + $importFromECB: function () { + return new Promise(function (resolve, reject) { QUIAjax.post('package_quiqqer_currency_ajax_importFromECB', resolve, { 'package': 'quiqqer/currency', onError: reject @@ -486,7 +486,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * * @param {String} currency */ - openUpdateDialog: function(currency) { + openUpdateDialog: function (currency) { new CurrencyWindow({ currency: currency, events: { @@ -500,7 +500,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ * * @param {Array} currencies */ - openDeleteDialog: function(currencies) { + openDeleteDialog: function (currencies) { if (!currencies.length) { return; } @@ -538,17 +538,17 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ maxWidth: 600, autoclose: false, events: { - onSubmit: function(Win) { + onSubmit: function (Win) { Win.Loader.show(); - self.deleteCurrency(currencies).then(function() { + self.deleteCurrency(currencies).then(function () { - self.refresh().then(function() { + self.refresh().then(function () { self.update(); Win.Loader.hide(); Win.close(); }); - }, function() { + }, function () { Win.Loader.hide(); }); } @@ -559,7 +559,7 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ /** * Opens the create dialog */ - openCreateDialog: function() { + openCreateDialog: function () { const self = this; new QUIPrompt({ @@ -570,13 +570,13 @@ define('package/quiqqer/currency/bin/settings/AllowedCurrencies', [ maxHeight: 300, maxWidth: 450, events: { - onSubmit: function(value, Win) { + onSubmit: function (value, Win) { Win.Loader.show(); - self.createCurrency(value).then(function() { + self.createCurrency(value).then(function () { Win.close(); self.openUpdateDialog(value); - }, function() { + }, function () { Win.Loader.hide(); }); } diff --git a/bin/settings/CurrencyList.js b/bin/settings/CurrencyList.js index 067109f8105bccbe7813036b8cbb63aee3a79624..6689ac9dd5cfc8dd1caf9ef0ddc1d96b1d2c4de3 100644 --- a/bin/settings/CurrencyList.js +++ b/bin/settings/CurrencyList.js @@ -9,7 +9,7 @@ define('package/quiqqer/currency/bin/settings/CurrencyList', [ 'qui/controls/buttons/Select', 'Ajax' -], function(QUI, QUIControl, QUISelect, QUIAjax) { +], function (QUI, QUIControl, QUISelect, QUIAjax) { 'use strict'; return new Class({ @@ -22,7 +22,7 @@ define('package/quiqqer/currency/bin/settings/CurrencyList', [ '$onSelectChange' ], - initialize: function(options) { + initialize: function (options) { this.parent(options); this.$Input = null; @@ -36,7 +36,7 @@ define('package/quiqqer/currency/bin/settings/CurrencyList', [ /** * event : on import */ - $onImport: function() { + $onImport: function () { this.$Input = this.getElm(); this.$Input.type = 'hidden'; @@ -54,7 +54,7 @@ define('package/quiqqer/currency/bin/settings/CurrencyList', [ } }).inject(this.$Elm); - this.getCurrencies().then(function(result) { + this.getCurrencies().then(function (result) { for (let i in result) { if (!result.hasOwnProperty(i)) { continue; @@ -84,8 +84,8 @@ define('package/quiqqer/currency/bin/settings/CurrencyList', [ * Return all available currencies * @returns {Promise} */ - getCurrencies: function() { - return new Promise(function(resolve, reject) { + getCurrencies: function () { + return new Promise(function (resolve, reject) { QUIAjax.get('package_quiqqer_currency_ajax_getAllowedCurrencies', resolve, { 'package': 'quiqqer/currency', onError: reject @@ -99,7 +99,7 @@ define('package/quiqqer/currency/bin/settings/CurrencyList', [ * @param {String} value * @param {Object} Select - qui/controls/buttons/Select */ - $onSelectChange: function(value, Select) { + $onSelectChange: function (value, Select) { this.$Input.value = value; this.fireEvent('change', [ this, diff --git a/bin/settings/CurrencyWindow.js b/bin/settings/CurrencyWindow.js index c72f660b5ce799233094783d026590bf318c6542..eacd80b4df63df8fb4da64c52c36a258e0c1b521 100644 --- a/bin/settings/CurrencyWindow.js +++ b/bin/settings/CurrencyWindow.js @@ -9,11 +9,11 @@ define('package/quiqqer/currency/bin/settings/CurrencyWindow', [ 'Locale', 'package/quiqqer/currency/bin/settings/Currency' -], function(QUI, QUIConfirm, QUILocale, Currency) { +], function (QUI, QUIConfirm, QUILocale, Currency) { 'use strict'; return new Class({ - + Extends: QUIConfirm, Type: 'package/quiqqer/currency/bin/settings/CurrencyWindow', @@ -32,7 +32,7 @@ define('package/quiqqer/currency/bin/settings/CurrencyWindow', [ maxWidth: 600 }, - initialize: function(options) { + initialize: function (options) { this.setAttribute( 'title', QUILocale.get('quiqqer/currency', 'control.currency.title', { @@ -53,7 +53,7 @@ define('package/quiqqer/currency/bin/settings/CurrencyWindow', [ /** * event : on open */ - $onOpen: function() { + $onOpen: function () { this.$Currency = new Currency({ currency: this.getAttribute('currency') }).inject(this.getContent()); @@ -62,10 +62,10 @@ define('package/quiqqer/currency/bin/settings/CurrencyWindow', [ /** * event : on submit */ - $onSubmit: function() { + $onSubmit: function () { this.Loader.show(); - this.$Currency.save().then(function() { + this.$Currency.save().then(function () { this.Loader.hide(); this.close(); }.bind(this)); diff --git a/bin/settings/Import.js b/bin/settings/Import.js index 4ee7b13ed5e0fa0c49b91c8a104dfc5c71899bf8..ec56caa36e421554d739f80e43985882ef17a201 100644 --- a/bin/settings/Import.js +++ b/bin/settings/Import.js @@ -19,13 +19,13 @@ define('package/quiqqer/currency/bin/settings/Import', [ return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/currency/bin/settings/Import', + Type: 'package/quiqqer/currency/bin/settings/Import', initialize: function (options) { this.parent(options); - this.$Input = null; - this.$Elm = null; + this.$Input = null; + this.$Elm = null; this.$Button = null; this.addEvents({ @@ -37,19 +37,19 @@ define('package/quiqqer/currency/bin/settings/Import', [ * event : on import */ $onImport: function () { - this.$Input = this.getElm(); + this.$Input = this.getElm(); this.$Input.type = 'hidden'; this.$Elm = new Element('div', { 'class': 'quiqqer-currency-allowed', - html : '<div class="quiqqer-currency-import-container"></div>', - styles : { + html: '<div class="quiqqer-currency-import-container"></div>', + styles: { width: '100%' } }).wraps(this.$Input); new QUIButton({ - text : QUILocale.get(lg, 'ecb.import.button.text'), + text: QUILocale.get(lg, 'ecb.import.button.text'), events: { onClick: this.openDialog }, @@ -69,14 +69,14 @@ define('package/quiqqer/currency/bin/settings/Import', [ */ openDialog: function () { new QUIConfirm({ - icon : 'fa fa-money', - texticon : 'fa fa-money', - title : QUILocale.get(lg, 'window.ecb.import.title'), - text : QUILocale.get(lg, 'window.ecb.import.text'), + icon: 'fa fa-money', + texticon: 'fa fa-money', + title: QUILocale.get(lg, 'window.ecb.import.title'), + text: QUILocale.get(lg, 'window.ecb.import.text'), information: QUILocale.get(lg, 'window.ecb.import.information'), - maxHeight : 300, - maxWidth : 600, - events : { + maxHeight: 300, + maxWidth: 600, + events: { onSubmit: function (Win) { Win.Loader.show(); QUIAjax.post('package_quiqqer_currency_ajax_importFromECB', function () { diff --git a/src/QUI/ERP/Currency/AbstractCurrency.php b/src/QUI/ERP/Currency/AbstractCurrency.php index 429715aea4c1af15bfd0b003f8355c0cf6bb141a..1bc053c86d3b5520f5ddc286bb80ff4c7c820c8a 100644 --- a/src/QUI/ERP/Currency/AbstractCurrency.php +++ b/src/QUI/ERP/Currency/AbstractCurrency.php @@ -46,7 +46,7 @@ abstract class AbstractCurrency implements CurrencyInterface /** * @var float|bool */ - protected bool|float $exchangeRate = false; + protected bool | float $exchangeRate = false; /** * @var int @@ -182,7 +182,7 @@ public function toArray(): array * @param null|QUI\Locale $Locale -optional * @return float */ - public function amount($amount, null |QUI\Locale $Locale = null): float + public function amount($amount, null | QUI\Locale $Locale = null): float { if (is_float($amount) || is_int($amount)) { return $amount; @@ -215,7 +215,7 @@ public function amount($amount, null |QUI\Locale $Locale = null): float * @param null|QUI\Locale $Locale - optional, locale object * @return string */ - public function format($amount, null|QUI\Locale $Locale = null): string + public function format($amount, null | QUI\Locale $Locale = null): string { if (!$Locale) { $Locale = $this->Locale; @@ -279,7 +279,7 @@ public function autoupdate(): bool * * @throws Exception */ - public function convert($amount, $Currency): float|int|string + public function convert($amount, $Currency): float | int | string { if (!is_numeric($amount)) { QUI\System\Log::addError('Only numeric are allowed Currency->convert()', [ @@ -347,7 +347,7 @@ public function convertFormat($amount, $Currency): string * @param boolean|string|Currency $Currency - optional, default = false -> return own exchange rate * @return float|boolean */ - public function getExchangeRate($Currency = false): float|bool + public function getExchangeRate($Currency = false): float | bool { if ($Currency === false) { return $this->exchangeRate; diff --git a/src/QUI/ERP/Currency/Calc.php b/src/QUI/ERP/Currency/Calc.php index 203012f3023a7e75b92fe2f70f46030b9f7b8407..6123952a25b7190c2bb89f4fa4ea1559508d70a9 100644 --- a/src/QUI/ERP/Currency/Calc.php +++ b/src/QUI/ERP/Currency/Calc.php @@ -26,9 +26,9 @@ class Calc * @throws QUI\Exception */ public static function convert( - float|int|string $amount, - Currency|array|string $currencyFrom, - Currency|array|string $currencyTo = 'EUR' + float | int | string $amount, + Currency | array | string $currencyFrom, + Currency | array | string $currencyTo = 'EUR' ): float { $From = Handler::getCurrency($currencyFrom); $To = Handler::getCurrency($currencyTo); @@ -47,9 +47,9 @@ public static function convert( * @throws QUI\Exception */ public static function convertWithSign( - float|int|string $amount, - Currency|array|string $currencyFrom, - Currency|array|string $currencyTo = 'EUR' + float | int | string $amount, + Currency | array | string $currencyFrom, + Currency | array | string $currencyTo = 'EUR' ): string { $From = Handler::getCurrency($currencyFrom); $To = Handler::getCurrency($currencyTo); @@ -67,9 +67,9 @@ public static function convertWithSign( * @throws QUI\Exception */ public static function getExchangeRateBetween( - Currency|array|string $currencyFrom, - Currency|array|string $currencyTo - ): float|bool { + Currency | array | string $currencyFrom, + Currency | array | string $currencyTo + ): float | bool { $From = Handler::getCurrency($currencyFrom); $To = Handler::getCurrency($currencyTo); diff --git a/src/QUI/ERP/Currency/Conf.php b/src/QUI/ERP/Currency/Conf.php index 1f15810f1e10f50ef9d83e215dc880a682392288..801e3577a6c972f0916f4e0850687f43c4be00e1 100644 --- a/src/QUI/ERP/Currency/Conf.php +++ b/src/QUI/ERP/Currency/Conf.php @@ -52,7 +52,7 @@ public static function getAccountingCurrency(): ?Currency * * @return array|bool|string */ - public static function conf(string $section, ?string $key): bool|array|string + public static function conf(string $section, ?string $key): bool | array | string { try { $Package = QUI::getPackage('quiqqer/currency'); diff --git a/src/QUI/ERP/Currency/Currency.php b/src/QUI/ERP/Currency/Currency.php index 52d55f332149fd54d78c79d188a56a1daf4d1707..a35ac7972654a1fcc08e5f9804d7b33700a1d4b3 100644 --- a/src/QUI/ERP/Currency/Currency.php +++ b/src/QUI/ERP/Currency/Currency.php @@ -23,7 +23,7 @@ class Currency extends AbstractCurrency * @param QUI\Locale|null $Locale * @return string */ - public static function getCurrencyTypeTitle(?QUI\Locale $Locale = null): string + public static function getCurrencyTypeTitle(null | QUI\Locale $Locale = null): string { if (empty($Locale)) { $Locale = QUI::getLocale(); diff --git a/src/QUI/ERP/Currency/Handler.php b/src/QUI/ERP/Currency/Handler.php index 719c614c5af7a30aa6ea50d3c78198d7fc9641d4..1b71cc239772bf26ab6f6dda76b6ffb121fb1274 100644 --- a/src/QUI/ERP/Currency/Handler.php +++ b/src/QUI/ERP/Currency/Handler.php @@ -57,19 +57,22 @@ public static function table(): string * Create a new currency * * @param string $currency - currency code - * @param integer|float $rate - currency exchange rate, default = 1 + * @param float|integer $rate - currency exchange rate, default = 1 * @param string $type (optional) - Currency type * @throws QUI\Exception */ - public static function createCurrency(string $currency, $rate = 1, string $type = self::CURRENCY_TYPE_DEFAULT) - { + public static function createCurrency( + string $currency, + float | int | string $rate = 1, + string $type = self::CURRENCY_TYPE_DEFAULT + ): void { QUI\Permissions\Permission::checkPermission('currency.create'); $Currency = null; try { $Currency = self::getCurrency($currency); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { } if (!is_null($Currency)) { @@ -94,10 +97,6 @@ public static function createCurrency(string $currency, $rate = 1, string $type ]); // create translations - $languageData = [ - 'datatype' => 'js,php' - ]; - $localeGroup = 'quiqqer/currency'; $localeText = 'currency.' . $currency . '.text'; $localeSign = 'currency.' . $currency . '.sign'; @@ -123,7 +122,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type 'currency.' . $currency . '.text', 'quiqqer/currency' ); - } catch (QUI\Exception $e) { + } catch (QUI\Exception) { } if (!empty($textData)) { @@ -142,7 +141,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type 'currency.' . $currency . '.sign', 'quiqqer/currency' ); - } catch (QUI\Exception $e) { + } catch (QUI\Exception) { } @@ -164,7 +163,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type * @param string $currency - currency code * @throws QUI\Exception */ - public static function deleteCurrency(string $currency) + public static function deleteCurrency(string $currency): void { QUI\Permissions\Permission::checkPermission('currency.delete'); @@ -188,7 +187,7 @@ public static function deleteCurrency(string $currency) /** * Return the default currency * - * @return Currency + * @return Currency|null * @throws QUI\Exception */ public static function getDefaultCurrency(): ?Currency @@ -200,7 +199,7 @@ public static function getDefaultCurrency(): ?Currency self::$Default = self::getCurrency( $Config->getValue('currency', 'defaultCurrency') ); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { QUI\System\Log::addWarning('Default currency is missing'); try { @@ -321,7 +320,7 @@ public static function getAllowedCurrencies(): array foreach ($allowed as $currency) { try { $list[] = self::getCurrency($currency); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { } } @@ -378,7 +377,7 @@ public static function getCurrency(Currency | string | array $currency): Currenc if (is_string($currency)) { $code = $currency; - } elseif (is_array($currency) && isset($currency['code'])) { + } elseif (isset($currency['code'])) { $code = $currency['code']; } @@ -415,10 +414,10 @@ public static function existCurrency(string $currency): bool /** * Return all currency entries * - * @param Locale|boolean $Locale - optional, for translation + * @param Locale|null $Locale - optional, for translation * @return array */ - public static function getCurrencies($Locale = false): array + public static function getCurrencies(null | QUI\Locale $Locale = null): array { if (!$Locale) { $Locale = QUI::getLocale(); @@ -429,12 +428,12 @@ public static function getCurrencies($Locale = false): array try { return QUI\Cache\Manager::get($cacheNameLang); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { } try { $currencies = QUI\Cache\Manager::get($cacheName); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { $currencies = []; $data = self::getData(); @@ -448,7 +447,7 @@ public static function getCurrencies($Locale = false): array foreach ($currencies as $currency) { try { $Currency = self::getCurrency($currency); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { continue; } @@ -465,7 +464,7 @@ public static function getCurrencies($Locale = false): array * @throws QUI\Database\Exception * @throws QUI\Exception */ - public static function updateCurrency($currency, $data) + public static function updateCurrency($currency, $data): void { QUI\Permissions\Permission::checkPermission('currency.edit');