-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoutRecord.php
330 lines (326 loc) · 12.7 KB
/
scoutRecord.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Scouting App</title>
<link rel="stylesheet" type="text/css" href="Style/scoutingStyle.css">
<head>
<link rel="apple-touch-icon" sizes="57x57" href="/Logo/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/Logo/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/Logo/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/Logo/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/Logo/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/Logo/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/Logo/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/Logo/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/Logo/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/Logo/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/Logo/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/Logo/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/Logo/favicon-16x16.png">
<link rel="manifest" href="/Logo/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/Logo/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1">
<body>
<h1><center>Bomb Botz Scouting App</center></h1>
</body>
<center><a class="clickme danger" href="index6217.php">Home</a></center>
<form enctype="multipart/form-data" action='confirmation.php' method='post'>
<?php
$serverName = getenv("ScoutAppDatabaseServerName");
$database = getenv("Database");
$userName = getenv("DatabaseUserName");
$password = getenv("DatabasePassword");
$connectionOptions = array(
"Database" => "$database",
"Uid" => "$userName",
"PWD" => "$password"
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
$loginEmailAddress = getenv("DefaultLoginEmailAddress");
$tsql = "select scoutGUID from Scout where emailAddress = '$loginEmailAddress'";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
$row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC);
$loginGUID = $row['scoutGUID'];
// Get values for page from database
$cntSR = 0;
if (isset($_GET['scoutRecordId'])) {
$scoutRecordId = "$_GET[scoutRecordId]";
$tsql = "select sr.matchId
, m.type + ' ' + m.number matchNumber
, sr.teamId
, t.teamNumber
, tm.alliance + convert(varchar, tm.alliancePosition) alliancePosition
, sr.scoutComment
, sr.scoutId
from ScoutRecord sr
inner join Match m
on m.id = sr.matchId
inner join Team t
on t.id = sr.teamId
inner join TeamMatch tm
on tm.teamId = sr.teamId
and tm.matchId = sr.matchId
where sr.id = " . $scoutRecordId . ";";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
$cntSR = 1;
$matchId = $row['matchId'];
$matchNumber = $row['matchNumber'];
$teamId = $row['teamId'];
$teamNumber = $row['teamNumber'];
$alliancePosition = $row['alliancePosition'];
$scoutComment = $row['scoutComment'];
$scoutId = $row['scoutId'];
}
}
// Get values for page from query string
if ($cntSR == 0) {
$matchId = "$_GET[matchId]";
$matchNumber = "$_GET[matchNumber]";
$teamId = "$_GET[teamId]";
$teamNumber = "$_GET[teamNumber]";
$alliancePosition = "$_GET[alliancePosition]";
$scoutId = "$_GET[scoutId]";
$scoutRecordId = "0";
}
?>
<center>
<div class="container" id="scout">
<?php
echo '<input type="hidden" name="scoutRecordId" value="' . $scoutRecordId . '">';
?>
<p><u><b>Match Selection</b></u></p>
<p>Scout:
<select style="width: 161px;" name="scout">
<?php
if ($scoutId <> "") {
$tsql = "select id, lastName + ', ' + firstName fullName from Scout where isActive = 'Y' or id = " . $scoutId . " order by lastName, firstName";
}
else {
$tsql = "select id, lastName + ', ' + firstName fullName from Scout where isActive = 'Y' order by lastName, firstName";
}
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
$cnt = 0;
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
if ($row['id'] == $scoutId)
echo "<option value=" . $row['id'] . " selected>" . $row['fullName'] . "</option>";
else
echo "<option value=" . $row['id'] . ">" . $row['fullName'] . "</option>";
}
?>
</select>
</p>
<p>Match:
<select style="width: 157px" name="match">
<option value="<?php echo ($matchId);?>" selected><?php echo ($matchNumber);?></option>
<?php
$tsql = "select m.matchId, m.matchNumber
from v_MatchHyperlinks6217 m
where loginGUID = '$loginGUID'
order by m.sortOrder, m.matchSort, m.matchNumber";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
?>
<option value="<?php echo ($row['matchId']);?>"><?php echo ($row['matchNumber']);?></option>
<?php
}
?>
</select>
</p>
<p>Team:
<select style="width: 154.5px;" name="team">
<?php
if ($teamId == "NA")
echo "<option value=''></option>";
else
echo "<option value=" . $teamId . " selected>" . $teamNumber . "</option>";
$tsql = "select t.id, t.teamNumber, t.teamName
from Team t
inner join TeamGameEvent tge on tge.teamId = t.id
inner join GameEvent ge on ge.id = tge.gameEventId
where ge.id in
(select ge2.id
from v_GameEvent ge2
where ge2.loginGUID = '$loginGUID')
order by t.teamNumber";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
echo "<option value=" . $row['id'] . ">" . $row['teamNumber'] . " - " . $row['teamName'] . "</option>";
}
?>
</select>
</p>
<p>Alliance Position:
<select name="alliancePosition" style="width: 70px;">
<?php
if ($alliancePosition != "B1")
echo "<option value='B1'>Blue 1</option>";
else
echo "<option value='B1' selected>Blue 1</option>";
if ($alliancePosition != "B2")
echo "<option value='B2'>Blue 2</option>";
else
echo "<option value='B2' selected>Blue 2</option>";
if ($alliancePosition != "B3")
echo "<option value='B3'>Blue 3</option>";
else
echo "<option value='B3' selected>Blue 3</option>";
if ($alliancePosition != "R1")
echo "<option value='R1'>Red 1</option>";
else
echo "<option value='R1' selected>Red 1</option>";
if ($alliancePosition != "R2")
echo "<option value='R2'>Red 2</option>";
else
echo "<option value='R2' selected>Red 2</option>";
if ($alliancePosition != "R3")
echo "<option value='R3'>Red 3</option>";
else
echo "<option value='R3' selected>Red 3</option>";
?>
</select>
</p>
<?php
if ($cntSR == 1)
$tsql = "select groupName
, objectiveName
, objectiveLabel
, displayValue
, integerValue
, groupSort
, objectiveSort
, objectiveValueSort
, scoutRecordHtml
from v_UpdateScoutRecordHTML
where loginGUID = '$loginGUID'
and scoutRecordId = " . $scoutRecordId . "
union
select esrh.groupName
, esrh.objectiveName
, esrh.objectiveLabel
, esrh.displayValue
, esrh.integerValue
, esrh.groupSort
, esrh.objectiveSort
, esrh.objectiveValueSort
, esrh.scoutRecordHtml
from v_EnterScoutRecordHTML esrh
where loginGUID = '$loginGUID'
and not exists
(select 1
from v_UpdateScoutRecordHTML usrh
where usrh.scoutRecordId = " . $scoutRecordId . "
and usrh.groupName = esrh.groupName
and coalesce(usrh.objectiveName, 'XXXXX') = coalesce(esrh.objectiveName, 'XXXXX')
and coalesce(usrh.objectiveLabel, 'XXXXX') = coalesce(esrh.objectiveLabel, 'XXXXX'))
order by groupSort, objectiveSort, objectiveValueSort";
else
$tsql = "select groupName
, objectiveName
, objectiveLabel
, displayValue
, integerValue
, groupSort
, objectiveSort
, objectiveValueSort
, scoutRecordHtml
from v_EnterScoutRecordHTML
where loginGUID = '$loginGUID'
order by groupSort, objectiveSort, objectiveValueSort";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
echo $row['scoutRecordHtml'];
}
// Add Scout Comment entry for all Scout Records
if ($cntSR == 1)
echo '<br><br>Match Comment<br><input type="text" name ="scoutComment" value="' . $scoutComment . '" style="width: 320px"><br>';
else
echo '<br><br>Match Comment<br><input type="text" name ="scoutComment" style="width: 320px"><br>';
?>
<p></p>
<center><input type="submit" value="Submit" name="submitToDatabase"></center>
</div>
<?php
if (isset($matchId) && !empty($matchId)) {
$cntVideo = 0;
$tsql = "select case when videoType = 'youtube'
then 'https://www.youtube.com/embed/'
else videoType end + trim(videoKey) videoUrl
from MatchVideo
where matchId = $matchId
order by id";
$getResults = sqlsrv_query($conn, $tsql);
if ($getResults == FALSE)
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
if ($cntVideo == 0) {
echo '<h1>Video</h1>';
}
$cntVideo += 1;
echo '<iframe width="560" height="315" src="' . $row['videoUrl'] . '" frameborder="0" allowfullscreen></iframe>';
echo '<p></p>';
}
}
sqlsrv_free_stmt($getResults);
sqlsrv_close($conn);
?>
</center>
</form>
</head>
</html>