<?php
if (!isset($_GET['id'])) {
    header('Location: 505');
    exit;
}
include_once "global.php";

$pageTitle = 'Edit Inquiry Service - ';
include_once 'header.php';

if (isset($_GET["id"])) {
    $serviceId = $_GET["id"];

    $sql = "SELECT * FROM `services` WHERE `id` = ?";
    $serviceData = $dbF->getRow($sql, [$serviceId]);
}

$checked = "";
if ($serviceData['publish'] == '1') {
    $checked = 'checked';
}
?>

<div class="card">
    <div class="card-body p-4">
        <h5 class="mb-4">Edit Inquiry Service</h5>
        <form id="serviceEditForm" class="row g-3" method="post">
            <input type="hidden" name="serviceId" value="<?php echo $serviceId; ?>">
            <div class="row mb-3">
                <label for="service" class="col-sm-3 col-form-label">Service Title</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" name="service" id="service"
                        value="<?php echo $serviceData["name"]; ?>">
                </div>
            </div>
            <div class="row mb-3">
                <label for="publish" class="col-sm-3 col-form-label">Publish</label>
                <div class="col-sm-9">
                    <div class="form-check form-switch form-check-success">
                        <input class="form-check-input" type="checkbox" name="publish" role="switch"
                            id="flexSwitchCheckSuccess" value="1" <?php echo $checked; ?>>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <button type="submit" class="btn btn-grd-primary px-4">Submit</button>
            </div>
        </form>
    </div>
</div>

<?php
include_once 'footer.php';
?>