<?php
include 'config.php';
if(!isset($_SESSION['user_id'])) exit();

if (isset($_POST['add_client'])) {
    $agency_id      = $_SESSION['agency_id'];
    $name           = $_POST['name'];
    $phone_number   = $_POST['phone_number'];
    $email          = $_POST['email'];
    $passport_no    = $_POST['passport_no'];
    $passport_expiry= $_POST['passport_expiry'];
    $city           = $_POST['city'];
    $address        = $_POST['address'];

    $stmt = $conn->prepare("INSERT INTO clients (agency_id, name, phone_number, email, passport_no, passport_expiry, city, address) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
    $stmt->bind_param("isssssss", $agency_id, $name, $phone_number, $email, $passport_no, $passport_expiry, $city, $address);

    if ($stmt->execute()) {
        header("Location: clients.php?success=ClientAdded");
    } else {
        echo "Error: " . $conn->error;
    }
}
?>