<?php
// Database connection
$db_server = "localhost";
$db_username = "hdigital_lSS_Landing";
$db_password = "-J?(A3.k^YW,";
$db_name = "hdigital_lSS_Landing";

$conn = new mysqli($db_server, $db_username, $db_password, $db_name);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Fetch data
$sql = "SELECT * FROM FreeQuote_Form ORDER BY id DESC"; // Assuming there's an 'id' column
$result = $conn->query($sql);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<title></title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="icon" type="image/x-icon" href="assets/images/favicon.png">
	<link rel="preconnect" href="https://fonts.googleapis.com">
	<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/default.css"/>
    <link rel="stylesheet" href="assets/css/style.css"/>
    <link rel="stylesheet" href="assets/css/responsive.css"/>
        <!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PKV7VKG');</script>
<!-- End Google Tag Manager -->
</head>

<body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PKV7VKG"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
	<header class="header">
		<div class="container">
			<div class="row">
				<div class="col-6 col-md-2">
					<a class="navbar-brand logo d-block" href="index.html">
						<img src="assets/images/logo.svg" alt="*">
					</a>
				</div>
				<div class="col-6 col-md-10">
					<div class="head-btn d-flex align-items-center justify-content-end gap-3 gap-lg-4 position-relative">
						<a class="btn LSS_phone" href="tel:+971529911111"><svg class="selfphone" width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
							<path d="M4.20536 1.44803L5.24304 1.13517C5.5855 1.03209 5.95378 1.0571 6.27916 1.20555C6.60455 1.354 6.86482 1.61574 7.01143 1.94196L7.73893 3.55982C7.86519 3.84049 7.90039 4.15366 7.83957 4.45536C7.77875 4.75706 7.62497 5.03213 7.39982 5.24196L6.2925 6.27375C6.14411 6.41464 6.25661 6.96375 6.79875 7.90339C7.34143 8.84357 7.76089 9.21535 7.95429 9.1575L9.405 8.71393C9.69906 8.62398 10.0139 8.62831 10.3054 8.7263C10.5968 8.82429 10.8504 9.01103 11.0304 9.26035L12.0643 10.6934C12.2731 10.9828 12.3698 11.3381 12.3364 11.6934C12.303 12.0487 12.1418 12.3798 11.8827 12.6252L11.0834 13.3821C10.8254 13.6265 10.5071 13.798 10.1612 13.8792C9.81523 13.9605 9.45391 13.9485 9.11411 13.8445C7.43946 13.3318 5.88857 11.8104 4.44054 9.3016C2.98929 6.7891 2.44125 4.66982 2.82321 2.93839C2.90025 2.58951 3.06894 2.26748 3.31189 2.00551C3.55484 1.74354 3.86326 1.5511 4.20536 1.44803Z" fill="#000"></path>
						</svg><i class="d-none d-lg-block selfphone">+971 52 99 11 111</i></a>
						<a class="btn LSS_email" href="mailto:cs@localstorage.ae"><svg class="selfemail" width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
							<path fill-rule="evenodd" clip-rule="evenodd" d="M3.12573 12.4999C2.62845 12.4999 2.15154 12.3023 1.79991 11.9507C1.44828 11.5991 1.25073 11.1222 1.25073 10.6249V4.37488C1.25073 3.8776 1.44828 3.40069 1.79991 3.04906C2.15154 2.69743 2.62845 2.49988 3.12573 2.49988H11.8757C12.373 2.49988 12.8499 2.69743 13.2016 3.04906C13.5532 3.40069 13.7507 3.8776 13.7507 4.37488V10.6249C13.7507 11.1222 13.5532 11.5991 13.2016 11.9507C12.8499 12.3023 12.373 12.4999 11.8757 12.4999H3.12573ZM4.76636 5.13738C4.70269 5.08302 4.62875 5.042 4.54893 5.01676C4.46911 4.99152 4.38502 4.98257 4.30168 4.99045C4.21833 4.99833 4.13741 5.02288 4.06374 5.06263C3.99006 5.10238 3.92511 5.15653 3.87276 5.22186C3.82042 5.2872 3.78172 5.36238 3.75899 5.44295C3.73625 5.52352 3.72994 5.60784 3.74042 5.6909C3.7509 5.77396 3.77796 5.85407 3.81999 5.92648C3.86202 5.99888 3.91817 6.0621 3.98511 6.11238L6.32886 7.98801C6.66141 8.25426 7.07472 8.39933 7.50073 8.39933C7.92674 8.39933 8.34005 8.25426 8.67261 7.98801L11.0164 6.11301C11.0805 6.06171 11.1338 5.99829 11.1734 5.92636C11.213 5.85444 11.238 5.77542 11.2471 5.69382C11.2562 5.61222 11.249 5.52964 11.2262 5.45079C11.2033 5.37194 11.1652 5.29836 11.1139 5.23426C11.0626 5.17016 10.9991 5.11678 10.9272 5.07719C10.8553 5.0376 10.7763 5.01257 10.6947 5.00351C10.6131 4.99446 10.5305 5.00157 10.4516 5.02443C10.3728 5.04729 10.2992 5.08546 10.2351 5.13676L7.89136 7.01176C7.78051 7.10051 7.64274 7.14887 7.50073 7.14887C7.35873 7.14887 7.22096 7.10051 7.11011 7.01176L4.76636 5.13676V5.13738Z" fill="#000"></path>
						</svg><i class="d-none d-lg-block selfemail">cs@localstorage.ae</i></a>
						<a class="btn LSS_whatsapp" href="https://api.whatsapp.com/send?phone=971529911111"><svg class="selfwhatsapp" width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
							<path d="M12.1506 3.32145C10.9678 2.13862 9.33382 1.40694 7.5288 1.40694C3.9192 1.40694 0.992464 4.33323 0.992464 7.94328C0.992464 9.14457 1.31653 10.2698 1.88156 11.2372L1.86486 11.2064L0.9375 14.5931L4.402 13.6842C5.30385 14.185 6.37983 14.4796 7.52484 14.4796H7.52748C11.1371 14.4783 14.0625 11.5516 14.0625 7.94196C14.0625 6.13782 13.3317 4.50472 12.1502 3.32189L12.1506 3.32145ZM7.52748 13.3755H7.52528C6.50559 13.3755 5.55097 13.0941 4.73618 12.6047L4.76081 12.6183L4.5625 12.5009L2.50684 13.0404L3.05516 11.0358L2.92588 10.8304C2.40482 10.0117 2.09526 9.01398 2.09526 7.94372C2.09526 4.94399 4.52732 2.51194 7.52704 2.51194C10.5268 2.51194 12.9588 4.94399 12.9588 7.94372C12.9588 10.9434 10.5276 13.3755 7.52748 13.3755ZM10.507 9.30771C10.3438 9.22592 9.54093 8.8315 9.39143 8.77653C9.24148 8.72201 9.13244 8.69519 9.02339 8.85876C8.91522 9.02189 8.60214 9.38949 8.50672 9.49854C8.41175 9.60803 8.31589 9.62122 8.15275 9.53988C7.64708 9.33497 7.21265 9.06191 6.83493 8.72553L6.83933 8.72948C6.488 8.4041 6.1868 8.03166 5.94364 7.62097L5.93132 7.5981C5.83635 7.43497 5.92121 7.34659 6.00256 7.26524C6.07599 7.19225 6.16613 7.0744 6.24748 6.97943C6.31168 6.90072 6.36664 6.81058 6.40841 6.71384L6.41105 6.70636C6.42996 6.66811 6.44095 6.6237 6.44095 6.57621C6.44095 6.51861 6.42468 6.46496 6.39654 6.41923L6.39742 6.42055C6.35609 6.33876 6.02982 5.53497 5.89395 5.20782C5.76115 4.88947 5.62616 4.933 5.52635 4.92772C5.43137 4.92333 5.32232 4.92245 5.21327 4.92245C5.03958 4.92684 4.88525 5.00511 4.77883 5.12603L4.7784 5.12691C4.42575 5.46154 4.20677 5.93335 4.20677 6.45617C4.20677 6.4676 4.20677 6.47947 4.20721 6.4909V6.48915C4.26481 7.13421 4.50665 7.71331 4.87865 8.18512L4.87337 8.17852C5.57867 9.2246 6.51878 10.0614 7.62202 10.6251L7.66335 10.644C7.90432 10.753 8.213 10.8696 8.52871 10.9694L8.59423 10.9874C8.78858 11.049 9.01239 11.0846 9.24456 11.0846C9.37779 11.0846 9.50883 11.0727 9.63547 11.0503L9.62184 11.052C10.0919 10.954 10.4819 10.6704 10.7198 10.283L10.7238 10.2755C10.7963 10.1146 10.8385 9.92682 10.8385 9.72939C10.8385 9.64805 10.8315 9.56846 10.8179 9.49107L10.8192 9.49942C10.7787 9.43127 10.6697 9.39081 10.5061 9.30859L10.507 9.30771Z" fill="#000"></path>
						</svg><i class="d-none d-lg-block selfwhatsapp">+971 52 99 11 111</i></a>
					</div>
				</div>
			</div>
		</div>
	</header>
    <div class="container pt-5">
        <div class="main-heading text-center pt-5">
            <h2 class="text-capitalize">Inquiries</h2>
        </div>


       <ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
  <li class="nav-item" role="presentation">
    <button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill"
        data-bs-target="#pills-home" type="button" role="tab"
        aria-controls="pills-home" aria-selected="true">Free Quote</button>
  </li>
  <li class="nav-item" role="presentation">
    <button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill"
        data-bs-target="#pills-profile" type="button" role="tab"
        aria-controls="pills-profile" aria-selected="false">Quotes Form</button>
  </li>
</ul>
        <div class="tab-content" id="pills-tabContent">

            <!-- First Tab Here -->
            <div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab" tabindex="0">

                <table class="table table-bordered table-hover table-striped">
                    <thead class="table-dark">
                        <tr>
                            <th>ID</th>
                            <th>First Name</th>
                            <th>Last Name</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Action</th>
                        </tr>
                    </thead>

                    <tbody>
                        <?php if ($result->num_rows > 0): 
                            $count = 1;
                            while($row = $result->fetch_assoc()): ?>
                                <tr>
                                    <td><?= $count++ ?></td>
                                    <td><?= htmlspecialchars($row['F_name']) ?></td>
                                    <td><?= htmlspecialchars($row['L_name']) ?></td>
                                    <td><?= htmlspecialchars($row['Phone']) ?></td>
                                    <td><?= htmlspecialchars($row['Email']) ?></td>
                                    <td><?= htmlspecialchars($row['Message']) ?></td>

                                    <td>
                                        <a href="delete.php?id=<?= $row['id'] ?>" 
                                           onclick="return confirm('Are you sure you want to delete this record?')" 
                                           class="btn btn-danger btn-sm">
                                           Delete
                                       </a>
                                   </td>


                               </tr>
                           <?php endwhile; else: ?>
                           <tr>
                            <td colspan="7" class="text-center">No records found</td>
                        </tr>
                    <?php endif; ?>
                </tbody>

            </table>

        </div>

        <!-- Second Tab Here -->
        <?php

        $sql2 = "SELECT * FROM quotes ORDER BY created_at DESC";
        $result2 = $conn->query($sql2);
        ?>
        <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab" tabindex="0">
          <table>
            <tr>
                <th>ID</th>
                <th>Name</th>
                <th>Email</th>
                <th>Phone</th>
                <th>Location</th>
                <th>Service</th>
                <th>Message</th>
                <th>About</th>
                <th>Promo Code</th>
                <th>Requested At</th>
                <th>Action</th>
            </tr>

            <?php
            if ($result2->num_rows > 0) {
                while($row = $result2->fetch_assoc()) {
                    echo "<tr>
                    <td>".$row['id']."</td>
                    <td>".$row['first_name']." ".$row['last_name']."</td>
                    <td>".$row['email']."</td>
                    <td>".$row['phone']."</td>
                    <td>".$row['location']."</td>
                    <td>".$row['service']."</td>
                    <td>".$row['message']."</td>
                    <td>".$row['about']."</td>
                    <td>".$row['promo_code']."</td>
                    <td>".$row['created_at']."</td>
                    <td><a href='delete.php?id=".$row['id']."' class='btn-delete' onclick='return confirm(\"Are you sure?\")'>Delete</a></td>
                    </tr>";
                }
            } else {
                echo "<tr><td colspan='11'>No records found.</td></tr>";
            }

            $conn->close();
            ?>

        </table>
    </div>


</div>


</div>




<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>

</body>
</html>




