norhusna / Change-Request

Phoenix - Online Food Ordering (Ah Kong Restaurant)
0 stars 0 forks source link

CR5 - UPDATE STAFF STATUS (ONLINE/OFFLINE) #5

Closed norhusna closed 3 years ago

norhusna commented 3 years ago

Admin does not aware other staff status and role in the restaurant

puterinorliana commented 3 years ago

image

puterinorliana commented 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'] != "staff") header("Location: login.php");

if (isset($_POST['btnStatus']) && isset($_POST['staffid'])) {

    $btnStatus = $sqlconnection->real_escape_string($_POST['btnStatus']);
    $staffID = $sqlconnection->real_escape_string($_POST['staffid']);

    if ($btnStatus== "Online")
        $status = "Offline";

    if ($btnStatus== "Offline")
        $status = "Online";

    $addOrderQuery = "UPDATE tbl_staff SET status = '{$status}' WHERE staffID = {$staffID};";

    if ($sqlconnection->query($addOrderQuery) === TRUE) {
            header("Location: index.php");
        } 

    else {
            //handle
            echo "someting wong";
            echo $sqlconnection->error;

    }
}

?>

norhusna commented 3 years ago

this change request CR has been completed and the issue will be closed