/
add_data.php
318 lines (300 loc) · 18.9 KB
/
add_data.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
<?php
session_start();
include_once(__DIR__ . "/logic_files/allfunctions.php");
if (!isset($_SESSION['sessiontype']) || strlen($_SESSION['sessiontype']) == 0) {
header("Location: login.php");
} else {
require(__DIR__ . "/logic_files/add_data_page_logic.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php require_once(__DIR__ . "/part_pages/all_page_dependencies.php"); ?>
<title>Add data</title>
</head>
<body class="has-navbar-fixed-top is-family-sans-serif">
<!-- Full nav bar -->
<?php
include(__DIR__ . "/part_pages/part_site_navbar.php");
?>
<!-- banner at the top of the page! -->
<section class="hero is-info is-bold pt-6">
<div class="hero-body">
<div class="container">
<h1 class="title mt-4 is-size-3 is-size-5-mobile">Add English Premier League Data</h1>
<p class="subtitle is-5 mt-2 is-size-6-mobile">Use this form to add data to our database</p>
</div>
</div>
</section>
<div class="has-text-centered master_site_width container columns" id="my_upload_result_form">
<div class="column is-8 is-offset-2">
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST') {
echo "<div class='mt-5 p-5 has-background-warning'>
<div>
<h3 class='title is-5'>{$submissionDisplayToUser}</h3>
<p class='subtitle is-6 pt-3'>Please add further data below</p>
</div>
</div>";
}
if (isset($_SESSION['sessiontype']) && $_SESSION['sessiontype'] === "admin") {
// only display the addition of referees, clubs and seasons to admins.
// general website users (joe public) can add matches
$suggestedNextSeason = findNextSuggestedSeason();
echo "
<!-- add new club, ref, season data into db! -->
<div class='mt-5 p-5 my_info_colour'>
<h2 class='title is-4 my_info_colour is-size-5-mobile'>Add new Clubs, Seasons or Referee Names</h2>
<h3 class='title is-5 mt-5 mb-1 my_info_colour is-size-6-mobile'>Add new Referee;</h3>
<div class=''>
<p class='p-2 is-size-7-mobile'>Please enter Referee's first and last name, with a space between e.g. New Referee</p>
<form method='POST' action='add_data.php' class='level columns'>
<input type='text' required id='new_referee' name='newrefname' minlength='4' maxlength='30' class='input level-item column is-5 my-3 is-half-tablet' placeholder='Referee Name'>
<div class='my_medium_form_item'>
<button class='button level-item my_medium_form_item is-danger m-3 is-rounded is-pulled-right' name='submit_new_referee'>
<span class='icon'>
<i class='fas fa-plus'></i>
</span>
<span>Add Referee</span>
</button>
</div>
</form>
</div>
<h3 class='title is-5 mt-5 mb-1 my_info_colour is-size-6-mobile'>Add new Season;</h3>
<div class=''>
<p class='p-2 is-size-7-mobile'>Please enter a season in the format 'firstyear-secondyear' with 4 digits for each year e.g. 2000-2001</p>
<form method='POST' action='add_data.php' class='level columns'>
<input type='text' required id='new_season' name='new_season' class='input level-item column is-5 my-3 is-half-tablet' placeholder='Suggested next season to add : {$suggestedNextSeason}'>
<div class='my_medium_form_item'>
<button class='button level-item my_medium_form_item is-danger m-3 is-rounded my-3 is-pulled-right' name='submit_new_season'>
<span class='icon'>
<i class='fas fa-plus'></i>
</span>
<span>Add New Season</span>
</button>
</div>
</form>
</div>
<h3 class='title is-5 mt-5 mb-1 my_info_colour is-size-6-mobile'>Add new Club;</h3>
<div class=''>
<p class='p-1 is-size-7-mobile'>Please use the official club name and do not abbreviate. Maximum 2 words.</p>
<p class='p-1 is-size-7-mobile mb-3'>Club Logo URL must link directly to a .jpg or .png image file</p>
<form method='POST' action='add_data.php' class='level columns'>
<input type='text' required id='new_club' name='new_club' class='input level-item column is-3 my-3 is-one-third-tablet' maxlength='35' placeholder='Club Name (max 35 Characters)'>
<input type='url' required id='new_club_img_url' name='new_club_img_url' class='input level-item column is-3 my-2 is-one-third-tablet' placeholder='Club Logo URL'>
<button class='button level-item is-danger is-rounded mt-4 m-3 is-pulled-right' name='submit_new_club'>
<span class='icon'>
<i class='fas fa-plus'></i>
</span>
<span>Add New Club</span>
</button>
</form>
</div>
</div>";
} elseif (isset($_SESSION['sessiontype']) && $_SESSION['sessiontype'] === "user") {
// if a user is signed in, show the bar allowing them to email a referee change request to admins
echo"
<div class='mt-5 p-3 my_info_colour '>
<div><h3 class='title is-4 p-4 my_info_colour is-size-5-mobile'>Request a new Season, Club or Referee</h3></div>
<div class='level'>
<a href='mailto:tkilpatrick01@qub.ac.uk?subject=StatFinder Website - Referee Change Request &body=Dear Admin, Could the following referee be add/removed from the database as they no longer officiate at Premier League Matches, Many thanks'>
<button class='level-item button is-danger m-3 is-rounded ml-3'>
<span class='material-icons'>sports</span>
<span class='ml-3'>Request Referee Changes</span>
</button>
</a>
<a href='mailto:tkilpatrick01@qub.ac.uk?subject=StatFinder Website - New Season Request &body=Dear Admin, Can a new Season be added to the statfinder website so new season match results can be added, Many thanks'>
<button class='level-item button is-danger m-3 is-rounded my-3'>
<span>
<i class='far fa-calendar-alt'></i>
</span>
<span class='ml-3'>Request New Season</span>
</button>
</a>
<a href='mailto:tkilpatrick01@qub.ac.uk?subject=StatFinder Website - Club Change Request &body=Dear Admin, Can i request the following club to be added/removed from the site club listing as they have been promoted/relegated from the Premier League, Many thanks'>
<button class='mr-5 level-item button is-danger m-3 is-rounded my-3'>
<span>
<i class='far fa-futbol'></i>
</span>
<span class='ml-3'>Request Club Changes</span>
</button>
</a>
</div>
</div>";
}
?>
<!-- add 1 new match details form -->
<div class="field">
<form method="POST" action='add_data.php'>
<div class="mt-5 p-5 my_info_colour">
<div>
<h2 class="title is-4 my_info_colour is-size-5-mobile">Add a new match result:</h2>
<h3 class="title is-size-5 my_info_colour is-size-6-mobile">Match Details:</h3>
</div>
<div class="mt-4">
<div class="my_match_metadata ">
<?php
// dynamically set the correct current season on the UI
$currentSeason = getCurrentSeason();
echo "<p class='mb-4 subtitle is-6 my_info_colour'>Current Season : {$currentSeason}</p>";
?>
</div>
</div>
<div class="columns is-mobile is-vcentered">
<div class="column is-6 has-text-right">
<label for="match_date" class="my_small_form_item">Match Date :</label>
</div>
<div class="column is-6 has-text-left">
<input type="date" id="users_match_date_entry" class="my_small_form_item my-1 input is-info " name="match_date">
</div>
</div>
<div class="columns is-mobile is-vcentered">
<div class="column is-6 has-text-right">
<label for="kickoff_time" class="my_small_form_item">Kick Off Time :</label>
</div>
<div class="column is-6 has-text-left">
<input type="time" class="my_small_form_item my-1 input is-info" id='kickoff_time' name="kickoff_time">
</div>
</div>
<div class="columns is-mobile is-vcentered">
<div class="column is-6 has-text-right">
<label for="select_ref" class="my_small_form_item ">Referee :</label>
</div>
<div class="column is-6 has-text-left">
<div class="select is-info my_small_form_item">
<select required class='my_small_form_item' name='select_ref' id='select_ref'>
<?php
require(__DIR__ . "/part_pages/part_referee_selector.php");
?>
</select>
</div>
</div>
</div>
</div>
<div class="field p-4 pt-5 mt-5 my_grey_highlight_para">
<div class="field">
<h2 class="title is-size-4 is-size-5-mobile my_grey_highlight_para">Select Teams:</h2>
</div>
<div class="level">
<div class="my_inline_divs m-1 mt-4">
<label class="is-size-5 mx-3 level-item is-size-6-mobile" id="ht_selector_text" for="ht_selector"><b>Home Team</b></label>
<div class="select is-success level-item">
<select required class='my_small_form_item mx-2 ' name='ht_selector' id='ht_selector'>
<?php
require(__DIR__ . "/part_pages/part_current_season_team_selector.php");
// control var for the second team <select> to ensure its unique
$htSelectorIsSet = true;
?>
</select>
</div>
</div>
<div class='my_inline_divs py-2' id="switch_club_select">
<span class="material-icons level-item" id="switch_club_logo">swap_horiz</span>
</div>
<div class="my_inline_divs m-1 mt-4">
<div class="select is-danger level-item">
<select required class='my_small_form_item mx-2' name='at_selector' id='at_selector'>
<?php
require(__DIR__ . "/part_pages/part_current_season_team_selector.php");
?>
</select>
</div>
<label class="is-size-5 mx-3 level-item is-size-6-mobile" id="at_selector_text" for="at_selector"><b>Away Team</b></label>
</div>
</div>
</div>
<!-- entry boxes -->
<div class="field ">
<div class="field">
<h2 class="title is-size-4 mt-6 is-size-5-mobile">Enter the new Match statistics:</h2>
</div>
</div>
<?php
// used for placeholder data and minimum entry values
$zero = 0;
$sectionTitles = array(
"Half Time Goals:",
"Full Time Goals:",
"Total Shots:",
"Shots on Target:",
"Corners:",
"Total Fouls:",
"Yellow Cards:",
"Red Cards:"
);
$maxValues = array(
50,
50,
50,
50,
200,
100,
22,
5
);
$homeNameValues = array(
"ht_ht_goals",
"ht_ft_goals",
"ht_total_shots",
"ht_shots_on_target",
"ht_corners",
"ht_total_fouls",
"ht_yellow_cards",
"ht_red_cards",
);
$awayNameValues = array(
"at_ht_goals",
"at_ft_goals",
"at_total_shots",
"at_shots_on_target",
"at_corners",
"at_total_fouls",
"at_yellow_cards",
"at_red_cards",
);
for ($i = 0; $i < 8; $i++) {
echo "<div class='field'>
<p>{$sectionTitles[$i]}</p>
<div class='my_inline_divs m-1 p-1'>
<input required class='my_small_num_entry input is-success' type='number' placeholder='{$zero}'
min='{$zero}' max='{$maxValues[$i]}' id='{$homeNameValues[$i]}' name='{$homeNameValues[$i]}'>
</div>
<div class='my_inline_divs m-1 p-1'>
<input class='my_small_num_entry input is-danger' type='number' required placeholder='{$zero}'
min='{$zero}' max='{$maxValues[$i]}' id='{$awayNameValues[$i]}' name='{$awayNameValues[$i]}'>
</div>
</div>";
}
?>
<!-- confirm accurate data panel -->
<div class="my_grey_highlight_para p-3">
<p>I have checked this match data is accurate prior to submitting</p>
<input required type="radio" id="yes_radio" name="confirmed_accurate"
class="control my_inline_divs ml-5 my-3 my_radio_button">
<label class="my_inline_divs ml-1 my_radio_button" for="yes_radio">Yes</label>
<input checked type="radio" id="no_radio" name="confirmed_accurate"
class="control my_inline_divs ml-5 my-3 my_radio_button">
<label class="my_inline_divs ml-1 my_radio_button" for="no_radio">No</label>
</div>
<!-- reset / submit button panel -->
<div class="columns is-mobile is-vcentered mt-2 mb-4">
<div class="column is-6 has-text-right mr-1">
<button type="reset" id="new_match_reset_button" class="button is-rounded is-info is-outlined">Reset Form</button>
</div>
<div class="column is-6 has-text-left ml-1">
<button type="submit" disabled name='submit_main_match' id="new_match_submit_button"
class="button mx-1 is-rounded is-info">
<span class="material-icons">send</span>
<span class='ml-3'>Submit</span>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<?php include(__DIR__ . "/part_pages/part_site_footer.php"); ?>
<script src="scripts/my_script.js"></script>
</body>
</html>