-
Notifications
You must be signed in to change notification settings - Fork 0
/
getTransactionHistory.php
97 lines (85 loc) · 3.4 KB
/
getTransactionHistory.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
<?php
include_once 'db.php';
include_once 'sessionStart.php';
function getTH($filtered, $transactionType, $searchID){
global $db;
if($filtered == 'no'){
$sql = "SELECT people_sender.username AS sender_username,
people_recipient.username AS recipient_username,
people_sender.ID AS sender_ID, people_recipient.ID AS recipient_ID,
transactionhistory.amount,
`time`, fulfilled,
transactionhistory.ID AS transaction_ID,
note, sendOrRequest, senderBalance, receiverBalance
FROM `transactionhistory`,
`people` AS `people_sender`,
`people` AS `people_recipient`
WHERE `sender` = `people_sender`.`ID`
AND `recipient` = `people_recipient`.`ID` AND (sender = ? OR recipient = ?)
ORDER BY `transactionhistory`.`time` DESC";
$stmt = $db->prepare($sql);
$stmt->bind_param("ii", $id, $id);
$id = $_SESSION['id'];
$stmt->execute();
$result = $stmt->get_result();
$ret = array();
while ($row = $result->fetch_assoc()) {
$ret[] = $row;
}
return $ret;
}
if($filtered == 'yes' && $transactionType != 'null'){
$sql = "SELECT people_sender.username AS sender_username,
people_recipient.username AS recipient_username,
people_sender.ID AS sender_ID, people_recipient.ID AS recipient_ID,
transactionhistory.amount,
`time`, fulfilled,
transactionhistory.ID AS transaction_ID,
note, sendOrRequest, senderBalance, receiverBalance
FROM `transactionhistory`,
`people` AS `people_sender`,
`people` AS `people_recipient`
WHERE `sendOrRequest` = ?
AND `sender` = `people_sender`.`ID`
AND `recipient` = `people_recipient`.`ID`
AND (sender = ? OR recipient = ?)
AND (sender = ? OR recipient = ?)
ORDER BY `transactionhistory`.`time` DESC";
$stmt = $db->prepare($sql);
$stmt->bind_param("siiii",$transactionType ,$userID, $userID, $searchID, $searchID);
$userID = $_SESSION['id'];
$stmt->execute();
$result = $stmt->get_result();
$ret = array();
while ($row = $result->fetch_assoc()) {
$ret[] = $row;
}
return $ret;
} else if($filtered == 'yes' && $transactionType == 'null'){
$sql = "SELECT people_sender.username AS sender_username,
people_recipient.username AS recipient_username,
people_sender.ID AS sender_ID, people_recipient.ID AS recipient_ID,
transactionhistory.amount,
`time`, fulfilled,
transactionhistory.ID AS transaction_ID,
note, sendOrRequest, senderBalance, receiverBalance
FROM `transactionhistory`,
`people` AS `people_sender`,
`people` AS `people_recipient`
WHERE `sender` = `people_sender`.`ID`
AND `recipient` = `people_recipient`.`ID`
AND (sender = ? OR recipient = ?)
AND (sender = ? OR recipient = ?)
ORDER BY `transactionhistory`.`time` DESC";
$stmt = $db->prepare($sql);
$stmt->bind_param("iiii",$userID, $userID, $searchID, $searchID);
$userID = $_SESSION['id'];
$stmt->execute();
$result = $stmt->get_result();
$ret = array();
while ($row = $result->fetch_assoc()) {
$ret[] = $row;
}
return $ret;
}
}