-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirmation.php
167 lines (163 loc) · 5.36 KB
/
confirmation.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
<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">
<body>
<h1><center>Bomb Botz Scouting App</center></h1>
</body>
<p></p>
<?php
$serverName = getenv("ScoutAppDatabaseServerName");
$database = getenv("Database");
$userName = getenv("DatabaseUserName");
$password = getenv("DatabasePassword");
$connectionOptions = array(
"Database" => "$database",
"Uid" => "$userName",
"PWD" => "$password"
);
//Establishes the connection to database
$conn = sqlsrv_connect($serverName, $connectionOptions);
// Get posted variables
$scoutRecordId = $_POST['scoutRecordId'];
$scout = $_POST['scout'];
$match = $_POST['match'];
$team = $_POST['team'];
$alliancePosition = $_POST['alliancePosition'];
$scoutComment = $_POST['scoutComment'];
$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'];
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
$value3 = $_POST['value3'];
$value4 = $_POST['value4'];
$value5 = $_POST['value5'];
$value6 = $_POST['value6'];
$value7 = $_POST['value7'];
$value8 = $_POST['value8'];
$value9 = $_POST['value9'];
$value10 = $_POST['value10'];
$value11 = $_POST['value11'];
$value12 = $_POST['value12'];
$value13 = $_POST['value13'];
$value14 = $_POST['value14'];
$value15 = $_POST['value15'];
$value16 = $_POST['value16'];
$value17 = $_POST['value17'];
$value18 = $_POST['value18'];
$value19 = $_POST['value19'];
$value20 = $_POST['value20'];
$alliance = substr($alliancePosition, 0, 1);
$position = substr($alliancePosition, 1, 1);
$tsql = "select m.id matchId
, m.type + ' ' + m.number matchNumber
, coalesce(convert(varchar, tm.teamId), 'NA') teamId
, coalesce(convert(varchar, t.teamNumber), 'NA') teamNumber
from Match m
left outer join TeamMatch tm
on tm.matchId = m.id
and tm.alliance = '$alliance'
and tm.alliancePosition = $position
left outer join Team t
on t.id = tm.teamId
where m.id =
(select top 1 m2.id
from Match m
inner join Match m2
on m2.gameEventId = m.gameEventId
where m2.isActive = 'Y'
and m2.dateTime > m.dateTime
and m.id = $match
order by m2.dateTime)";
$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)) {
echo "<center><a class='clickme danger' href='scoutRecord.php?matchId=" . $row['matchId'] . "&matchNumber=" . $row['matchNumber'] . "&teamId=" . $row['teamId'] . "&teamNumber=" . $row['teamNumber'] . "&alliancePosition=" . $alliancePosition . "&scoutId=" . $scout . "'>Another Scout Record</a></center>";
$cnt += 1;
}
if ($cnt == 0) {
echo "<center><a class='clickme danger' href='scoutRecord.php'>Another Scout Record</a></center>";
}
echo "<p></p>";
echo "<center><a class='clickme danger' href='Reports/matchReport6217.php?matchId=" . $match . "'>Match Report</a></center>";
?>
<p></p>
<center><a class="clickme danger" href="index6217.php">Home</a></center>
<?php
$tsql = "sp_ins_scoutRecord $scoutRecordId, $scout, $match, $team, $alliancePosition, '$scoutComment', '$loginGUID', '$value1'";
if (isset($value2))
$tsql .= ", '$value2'";
if (isset($value3))
$tsql .= ", '$value3'";
if (isset($value4))
$tsql .= ", '$value4'";
if (isset($value5))
$tsql .= ", '$value5'";
if (isset($value6))
$tsql .= ", '$value6'";
if (isset($value7))
$tsql .= ", '$value7'";
if (isset($value8))
$tsql .= ", '$value8'";
if (isset($value9))
$tsql .= ", '$value9'";
if (isset($value10))
$tsql .= ", '$value10'";
if (isset($value11))
$tsql .= ", '$value11'";
if (isset($value12))
$tsql .= ", '$value12'";
if (isset($value13))
$tsql .= ", '$value13'";
if (isset($value14))
$tsql .= ", '$value14'";
if (isset($value15))
$tsql .= ", '$value15'";
if (isset($value16))
$tsql .= ", '$value16'";
if (isset($value17))
$tsql .= ", '$value17'";
if (isset($value18))
$tsql .= ", '$value18'";
if (isset($value19))
$tsql .= ", '$value19'";
if (isset($value20))
$tsql .= ", '$value20'";
$results = sqlsrv_query($conn, $tsql);
if($results)
echo "<center>Submission Succeeded!</center>";
if(!$results)
{
echo "It is not working!<br />";
echo $tsql."<br />";
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
sqlsrv_free_stmt($getResults);
sqlsrv_close($conn);
?>
</html>