Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
990 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,310 @@ | ||
<div class="row mt-4"> | ||
<div class="col-md-8 mx-auto"> | ||
<h3 class="float-start">Engineers</h3> | ||
<button type="button" class="btn btn-primary float-end mb-2" data-bs-toggle="modal" data-bs-target="#addModal"> | ||
New engineer | ||
</button> | ||
<div style="clear: both"></div> | ||
<?php | ||
|
||
|
||
if (isset($_POST['addEngineer'])) { | ||
engineer::add($_POST['name'], $_POST['category'], $_POST['email'], $_POST['password']); | ||
} | ||
|
||
if (isset($_POST['editEngineer'])) { | ||
engineer::edit($_POST['id'], $_POST['name'], $_POST['category'], $_POST['email']); | ||
} | ||
|
||
if (isset($_POST['removeEngineer'])) { | ||
engineer::remove($_POST['id']); | ||
} | ||
|
||
if (isset($_POST['addSchedule'])) { | ||
if (isset($_POST['aircraft_id']) && isset($_POST['engineer_id'])) { | ||
schedule::add($_POST['aircraft_id'], $_POST['engineer_id'], $_POST['task'], true); | ||
}else { | ||
respond::alert('warning', '', 'All fields are required'); | ||
} | ||
} | ||
|
||
if (isset($_POST['removeSchedule'])) { | ||
engineer::removeSchedule($_POST['id']); | ||
} | ||
|
||
$engineers = engineer::all(); | ||
|
||
?> | ||
<div class="card"> | ||
<?php | ||
|
||
if ($engineers) { | ||
?> | ||
<table class="table table-hover table-striped card-body mb-0"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Email address</th> | ||
<th>Category</th> | ||
<th>Maintenance</th> | ||
<th>Date added</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php | ||
foreach ($engineers as $engineer) { | ||
$date = new DateTime($engineer['createdAt']); | ||
$engineer_id = $engineer['id']; | ||
$name = $engineer['name']; | ||
$email = $engineer['email']; | ||
// h:i A | ||
?> | ||
<tr> | ||
<td><?= $name; ?></td> | ||
<td><?= $email; ?></td> | ||
<td><?= $engineer['category']; ?></td> | ||
<td> | ||
<?php | ||
$status = engineer::checkSchedule($engineer_id); | ||
if ($status) { | ||
echo '<span class="text-success">Assigned</span>'; | ||
}else { | ||
echo '<span class="text-danger">Unassigned</span>'; | ||
} | ||
?> | ||
</td> | ||
<td><?= $date->format("F d, Y"); ?></td> | ||
<td> | ||
<div class="dropdown"> | ||
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Options | ||
</button> | ||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1"> | ||
<li> | ||
<a class="dropdown-item" onclick=" | ||
$('.engineer_id').val('<?= $engineer_id ?>'); | ||
$('.name').val('<?= $name ?>'); | ||
$('.email').val('<?= $email ?>'); | ||
" href="javascript:;" data-bs-toggle="modal" data-bs-target="#updateModal">Edit</a> | ||
</li> | ||
<li> | ||
<?php | ||
if ($status) { | ||
?> | ||
<a class="dropdown-item" onclick="$('.engineer_id').val('<?= $engineer_id ?>')" href="javascript:;" data-bs-toggle="modal" data-bs-target="#removeTaskModal">Remove task</a> | ||
<?php | ||
}else { | ||
?> | ||
<a class="dropdown-item" onclick="$('.engineer_id').val('<?= $engineer_id ?>')" href="javascript:;" data-bs-toggle="modal" data-bs-target="#assignTaskModal">Assign task</a> | ||
<?php | ||
} | ||
?> | ||
</li> | ||
<li><a href="javascript:;" onclick="$('.engineer_id').val('<?= $engineer_id ?>')" class="dropdown-item text-danger" data-bs-toggle="modal" data-bs-target="#removeModal">Remove engineer</a></li> | ||
</ul> | ||
</div> | ||
</td> | ||
</tr> | ||
<?php | ||
} | ||
?> | ||
</tbody> | ||
</table> | ||
<?php | ||
}else { | ||
?> | ||
<div class="alert alert-info alert-custom alert-dismissible" style="text-align: center; margin-bottom: 0; width: 100%;"> | ||
|
||
<p style="margin-bottom: 0;">No engineer has been added</p> | ||
</div> | ||
<?php | ||
} | ||
|
||
?> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Add Modal --> | ||
<div class="modal fade" id="addModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="exampleModalLabel">New engineer</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<form action="" method="post"> | ||
<div class="modal-body"> | ||
<div class="mb-3"> | ||
<label for="exampleFormControlInput1" class="form-label">Name</label> | ||
<input type="text" required name="name" class="form-control" id="exampleFormControlInput1" placeholder="Engineer name"> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="category" class="form-label">Category</label> | ||
<select name="category" id="category" class="form-control"> | ||
<option value="Category B1 Mechanic">Category B1 Mechanic</option> | ||
</select> | ||
</div> | ||
<hr> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<div class="mb-3"> | ||
<label for="email" class="form-label">Email address</label> | ||
<input type="email" name="email" class="email form-control" id="editEmail" placeholder="Engineer email address"> | ||
</div> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="mb-3"> | ||
<label for="password" class="form-label">Password</label> | ||
<input type="password" name="password" class="email form-control" id="password" placeholder="Account password"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> | ||
<button type="submit" class="btn btn-primary" name="addEngineer">Add engineer</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- edit Modal --> | ||
<div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="exampleModalLabel">Update engineer</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<form action="" method="post"> | ||
<div class="modal-body"> | ||
<input type="hidden" name="id" class="engineer_id"> | ||
<div class="mb-3"> | ||
<label for="exampleFormControlInput1" class="form-label">Name</label> | ||
<input type="text" name="name" required class="name form-control" id="exampleFormControlInput1" placeholder="Engineer name"> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<div class="mb-3"> | ||
<label for="editEmail" class="form-label">Email address</label> | ||
<input type="email" required name="email" class="email form-control" id="editEmail" placeholder="Engineer email address"> | ||
</div> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="mb-3"> | ||
<label for="category" class="form-label">Category</label> | ||
<select name="category" id="category" class="form-control"> | ||
<option value="Category B1 Mechanic">Category B1 Mechanic</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> | ||
<button type="submit" class="btn btn-primary" name="editEngineer">Save changes</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- remove Modal --> | ||
<div class="modal fade" id="removeModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog modal-sm"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="exampleModalLabel">Remove engineer</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<form action="" method="post"> | ||
<div class="modal-body"> | ||
<div class="mb-3"> | ||
<input type="hidden" name="id" class="engineer_id"> | ||
<p align="center">Are you sure you want to remove this engineer?</p> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> | ||
<button type="submit" class="btn btn-danger" name="removeEngineer">Yes, remove</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Assign Task Modal --> | ||
<div class="modal fade" id="assignTaskModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="exampleModalLabel">Assign task</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<form action="" method="post"> | ||
<input type="hidden" name="engineer_id" class="engineer_id"> | ||
<div class="modal-body"> | ||
<?php | ||
$aircraft = aircraft::unscheduledAircraft(); | ||
if (!$aircraft) { | ||
respond::alert('info', '', 'All aircraft has been scheduled for maintenance'); | ||
}else { | ||
?> | ||
<div class="mb-3"> | ||
<label for="aircraft" class="form-label">Aircraft</label> | ||
<select name="aircraft_id" required class="form-control" id="aircraft"> | ||
<option value="">Select aircraft</option> | ||
<?php | ||
foreach ($aircraft as $aircraft_) { | ||
?> | ||
<option value="<?= $aircraft_['id'] ?>"><?= $aircraft_['company'].' - '.$aircraft_['number'] ?></option> | ||
<?php | ||
} | ||
?> | ||
</select> | ||
</div> | ||
<?php | ||
} | ||
?> | ||
<div class="mb-3"> | ||
<label for="task" class="form-label">Task</label> | ||
<textarea name="task" required class="form-control" id="task" rows="3"></textarea> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> | ||
<button type="submit" class="btn btn-primary" name="addSchedule">Assign</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Remove Task Modal --> | ||
<div class="modal fade" id="removeTaskModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog modal-sm"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="exampleModalLabel">Remove task</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<form action="" method="post"> | ||
<div class="modal-body"> | ||
<div class="mb-3"> | ||
<input type="hidden" name="id" class="engineer_id"> | ||
<p align="center">Are you sure you want to remove task from this engineer?</p> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> | ||
<button type="submit" class="btn btn-danger" name="removeSchedule">Yes, remove</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
|
||
unset($_SESSION['user']); | ||
header("location: /login"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<div class="row mt-4"> | ||
<div class="col-md-8 mx-auto"> | ||
<h3 class="float-start">My schedules</h3> | ||
<div style="clear: both"></div> | ||
<?php | ||
|
||
$schedules = engineer::schedules($account['id']); | ||
|
||
?> | ||
<div class="card"> | ||
<?php | ||
|
||
if ($schedules) { | ||
?> | ||
<table class="table table-hover table-striped card-body mb-0"> | ||
<thead> | ||
<tr> | ||
<th>Aircraft</th> | ||
<th>Task</th> | ||
<th>Date added</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php | ||
foreach ($schedules as $schedule) { | ||
$date = new DateTime($schedule['createdAt']); | ||
$id = $schedule['id']; | ||
$engineer_id = $schedule['engineer_id']; | ||
$aircraft_id = $schedule['aircraft_id']; | ||
$engineer = $schedule['name']; | ||
$aircraft = $schedule['company']; | ||
$task = $schedule['task']; | ||
?> | ||
<tr> | ||
<td> | ||
<strong><?= $aircraft; ?></strong> | ||
<br> | ||
<small><?= $schedule['aircraft_type'].' - '. $schedule['number'] ?></small> | ||
</td> | ||
<td><?= $task ?></td> | ||
<td><?= $date->format("F d, Y"); ?></td> | ||
</tr> | ||
<?php | ||
} | ||
?> | ||
</tbody> | ||
</table> | ||
<?php | ||
}else { | ||
?> | ||
<div class="alert alert-info alert-custom alert-dismissible" style="text-align: center; margin-bottom: 0; width: 100%;"> | ||
|
||
<p style="margin-bottom: 0;">No schedule has been added</p> | ||
</div> | ||
<?php | ||
} | ||
|
||
?> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> | ||
<!-- Option 1: Bootstrap Bundle with Popper --> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> | ||
|
||
|
||
</body> | ||
</html> |
Oops, something went wrong.