<?php
error_reporting(E_ALL);
ini_set('display_errors',1);

if(!isset($_GET['id']) || !isset($_POST['tableNo']))
{
    http_response_code(500);
            echo json_encode(['error_text' => 'Something Went Wrong']);
            exit;
}
$id = $_GET['id'];

session_start();
require_once "../check_admin.php";
require_once '../database.php';
if(!isset($_SESSION['user_type']) || $_SESSION['user_type'] !='staff')
{
        http_response_code(403);
        echo json_encode(['error_text' => 'Authentication Error']);
        exit;
}
    
class saveTable extends database
{
    public function updateData($data, $id)
    {
        return $this->update('orders', $data, ['id' => $id]);
    }
    
}
    
$tableNo = $_POST['tableNo'];

    $data['table_no'] = $tableNo;
    
    $obj = new saveTable();
    $res = $obj->updateData($data, $id);
    if(!$res)
    {
        http_response_code(500);
        echo json_encode(['error_text' => 'Something Went Wrong']);
        exit;
    }
    
    http_response_code(200);
        echo json_encode(['message' => 'Item Added Successful']);
        exit;