-
Notifications
You must be signed in to change notification settings - Fork 1
/
createEvent.php
303 lines (251 loc) · 14.5 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
<!DOCTYPE html>
<?php
session_start();
//if (!isset($_SESSION['id'])) {
// header("location:login.html");
//}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>MSP| Schedule management</title>
<!-- Bootstrap Core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="dist/css/sb-admin-2.css" rel="stylesheet">
<style>
.error {
color: #F00;
background-color: #FFF;
}
</style>
<!-- Custom Fonts -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="wrapper">
<?php
include("template/top.php");
?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Add Event</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<div id="page-content">
<?php
include('private/conn.php');
?>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Add a new Event
</div>
<div class="panel-body ">
<div class="row">
<div class="col-lg-6">
<div name="error" id="error">
</div>
<form role="form" method="POST" id="create_event_form" name="create_event_form" action="insertEvent.php">
<div class="form-group">
<label>Event Name</label>
<input name="event_name" class="form-control" type="text">
</div>
<div class="form-group">
<label>Description</label>
<textarea name="description" class="form-control" type="text" rows="6" cols="4"></textarea>
</div>
<div class="form-group">
<label>Date</label>
<input name="event_date" class="form-control" type="date" data-provide="datepicker">
</div>
<div class="form-group">
<label>Start Time</label>
<div class="input-group clockpicker">
<input name="start_time" type="time" class="form-control" value="09:30">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
<div class="form-group">
<label>End Time</label>
<div class="input-group clockpicker">
<input name="end_time" type="time" class="form-control" value="09:30">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
<div class="form-group">
<label>Category</label>
<select name="category" class="form-control">
<?php
$result = $db->get_results("select * from event_category;");
foreach ($result as $value) {
?>
<option value="<?php echo $value->category_name; ?>"><?php echo $value->category_name; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label>Venue</label>
<input name="venue" class="form-control" type="text">
</div>
<div class="text-center">
<button type="submit" id="btn_submit" class="btn btn-lg btn-primary">Submit Button</button>
</div>
</form>
</div>
<!-- /.col-lg-6 (nested) -->
<div class="col-lg-3"></div>
</div>
<!-- /.col-lg-6 (nested) -->
</div>
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
<?php
include("template/bottomScripts.php");
?>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script>
$('document').ready(function ()
{
/* validation */
$("#create_event_form").validate({
rules:
{
event_name: {
required: true,
minlength: 3
},
description: {
required: true,
},
start_time: {
required: true
},
end_time: {
required: true
},
event_date: {
required: true,
date: true
},
venue: {
required: true
}
},
messages:
{
event_name:
{
required:"Event Name is required",
minlength: "Event Name is required"
},
description: {
required: "Please provide Event Description(Minimum 20 Chars)"
},
event_date:
{
date:"Enter a Valid Date",
required: "Event Date is Required"
},
start_time: {
required: "Event start time is required"
},
end_time:
{
required: "Event ending time is required."
},
venue:
{
required:"Venue details are required."
}
},
submitHandler: submitForm
});
/* validation */
$.validator.addMethod("date", function(value, element) {
var curDate = new Date();
var inputDate = new Date(value);
if (inputDate >= curDate)
return true;
return false;
}, "Invalid Date!"); // error message
$("#frm").validate({
rules: {
}
});
/* form submit */
function submitForm()
{
var data = $("#create_event_form").serialize();
$.ajax({
type: 'POST',
url: 'insertEvent.php',
data: data,
beforeSend: function ()
{
$("#error").fadeOut();
$("#btn_submit").html('<span class="glyphicon glyphicon-transfer"></span> Adding Event ...');
},
success: function (data)
{
if (data === "EventInserted")
{
$("#btn_submit").html('Signing Up');
setTimeout('$(".form-signin").fadeOut(500, function(){ $(".signin-form").load("template/successReg.php"); }); ', 5000);
alert("Event Submitted Successfully");
window.location.href = "./index.php";
} else {
$("#error").fadeIn(1000, function () {
$("#error").html('<div class="alert alert-danger"><span class="glyphicon glyphicon-info-sign"></span> ' + data + ' !</div>');
$("#btn_submit").html('<span class="glyphicon glyphicon-log-in"></span> Create Account');
});
}
}
});
return false;
}
/* form submit */
});
</script>
</div>
</div>
</div>
<script>
function loadDoc(filename) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
document.getElementById("page-content").innerHTML = this.responseText;
}
};
xhttp.open("GET", "component/" + filename, true);
xhttp.send();
}
</script>
</body>
</html>