/
transactions.php
77 lines (75 loc) · 2.66 KB
/
transactions.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
<?php
include 'include/config.php';
include 'include/common.inc.php';
?>
<!doctype html>
<META HTTPEQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<meta httpequiv="expires" content="0" />
<html lang="en">
<head>
<title>Transactions</title>
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
</head>
<body>
<div class="container">
<!-- <div class="row">
<div class="col align-self-start">
LEFT
</div>
</div>-->
<div class="row">
<div class="col align-self-center">
<blockquote class="blockquote text-center"><h3>Transactions for last 30 Days</h3></blockquote>
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th scope="col">Place</th>
<th scope="col">Amount</th>
<th scope="col">Date</th>
</tr>
</thead>
<tbody>
<?php
// Get Transactions
$account_id = $_GET['acct'];
$date = date('Y-m-d');
$startDate = date('Y-m-d', strtotime($date. ' - 30 days'));
$transactions = plaid_getTransactions($dbh, $account_id ,$startDate, date('Y-m-d'));
$amt_in = 0;
$amt_out = 0;
foreach($transactions as $key => $value) {
$amount = sprintf("%0.2f", $value['amount']);
if ($amount < 0) {
$color = 'text-success';
$amt_in += $amount;
}
else {
$color = 'text-danger';
$amt_out += $amount;
}
echo "<tr>";
echo "<td>{$value['name']}</td>";
echo "<td><p class=\"$color\">$amount</p></td>";
echo "<td>{$value['date']}</td>";
echo "</td>";
}
?>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col align-self-center">
<blockquote class="blockquote text-center">Totals: <?php echo "IN: " . str_replace("-","",$amt_in) . " / OUT: " . $amt_out; ?></blockquote>
</div>
</div>
</div>
<?php
?>
<!--<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
</body>
</html>