forked from Kazeeem/Mini-classroom-php-version
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-items.php
More file actions
159 lines (148 loc) · 5.58 KB
/
add-items.php
File metadata and controls
159 lines (148 loc) · 5.58 KB
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
<?php
include 'lib/Session.php';
Session::checkTeacherSession();
spl_autoload_register(function($class){
include_once "classes/".$class.".php";
});
$class = new ClassApp();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="icon" href="Mini-class App designs/mathisi logo.png" type="image/png">
<link rel="stylesheet" href="css/addItems.css">
<title>Add items</title>
<style type="text/css">
.success {
background: #274970;
color: white;
padding: 10px;
z-index: 30;
width: 100%;
margin: 40px auto;
}
.error {
background: #C63305;
color: white;
padding: 10px;
z-index: 30;
width: 100%;
margin: 40px auto;
}
.add {
color: #fff;
padding: 20px;
display: block;
text-decoration: none;
font-size: 20px;
}
.greeting {
color: #C63305;
}
.select-item {
display: inline-block;
text-decoration: none;
background-color: #C63305;
color: #000;
padding: 12px 15px;
border-radius: 30px;
color: #fff;
}
</style>
</head>
<body>
<?php
if (isset($_GET['action']) && $_GET['action'] == 'logout') {
Session::destroy();
}
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit'])) {
$addItem = $class->addNewItem($_POST, $_FILES);
}
?>
<header>
<a href="index.html"><img src="Mini-class App designs/Logo.svg" class="logo" alt="Logo" width="15%"></a>
<a href="?action=logout" class="sign-out-btn">Sign Out</a>
</header>
<main>
<div class="container">
<div class='row'>
<div class='column'>
<div class='column-left'>
<!-- greeting -->
<h4 class="greeting">
Hello teacher <?php echo Session::get('teacherName'); ?>!
</h4>
<!-- End of greeting -->
<h2>Add Items</h2>
<!-- success/error message -->
<?php
if (isset($addItem)) {
echo $addItem;
}
?>
<form action="" method="post" enctype="multipart/form-data">
<!-- Select class drop down menu -->
<select class="choose-item" name="classId" required>
<option>Select Class</option>
<!-- get all classes -->
<?php
$getAllClasses = $class->selectAllClasses();
if ($getAllClasses) {
while ($result = $getAllClasses->fetch_assoc()) {
?>
<option value="<?php echo $result['id']; ?>"><?php echo $result['class_name']; ?></option>
<?php } } ?>
</select>
<br>
<!-- select file to add to class -->
<div style="margin-top: 15px;">
<input type="file" name="classFile" class="select-item" accept=".pdf, .doc, .ppt" required>
</div>
<div class="btn">
<button name="submit" class="add-btn">Add Item</button>
</div>
</form>
<!-- Back button -->
<!-- <a href="create-class.php" class="add-btn"><< Back</a> -->
</div>
</div>
<div class="line"></div>
<div class='column'>
<div class='column-right'>
<table id="items" class="main-section">
<tr>
<th>Class</th>
<th>Item(s)</th>
</tr>
<?php
$getAllClasses2 = $class->selectAllClasses();
if ($getAllClasses2) {
while ($result2 = $getAllClasses2->fetch_assoc()) {
?>
<tr>
<td><?php echo $result2['class_name']; ?></td>
<?php
// id from the class table
$id2 = $result2['id'];
// we use the id to get the number of items on each class
$getAllItems = $class->selectAllItemsOfaClass($id2);
$count = $getAllItems->fetch_array();
?>
<td class="mr"><?php echo $count['items_count']; ?></td>
</tr>
<?php } } ?>
<tr class="last">
<td></td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</main>
</body>
</html>