Remove duplicate category.
Fix changing main currency. Fix currency conversion. Pre-Select main currency when adding a new subscription.
This commit is contained in:
parent
eee998c93d
commit
7e4ca23811
@ -108,7 +108,7 @@ INSERT INTO categories (id, name) VALUES
|
||||
(11, 'Insurance'),
|
||||
(12, 'Gaming'),
|
||||
(13, 'News & Magazines'),
|
||||
(14, 'Productivity'),
|
||||
(14, 'Software'),
|
||||
(15, 'Technology'),
|
||||
(16, 'Charity & Donations:');
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ if (!file_exists($databaseFile)) {
|
||||
(11, 'Insurance'),
|
||||
(12, 'Gaming'),
|
||||
(13, 'News & Magazines'),
|
||||
(14, 'Productivity'),
|
||||
(14, 'Software'),
|
||||
(15, 'Technology'),
|
||||
(16, 'Cloud Services'),
|
||||
(17, 'Charity & Donations')");
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
$mainCurrencyCode = $row['code'];
|
||||
$mainCurrencyId = $row['main_currency'];
|
||||
|
||||
$api_url = "http://data.fixer.io/api/latest?access_key=". $apiKey . "&base=" . $mainCurrencyCode . "&symbols=" . $codes;
|
||||
$api_url = "http://data.fixer.io/api/latest?access_key=". $apiKey . "&base=EUR&symbols=" . $codes;
|
||||
$response = file_get_contents($api_url);
|
||||
$apiData = json_decode($response, true);
|
||||
|
||||
@ -131,6 +131,7 @@
|
||||
$_SESSION['avatar'] = $avatar;
|
||||
|
||||
if ($main_currency != $mainCurrencyId) {
|
||||
$_SESSION['main_currency'] = $main_currency;
|
||||
update_exchange_rate($db);
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
return $price;
|
||||
} else {
|
||||
$fromRate = $exchangeRate['rate'];
|
||||
return number_format($price * $fromRate, 2);
|
||||
return number_format($price / $fromRate, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -147,8 +147,9 @@
|
||||
<select id="currency" name="currency_id" placeholder="Currency">
|
||||
<?php
|
||||
foreach ($currencies as $currency) {
|
||||
$selected = ($currency['id'] == $main_currency) ? 'selected' : '';
|
||||
?>
|
||||
<option value="<?= $currency['id'] ?>"><?= $currency['name'] ?></option>
|
||||
<option value="<?= $currency['id'] ?>" <?= $selected ?>><?= $currency['name'] ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user