-
Notifications
You must be signed in to change notification settings - Fork 1
/
createEvent.php
342 lines (286 loc) · 14.2 KB
/
createEvent.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
331
332
333
334
335
336
337
338
339
340
341
342
<?php
require_once("scripts/func.php");
connectToDb();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSH - RIDE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="../bootstrap/timepicker/compiled/timepicker.css" type="text/css" rel="stylesheet" />
<link href="../bootstrap/datepicker/css/datepicker.css" rel="stylesheet">
<style type="text/css">
body {<link rel="stylesheet" type="text/css" href="">
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Le fav and touch icons -->
<script>$('.timepicker-default').timepicker();</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.php">RIDE</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="index.php?r=1">Home</a></li>
<li><a href="selectEvent.php?type=join">Current Events</a></li>
<li><a href="userDetails.php">User Details</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<?php
if($_GET['edit']==1)
{
//get info from database for form fields
$eventId = $_GET['eventId'];
$query = "SELECT * FROM `kevin_ride`.`eventList` WHERE `eventList`.`id` = $eventId";
//echo $query;
$eventTable = mysql_query($query);
$event = mysql_fetch_array( $eventTable );
$eventDepartStart = $event['depatrueStart'];
$eventDepartStartTimeStamp = strtotime($eventDepartStart);
$eventDepartStartTime = date("h:i A",$eventDepartStartTimeStamp);
$eventDepartEnd = $event['depatrueEnd'];
$eventDepartEndTimeStamp = strtotime($eventDepartEnd);
$eventDepartEndTime = date("h:i A",$eventDepartEndTimeStamp);
$currentTime = date_create();
$currentTimeStamp = 0;//date_timestamp_get($date); Causes warning. Removed but works without.
// echo $currentTimeStamp;
}
?>
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="hero-unit">
<?php
//Print sussess messae if user was removed susessfully
//1 = Event Created Suc
$eData = $_GET['e']; //Success messages
$eeData = $_GET['ee']; //Error Messages
$outputE = array("Event Created Sucessfully","Event Updated Sucessfully");
$outputEE = array("");
if($eData<=0)
{
}
else
{
echo '<table class="table table-condensed" align="center">
<tr class="success">
<td>'.$outputE[$eData-1].'</td>
</tr>
</table>';
}
if($eeData<=0)
{
}
else
{
echo '<table class="table table-condensed" align="center">
<tr class="error">
<td>'.$outputEE[$eeData-1].'</td>
</tr>
</table>';
}
?>
<table class="table table-condensed" align="center" style="display:none;" id="pastWarning">
<tr class="warning">
<td>Warning: Event Starts in past</td>
</tr>
</table>
<table class="table table-condensed" align="center" style="display:none;" id="endDateError">
<tr class="error">
<td>ERROR: End date cannot be before start date</td>
</tr>
</table>
<form ACTION=<?php if($_GET['edit']==1) {echo "scripts/sEditEvent.php";}else{echo 'scripts/sCreateEvent.php';} ?> METHOD="post">
<input type="hidden" name="eventId" value="<?php echo $event['id'];?>">
<legend>Creating An Event:</legend>
<label>Event Name</label>
<input name="eventName" type="text" placeholder="Event Name" value="<?php if($_GET['edit']==1) {echo $event['eventName'];} ?>">
<label>Description</label>
<textarea rows="2" cols="20" name="description"><?php if($_GET['edit']==1) {echo $event['description'];} ?></textarea>
<label class="checkbox">
<!--<input type="checkbox" name="campingTrip" <?php //if($event['isCamping']==1){echo 'checked'; }?>>Camping Trip
</label>
<span class="help-block">Adds ability to create/join tents as well as rides. (Fall Camping)</span> -->
<label><h5>Event Time: </h5></label>
<div style="margin-left:15px"> <label>Event Start Time: </label>
<div class="input-append date" onmouseover="validDates()" id="dp2" data-date="<?php if($_GET['edit']==1) {echo (date('m-d-Y',$eventDepartStartTimeStamp));} else {echo (date('m-d-Y'));} ?>"data-date-format="mm-dd-yyyy">
<input class="span2" size="16" id="startDate" onchange="validDates()" onfocus="validDates()" type="text" value="<?php if($_GET['edit']==1) {echo (date('m-d-Y',$eventDepartStartTimeStamp));} else {echo (date('m-d-Y'));} ?>" readonly name="startDate">
<span class="add-on" ><i class="icon-th"></i></span>
</div>
<div class="input-append bootstrap-timepicker-component">
<input type="text" onchange="validDates()" class="timepicker-1 input-small" name="startTime" id="startTime">
<span class="add-on" onmouseover="validDates()">
<i class="icon-time" onmouseover="validDates()"></i>
</span>
</div>
</div>
<div style="margin-left:15px"> <label>Event End Time: </label>
<div class="input-append date" onmouseover="validDates()" onchange="validDates()" id="dp3" data-date="<?php if($_GET['edit']==1) {echo (date('m-d-Y',$eventDepartEndTimeStamp));} else { echo (date('m-d-Y')); }?>" data-date-format="mm-dd-yyyy">
<input class="span2" size="16" type="text" id="endDate" value="<?php if($_GET['edit']==1) {echo (date('m-d-Y',$eventDepartEndTimeStamp));} else { echo (date('m-d-Y')); }?>" readonly name="endDate">
<span class="add-on"><i class="icon-th"></i></span>
</div>
<div class="input-append bootstrap-timepicker-component">
<input type="text" onchange="validDates()" class="timepicker-2 input-small" name="endTime" id="endTime">
<span class="add-on" onmouseover="validDates()">
<i class="icon-time" onmouseover="validDates()" ></i>
</span>
</div>
</div>
<br>
<div id="dynamicInput" style="margin-left:15px" ></div>
<button type="submit" id="submit1" onmouseover="validDates()" class="btn btn-<?php if($_GET['edit']==1) {echo "info";} else {echo 'primary';} ?> btn-large"><?php if($_GET['edit']==1) {echo "Edit";} else {echo 'Create';} ?> Event»</button>
</form>
</div>
<hr>
<!--<input type="text" id="test">
<input type="button" onclick="validDates()" value="123"> -->
<footer>
<p>Created by Kevin J Dolan</p>
</footer>
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../bootstrap/js/jquery.js"></script>
<script src="../bootstrap/js/bootstrap.js"></script>
<!-- <script src="../bootstrap/js/bootstrap-alert.js"></script>
<script src="../bootstrap/js/bootstrap-modal.js"></script>
<script src="../bootstrap/js/bootstrap-dropdown.js"></script>
<script src="../bootstrap/js/bootstrap-scrollspy.js"></script>
<script src="../bootstrap/js/bootstrap-tab.js"></script>
<script src="../bootstrap/js/bootstrap-tooltip.js"></script>
<script src="../bootstrap/js/bootstrap-popover.js"></script>
<script src="../bootstrappjs/bootstrap-button.js"></script>
<script src="../bootstrap/js/bootstrap-collapse.js"></script>
<script src="../bootstrap/js/bootstrap-carousel.js"></script>-->
<script src="../bootstrap/timepicker/js/bootstrap-timepicker.js"></script>
<script src="../bootstrap/datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript">
function validDates()
{
var test = document.getElementById("test");
var submitButton = document.getElementById("submit1");
var startDate = document.getElementById("startDate");
var startTime = document.getElementById("startTime");
var endDate = document.getElementById("endDate");
var endTime = document.getElementById("endTime");
var pastWarning = document.getElementById("pastWarning");
var endDateError = document.getElementById("endDateError");
var startDateTime = new Date(startDate.value+" "+startTime.value)
var endDateTime = new Date(endDate.value+" "+endTime.value)
var today = new Date();
if(endDateTime<startDateTime)
{
pastWarning.style.display="none";
endDateError.style.display="";
submitButton.disabled=true;
}
else if(startDateTime<today)
{
//past
pastWarning.style.display="";
endDateError.style.display="none";
submitButton.disabled=false;
}
else
{
pastWarning.style.display="none";
endDateError.style.display="none";
submitButton.disabled=false;
}
}
</script>
<?php
$date = new DateTime();
$currentTimeStamp = $date->getTimestamp();
$prev = $date->getTimestamp() - ($date->getTimestamp() % 1800);
$currentTimeStamp = $prev + 1800;
?>
<script type="text/javascript">
$(document).ready(function () {
$('.timepicker-default').timepicker();
$('.timepicker-1').timepicker({
minuteStep: 1,
showSeconds: false,
showMeridian: true,
defaultTime: <?php if($_GET['edit']==1) {echo "'".$eventDepartStartTime."'";} else {echo "'".(date('h:i A',$currentTimeStamp+1))."'";} ?>
});
$('.timepicker-2').timepicker({
minuteStep: 1,
showSeconds: false,
showMeridian: true,
defaultTime: <?php if($_GET['edit']==1) {echo "'".$eventDepartEndTime."'";} else {echo "'".(date('h:i A',$currentTimeStamp+5400))."'";} ?>
});
$('.timepicker-3').timepicker({
minuteStep: 1,
secondStep: 5,
showInputs: false,
template: 'modal',
modalBackdrop: true,
showSeconds: true,
showMeridian: false
});
$('.timepicker-4').timepicker({
template: false,
showInputs: false,
minuteStep: 5
});
});
</script>
<script>
$(function(){
window.prettyPrint && prettyPrint();
$('#dp1').datepicker({
format: 'mm-dd-yyyy'
});
$('#dp2').datepicker();
$('#dp3').datepicker();
var startDate = new Date(2012,1,20);
var endDate = new Date(2012,1,25);
$('#dp4').datepicker()
.on('changeDate', function(ev){
if (ev.date.valueOf() > endDate.valueOf()){
$('#alert').show().find('strong').text('The start date can not be greater then the end date');
} else {
$('#alert').hide();
startDate = new Date(ev.date);
$('#startDate').text($('#dp4').data('date'));
}
$('#dp4').datepicker('hide');
});
$('#dp5').datepicker()
.on('changeDate', function(ev){
if (ev.date.valueOf() < startDate.valueOf()){
$('#alert').show().find('strong').text('The end date can not be less then the start date');
} else {
$('#alert').hide();
endDate = new Date(ev.date);
$('#endDate').text($('#dp5').data('date'));
}
$('#dp5').datepicker('hide');
});
});
</script>
</body>
</html>