forked from udsaxman/Sapphirev2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TDSInViewOp.php
272 lines (218 loc) · 7.22 KB
/
TDSInViewOp.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<?php
session_start();
include 'header.html';
?>
<!-- InstanceBeginEditable name="content" -->
<div id="content_area" align="left">
<br/>
<br/>
<br/>
<br/>
<form action="TDSInViewOp.php"
method="">
<fieldset>
<legend>Zeh Op</legend>
<?php
//Login Check
if (isset($_SESSION["userName"])) {
echo "<a href = './TDSinLiveOp.php'><input type = 'button' value = 'Live Ops' /></a>";
echo "<a href = './TDSInViewItems.php'><input type = 'button' value = 'View Items' /></a>";
echo "<br />";
$opArray[0] = "";
$opIDArray[0] = 0;
$opCount = 0;
$selectedOp = 0;
include 'connection.php';
//$sql = select op_name from Ops;
$sql = "Select op_id, op_name From Ops order by op_id desc LIMIT 0,20";
$result = $mysqli->query($sql);
while ($row = $result->fetch_assoc()) {
$OPArray[] = $row;
}
$result->free();
if (isset($_REQUEST["selOp"])) {
$selectedOp = $_REQUEST["selOp"];
}
echo "<select name = 'selOp'>";
foreach ($OPArray as $oplist){
echo "<option value=".$oplist['op_id'];
if ($oplist['op_id'] == $selectedOp){
echo " selected = 'selected'";
}
echo ">".$oplist['op_name'];
echo "</option>";
}
echo "</select>";
echo "<input type = 'submit' value = 'View Op' />";
//Create form that shows ALL of the op detail
//op_id = $_REQUEST["selOp"] + 1
//Btw, deleting stuff is bad
if (isset($_REQUEST["selOp"])) {
//Get ALL the opInfo
$op_ID = ($_REQUEST["selOp"]); //Database is base 1, we are base 0
$sql = "SELECT op_id, op_name, op_date, op_tax, op_taxAmount,op_shareValue,op_iskValue, user_name as processor_name FROM Ops JOIN Users where Ops.op_processor = Users.user_id and op_id =" . $op_ID."";
$result = $mysqli->query($sql);
$op = $result->fetch_assoc();
$result->free();
$opName = $op["op_name"];
$opProcessor = $op['processor_name'];
$opDate = $op['op_date'];
$opTax = $op['op_tax'];
$opTaxAmount = $op['op_taxAmount'];
$opShareValue = $op['op_shareValue'];
$opValue = $op['op_iskValue'];
//Get all the Attendance Info
$sql = "Select
user_name, shares
from
Users
left join
Op_Attendence
on
op_id = " . $op_ID . "
AND
Op_Attendence.user_id = Users.user_id
where
Users.user_id =
ANY
(select user_id from Op_Attendence where op_id = " . $op_ID . ")
group by
user_name";
$result = $mysqli->query($sql);
while ($row = $result->fetch_array(MYSQLI_BOTH)) {
$Users[] = $row;
}
$result->free();
//Get all of the Op_Loot
$sql = "Select
item_name, item_type, amount
from
Items
left join
Op_Loot
on
op_id = " . $op_ID . "
AND
Op_Loot.item_id = Items.item_id
where
Items.item_id =
ANY
(select item_id from Op_Loot where op_id = " . $op_ID . ")
group by
item_name
order by
item_type, item_order";
$result = $mysqli->query($sql);
while ($row = $result->fetch_array(MYSQLI_BOTH)) {
$items[] = $row;
}
$sql = "select * from Item_Category order by category_order";
$result = $mysqli->query($sql);
while ($row = $result->fetch_array(MYSQLI_BOTH)) {
$categories[] = $row;
}
//Build basic Op information from Ops Table
echo "<br />";
echo "<br />";
echo "Op Information";
echo "<br />";
echo "<table class='Display' border=''>";
echo "<tr>";
echo "<td>Op Name</td>";
echo "<td>" . $opName . "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td>Op Processor</td>";
echo "<td>" . $opProcessor . "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td>Op Process Date</td>";
echo "<td>" . $opDate . "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td>Op Tax %</td>";
echo "<td style='text-align:right'>" . number_format($opTax, 3, '.', ',') . "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td>Op Tax Amount</td>";
echo "<td style='text-align:right'>" . number_format($opTaxAmount, 2, '.', ',') . "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td>Op Value (After Tax)</td>";
echo "<td style='text-align:right'>" . number_format($opValue, 2, '.', ',') . "</tr>";
echo "</tr>";
echo "<tr>";
echo "<td>Op Value Per Share</td>";
echo "<td style='text-align:right'>" . number_format($opShareValue, 2, '.', ',') . "</tr>";
echo "</tr>";
echo "</table>";
//Build Pilot Information from Op_Attendence and Users Tables
echo "<fieldset>";
echo "<legend>Pilots</legend>";
echo "<table class='Display' border=''>";
echo "<tr>";
echo "<th>Pilot Name</th>";
echo "<th>Shares</th>";
echo "</tr>";
foreach ($Users as $user){
echo "<tr>";
echo "<td>" . $user['user_name'] . "</td>";
echo "<td>" . $user['shares'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</fieldset>";
$showCat[0] = false;
foreach ($categories as $category) {
$showCat[$category['category_id']] = false;
foreach($items as $item) {
if ($item['item_type'] == $category['category_id']) {
$showCat[$category['category_id']] = true;
}
}
}
echo "<fieldset>";
echo "<legend>Items</legend>";
foreach ($categories as $category) {
if ($showCat[$category['category_id']] == true) {
echo "<fieldset>";
if ($category['category_useOverride'] == 0) {
echo "<legend>" . $category['category_name'] . "</legend>";
} else {
echo "<legend>" . $category['category_name'] . " - Tax Override: " . $category['category_taxOverride'] . "%</legend>";
}
echo "<table class='Display' border=''>";
echo "<tr>";
echo "<th>Item Name</td>";
echo "<th>Amount</td>";
echo "</tr>";
foreach ($items as $item) {
if ($item['item_type'] == $category['category_id']) {
echo "<tr>";
echo "<td>" . $item['item_name'] . "</td>";
echo "<td style='text-align:right'>" . number_format($item['amount'], 0, '.', ',') . "</td>";
echo "</tr>";
}
}
echo "</table>";
echo "</fieldset>";
}
}
echo "</fieldset>";
}
} else {
echo "<p> You are not logged in as anyone, thus you cannot see this page </p>";
}
?>
</fieldset>
</form>
</div>
<!-- InstanceEndEditable -->
<!-- Add Footer -->
<?php include('footer.html'); ?>
</DIV>
</td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>