diff --git a/app/Database/migrations/2017_06_07_014930_create_settings_table.php b/app/Database/migrations/2017_06_07_014930_create_settings_table.php index af8afbac..982809f0 100644 --- a/app/Database/migrations/2017_06_07_014930_create_settings_table.php +++ b/app/Database/migrations/2017_06_07_014930_create_settings_table.php @@ -2,6 +2,7 @@ use App\Models\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; +use Money\Currencies\CurrencyList; class CreateSettingsTable extends Migration { @@ -22,7 +23,7 @@ class CreateSettingsTable extends Migration $table->string('default')->nullable(); $table->string('group')->nullable(); $table->string('type')->nullable(); - $table->string('options')->nullable(); + $table->text('options')->nullable(); $table->string('description')->nullable(); $table->primary('id'); @@ -50,58 +51,67 @@ class CreateSettingsTable extends Migration 'description' => 'Email where notices, etc are sent', ]); - $this->addSetting('general.currency', [ + /*$this->addSetting('general.currency', [ 'name' => 'Currency to Use', 'group' => 'general', - 'value' => 'dollar', + 'value' => 'USD', 'type' => 'select', - 'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble', - 'description' => 'Currency to show in the interface', - ]); + 'options' => 'USD,EUR,GBP,JPY,RUB', + 'description' => 'Currency to use. NOTE: If you change this, then current amounts won\'t be converted', + ]);*/ - $this->addSetting('general.distance_unit', [ + $this->addSetting('units.distance', [ 'name' => 'Distance Units', - 'group' => 'general', + 'group' => 'units', 'value' => 'NM', 'type' => 'select', - 'options' => 'km,mi,NM', - 'description' => 'The distance unit to show', + 'options' => 'km=kilometers,mi=miles,NM=nautical miles', + 'description' => 'The distance unit for display', ]); - $this->addSetting('general.weight_unit', [ + $this->addSetting('units.weight', [ 'name' => 'Weight Units', - 'group' => 'general', + 'group' => 'units', 'value' => 'lbs', 'type' => 'select', 'options' => 'lbs,kg', - 'description' => 'The weight unit', + 'description' => 'The weight unit for display', ]); - $this->addSetting('general.speed_unit', [ + $this->addSetting('units.speed', [ 'name' => 'Speed Units', - 'group' => 'general', + 'group' => 'units', 'value' => 'knot', 'type' => 'select', 'options' => 'km/h,knot', - 'description' => 'The speed unit', + 'description' => 'The speed unit for display', ]); - $this->addSetting('general.altitude_unit', [ + $this->addSetting('units.altitude', [ 'name' => 'Altitude Units', - 'group' => 'general', + 'group' => 'units', 'value' => 'ft', 'type' => 'select', - 'options' => 'ft,m', - 'description' => 'The altitude units', + 'options' => 'ft=feet,m=meters', + 'description' => 'The altitude unit for display', ]); - $this->addSetting('general.fuel_unit', [ + $this->addSetting('units.fuel', [ 'name' => 'Fuel Units', - 'group' => 'general', + 'group' => 'units', 'value' => 'lbs', 'type' => 'select', 'options' => 'lbs,kg', - 'description' => 'The units for fuel', + 'description' => 'The units for fuel for display', + ]); + + $this->addSetting('units.volume', [ + 'name' => 'Volume Units', + 'group' => 'units', + 'value' => 'gallons', + 'type' => 'select', + 'options' => 'gallons,l=liters', + 'description' => 'The units for fuel for display', ]); /** diff --git a/app/Support/Units/Altitude.php b/app/Support/Units/Altitude.php index 1e4474bf..f3a5cb79 100644 --- a/app/Support/Units/Altitude.php +++ b/app/Support/Units/Altitude.php @@ -15,7 +15,7 @@ class Altitude extends \PhpUnitsOfMeasure\PhysicalQuantity\Length implements Arr */ public function __toString() { - $unit = setting('general.altitude_unit'); + $unit = setting('units.altitude'); $value = $this->toUnit($unit); return (string) round($value, 2); } diff --git a/app/Support/Units/Distance.php b/app/Support/Units/Distance.php index 9460b246..65db2628 100644 --- a/app/Support/Units/Distance.php +++ b/app/Support/Units/Distance.php @@ -15,7 +15,7 @@ class Distance extends \PhpUnitsOfMeasure\PhysicalQuantity\Length implements Arr */ public function __toString() { - $unit = setting('general.distance_unit'); + $unit = setting('units.distance'); $value = $this->toUnit($unit); return (string) round($value, 2); } diff --git a/app/Support/Units/Fuel.php b/app/Support/Units/Fuel.php index 1ca894c1..7572fb8c 100644 --- a/app/Support/Units/Fuel.php +++ b/app/Support/Units/Fuel.php @@ -15,7 +15,7 @@ class Fuel extends \PhpUnitsOfMeasure\PhysicalQuantity\Mass implements Arrayable */ public function __toString() { - $unit = setting('general.fuel_unit'); + $unit = setting('units.fuel'); $value = $this->toUnit($unit); return (string) round($value, 2); } diff --git a/app/Support/Units/Mass.php b/app/Support/Units/Mass.php index e4597517..4828d245 100644 --- a/app/Support/Units/Mass.php +++ b/app/Support/Units/Mass.php @@ -15,7 +15,7 @@ class Mass extends \PhpUnitsOfMeasure\PhysicalQuantity\Mass implements Arrayable */ public function __toString() { - $unit = setting('general.weight_unit'); + $unit = setting('units.weight'); $value = $this->toUnit($unit); return (string) round($value, 2); } diff --git a/app/Support/Units/Velocity.php b/app/Support/Units/Velocity.php index 88a108b4..c0b9196d 100644 --- a/app/Support/Units/Velocity.php +++ b/app/Support/Units/Velocity.php @@ -15,7 +15,7 @@ class Velocity extends \PhpUnitsOfMeasure\PhysicalQuantity\Velocity implements A */ public function __toString() { - $unit = setting('general.speed_unit'); + $unit = setting('units.speed'); $value = $this->toUnit($unit); return (string) round($value, 2); } diff --git a/app/Support/Units/Volume.php b/app/Support/Units/Volume.php index e7d75fcb..a3a22878 100644 --- a/app/Support/Units/Volume.php +++ b/app/Support/Units/Volume.php @@ -15,7 +15,7 @@ class Volume extends \PhpUnitsOfMeasure\PhysicalQuantity\Volume implements Array */ public function __toString() { - $unit = setting('general.liquid_unit'); + $unit = setting('units.volume'); $value = $this->toUnit($unit); return (string) round($value, 2); } diff --git a/app/helpers.php b/app/helpers.php index 8eb45b72..3d28f4f5 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -43,7 +43,13 @@ if(!function_exists('list_to_assoc')) { { $ret = []; foreach($list as $item) { - $ret[$item] = $item; + if(substr_count($item, '=')) { + [$item, $title] = explode('=', $item); + } else { + $title = $item; + } + + $ret[$item] = $title; } return $ret; diff --git a/composer.json b/composer.json index 9934d862..9237e526 100755 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "irazasyed/laravel-gamp": "1.3.x", "vierbergenlars/php-semver": "3.0.x", "php-units-of-measure/php-units-of-measure": "2.1.x", - "markrogoyski/math-php": "^0.38.0" + "markrogoyski/math-php": "^0.38.0", + "moneyphp/money": "^3.1" }, "require-dev": { "phpunit/phpunit": "~7.0", diff --git a/composer.lock b/composer.lock index 1355659d..ab307bcb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "dbfae0d2bcd1653a30a90bb2e244308c", + "content-hash": "4d004ed24ecf6bf961fc610d54213848", "packages": [ { "name": "arrilot/laravel-widgets", @@ -1861,6 +1861,86 @@ ], "time": "2017-12-11T05:05:12+00:00" }, + { + "name": "moneyphp/money", + "version": "v3.1.3", + "source": { + "type": "git", + "url": "https://github.com/moneyphp/money.git", + "reference": "5e6a3c98ba2cb190d48d35656967eacf30716034" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/moneyphp/money/zipball/5e6a3c98ba2cb190d48d35656967eacf30716034", + "reference": "5e6a3c98ba2cb190d48d35656967eacf30716034", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "cache/taggable-cache": "^0.4.0", + "doctrine/instantiator": "^1.0.5", + "ext-bcmath": "*", + "ext-gmp": "*", + "ext-intl": "*", + "florianv/swap": "^3.0", + "leanphp/phpspec-code-coverage": "^3.0 || ^4.0", + "moneyphp/iso-currencies": "^3.0", + "php-http/message": "^1.4", + "php-http/mock-client": "^0.3.3", + "phpspec/phpspec": "^3.0", + "phpunit/phpunit": "^5", + "psr/cache": "^1.0", + "sllh/php-cs-fixer-styleci-bridge": "^2.1", + "symfony/phpunit-bridge": "^4" + }, + "suggest": { + "ext-bcmath": "Calculate without integer limits", + "ext-gmp": "Calculate without integer limits", + "ext-intl": "Format Money objects with intl", + "florianv/swap": "Exchange rates library for PHP", + "psr/cache-implementation": "Used for Currency caching" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Money\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mathias Verraes", + "email": "mathias@verraes.net", + "homepage": "http://verraes.net" + }, + { + "name": "Frederik Bosch", + "email": "f.bosch@genkgo.nl" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagi-kazar@gmail.com" + } + ], + "description": "PHP implementation of Fowler's Money pattern", + "homepage": "http://verraes.net/2011/04/fowler-money-pattern-in-php/", + "keywords": [ + "Value Object", + "money", + "vo" + ], + "time": "2018-02-16T11:04:16+00:00" + }, { "name": "monolog/monolog", "version": "1.23.0", diff --git a/config/phpvms.php b/config/phpvms.php index 85125210..84b0e0da 100644 --- a/config/phpvms.php +++ b/config/phpvms.php @@ -21,6 +21,15 @@ return [ */ 'skin' => env('APP_SKIN', 'default'), + /** + * The ISO "Currency Code" to use + * http://www.xe.com/iso4217.php + * + * Note, do not change this after you've set it, unless you don't + * care that the currencies aren't "exchanged" into the new format + */ + 'currency' => 'USD', + /** * Your vaCentral API key */ diff --git a/resources/stubs/installer/config.stub b/resources/stubs/installer/config.stub index 53399100..7f9a1cc8 100644 --- a/resources/stubs/installer/config.stub +++ b/resources/stubs/installer/config.stub @@ -21,6 +21,15 @@ return [ 'phpvms' => [ 'skin' => 'default', 'vacentral_api_key' => '', + + /** + * The ISO "Currency Code" to use + * http://www.xe.com/iso4217.php + * + * Note, do not change this after you've set it, unless you don't + * care that the currencies aren't "exchanged" into the new format + */ + 'currency' => 'USD', ], # overrides cache.php diff --git a/resources/views/admin/app.blade.php b/resources/views/admin/app.blade.php index e75c9bf6..7782406e 100644 --- a/resources/views/admin/app.blade.php +++ b/resources/views/admin/app.blade.php @@ -161,7 +161,7 @@ $(document).ready(function () { const caret = $("a." + id + " b"); caret.addClass("pe-7s-angle-down"); - caret.removeClass("pe-7s-angle-up"); + caret.removeClass("pe-7s-angle-right"); } $(".collapse").on("hide.bs.collapse", function () { @@ -169,7 +169,7 @@ $(document).ready(function () { const id = $(this).attr('id'); const elem = $("a." + id + " b"); elem.removeClass("pe-7s-angle-down"); - elem.addClass("pe-7s-angle-up"); + elem.addClass("pe-7s-angle-right"); removeItem(storage.menu, id); saveStorage("phpvms.admin", storage); @@ -180,7 +180,7 @@ $(document).ready(function () { const id = $(this).attr('id'); const caret = $("a." + id + " b"); caret.addClass("pe-7s-angle-down"); - caret.removeClass("pe-7s-angle-up"); + caret.removeClass("pe-7s-angle-right"); addItem(storage.menu, id); saveStorage("phpvms.admin", storage); diff --git a/resources/views/admin/menu.blade.php b/resources/views/admin/menu.blade.php index d057e906..bac6a7a3 100644 --- a/resources/views/admin/menu.blade.php +++ b/resources/views/admin/menu.blade.php @@ -5,7 +5,7 @@