<?php
session_start();
include_once('../../includes/config.php');

header('Content-Type: application/json');

if (!isset($_SESSION['uid'])) {
    echo json_encode(['success' => false, 'message' => 'Unauthorized access']);
    exit();
}

$storeCode = isset($_GET['storeCode']) ? mysqli_real_escape_string($con, $_GET['storeCode']) : 'ST0002';

$query = "SELECT * FROM tblstore_settings WHERE StoreCode = '$storeCode' LIMIT 1";
$result = mysqli_query($con, $query);

if ($result && mysqli_num_rows($result) > 0) {
    $storeSettings = mysqli_fetch_assoc($result);
    echo json_encode([
        'success' => true,
        'storeSettings' => $storeSettings
    ]);
} else {
    echo json_encode([
        'success' => false,
        'message' => 'Store settings not found'
    ]);
}
?>
