<?php include('include/head.php');  ?>


<body>

  <?php include('include/header.php');  ?>



  <!-- ==== service-detail banner start ==== -->
  <section class="whykrimson">
    <div class="service-banner-text">
      <h1>Location</h1>
      <p>Electrical Power Solutions</p>
    </div>
  </section>
  <!-- ==== service-detail banner end ==== -->

  <?php
  $slug = $_GET['slug'];

// Query the database
$blog = mysqli_query($conn, "SELECT * FROM `tbl_locations` WHERE `slug` = '$slug' AND is_active = 1");

// Check if a matching row exists
if (mysqli_num_rows($blog) == 0) {
    // Redirect to 404 page
     echo "<script>window.location.href = 'https://www.kirmson.in/404.php';</script>";
    exit();
}

// Process the data if the slug matches
while ($rol = mysqli_fetch_array($blog)) {
    $name = $rol['location_name'];
    $slug = $rol['slug'];
    $image = $rol['image'];
    $description = $rol['location_description'];
}

  ?>
  <div class="c-section my-5">
    <div class="container py-5">
      <div class="row">

        <div class="col-md-9 order-md-0 order-1 ">
        <h3><?php echo $name; ?></h3>
        <hr>
          <img src="<?php path(); ?>/admin/assets/images/location-images/<?php echo $image; ?>" class="img-fluid" alt="<?php echo $name; ?>-image" />
          <div class="location-brief mt-3">
            
            <?php echo html_entity_decode($description) ?>

          </div>
        </div>

        <div class="col-md-3 order-md-0 order-2 mt-3 mt-md-0">
          <div class="inner-loc-list">
            <h3>Other Locations</h3>
            <?php

            $locationSql = mysqli_query($conn, "SELECT location_name, slug FROM `tbl_locations` WHERE `is_active` = 1");
            while ($locations = mysqli_fetch_array($locationSql)) {
              $locName = $locations['location_name'];
              $slug = $locations['slug'];
              // echo ($locName);
            ?>
              <ul>
                <li><svg aria-hidden="true" style="width: 15px;" class="e-font-icon-svg e-fas-map-marker-alt" viewBox="0 0 384 512" xmlns="http://www.w3.org/2000/svg">
                    <path fill="#232176" d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z">
                    </path>
                  </svg>&ensp;<a class="text-decoration-none" href="<?php path(); ?>/locations/<?php echo $slug; ?>"><?php echo $locName; ?></a></li>

              </ul>

            <?php
            }
            ?>
          </div>


        </div>
      </div>
    </div>
  </div>
  </div>

  <?php include('include/footer.php');  ?>

</body>

</html>