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

if(!isset($_GET['id']))
{
    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 getItems extends database
{
    public function index($id)
    {
        $sql = 'SELECT oi.*,  mi.name FROM  order_item oi INNER JOIN menu_item mi ON oi.item_id=mi.id WHERE  oi.deleted_at IS NULL AND oi.order_id=? ';
        return $this->callQuery($sql, [$id]);
        //return $this->fetchAll('order_item', ['id' => $id]);
    }
}

$obj = new getItems();
$items = $obj->index($id);
echo json_encode($items);