-
Notifications
You must be signed in to change notification settings - Fork 0
/
memberTHPage.php
135 lines (123 loc) · 6.17 KB
/
memberTHPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html>
<head>
<link rel="stylesheet" href="moneyApp.css"> <?php include 'themes.php'; ?>
</head>
<body>
<header>
<?php include_once 'header.php'; ?>
<img src='images/filterIcon.png' id='filterIcon' class='closed'>
<div id='filtersContainer' class='hidden'>
<div class='Etext' id='filtersTitle'>Filters</div>
<div id='filtersArea'>
<form action='memberTHPage.php' method='post'>
<div>
<label class="container">Send
<input type="radio" name='transactionType' value="send">
<span class="checkmark"></span>
</label>
<label class="container">Request
<input type="radio" name='transactionType' value="request">
<span class="checkmark"></span>
</label>
<label class="container">Allowance
<input type="radio" name='transactionType' value="allowance">
<span class="checkmark"></span>
</label>
</div>
<div>
<div class="Btext">
Search by person
</div>
<select name="searchID" id="searchID" class="formBox">
<?php include_once 'memberDropDownMenu.php';
makeDropDown($_POST['id']);
?>
</select>
</div>
<button name='id' value="<?php print_r($_POST['id']); ?>" id='filterSubmit'>Filter</button>
</form>
</div>
</div>
<div id="requestAlerts">
<?php
include_once 'getMemberTH.php';
include_once 'parentCheck.php';
include_once 'db_people.php';
if (!isset($_POST['searchID']) && !isset($_POST['transactionType'])) {
$transactions = getTH($_POST['id'], 'no', 'null', 'null');
// print_r("Unfiltered ");
} else {
if ($_POST['searchID'] == '?null') {
$searchID = $_POST['id'];
} else {
$searchID = $_POST['searchID'];
}
if (!isset($_POST['transactionType'])) {
$transactionType = 'null';
} else {
$transactionType = $_POST['transactionType'];
}
$transactions = getTH($_POST['id'], 'yes', $transactionType, $searchID);
}
$userID = $_POST['id'];
$memberUsername = getNameFromId($userID)['username'];
// print_r($transactions);
// print_r($_POST);
foreach ($transactions as $row) {
$Unixdate = strtotime($row['time']);
$date = date('F j, Y, g:i a', $Unixdate);
if ($row['sender_ID'] == $userID) {
$balanceText = "$memberUsername's balance: $$row[senderBalance]";
if ($row['sendOrRequest'] == 'allowance') {
$text = ("$memberUsername received $$row[amount] as their allowance");
}
if ($row['sendOrRequest'] == 'send') {
$text = ("$memberUsername sent $$row[amount] to $row[recipient_username] for $row[note]");
}
if ($row['sendOrRequest'] == 'request') {
if ($row['fulfilled'] == 'sent') {
$text = ("$memberUsername sent $$row[amount] to $row[recipient_username] for $row[note] upon their request");
}
if ($row['fulfilled'] == 'declined') {
$text = ("$memberUsername declined a $$row[amount] request from $row[recipient_username] for $row[note]");
}
if ($row['fulfilled'] == 'pending') {
$text = ("$memberUsername has a $$row[amount] pending request from $row[recipient_username] for $row[note]");
}
if ($row['fulfilled'] == 'taken') {
$text = ("$row[recipient_username] took $$row[amount] from $memberUsername for $row[note]");
}
}
}
if ($row['recipient_ID'] == $userID) {
$balanceText = "$memberUsername's balance: $$row[receiverBalance]";
if ($row['sendOrRequest'] == 'send') {
$text = ("$row[sender_username] sent $$row[amount] to $memberUsername for $row[note]");
}
if ($row['sendOrRequest'] == 'request') {
if ($row['fulfilled'] == 'sent') {
$text = ("$row[sender_username] sent $$row[amount] to $memberUsername for $row[note] upon their request");
}
if ($row['fulfilled'] == 'declined') {
$text = ("$row[sender_username] declined $memberUsername's $$row[amount] request for $row[note]");
}
if ($row['fulfilled'] == 'pending') {
$text = ("$memberUsername's $$row[amount] request to $row[sender_username] for $row[note] is pending");
}
if ($row['fulfilled'] == 'taken') {
$text = ("$memberUsername took $$row[amount] from $row[sender_username] for $row[note]");
}
}
}
if ($text) {
print("<div id='requestAlerts'><div class='alert'>$text <div class='exDetails'><div class='transactionBalance'>$balanceText</div> <div class='transactionDate'>$date</div></div></div></div>");
} else {
print_r($row);
}
}
?>
</div>
</header>
<script src="moneyApp.js"></script>
</body>
</html>