-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.php
More file actions
316 lines (307 loc) · 17.7 KB
/
Copy pathtasks.php
File metadata and controls
316 lines (307 loc) · 17.7 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
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
<?php
session_start();
include 'config.php';
$sql = "SELECT * FROM tasks";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<?php include 'head.php'; ?>
<!-- data table -->
<script>
$(document).ready(function() {
$('#tabletasks').DataTable({
columnDefs: [
{ "targets": [0], "searchable": false, "orderable": false} ,{"visible": true }
],
order: [[ 1,'asc']],
"oLanguage": {
"sEmptyTable": "no data found tasks admin"
},
language: {
search:"",
searchPlaceholder: "Search",
paginate: {
previous: '<span class="fa fa-chevron-left"></span>',
next: '<span class="fa fa-chevron-right"></span>'
},
lengthMenu: 'Show <select class="form-control input-sm">'+
'<option value="10">10</option>'+
'<option value="20">20</option>'+
'<option value="30">30</option>'+
'<option value="40">40</option>'+
'<option value="50">50</option>'+
'<option value="-1">All</option>'
}
})
} );
</script>
<body id="page-top">
<div id="wrapper" >
<?php include 'navbar.php'; ?>
<div class="d-flex flex-column" id="content-wrapper">
<div id="content">
<?php include 'header.php'; ?>
<div class="container-fluid">
<div class="d-sm-flex justify-content-between align-items-center mb-2">
<h3 class="text-dark mb-4 fw-bold">tasks</h3>
<a class="btn btn-primary btn-sm d-none d-sm-inline-block " role="button" href="#"><i class="fas fa-download fa-sm text-white-50"></i> Export</a>
</div>
<div class="card shadow">
<div class="card-header py-3 flex-row justify-content-between align-items-center">
<div class="col-auto float-start pt-2">
<p class="text-primary fw-bold">tasks info</p>
</div>
<div class="btn-group float-end" role="group">
<button id="add-btn" type="button" class="btn btn-primary" >Add</button>
<button id="edit-btn" type="button"class="btn btn-primary" >Edit</button>
<button id="delete-btn" type="button"class="btn btn-primary" >Delete</button>
</div>
</div>
<div class="card-body">
<div class="table-responsive table mt-2" id="dataTable" role="grid" >
<table class="table my-0 table-striped" id="tabletasks">
<thead>
<tr>
<th style="width: 10%;" ></th>
<th>task name</th>
<th>teacher task</th>
<th>task started</th>
<th>task deadline</th>
<th>description</th>
<th>task status</th>
<th>action</th>
</tr>
</thead>
<tbody>
<?php
while($row = $result->fetch_assoc()) {
$description = $row["description"];
$shortDescription = substr($description, 0, 15);
if (strlen($description) > 15) {$shortDescription .= "...";}
echo '<tr><td><input class="form-check-input" type="checkbox" /></td>
<td>' . $row["task_title"].
"</td><td>" . $row["teachertask_name"].
"</td><td>" . $row["task_started"].
"</td><td>" . $row["task_deadline"].
"</td><td>" . $shortDescription ."</td>".
"</td><td>" . $row["status"].
"<td>
<button type=\"button\" class=\"btn\" ><i class=\"fa-sharp fa-solid fa-pen-to-square\"></i> view</button>
</td>
</tr>";
}
?>
</tbody>
<tfoot>
<tr>
<td class="col" ><input id="check-all" class="form-check-input" type="checkbox" /> Check All</td>
<td><strong>task name</strong></td>
<td><strong>teacher task</strong></td>
<td><strong>task started</strong></td>
<td><strong>task deadline</strong></td>
<td><strong>description</strong></td>
<td><strong>task status</strong></td>
<td><strong>action</strong></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<footer class="bg-white sticky-footer">
<div class="container my-auto">
<div class="text-center my-auto copyright"><span>Copyright ©2023 devlopped By Med Arafet khadraoui</span></div>
</div>
</footer>
</div>
</div>
<a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a>
</div>
</div>
<div id="popup" >
<div id="popupadd">
<div class="modal fade" id="popup-add" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Item</h5>
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal"></button>
</div>
<form id="addTaskForm" method="POST" action="addtask.php">
<div class="modal-body">
<div class="mb-3">
<label for="taskName" class="form-label">Task Name</label>
<input type="text" class="form-control" id="taskName" name="taskName" value="" required>
</div>
<div class="mb-3">
<label for="taskStarted" class="form-label">Task Started</label>
<input type="date" class="form-control" id="taskStarted" name="taskStarted" value="" required>
</div>
<div class="mb-3">
<label for="taskDeadline" class="form-label">Task Deadline</label>
<input type="date" class="form-control" id="taskDeadline" name="taskDeadline" value="" required>
</div>
<div class="mb-3">
<label for="taskDescription" class="form-label">Task Description</label>
<textarea class="form-control" id="taskDescription" name="taskDescription" required></textarea>
</div>
<div class="mb-3">
<label for="teachergroups" class="form-label" >Groups</label>
<select id="teachergroups" name="group_ids[]" class="form-control" multiple >
<?php
$sql3 = "SELECT * FROM groupes";
$result3 = $conn->query($sql3);
if ($result3->num_rows > 0) {
while($row3 = $result3->fetch_assoc()) {
echo '<option value="'.$row3["id"].'">'.$row3["name"].'</option>';
}
} else {
echo "<option value='0'>0 results</option>";
}
?>*
</select>
</div>
</div>
<div class="modal-footer">
<div id="message" class=" alert" ></div>
<div >
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" value="Submit">Save changes</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="popupedit">
<div class="modal fade" id="popup-edit" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">edit Item</h5>
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal"></button>
</div>
<form id="editTaskForm" method="POST" action="editTask.php">
<div class="modal-body">
<div class="mb-3">
<label for="taskNameEdit" class="form-label">Task Name</label>
<input type="text" class="form-control" id="taskNameEdit" name="taskNameEdit" value="" required>
</div>
<div class="mb-3">
<label for="taskStartedEdit" class="form-label">Task Started</label>
<input type="date" class="form-control" id="taskStartedEdit" name="taskStartedEdit" value="" required>
</div>
<div class="mb-3">
<label for="taskDeadlineEdit" class="form-label">Task Deadline</label>
<input type="date" class="form-control" id="taskDeadlineEdit" name="taskDeadlineEdit" value="" required>
</div>
<div class="mb-3">
<label for="taskDescriptionEdit" class="form-label">Task Description</label>
<textarea class="form-control" id="taskDescriptionEdit" name="taskDescriptionEdit" required></textarea>
</div>
<div class="mb-3">
<label for="teachergroupsEdit" class="form-label" >Groups</label>
<select id="teachergroupsEdit" name="group_ids[]" class="form-control" multiple >
<?php
$sql3 = "SELECT * FROM groupes";
$result3 = $conn->query($sql3);
if ($result3->num_rows > 0) {
while($row3 = $result3->fetch_assoc()) {
echo '<option value="'.$row3["id"].'">'.$row3["name"].'</option>';
}
} else {
echo "<option value='0'>0 results</option>";
}
?>*
</select>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" value="Submit">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="popupdelete" >
<div class="modal fade" id="staticBackdrop" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<h6>are you sure to delete </h6>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" id="delete-btn" class="btn btn-primary">delete</button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
document.getElementById('check-all').addEventListener('change', function() {
var checkboxes = document.querySelectorAll('.form-check-input');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = this.checked;
}
});
$('#add-btn').click(function() {
$('#taskName').val('');
$('#taskStarted').val('');
$('#taskDeadline').val('');
$('#taskDescription').val('');
$('#message').html('');
$('#popup-add').modal('show');
});
$('#edit-btn').click(function() {
var checkbox = $('input[type="checkbox"]:checked');
if(checkbox.length === 1) {
var row = checkbox.closest('tr');
var taskName = row.find('td:eq(1)').text();
var taskStarted = row.find('td:eq(3)').text();
var taskDeadline = row.find('td:eq(4)').text();
var taskDescription = row.find('td:eq(5)').text();
$('#popup-edit').modal('show');
$('#taskNameEdit').val(taskName);
$('#taskStartedEdit').val(taskStarted);
$('#taskDeadlineEdit').val(taskDeadline);
$('#taskDescriptionEdit').val(taskDescription);
}
else if(checkbox.length > 1){
alert('select just one row');
}
else {
alert('No row selected');
}
});
$('#delete-btn').click(function() {
var checkboxes = $('input[type="checkbox"]:checked');
if(checkboxes.length > 0) {
if(confirm('Are you sure you want to delete ')) {
checkboxes.each(function() {
var row = $(this).closest('tr');
var taskName = row.find('td:eq(1)').text();
$.ajax({
url: 'deletetask.php',
type: 'POST',
data: { name: taskName },
success :function(response){
location.reload();
}
});
});
}
} else {
alert('No row selected');
}
});
</script>
</html>