<?php
header("Content-Type: application/json");
include '../connection.php';

$outlet_name = $_POST['outlet_name'];
$address = $_POST['address'];
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];
$employee_id = $_POST['employee_id'];

$sql = "INSERT INTO tbl_outlet (outlet_name, address, latitude, longitude, assigned_employee_id) 
        VALUES (?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssddi", $outlet_name, $address, $latitude, $longitude, $employee_id);

if ($stmt->execute()) {
    echo json_encode(["success" => true, "message" => "Outlet added successfully."]);
} else {
    echo json_encode(["success" => false, "message" => "Failed to add outlet."]);
}
?>
