Skip to content

Commit 2e5b330

Browse files
committed
admin added
1 parent dbca5d3 commit 2e5b330

File tree

7 files changed

+355
-0
lines changed

7 files changed

+355
-0
lines changed

admin/forms/addCoordinator.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<form role="form" method="POST" class="addCoordinator-form">
2+
<input type="text" class="form-control" name="name" placeholder="Coordinator Name" required>
3+
<input type="email" class="form-control" name="email" placeholder="Email">
4+
<input type="text" class="form-control" name="phone" placeholder="Mobile Number" required>
5+
<div class="col-sm-4 category radio">
6+
<label>
7+
<input type="radio" name='category' value="1">SPLASH</label>
8+
<label>
9+
<input type="radio" name='category' value="2">QUANTA</label>
10+
<label>
11+
<input type="radio" name='category' value="3">ENDEAVOUR</label>
12+
</div>
13+
<div class="col-sm-8 dropdown editEvents-dropdown">
14+
<button class="btn btn-default dropdown-toggle" type="button" id="eventNames" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
15+
Select Event
16+
<span class="caret"></span>
17+
</button>
18+
<ul class="event-dropdown" aria-labelledby="eventCategory">
19+
</ul>
20+
</div>
21+
<input type="hidden" name="eventid">
22+
<button name="addCoordinator" type="submit" class="btn btn-default">Submit</button>
23+
</form>

admin/forms/addEvent.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<form role="form" method="POST" class="addEvent-form">
2+
<input type="text" class="form-control" name="id" placeholder="Enter Event ID" required>
3+
<input type="text" class="form-control" name="name" placeholder="Enter Event Name" required>
4+
<div class="dropdown eventCategory">
5+
<button class="btn btn-default dropdown-toggle" type="button" name="eventCategory" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
6+
Event Category
7+
<span class="caret"></span>
8+
</button>
9+
<ul class="dropdown-menu" aria-labelledby="eventCategory">
10+
<li><a id="1" href="#">SPLASH</a></li>
11+
<li><a id="2" href="#">QUANTA</a></li>
12+
<li><a id="3" href="#">ENDEAVOUR</a></li>
13+
<li><a id="4" href="#">ALUMNI</a></li>
14+
</ul>
15+
<input type="hidden" name="category">
16+
</div>
17+
<div class="quantaCategory">
18+
<div class="radio">
19+
<label>
20+
<input type="radio" name="radio" value="1">CONSTRUCTO</label>
21+
</div>
22+
<div class="radio">
23+
<label>
24+
<input type="radio" name="radio" value="2">CARRIAGE RETURN</label>
25+
</div>
26+
<div class="radio">
27+
<label>
28+
<input type="radio" name="radio" value="3">ROBO FIESTA</label>
29+
</div>
30+
</div>
31+
<div class="splashCategory">
32+
<div class="radio">
33+
<label>
34+
<input type="radio" name="radio" value="1">Indoor</label>
35+
</div>
36+
<div class="radio">
37+
<label>
38+
<input type="radio" name="radio" value="2">Outdoor</label>
39+
</div>
40+
</div>
41+
<textarea name="about" placeholder="About The Event" required></textarea>
42+
<textarea name="rules" placeholder="Event Rules" required></textarea>
43+
<textarea name="fees" placeholder="Event Fees" required></textarea>
44+
<!-- <input type="text" class="form-control" name="thumbnail" placeholder="Enter Thumb" required> -->
45+
<input type="text" class="form-control" name="venue" placeholder="Enter Venue" required>
46+
<textarea name="prize" placeholder="Event Prizes" required></textarea>
47+
<textarea name="coordinators" placeholder="Coordinator Names - Number" required></textarea>
48+
<button name="addEvent" type="submit" class="btn btn-default">Submit</button>
49+
</form>

admin/forms/editEvent.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div class="col-sm-4 category radio">
2+
<label>
3+
<input type="radio" name='category' value="1">SPLASH</label>
4+
<label>
5+
<input type="radio" name='category' value="2">QUANTA</label>
6+
<label>
7+
<input type="radio" name='category' value="3">ENDEAVOUR</label>
8+
<label>
9+
<input type="radio" name='category' value="4">ALUMNI</label>
10+
</div>
11+
<div class="col-sm-8 dropdown editEvents-dropdown">
12+
<button class="btn btn-default dropdown-toggle" type="button" id="eventNames" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
13+
Select Event
14+
<span class="caret"></span>
15+
</button>
16+
<ul class="event-dropdown" aria-labelledby="eventCategory">
17+
</ul>
18+
</div>
19+
20+
<form role="form" method="POST" class="editEvent-form">
21+
<input type="text" class="form-control disabled" name="id" placeholder="Enter Event ID">
22+
<input type="text" class="form-control" name="name" placeholder="Enter Event Name" required>
23+
<textarea name="about" placeholder="About The Event" required></textarea>
24+
<textarea name="rules" placeholder="Event Rules" required></textarea>
25+
<textarea name="fees" placeholder="Event Fees" required></textarea>
26+
<input type="text" class="form-control" name="thumbnail" placeholder="Enter Thumb" required>
27+
<textarea name="venue" placeholder="Enter Venue" required></textarea>
28+
<textarea name="prize" placeholder="Event Prizes" required></textarea>
29+
<textarea name="coordinators" placeholder="Coordinator Names - Number" required></textarea>
30+
<button name="editEvent" type="submit" class="btn btn-default">Submit</button>
31+
</form>

admin/functions.php

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
require_once '../inc/connection.php';
4+
5+
function addEvent($data) {
6+
global $db;
7+
$id = $data['id'];
8+
$name = $data['name'];
9+
$category = $data['category'];
10+
if (isset($data['radio'])) {
11+
$type = $data['radio'];
12+
} else {
13+
$type = 0;
14+
}
15+
$about = $data['about'];
16+
$rules = $data['rules'];
17+
$fees = $data['fees'];
18+
$venue = $data['venue'];
19+
$prize = $data['prize'];
20+
$coordinators = $data['coordinators'];
21+
$title = strtolower(str_replace(' ', '-', $name));
22+
23+
$sql = 'INSERT INTO `events` (id, name, category, type, title) VALUES (:id, :name, :category, :type, :title)';
24+
$q = $db->prepare($sql);
25+
$q->execute(array(':id' => $id,
26+
':name' => $name,
27+
':category' => $category,
28+
':type' => $type,
29+
':title' => $title,
30+
));
31+
32+
if ($category == 1) {
33+
$thumbnail = 'splash/';
34+
} elseif ($category == 2) {
35+
$thumbnail = 'quanta/';
36+
} elseif ($category == 3) {
37+
$thumbnail = 'endeavour/';
38+
} elseif ($category == 4) {
39+
$thumbnail = 'alumni/';
40+
}
41+
$thumbnail .= $title.'.png';
42+
43+
$sql = 'INSERT INTO `eventdetails` (id, about, rules, fees, thumbnail, venue, prize, coordinators) VALUES (:id, :about, :rules, :fees, :thumbnail, :venue, :prize, :coordinators)';
44+
$q = $db->prepare($sql);
45+
$q->execute(array(':id' => $id,
46+
':about' => $about,
47+
':rules' => $rules,
48+
':fees' => $fees,
49+
':thumbnail' => $thumbnail,
50+
':venue' => $venue,
51+
':prize' => $prize,
52+
':coordinators' => $coordinators,
53+
));
54+
}
55+
56+
function editEvent($data) {
57+
global $db;
58+
$id = $data['id'];
59+
$name = $data['name'];
60+
$about = $data['about'];
61+
$rules = $data['rules'];
62+
$fees = $data['fees'];
63+
$thumbnail = $data['thumbnail'];
64+
$venue = $data['venue'];
65+
$prize = $data['prize'];
66+
$coordinators = $data['coordinators'];
67+
68+
$sql = 'UPDATE `events` SET name=:name WHERE id=:id';
69+
$q = $db->prepare($sql);
70+
$q->execute(array(':name' => $name,
71+
':id' => $id,
72+
));
73+
74+
$sql = 'UPDATE `eventdetails` SET about=:about, rules=:rules, fees=:fees, thumbnail=:thumbnail, venue=:venue, prize=:prize, coordinators=:coordinators WHERE id=:id';
75+
$q = $db->prepare($sql);
76+
$q->execute(array(':about' => $about,
77+
':rules' => $rules,
78+
':fees' => $fees,
79+
':thumbnail' => $thumbnail,
80+
':venue' => $venue,
81+
':prize' => $prize,
82+
':id' => $id,
83+
':coordinators' => $coordinators,
84+
));
85+
}
86+
87+
function addCoordinator($data) {
88+
global $db;
89+
$name = $data['name'];
90+
$email = $data['email'];
91+
$phone = $data['phone'];
92+
$eventid = $data['eventid'];
93+
94+
$sql = 'INSERT INTO `coordinators` (name, email, phone, eventid) VALUES (:name, :email, :phone, :eventid)';
95+
$q = $db->prepare($sql);
96+
$q->execute(array(':name' => $name,
97+
':email' => $email,
98+
':phone' => $phone,
99+
':eventid' => $eventid,
100+
));
101+
}

admin/index.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
//require_once 'functions.php';
3+
if (isset($_POST['addEvent'])) {
4+
addEvent($_POST);
5+
} elseif (isset($_POST['editEvent'])) {
6+
editEvent($_POST);
7+
} elseif (isset($_POST['addCoordinator'])) {
8+
addCoordinator($_POST);
9+
}
10+
?>
11+
<!DOCTYPE html>
12+
<html>
13+
<head>
14+
<meta charset="utf-8">
15+
<meta name="robots" content="noindex,nofollow">
16+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
17+
<meta name="viewport" content="width=device-width, initial-scale=1">
18+
<title>ADMIN | Renaissance 16</title>
19+
<link href='../assets/css/bootstrap.min.css' rel=stylesheet />
20+
<link href='style.css' rel=stylesheet />
21+
</head>
22+
<body>
23+
<br>
24+
<div class="container">
25+
26+
<!-- Nav tabs -->
27+
<ul class="nav nav-tabs" role="tablist">
28+
<li role="presentation" class="active"><a href="#addEvent" aria-controls="addEvent" role="tab" data-toggle="tab">Add Event</a></li>
29+
<li role="presentation"><a href="#editEvent" aria-controls="editEvent" role="tab" data-toggle="tab">Edit Event</a></li>
30+
</ul>
31+
<br>
32+
<!-- Tab panes -->
33+
<div class="tab-content">
34+
<div role="tabpanel" class="tab-pane fade in active" id="addEvent">
35+
<?php include 'forms/addEvent.html'; ?>
36+
</div>
37+
<div role="tabpanel" class="tab-pane fade" id="editEvent">
38+
<?php include 'forms/editEvent.html'; ?>
39+
</div>
40+
</div>
41+
42+
</div>
43+
44+
<script src='../assets/js/jquery-1.11.2.min.js'></script>
45+
<script src='../assets/js/bootstrap.min.js'></script>
46+
<script src='script.js'></script>
47+
</body>
48+
</html>

admin/script.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
$('#myTabs a').click(function(e) {
2+
e.preventDefault()
3+
$(this).tab('show')
4+
});
5+
6+
/* addEvent */
7+
$(".eventCategory .dropdown-menu li a").click(function() {
8+
$(".eventCategory .btn:first-child").html($(this).text() + ' <span class="caret"></span>');
9+
$(".eventCategory .btn:first-child").val($(this).text());
10+
if ($(this).text() == 'QUANTA') {
11+
$('.quantaCategory').show();
12+
$('.splashCategory').hide();
13+
} else if ($(this).text() == 'SPLASH') {
14+
$('.splashCategory').show();
15+
$('.quantaCategory').hide();
16+
} else {
17+
$('.quantaCategory').hide();
18+
$('.splashCategory').hide();
19+
}
20+
});
21+
22+
$(document).ready(function() {
23+
$(".eventCategory .dropdown-menu li a").click(function() {
24+
id = $(this).closest("li a").attr('id');
25+
$(".addEvent-form input[name='category']").val(id);
26+
});
27+
});
28+
29+
/* editEvent */
30+
$(".event-dropdown").on('click', 'a', function() {
31+
var event = $(this).text();
32+
var eventID = $(this).attr('id');
33+
34+
$(".editEvents-dropdown .btn:first-child").html(event + ' <span class="caret"></span>');
35+
$(".editEvents-dropdown .btn:first-child").val(event);
36+
37+
$.getJSON("/api/events/" + eventID, function(data) {
38+
for (key in data) {
39+
if (data.hasOwnProperty(key)) {
40+
$('.editEvent-form input[name=' + key + ']').val(data[key]);
41+
$('.editEvent-form textarea[name=' + key + ']').val(data[key]);
42+
}
43+
}
44+
$('.editEvent-form').fadeIn();
45+
});
46+
});
47+
$(".radio input[type='radio']").click(function() {
48+
var that = $(this);
49+
var id = that.val();
50+
51+
$('.editEvent-form').fadeOut();
52+
$('#event-dropdown').html('');
53+
$('.editEvents-dropdown .dropdown-toggle').html('loading...');
54+
55+
$.getJSON("/api/events/categories/" + id, function(data) {
56+
var items = [];
57+
events = data['events'];
58+
$.each(events, function(key, val) {
59+
items.push("<li><a id='" + val.id + "' href='#'>" + val.name + "</a></li>");
60+
});
61+
62+
$('.editEvents-dropdown .dropdown-toggle').html(data['details'].name + ' Events <span class="caret"></span>');
63+
$('.event-dropdown').addClass('dropdown-menu');
64+
$('.event-dropdown').html(items);
65+
66+
});
67+
});
68+
69+
/* addCoordinator */
70+
$(".addCoordinator-form .event-dropdown").on('click', 'a', function(e) {
71+
var eventID = $(this).attr('id');
72+
$(".addCoordinator-form input[name='eventid']").val(eventID);
73+
});

admin/style.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
form input, form div, form button, form textarea {
2+
margin-bottom: 10px;
3+
}
4+
form textarea {
5+
min-width: 100%;
6+
}
7+
.quantaCategory, .splashCategory {
8+
display: none;
9+
}
10+
.quantaCategory .radio, .splashCategory .radio {
11+
display: inline;
12+
margin-left: 10px;
13+
}
14+
#editEvent label {
15+
display: inline-block;
16+
margin-right: 10px;
17+
}
18+
#editEvent .dropdown-toggle {
19+
width: 100%;
20+
}
21+
.open>.dropdown-menu {
22+
width: 100%;
23+
}
24+
.editEvent-form {
25+
display: none;
26+
}
27+
.disabled {
28+
background-color: #EEEEEE;
29+
cursor: not-allowed;
30+
}

0 commit comments

Comments
 (0)