function created() { $transaction = new transaction(); $transaction->account_id = $_POST['account_id']; $transaction->type = $_POST['type']; $transaction->amount = $_POST['amount']; $transaction->extra_cost = $_POST['extra_cost']; $transaction->datetime = date("Y-m-d H:i:s"); $transaction->comment = $_POST['comment']; $transaction->create(); header("location: index.php?c=users&a=profile&user_id=" . $_POST['user_id']); }
} catch (PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } } public static function type_translate($type) { if ($type == "cash_in") { return "Insättning"; } elseif ($type == "cash_out") { return "Uttag"; } elseif ($type == "bonus") { return "Bonus"; } elseif ($type == "correction") { return "Rättelse"; } } } if (isset($_GET['c']) && $_GET['c'] == "create") { $transaction = new transaction(); $transaction->account_id = $_POST['account_id']; $transaction->type = $_POST['type']; $transaction->amount = $_POST['amount']; $transaction->datetime = $_POST['datetime']; $transaction->comment = $_POST['comment']; $id = $transaction->create(); return $id; } elseif (isset($_GET['c']) && $_GET['c'] == "all") { $transactions = transaction::all(); echo json_encode($transactions); exit; }