-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummary.php
187 lines (155 loc) · 3.94 KB
/
summary.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
session_start();
if (!isset($_SESSION['isLoggedIn']) || !$_SESSION['isLoggedIn']) {
header('location:login.php');
exit;
}
require_once('TrxnFactory.php');
$currUserName = $_SESSION['user']['fname'].' '.$_SESSION['user']['lname'];
$summary = TrxnFactory::getTrxnSummary($_SESSION['user']['id']);
$trxns = $summary['trxns'];
$total = $summary['sum'];
$categories = TrxnFactory::getCategories();
$trxnTypes = TrxnFactory::getTypes();
?>
<link rel="stylesheet" type="text/css" href="commonstyle.css" />
<style>
body {
background: #ccc;
margin: 0;
padding: 0;
}
.mainContainer{
width: 900px;
margin: 0 auto;
background: #fff;
}
.content{
padding: 30px;
}
.content h1{
margin: 0;
}
.header{
margin: 0 0 2em 0;
}
.header a{
text-align: right;
}
.content h3{
margin: 0;
}
.blockHeader{
border: 1px solid #DDD;
display: inline-block;
padding: 0.4em;
border-bottom: none;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
background: #EEE;
}
#trxnsummary ul{
list-style: none;
margin: 0;
padding: 0;
}
#trxnsummary .trxnrow li{
display: inline-block;
width: 275px;
border: 1px solid #aaa;
margin: 0;
padding: 0;
padding-left: 5px;
text-transform: capitalize;
background: #fff;
margin-right: -5px;
}
#trxnsummary .earn li{
background: #9AFF9A;
border: 1px solid #548B54;
}
#trxnsummary .header li{
font-weight: bold;
background: #ddd;
}
#trxnsummary .trxnrow .empty{
border: 1px solid white;
}
#addTrxnForm{
width: 600px;
border: 1px solid #DDD;
padding: 1em;
}
#addTrxnForm input[type="submit"]{
margin:0;
}
</style>
<div class='mainContainer'>
<div class='content'>
<div class='header budget-grid'>
<h1 class='budget-unit size7of8'>Budget for <?=$currUserName?></h1>
<a class='budget-unit size1of8' href='logout.php'>Logout</a>
</div>
<div class='blockHeader'>
<h3>Add a new Entry</h3>
</div>
<form method='POST' action='AddTrxn.php' class='budget-grid' id='addTrxnForm'>
<label class='budget-unit size1of2' for='desc'>Describe your transaction breifly (optional): </label>
<input class='budget-unit size1of2' type='text' name='desc' />
<br/>
<label class='budget-unit size1of2' for='amount'>Amount: </label>
<input class='budget-unit size1of6' type='number' name='amount' />
<br/>
<label class='budget-unit size1of2' for='category'>Category: </label>
<select class='budget-unit' name='category'>
<?php foreach ($categories as $cat) {?>
<option value='<?=$cat->id?>'><?=ucfirst($cat->name)?></option>
<?php } ?>
</select>
<br/>
<label class='budget-unit size1of2' for='trxntype'>Type: </label>
<select class='budget-unit' name='trxntype'>
<?php foreach ($trxnTypes as $t) {?>
<option value='<?=$t->id?>'><?=ucfirst($t->name)?></option>
<?php } ?>
</select>
<br/>
<br/>
<input type='submit' value='Submit' />
</form>
<br/>
<div class='blockHeader'>
<h3>Summary</h3>
</div>
<div id='trxnsummary'>
<ul>
<li>
<ul class='trxnrow header'>
<li>Category</li>
<li>Description</li>
<li>Amount</li>
</ul>
</li>
<?php foreach ($trxns as $trxn) { ?>
<li>
<ul class='trxnrow <?php if($trxn->type=='earn'){ echo 'earn';}?>'>
<li><?=$trxn->category?></li>
<li><?=$trxn->description?></li>
<li><?=(($trxn->type=='earn')?'-':'').'$'.number_format($trxn->amount, 2);?></li>
</ul>
</li>
<?php } ?>
<li>
<ul class='trxnrow header'>
<li class='empty'></li>
<li>Total spent: </li>
<li><?='$'.number_format($total, 2);?></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<?php
die();
?>