summaryrefslogtreecommitdiff
path: root/Application/AddTransaction
diff options
context:
space:
mode:
Diffstat (limited to 'Application/AddTransaction')
-rw-r--r--Application/AddTransaction/index.php13
1 files changed, 4 insertions, 9 deletions
diff --git a/Application/AddTransaction/index.php b/Application/AddTransaction/index.php
index e6b7d34..ef2f339 100644
--- a/Application/AddTransaction/index.php
+++ b/Application/AddTransaction/index.php
@@ -43,16 +43,14 @@ if (!isset($_GET['Currency']) || !isset($_GET['Amount']) || !is_numeric($_GET['A
die();
}
-$list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json"), true);
+$transaction = [];
$exchangeRate = (float)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/ExchangeRate.txt");
$eurToGbp = $exchangeRate;
$gbpToEur = 1 / $eurToGbp;
-$list = array_reverse($list);
-
if ($_GET['Currency'] === "€") {
- $list[] = [
+ $transaction = [
'author' => $_PROFILE['id'],
'type' => $_GET['Operation'] === "+" || $_GET['Operation'] === " " ? "gain" : "pay",
'amount' => [
@@ -64,7 +62,7 @@ if ($_GET['Currency'] === "€") {
'description' => base64url_decode($_GET['Description'])
];
} else {
- $list[] = [
+ $transaction = [
'author' => $_PROFILE['id'],
'type' => $_GET['Operation'] === "+" || $_GET['Operation'] === " " ? "gain" : "pay",
'amount' => [
@@ -77,7 +75,4 @@ if ($_GET['Currency'] === "€") {
];
}
-$list = array_reverse($list);
-
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions." . str_replace(":", "-", date('c')) . ".json", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json"));
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json", json_encode($list)); \ No newline at end of file
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions/" . date('U') . ".json", json_encode($transaction)); \ No newline at end of file