/
accountHistory.php
136 lines (127 loc) · 4.78 KB
/
accountHistory.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
<?php
/**************************************************************************
* Copyright 2014 Nikki Lehman, Erik Vanlandingham, Brent Zerbe *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
**************************************************************************/
$page_title = '';
$idNumber = '';
require("config.php");
require("functions.php");
$mysqli = iwu_startMysql();
if ($_COOKIE["user"]!="") {
$idNumber = $_COOKIE["user"];
$sql = "SELECT firstName, lastName
FROM Student_Account
WHERE studentID = ".mysql_real_escape_string($idNumber);
$row = iwu_getRow($sql, $mysqli);
$userID = $row['firstName'].' '.$row['lastName'];
}
else {
header('Location: /');
exit;
}
if ($_GET["type"]== "mealSwipes") {
//display history for mealswipes
$page_type = "Meal Swipes";
$page_title = 'Meal Swipe History';
$sql = "SELECT lastUsed, totalMealswipes, location
FROM Student_Account, Mealswipe_History, Locations
WHERE Student_Account.StudentID = ".mysql_real_escape_string($idNumber)." AND
Student_Account.id = Mealswipe_History.Student_Account_id AND
Mealswipe_History.Locations_id = Locations.id
ORDER BY lastUsed DESC";
$Full_list = iwu_getResults($sql, $mysqli);
$loop_total = 'totalMealswipes';
$loop_cost = 'location';
}
else if ($_GET["type"]== "points") {
//display history for points
$page_type = "Points";
$page_title = 'Point History';
$sql = "SELECT lastUsed, pointsSpent, totalPoints, location
FROM Student_Account, Point_History, Locations
WHERE Student_Account.StudentID = ".mysql_real_escape_string($idNumber)." AND
Student_Account.id = Point_History.Student_Account_id AND
Point_History.Locations_id = Locations.id
ORDER BY lastUsed DESC";
$Full_list = iwu_getResults($sql, $mysqli);
$loop_cost = 'pointsSpent';
$loop_total = 'totalPoints';
}
iwu_stopMysql($mysqli);
//display template page below
require("header.php");
?>
<div class="row">
<div class="large-5 columns large-centered text-center medium-6 medium-centered last">
<h4 class="show-for-small"><a href="<?=$site_url?>" class="button tiny left">Back</a>Account History<a href="/logout.php" class="button secondary tiny right">Logout</a></h4>
<h3 class="hide-for-small"><a href="<?=$site_url?>" class="button tiny left">Back</a>Account History<a href="/logout.php" class="button secondary tiny right">Logout</a></h3>
<hr>
<h3><?php echo $userID?></h3>
<ul class="pricing-table">
<li class="title"><?php echo $page_type?></li>
<li class="price"><?php
if ($page_type == "Points") {
echo number_format($Full_list[0][$loop_total], 2, '.', '');
}
else {
echo $Full_list[0][$loop_total];
}
?></li>
<!--<li class="description">as of [current time]</li>
<li class="bullet-item">Last Used: <?php echo $date.' '.$time.' at '.$location;?></li> future feature for mockup purposes-->
</ul>
<div class="row">
<div class="small-6 columns">
<a href="yourTrends.php?type=<?=$_GET["type"]?>" class="button expand">Your Trends</a>
</div>
<div class="small-6 columns">
<a href="schoolTrends.php?type=<?=$_GET["type"]?>" class="button expand">School Trends</a>
</div>
</div>
</ul>
<table class="myTable">
<thead>
<tr>
<th width="350" data-sorter="usLongDate">Date</th>
<th style="padding-right:20px">Location</th>
<?php if ($page_type == "Points") {
echo '<th width="75" class="text-center" style="padding-right:15px">Cost</th>';
}?>
<th width="75" class="text-center" style="padding-right:15px">Total</th>
</tr>
</thead>
<tbody>
<?php
foreach ($Full_list as $list) {
echo '<tr>';
echo '<td>'.date('F d, Y h:mA', strtotime($list['lastUsed'])).'</td>';
echo '<td>'.$list['location'].'</td>';
if ($page_type == "Points") {
echo '<td>'.number_format($list[$loop_cost], 2, '.', '').'</td>';
echo '<td>'.number_format($list[$loop_total], 2, '.', '').'</td>';
}
else {
echo '<td>'.$list[$loop_total].'</td>';
}
echo '</tr>';
}
?>
</tbody>
</table>
</div>
</div>
<?php
require('footer.php');
?>