<?php

include("admin/connection.php");
include('include/header.php');
?>
<?php
$slug = $_GET['slug'];
$ser = mysqli_query($con, "SELECT * FROM `upvc_door` where slug='$slug'");
while ($row = mysqli_fetch_array($ser)) {
    $title = $row['title'];
    $short_des = $row['short_des'];
    $slug = $row['slug'];
    $Image = $row['Image'];
    $id = $row['id'];
    $description = $row['description'];
}
?>

<div class="breadcumb-wrapper" data-bg-src="<?php path() ?>/assets/img/hero/banner1.webp">
    <div class="container">
        <div class="breadcumb-content">
            <h1 class="breadcumb-title"><?php echo $title; ?></h1>
            <ul class="breadcumb-menu">
                <li><a href="<?php path() ?>/index.php">Home</a></li>
                <li><?php echo $title; ?></li>
            </ul>
        </div>
    </div>
</div>
<section class="space space-extra-bottom">
    <div class="container">
        <div class="row">
            <div class="col-xxl-8 col-lg-8">
                <?php
                // Fetch service details by ID (make sure $id is defined earlier)
                $ser = mysqli_query($con, "SELECT * FROM `upvc_door` WHERE id = '$id'");
                if ($row = mysqli_fetch_array($ser)) {
                    $Image = $row['Image'];
                    $title = $row['title'];
                    $short_des = $row['short_des'];
                    $description = $row['description'];
                ?>
                    <div class="page-single mb-2">
                        <div class="page-img">
                            <img src="<?php path(); ?>/admin/assets/images/service/<?php echo htmlspecialchars($Image); ?>" alt="Service Image">

                        </div>
                        <div class="page-content">
                            <h2 class="sec-title"><?php echo $title; ?></h2>
                            <p class=""><?php echo htmlspecialchars(strip_tags($description)); ?></p>
                        </div>
                        <div class="widget widget_search">
                            <p class=""><?php echo htmlspecialchars(strip_tags($short_des)); ?></p>
                        </div>
                    </div>
                <?php
                }
                ?>
            </div>
            <div class="col-xxl-4 col-lg-4">
                <aside class="sidebar-area">

                    <div class="widget">
                        <h3 class="widget_title">All UPVC DOOR</h3>
                        <div class="recent-post-wrap featured-listing">
                            <?php

                            $services = mysqli_query($con, "SELECT slug, title, Image FROM `upvc_door`");
                            while ($s = mysqli_fetch_array($services)) {
                                $slug = $s['slug'];
                                $title = $s['title'];
                                $Image = $s['Image'];
                            ?>
                                <div class="recent-post">
                                    <div class="media-img">
                                        <a href="<?php path(); ?>/upvc-door-details.php?slug=<?php echo $slug; ?>">
                                            <img src="<?php path(); ?>/admin/assets/images/service/<?php echo htmlspecialchars($Image); ?>" alt="<?php echo htmlspecialchars($title); ?>">
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <h4 class="post-title">
                                            <a class="text-inherit" href="<?php path(); ?>/upvc-door-details.php?slug=<?php echo $slug; ?>">
                                                <?php echo htmlspecialchars($title); ?>
                                            </a>
                                        </h4>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>

                    </div>
                    <div class="widget sidebar-contact-form">
                        <h3 class="widget_title">Contact Us</h3>
                        <div class="contact-form-widget">
                            <form action="#" class="newsletter-form" onsubmit="return gotoChatService(event)">
                                <div class="form-group">
                                    <input class="form-control" type="text" name="name" id="Name" placeholder="Your Name"
                                    oninput="this.value = this.value.replace(/[^a-zA-Z\s]/g, '')" required>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" type="email" name="email" id="Email" placeholder="Your Email" required>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" type="text" name="phone" id="Phone" placeholder="Your Phone"
                                    maxlength="10" oninput="this.value = this.value.replace(/[^0-9]/g, '')" required>
                                </div>
                                <div class="form-group mb-3">
                                    <select name="subject" id="Service" class="orderby" required>
                                        <option value="" disabled selected hidden>Select Service</option>
                                        <option value="Sliding UPVC Door">Sliding UPVC Door</option>
                                        <option value="Casement UPVC Door">Casement UPVC Door</option>
                                        <option value="Slide & Fold UPVC Door">Slide & Fold UPVC Door</option>
                                        <option value="Designer UPVC Door">Designer UPVC Door</option>
                                        <option value="Casement UPVC Windows">Casement UPVC Windows</option>
                                        <option value="Sliding Windows">Sliding Windows</option>
                                        <option value="Top Hung Windows">Top Hung Windows</option>
                                        <option value="Tilt and Turn UPVC Windows">Tilt and Turn UPVC Windows</option>
                                        <option value="Coloured upvc Window">Coloured upvc Window</option>
                                        <option value="Villa Window">Villa Window</option>
                                        <option value="Bay Window">Bay Window</option>
                                    </select>
                                </div>
                                <div class="form-group mb-4">
                                    <textarea name="message" id="Message" cols="30" rows="3" class="form-control" placeholder="Your Message" required></textarea>
                                </div>

                                <div class="form-btn pt-2">
                                    <button type="submit" class="th-btn radius">Send Us</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </aside>
            </div>
        </div>
    </div>
</section>
<?php
include("include/footer.php");
?>