Closed norhusna closed 3 years ago
<?php include("../functions.php");
if((!isset($_SESSION['uid']) && !isset($_SESSION['username']) && isset($_SESSION['user_level'])) ) header("Location: login.php");
if($_SESSION['user_level'] != "admin") header("Location: login.php");
if (!empty($_POST['role'])) { $role = $sqlconnection->real_escape_string($_POST['role']); $staffID = $sqlconnection->real_escape_string($_POST['staffID']);
$updateRoleQuery = "UPDATE tbl_staff SET role = '{$role}' WHERE staffID = {$staffID} ";
if ($sqlconnection->query($updateRoleQuery) === TRUE) {
echo "";
}
else {
//handle
echo "someting wong";
echo $sqlconnection->error;
}
} ?>
<!DOCTYPE html>
Manage current staff that avalaible.
# | Username | Status | Role | Option | There are currently no staff. | "; } $staffno = 1; while($staff = $result->fetch_array(MYSQLI_ASSOC)) { ?>
---|---|---|---|---|
Online"; } if ($staff['status'] == "Offline") { echo " | Offline | "; } ?>Delete |
ADD STAFF
<?php include("../functions.php");
if((!isset($_SESSION['uid']) && !isset($_SESSION['username']) && isset($_SESSION['user_level'])) )
header("Location: login.php");
if($_SESSION['user_level'] != "admin")
header("Location: login.php");
if (isset($_POST['addstaff'])) {
if (!empty($_POST['staffname']) && !empty($_POST['staffrole'])) {
$staffUsername = $sqlconnection->real_escape_string($_POST['staffname']);
$staffRole = $sqlconnection->real_escape_string($_POST['staffrole']);
$addStaffQuery = "INSERT INTO tbl_staff (username ,password ,status ,role) VALUES ('{$staffUsername}' ,'abc123' ,'Offline' ,'{$staffRole}') ";
if ($sqlconnection->query($addStaffQuery) === TRUE) {
echo "added.";
header("Location: staff.php");
exit();
}
else {
//handle
echo "someting wong";
echo $sqlconnection->error;
}
}
}
?>
DELETE STAFF
<?php
include("../functions.php");
if((!isset($_SESSION['uid']) && !isset($_SESSION['username']) && isset($_SESSION['user_level'])) )
header("Location: login.php");
if($_SESSION['user_level'] != "admin")
header("Location: login.php");
//Deleting Item
if (isset($_GET['staffID'])) {
$del_staffID = $sqlconnection->real_escape_string($_GET['staffID']);
$deleteStaffQuery = "DELETE FROM tbl_staff WHERE staffID = {$del_staffID}";
if ($sqlconnection->query($deleteStaffQuery) === TRUE) {
echo "deleted.";
header("Location: staff.php");
exit();
}
else {
//handle
echo "someting wrong";
echo $sqlconnection->error;
}
//echo "<script>alert('{$del_menuID} & {$del_itemID}')</script>";
}
?>
change request approved!
To provide easy access for admin to manage staff of the restaurant