<?php
include '../../koneksi.php';

$user_id = 36;

$query = "
  SELECT l.*, s.*, d.*, u.no_hp
    FROM landingpage l
    JOIN seo s ON l.id_seo = s.id_seo
    JOIN datausaha d ON l.id_usaha = d.id_usaha
    JOIN users u ON l.id_user = u.id_user
    WHERE l.id_user = ?
";

$stmt = $conn->prepare($query);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows > 0) {
  $row = $result->fetch_assoc();

  // Data SEO 
  $title = $row['judul_seo'];
  $description = $row['deskripsi_seo'];
  $keywords = $row['katakunci_seo'];

  // Data Usaha
  $namaUsaha = $row['nama_usaha'];
  $alamat = $row['alamat'];
  $alamatGmaps = $row['alamat_gmaps'];
  $usernameFb = $row['username_fb'];
  $usernameIg = $row['username_ig'];
  $noWa = $row['no_hp'];

  //Data Landing Page
  $noTemplate = $row['no_template'];
  $judulUtama = $row['judul_utama'];
  $deskripsiUtama = $row['deskripsi_utama'];
  $gambarUtama = $row['gambar_utama'];
  $tentangUsaha = $row['tentang_usaha'];
  $gambarTentang = $row['gambar_tentang'];
  $gambarKeunggulan   = $row['gambar_keunggulan'];
  $keteranganCTABawah   = $row['keterangan_cta_bawah'];
  $slug_url   = $row['slug_url'];

} else {
  // Default jika tidak ada data ditemukan
  $title = "";
  $description = "";
  $keywords = "";

  $namaUsaha = "";
  $alamat = "";
  $alamatGmaps = "";
  $usernameFb = "";
  $usernameIg = "";
  $noWa = "";

  $noTemplate = "";
  $judulUtama = "";
  $deskripsiUtama = "";
  $gambarUtama = "";
  $tentangUsaha = "";
  $gambarTentang = "";
  $gambarKeunggulan   = "";
  $keteranganCTABawah   = "";
  $slug_url   = "";
}

//Mengambil Data Keunggulan
$querySelectKeunggulan = "
    SELECT dk.deskripsi_keunggulan
    FROM keunggulan k
    JOIN detail_keunggulan dk ON k.id_keunggulan = dk.id_keunggulan
    WHERE k.id_user = ?
";

$stmt = $conn->prepare($querySelectKeunggulan);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();

// Periksa apakah ada data yang ditemukan
$keunggulans = [];
if ($result->num_rows > 0) {
  // Ambil data dari hasil query
  while ($row = $result->fetch_assoc()) {
    $keunggulans[] = $row; // Menyimpan data keunggulan ke dalam array
  }
}

//Mengambil Data Produk
$querySelectProduk = "
    SELECT dp.id_produk, dp.nama_produk, dp.harga_produk, dp.gambar_produk
    FROM produk p
    JOIN detail_produk dp ON p.id_produk = dp.id_produk
    WHERE p.id_user = ?
";

$stmt = $conn->prepare($querySelectProduk);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();

// Periksa apakah ada data yang ditemukan
$produks = [];
if ($result->num_rows > 0) {
  // Ambil data produk dari hasil query
  while ($row = $result->fetch_assoc()) {
    $produks[] = $row; // Menyimpan data produk ke dalam array
  }
}

//Mengambil Data Testimoni
$querySelectTestimoni = "
    SELECT dt.id_testimoni, dt.nama_konsumen, dt.ulasan_konsumen
    FROM testimoni t
    JOIN detail_testimoni dt ON t.id_testimoni = dt.id_testimoni
    WHERE t.id_user = ?
";

$stmt = $conn->prepare($querySelectTestimoni);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();

// Periksa apakah ada data yang ditemukan
$testimonis = [];
if ($result->num_rows > 0) {
  // Ambil data testimoni dari hasil query
  while ($row = $result->fetch_assoc()) {
    $testimonis[] = $row; // Menyimpan data testimoni ke dalam array
  }
}

// Menutup statement dan koneksi
$stmt->close();
$conn->close();

?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title><?php echo htmlspecialchars($title); ?></title>
  <meta name="description" content="<?php echo htmlspecialchars($description); ?>">
  <meta name="keywords" content="<?php echo htmlspecialchars($keywords); ?>">
  <meta name="author" content="Portal UMKM">
  <meta name="robots" content="index, follow">
  <link rel="canonical" href="https://portalumkm.com/<?php echo htmlspecialchars($slug_url); ?>">

  <meta name="google-site-verification" content="e9f6S8EGZWNTqWTr7HenznoRKYDMXP6VPmjjcpqOZPU" />
  <meta name="msvalidate.01" content="7FD794BF2AAC41A7F1D8248099D2ED62" />
  <meta name="yandex-verification" content="d49629d3a04a87f2" />

  <!-- Open Graph Meta Tags (Untuk berbagi di media sosial) -->
  <meta property="og:title" content="<?php echo htmlspecialchars($title); ?>">
  <meta property="og:description" content="<?php echo htmlspecialchars($description); ?>">
  <meta property="og:image" content="https://portalumkm.com/uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>">
  <meta property="og:url" content="https://portalumkm.com/<?php echo htmlspecialchars($slug_url); ?>">
  <meta property="og:type" content="website">

  <!-- Twitter Card Meta Tags -->
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="<?php echo htmlspecialchars($title); ?>">
  <meta name="twitter:description" content="<?php echo htmlspecialchars($description); ?>">
  <meta name="twitter:image" content="https://portalumkm.com/uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>">

  <!-- Favicons -->
  <link href="../../assets/img/favicon.png" rel="icon">
  <link href="../../assets/img/apple-touch-icon.png" rel="apple-touch-icon">

  <!-- Fonts -->
  <link href="https://fonts.googleapis.com" rel="preconnect">
  <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">

  <!-- Vendor CSS Files -->
  <link href="../../assets/template2/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="../../assets/template2/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">

  <!-- Main CSS File -->
  <link href="../../assets/template2/css/main.css" rel="stylesheet">

</head>

<body class="index-page">

  <header id="header" class="header d-flex align-items-center sticky-top">
    <div class="container-fluid container-xl position-relative d-flex align-items-center justify-content-between">

      <a href="/<?php echo htmlspecialchars($slug_url); ?>" class="logo d-flex align-items-center">
        <h1 class="sitename"><?php echo htmlspecialchars($namaUsaha); ?></h1>
      </a>

      <nav id="navmenu" class="navmenu">
        <ul>
          <li><a href="#beranda" class="active">Beranda</a></li>
          <li><a href="#tentang">Tentang</a></li>
          <li><a href="#keunggulan">Keunggulan</a></li>
          <?php if (in_array($noTemplate, [1, 2, 3])): ?>
            <li><a href="#produk">Produk</a></li>
          <?php elseif (in_array($noTemplate, [4, 5, 6])): ?>
            <li><a href="#layanan">Layanan</a></li>
          <?php endif; ?>
          <li><a href="#testimoni">Testimoni</a></li>
          <li>
            <?php if ($noTemplate == 1): ?>
              <a class="btn-get-contact px-4 py-2 m-1" href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20pemesanan%20produk.%20Bisa%20bantu%20saya%20untuk%20memproses%20pesanan%20ini?%20Terima%20kasih!">
                <span class="btn-text-contact">WhatsApp Sekarang</span>
              </a>
            <?php elseif ($noTemplate == 2): ?>
              <a class="btn btn-primary px-4 py-2 m-1 rounded-pill btn-font-text text-white" href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20pemesanan%20produk.%20Bisa%20bantu%20saya%20untuk%20memproses%20pesanan%20ini?%20Terima%20kasih!">
                WhatsApp Sekarang
              </a>
            <?php elseif ($noTemplate == 3): ?>
              <a class="btn btn-warning px-4 py-2 m-1 rounded-pill btn-font-text text-white" href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20pemesanan%20produk.%20Bisa%20bantu%20saya%20untuk%20memproses%20pesanan%20ini?%20Terima%20kasih!">
                WhatsApp Sekarang
              </a>
            <?php elseif ($noTemplate == 4): ?>
              <a class="btn-get-contact px-4 py-2 m-1" href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20pemesanan%20produk.%20Bisa%20bantu%20saya%20untuk%20memproses%20pesanan%20ini?%20Terima%20kasih!">
                <span class="btn-text-contact">WhatsApp Sekarang</span>
              </a>
            <?php elseif ($noTemplate == 5): ?>
              <a class="btn btn-primary px-4 py-2 m-1 rounded-pill btn-font-text text-white" href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20pemesanan%20produk.%20Bisa%20bantu%20saya%20untuk%20memproses%20pesanan%20ini?%20Terima%20kasih!">
                WhatsApp Sekarang
              </a>
            <?php elseif ($noTemplate == 6): ?>
              <a class="btn btn-warning px-4 py-2 m-1 rounded-pill btn-font-text text-white" href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20pemesanan%20produk.%20Bisa%20bantu%20saya%20untuk%20memproses%20pesanan%20ini?%20Terima%20kasih!">
                WhatsApp Sekarang
              </a>
            <?php endif; ?>
          </li>
        </ul>
        <i class="mobile-nav-toggle d-xl-none bi bi-list"></i>
      </nav>

    </div>
  </header>

  <main class="main">

    <!-- Hero Section -->
    <section id="beranda" class="hero section light-background">

      <?php if ($noTemplate == 1): ?>
        <div class="container position-relative" >
          <div class="row gy-5">
            <div class="col-lg-6 order-2 order-lg-1 d-flex flex-column justify-content-center">
              <h2><?php echo htmlspecialchars($judulUtama); ?></h2>
              <p><?php echo htmlspecialchars($deskripsiUtama); ?></p>
              <div class="d-flex">
                <a href="#produk" class="btn-get-started">Lihat Produk</a>
              </div>
            </div>
            <div class="col-lg-6 order-1 order-lg-2">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>" class="img-fluid" style="width: 768px; height: 398px; object-fit: cover;" alt="<?php echo htmlspecialchars($title); ?>">
            </div>
          </div>
        </div>

        <div class="icon-boxes position-relative" >
          <div class="container position-relative">
            <div class="row gy-4 mt-5">

            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 2): ?>

        <div class="container position-relative" >
          <div class="row gy-5">
            <div class="col-lg-6 order-2 order-lg-2 d-flex flex-column justify-content-center text-lg-end">
              <h2><?php echo htmlspecialchars($judulUtama); ?></h2>
              <p><?php echo htmlspecialchars($deskripsiUtama); ?></p>
              <div class="d-flex justify-content-lg-end">
                <a href="#produk" class="btn btn-primary text-white px-4 py-2 rounded-pill btn-font-text">Lihat Produk</a>
              </div>
            </div>
            <div class="col-lg-6 order-1 order-lg-1">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>" class="img-fluid" style="width: 768px; height: 398px; object-fit: cover;" alt="<?php echo htmlspecialchars($title); ?>">
            </div>
          </div>
        </div>

        <div class="icon-boxes position-relative" >
          <div class="container position-relative">
            <div class="row gy-4 mt-5">

            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 3): ?>

        <div class="container position-relative" >
          <div class="row gy-5">
            <div class="col-lg-6 order-2 order-lg-1 d-flex flex-column justify-content-center">
              <h2><?php echo htmlspecialchars($judulUtama); ?></h2>
              <p><?php echo htmlspecialchars($deskripsiUtama); ?></p>
              <div class="d-flex">
                <a href="#produk" class="btn btn-warning text-white px-4 py-2 rounded-pill btn-font-text">Lihat Produk</a>
              </div>
            </div>
            <div class="col-lg-6 order-1 order-lg-2">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>" class="img-fluid" style="width: 768px; height: 398px; object-fit: cover;" alt="<?php echo htmlspecialchars($title); ?>">
            </div>
          </div>
        </div>

        <div class="icon-boxes position-relative" >
          <div class="container position-relative">
            <div class="row gy-4 mt-5">

            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 4): ?>

        <div class="container position-relative" >
          <div class="row gy-5">
            <div class="col-lg-6 order-2 order-lg-1 d-flex flex-column justify-content-center">
              <h2><?php echo htmlspecialchars($judulUtama); ?></h2>
              <p><?php echo htmlspecialchars($deskripsiUtama); ?></p>
              <div class="d-flex">
                <a href="#layanan" class="btn-get-started">Lihat Layanan</a>
              </div>
            </div>
            <div class="col-lg-6 order-1 order-lg-2">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>" class="img-fluid" style="width: 768px; height: 398px; object-fit: cover;" alt="<?php echo htmlspecialchars($title); ?>">
            </div>
          </div>
        </div>

        <div class="icon-boxes position-relative" >
          <div class="container position-relative">
            <div class="row gy-4 mt-5">

            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 5): ?>

        <div class="container position-relative" >
          <div class="row gy-5">
            <div class="col-lg-6 order-2 order-lg-2 d-flex flex-column justify-content-center text-lg-end">
              <h2><?php echo htmlspecialchars($judulUtama); ?></h2>
              <p><?php echo htmlspecialchars($deskripsiUtama); ?></p>
              <div class="d-flex justify-content-lg-end">
                <a href="#layanan" class="btn btn-primary text-white px-4 py-2 rounded-pill btn-font-text">Lihat Layanan</a>
              </div>
            </div>
            <div class="col-lg-6 order-1 order-lg-1">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>" class="img-fluid" style="width: 768px; height: 398px; object-fit: cover;" alt="<?php echo htmlspecialchars($title); ?>">
            </div>
          </div>
        </div>

        <div class="icon-boxes position-relative" >
          <div class="container position-relative">
            <div class="row gy-4 mt-5">

            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 6): ?>
        <div class="container position-relative" >
          <div class="row gy-5">
            <div class="col-lg-6 order-2 order-lg-1 d-flex flex-column justify-content-center">
              <h2><?php echo htmlspecialchars($judulUtama); ?></h2>
              <p><?php echo htmlspecialchars($deskripsiUtama); ?></p>
              <div class="d-flex">
                <a href="#layanan" class="btn btn-warning text-white px-4 py-2 rounded-pill btn-font-text">Lihat Layanan</a>
              </div>
            </div>
            <div class="col-lg-6 order-1 order-lg-2">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarUtama); ?>" class="img-fluid" style="width: 768px; height: 398px; object-fit: cover;" alt="<?php echo htmlspecialchars($title); ?>">
            </div>
          </div>
        </div>

        <div class="icon-boxes position-relative" >
          <div class="container position-relative">
            <div class="row gy-4 mt-5">

            </div>
          </div>
        </div>

      <?php endif; ?>

    </section><!-- /Hero Section -->

    <!-- About Section -->
    <section id="tentang" class="about section">

      <div class="container">

        <?php if (in_array($noTemplate, [1, 2, 4, 5])): ?>

          <div class="row gy-4">
            <div class="col-lg-6 content" >
              <h3>Tentang Kami</h3>

            <p class="fst-italic">
                <?php 
                    $tentangUsaha = htmlspecialchars($tentangUsaha); 
                    
                    $kalimatArray = preg_split('/(?<=\.)\s+/', $tentangUsaha);
            
                    $formattedText = '';
                    foreach ($kalimatArray as $index => $kalimat) {
                        $formattedText .= $kalimat . ' ';
                        if (($index + 1) % 3 == 0) {
                            $formattedText .= '<br><br>'; 
                        }
                    }
            
                    echo nl2br(htmlspecialchars_decode(trim($formattedText))); 
                ?>
            </p>

            </div>

            <div class="col-lg-6 about-images" >
              <div class="row gy-12">
                <div class="col-lg-12">
                  <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarTentang); ?>" style="width: 770px; height: 524px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
                </div>
              </div>
            </div>
          </div>

        <?php elseif (in_array($noTemplate, [3, 6])): ?>

          <div class="row align-items-center gy-4">
            <!-- Kolom Gambar di Kiri -->
            <div class="col-lg-6 text-center" >
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarTentang); ?>" style="width: 770px; height: 524px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
            </div>

            <!-- Kolom Teks di Kanan -->
            <div class="col-lg-6" >
              <h3>Tentang Kami</h3>
                     <p class="fst-italic">
                <?php 
                    $tentangUsaha = htmlspecialchars($tentangUsaha); 
                    
                    $kalimatArray = preg_split('/(?<=\.)\s+/', $tentangUsaha);
            
                    $formattedText = '';
                    foreach ($kalimatArray as $index => $kalimat) {
                        $formattedText .= $kalimat . ' ';
                        if (($index + 1) % 3 == 0) {
                            $formattedText .= '<br><br>'; 
                        }
                    }
            
                    echo nl2br(htmlspecialchars_decode(trim($formattedText))); 
                ?>
            </p>
            </div>
          </div>

        <?php endif; ?>

      </div>
    </section><!-- /About Section -->

    <!-- Features Section -->
    <section id="keunggulan" class="features section light-background">

      <?php if ($noTemplate == 1): ?>

        <!-- Section Title -->
        <div class="container section-title">
          <h3>
            <div><span>Mengapa Memilih</span> <span class="description-title"><?php echo htmlspecialchars($namaUsaha); ?></span>?</div>
          </h3>
          <p class="btn-font-text">
            Inilah alasan mengapa kami adalah pilihan terbaik untuk Anda!
          </p>
        </div><!-- End Section Title -->

        <div class="container">

          <div class="row gy-5 justify-content-between">

            <div class="col-xl-5">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarKeunggulan); ?>" style="width: 490px; height: 394px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
            </div>

            <div class="col-xl-6 d-flex">
              <div class="row align-self-center gy-4">

                <?php if (count($keunggulans) > 0): ?>
                  <?php foreach ($keunggulans as $keunggulan): ?>
                    <div class="col-md-6" >
                      <div class="feature-box d-flex align-items-center">
                        <i class="bi bi-check"></i>
                        <h4><?php echo htmlspecialchars($keunggulan['deskripsi_keunggulan']); ?></h4>
                      </div>
                    </div><!-- End Feature Item -->
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Keunggulan tidak ditemukan.</p>
                <?php endif; ?>

              </div>
            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 2): ?>

        <!-- Section Title -->
        <div class="container section-title">
          <h3>
            <div><span>Mengapa Memilih</span> <span class="description-title text-primary"><?php echo htmlspecialchars($namaUsaha); ?></span>?</div>
          </h3>
          <p class="btn-font-text">
            Inilah alasan mengapa kami adalah pilihan terbaik untuk Anda!
          </p>
        </div><!-- End Section Title -->

        <div class="container">

          <div class="row gy-5 justify-content-between">

            <div class="col-xl-5">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarKeunggulan); ?>" style="width: 490px; height: 394px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
            </div>

            <div class="col-xl-6 d-flex">
              <div class="row align-self-center gy-4">

                <?php if (count($keunggulans) > 0): ?>
                  <?php foreach ($keunggulans as $keunggulan): ?>
                    <div class="col-md-6" >
                      <div class="feature-box d-flex align-items-center">
                        <i class="bi bi-check text-primary"></i>
                        <h4><?php echo htmlspecialchars($keunggulan['deskripsi_keunggulan']); ?></h4>
                      </div>
                    </div><!-- End Feature Item -->
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Keunggulan tidak ditemukan.</p>
                <?php endif; ?>

              </div>
            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 3): ?>

        <!-- Section Title -->
        <div class="container section-title" >
          <h3>
            <div><span>Mengapa Memilih</span> <span class="description-title text-warning"><?php echo htmlspecialchars($namaUsaha); ?></span>?</div>
          </h3>
          <p class="btn-font-text">
            Inilah alasan mengapa kami adalah pilihan terbaik untuk Anda!
          </p>
        </div><!-- End Section Title -->

        <div class="container">
          <div class="row gy-5 justify-content-between">

            <div class="col-xl-6 d-flex order-lg-first order-last">
              <div class="row align-self-center gy-4">

                <?php if (count($keunggulans) > 0): ?>
                  <?php foreach ($keunggulans as $keunggulan): ?>
                    <div class="col-md-6" >
                      <div class="feature-box d-flex align-items-center px-3 py-2 bg-light rounded-pill shadow">
                        <i class="bi bi-check text-warning"></i>
                        <h4><?php echo htmlspecialchars($keunggulan['deskripsi_keunggulan']); ?></h4>
                      </div>
                    </div><!-- End Feature Item -->
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Keunggulan tidak ditemukan.</p>
                <?php endif; ?>

              </div>
            </div>

            <div class="col-xl-5 text-center order-lg-last order-first">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarKeunggulan); ?>" style="width: 490px; height: 394px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 4): ?>

        <!-- Section Title -->
        <div class="container section-title">
          <h3>
            <div><span>Mengapa Memilih</span> <span class="description-title"><?php echo htmlspecialchars($namaUsaha); ?></span>?</div>
          </h3>
          <p class="btn-font-text">
            Inilah alasan mengapa kami adalah layanan terbaik untuk Anda!
          </p>
        </div><!-- End Section Title -->

        <div class="container">

          <div class="row gy-5 justify-content-between">

            <div class="col-xl-5">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarKeunggulan); ?>" style="width: 490px; height: 394px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
            </div>

            <div class="col-xl-6 d-flex">
              <div class="row align-self-center gy-4">

                <?php if (count($keunggulans) > 0): ?>
                  <?php foreach ($keunggulans as $keunggulan): ?>
                    <div class="col-md-6" >
                      <div class="feature-box d-flex align-items-center">
                        <i class="bi bi-check"></i>
                        <h4><?php echo htmlspecialchars($keunggulan['deskripsi_keunggulan']); ?></h4>
                      </div>
                    </div><!-- End Feature Item -->
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Keunggulan tidak ditemukan.</p>
                <?php endif; ?>

              </div>
            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 5): ?>

        <!-- Section Title -->
        <div class="container section-title">
          <h3>
            <div><span>Mengapa Memilih</span> <span class="description-title text-primary"><?php echo htmlspecialchars($namaUsaha); ?></span>?</div>
          </h3>
          <p class="btn-font-text">
            Inilah alasan mengapa kami adalah pilihan layanan terbaik untuk Anda!
          </p>
        </div><!-- End Section Title -->

        <div class="container">

          <div class="row gy-5 justify-content-between">

            <div class="col-xl-5">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarKeunggulan); ?>" style="width: 490px; height: 394px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
            </div>

            <div class="col-xl-6 d-flex">
              <div class="row align-self-center gy-4">

                <?php if (count($keunggulans) > 0): ?>
                  <?php foreach ($keunggulans as $keunggulan): ?>
                    <div class="col-md-6" >
                      <div class="feature-box d-flex align-items-center">
                        <i class="bi bi-check text-primary"></i>
                        <h4><?php echo htmlspecialchars($keunggulan['deskripsi_keunggulan']); ?></h4>
                      </div>
                    </div><!-- End Feature Item -->
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Keunggulan tidak ditemukan.</p>
                <?php endif; ?>

              </div>
            </div>
          </div>
        </div>

      <?php elseif ($noTemplate == 6): ?>


        <!-- Section Title -->
        <div class="container section-title">
          <h3>
            <div><span>Mengapa Memilih</span> <span class="description-title text-warning"><?php echo htmlspecialchars($namaUsaha); ?></span>?</div>
          </h3>
          <p class="btn-font-text">
            Inilah alasan mengapa kami layanan terbaik untuk Anda!
          </p>
        </div><!-- End Section Title -->

        <div class="container">
          <div class="row gy-5 justify-content-between">

            <!-- Kolom Teks (Kiri di Desktop, Bawah di Mobile) -->
            <div class="col-xl-6 d-flex order-lg-first order-last">
              <div class="row align-self-center gy-4">

                <?php if (count($keunggulans) > 0): ?>
                  <?php foreach ($keunggulans as $keunggulan): ?>
                    <div class="col-md-6" >
                      <div class="feature-box d-flex align-items-center px-3 py-2 bg-light rounded-pill shadow">
                        <i class="bi bi-check text-warning"></i>
                        <h4><?php echo htmlspecialchars($keunggulan['deskripsi_keunggulan']); ?></h4>
                      </div>
                    </div><!-- End Feature Item -->
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Keunggulan tidak ditemukan.</p>
                <?php endif; ?>

              </div>
            </div>

            <div class="col-xl-5 text-center order-lg-last order-first">
              <img src="../../uploads/assets/<?php echo htmlspecialchars($gambarKeunggulan); ?>" style="width: 490px; height: 394px; object-fit: cover;" class="img-fluid rounded" alt="<?php echo htmlspecialchars($title); ?>">
            </div>

          </div>
        </div>

      <?php endif; ?>

    </section><!-- /Features Section -->

    <!-- Product Section -->
    <?php if (in_array($noTemplate, [1, 2, 3])): ?>
      <section id="produk" class="pricing section">
      <?php elseif (in_array($noTemplate, [4, 5, 6])): ?>
        <section id="layanan" class="pricing section">
        <?php endif; ?>

        <!-- Section Title -->
        <div class="container section-title">
          <?php if ($noTemplate == 1): ?>

            <h3>
              <div><span>Daftar</span> <span class="description-title">Produk Kami</span></div>
            </h3>
            <p class="btn-font-text">
              Yuk, lihat koleksi produk usaha kami—pilihan terbaik hanya untuk Anda!
            </p>

          <?php elseif ($noTemplate == 2): ?>
            <h3>
              <div><span>Daftar</span> <span class="description-title text-primary">Produk Kami</span></div>
            </h3>
            <p class="btn-font-text">
              Temukan produk berkualitas yang siap memenuhi kebutuhan Anda!
            </p>

          <?php elseif ($noTemplate == 3): ?>
            <h3>
              <div><span>Daftar</span> <span class="description-title text-warning">Produk Kami</span></div>
            </h3>
            <p class="btn-font-text">
              Penasaran dengan produk kami? Yuk, intip koleksi usaha terbaik kami!
            </p>

          <?php elseif ($noTemplate == 4): ?>
            <h3>
              <div><span>Daftar</span> <span class="description-title">Layanan Kami</span></div>
            </h3>
            <p class="btn-font-text">
              Butuh layanan profesional? Kami siap membantu dengan solusi terbaik!
            </p>
          <?php elseif ($noTemplate == 5): ?>
            <h3>
              <div><span>Daftar</span> <span class="description-title text-primary">Layanan Kami</span></div>
            </h3>
            <p class="btn-font-text">
              Kami siap membantu! Temukan layanan terbaik yang sesuai dengan kebutuhan Anda.
            </p>
          <?php elseif ($noTemplate == 6): ?>
            <h3>
              <div><span>Daftar</span> <span class="description-title text-warning">Layanan Kami</span></div>
            </h3>
            <p class="btn-font-text">
              Solusi tepat untuk Anda! Lihat layanan unggulan kami sekarang.
            </p>

          <?php endif; ?>

        </div><!-- End Section Title -->

        <div class="container">

          <div class="row gy-4">

            <?php if (in_array($noTemplate, [1, 4])): ?>

              <?php if (count($produks) > 0): ?>
                <?php foreach ($produks as $produk): ?>
                  <div class="col-lg-3 col-md-6">
                    <div class="product-card">
                      <img src="../../uploads/produk/<?php echo htmlspecialchars($produk['gambar_produk']); ?>" style="width: 100%; height: 220px; object-fit: cover;" alt="<?php echo htmlspecialchars($produk['nama_produk']); ?>" class="product-image">
                      <h4 class="product-name"><?php echo htmlspecialchars($produk['nama_produk']); ?></h4>
                      <div class="product-price">
                        <?php
                        if ($produk['harga_produk'] == 0) {
                          echo "Rp. Custom";
                        } else {
                          echo "Rp. " . number_format($produk['harga_produk'], 0, ',', '.');
                        }
                        ?>
                      </div>
                      <a href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Hallo%20kak,%20saya%20ingin%20melakukan%20pemesanan%20<?php echo htmlspecialchars($produk['nama_produk']); ?>.%20Terimakasih!" class="btn-buy">
                        <?php if ($noTemplate == 1): ?>
                          Beli Sekarang</a>
                    <?php elseif ($noTemplate == 4): ?>
                      Order Sekarang
                      </a>
                    <?php endif; ?>
                    </div>
                  </div>
                <?php endforeach; ?>
              <?php else: ?>
                <p>Produk tidak ditemukan.</p>
              <?php endif; ?>

            <?php elseif (in_array($noTemplate, [2, 5])): ?>

              <?php if (count($produks) > 0): ?>
                <?php foreach ($produks as $produk): ?>
                  <div class="col-lg-3 col-md-6">
                    <div class="card shadow-sm border-0">
                      <img src="../../uploads/produk/<?php echo htmlspecialchars($produk['gambar_produk']); ?>" style="width: 100%; height: 220px; object-fit: cover;" alt="<?php echo htmlspecialchars($produk['nama_produk']); ?>" class="product-image">
                      <div class="card-body text-center">
                        <h4 class="product-name"><?php echo htmlspecialchars($produk['nama_produk']); ?></h4>
                        <div class="card-text fw-bold text-primary mb-2">
                          <?php
                          if ($produk['harga_produk'] == 0) {
                            echo "Rp. Custom";
                          } else {
                            echo "Rp. " . number_format($produk['harga_produk'], 0, ',', '.');
                          }
                          ?>
                        </div>
                        <a href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Hallo%20kak,%20saya%20ingin%20melakukan%20pemesanan%20<?php echo htmlspecialchars($produk['nama_produk']); ?>.%20Terimakasih!" class="btn btn-primary w-100 btn-font-text">
                          <?php if ($noTemplate == 2): ?>
                            Beli Sekarang</a>
                      <?php elseif ($noTemplate == 5): ?>
                        Order Sekarang
                        </a>
                      <?php endif; ?>
                      </div>
                    </div>
                  </div>
                <?php endforeach; ?>
              <?php else: ?>
                <p>Produk tidak ditemukan.</p>
              <?php endif; ?>

            <?php elseif (in_array($noTemplate, [3, 6])): ?>

              <?php if (count($produks) > 0): ?>
                <?php foreach ($produks as $produk): ?>
                  <div class="col-lg-3 col-md-6">
                    <div class="product-card">
                      <img src="../../uploads/produk/<?php echo htmlspecialchars($produk['gambar_produk']); ?>" style="width: 100%; height: 220px; object-fit: cover;" alt="<?php echo htmlspecialchars($produk['nama_produk']); ?>" class="product-image">
                      <h4 class="product-name mt-2"><?php echo htmlspecialchars($produk['nama_produk']); ?></h4>
                      <div class="product-info d-flex justify-content-between align-items-center">
                        <div class="product-price text-dark">
                          <?php
                          if ($produk['harga_produk'] == 0) {
                            echo "Rp. Custom";
                          } else {
                            echo "Rp. " . number_format($produk['harga_produk'], 0, ',', '.');
                          }
                          ?>
                        </div>
                        <a href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Hallo%20kak,%20saya%20ingin%20melakukan%20pemesanan%20<?php echo htmlspecialchars($produk['nama_produk']); ?>.%20Terimakasih!" class="btn btn-warning btn-font-text text-white rounded-pill">
                          <?php if ($noTemplate == 3): ?>
                            Beli Sekarang</a>
                      <?php elseif ($noTemplate == 6): ?>
                        Order Sekarang
                        </a>
                      <?php endif; ?>
                      </div>
                    </div>
                  </div>
                <?php endforeach; ?>
              <?php else: ?>
                <p>Produk tidak ditemukan.</p>
              <?php endif; ?>

            <?php endif; ?>
          </div>
        </div>

        </section><!-- /Pricing Section -->

        <!-- Testimoni Section -->
        <section id="testimoni" class="services section  light-background">

          <!-- Section Title -->
          <div class="container section-title">
            <?php if ($noTemplate == 1): ?>

              <h3>
                <div><span>Testimoni</span> <span class="description-title">Pelanggan</span></div>
              </h3>
              <p class="btn-font-text">
                Lihat apa yang mereka katakan! Testimoni asli dari pelanggan kami.
              </p>

            <?php elseif ($noTemplate == 2): ?>
              <h3>
                <div><span>Testimoni</span> <span class="description-title text-primary">Pelanggan</span></div>
              </h3>
              <p class="btn-font-text">
                Lihat apa yang mereka katakan! Testimoni asli dari pelanggan kami.
              </p>

            <?php elseif ($noTemplate == 3): ?>

              <h3>
                <div><span>Testimoni</span> <span class="description-title text-warning">Pelanggan</span></div>
              </h3>
              <p class="btn-font-text">
                Apa kata mereka tentang kami? Simak testimoni asli pelanggan!
              </p>

            <?php elseif ($noTemplate == 4): ?>
              <h3>
                <div><span>Testimoni</span> <span class="description-title">Pelanggan</span></div>
              </h3>
              <p class="btn-font-text">
                Lihat apa yang mereka katakan! Testimoni asli dari pelanggan kami.
              </p>

            <?php elseif ($noTemplate == 5): ?>
              <h3>
                <div><span>Testimoni</span> <span class="description-title text-primary">Pelanggan</span></div>
              </h3>
              <p class="btn-font-text">
                Apa kata pelanggan kami? Simak testimoni mereka di sini!
              </p>

            <?php elseif ($noTemplate == 6): ?>
              <h3>
                <div><span>Testimoni</span> <span class="description-title text-warning">Pelanggan</span></div>
              </h3>
              <p class="btn-font-text">
                Apa pendapat mereka? Simak pengalaman nyata pelanggan kami!
              </p>

            <?php endif; ?>
          </div><!-- End Section Title -->

          <div class="container">

            <div class="row gy-4">

              <?php if (in_array($noTemplate, [1, 4])): ?>

                <?php if (count($testimonis) > 0): ?>
                  <?php foreach ($testimonis as $testimoni): ?>
                    <div class="col-lg-4 col-md-6" >
                      <div class="service-item position-relative">
                        <div class="icon">
                          <i class="bi bi-quote"></i>
                        </div>
                        <h4><?php echo htmlspecialchars($testimoni['nama_konsumen']); ?></h4>
                        <p><?php echo htmlspecialchars($testimoni['ulasan_konsumen']); ?></p>
                      </div>
                    </div><!-- End Service Item -->
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Testimoni tidak ditemukan.</p>
                <?php endif; ?>

              <?php elseif (in_array($noTemplate, [2, 5])): ?>

                <?php if (count($testimonis) > 0): ?>
                  <?php foreach ($testimonis as $testimoni): ?>
                    <div class="col-lg-4 col-md-6 text-center" >
                      <div class="card border-0 shadow p-4">
                        <div class="mx-auto mb-3 d-flex justify-content-center align-items-center rounded-circle bg-primary text-white" style="width: 70px; height: 70px;">
                          <i class="bi bi-quote fs-2"></i>
                        </div>
                        <h4><?php echo htmlspecialchars($testimoni['nama_konsumen']); ?></h4>
                        <p><?php echo htmlspecialchars($testimoni['ulasan_konsumen']); ?></p>
                      </div>
                    </div>
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Testimoni tidak ditemukan.</p>
                <?php endif; ?>

              <?php elseif (in_array($noTemplate, [3, 6])): ?>

                <?php if (count($testimonis) > 0): ?>
                  <?php foreach ($testimonis as $testimoni): ?>
                    <div class="col-lg-4 col-md-6 text-center" >
                      <div class="card border-0 shadow p-4">
                        <div class="mx-auto mb-3 d-flex justify-content-center align-items-center rounded-circle bg-warning text-white" style="width: 70px; height: 70px;">
                          <i class="bi bi-quote fs-2"></i>
                        </div>
                        <h4><?php echo htmlspecialchars($testimoni['nama_konsumen']); ?></h4>
                        <p><?php echo htmlspecialchars($testimoni['ulasan_konsumen']); ?></p>
                      </div>
                    </div>
                  <?php endforeach; ?>
                <?php else: ?>
                  <p>Testimoni tidak ditemukan.</p>
                <?php endif; ?>

              <?php endif; ?>
            </div>

        </section><!-- /Services Section -->

        <!-- Maps Section -->
        <section id="maps" class="faq section">

          <div class="container">

            <div class="row gy-4">

              <div class="col-lg-4" >
                <div class="content px-xl-5">
                  <h3><span>Alamat </span><strong>Usaha Kami</strong></h3>
                  <p>
                    Temukan lokasi usaha kami dengan mudah di Google Maps! Klik dan kunjungi sekarang!
                  </p>
                </div>
              </div>

              <div class="col-lg-8" >

                <div class="faq-container">

                  <iframe src="<?php echo htmlspecialchars($alamatGmaps); ?>" width="800" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>

                </div>

              </div>
            </div>

          </div>

        </section><!-- /Faq Section -->

        <!-- Contact Section -->
        <section id="contact" class="contact section light-background">
          <!-- Section Title -->
          <div class="container text-center">
            <h3 class="mb-3">
              <span><?php echo htmlspecialchars($keteranganCTABawah); ?></span>
            </h3>

            <?php if (in_array($noTemplate, [1, 4])): ?>

              <a href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20konsultasi.%20Terima%20kasih!" class="btn-consult btn-font-text">
                WhatsApp Sekarang!
              </a>

            <?php elseif (in_array($noTemplate, [2, 5])): ?>
              <a href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20konsultasi.%20Terima%20kasih!" class="btn btn-primary btn-font-text px-4 py-3 rounded-pill text-white">
                WhatsApp Sekarang!
              </a>

            <?php elseif (in_array($noTemplate, [3, 6])): ?>
              <a href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>?text=Halo,%20saya%20ingin%20melakukan%20konsultasi.%20Terima%20kasih!" class="btn btn-warning btn-font-text px-4 py-3 rounded-pill text-white">
                WhatsApp Sekarang!
              </a>
            <?php endif; ?>
          </div>
        </section>

  </main>

  <footer id="footer" class="footer dark-background">

    <div class="container text-center">
      <div class="copyright text-center ">
        <h4><?php echo htmlspecialchars($namaUsaha); ?></h4>
        <p><?php echo htmlspecialchars($alamat); ?></p>
      </div>
      <div class="social-links d-flex justify-content-center">
        <a href="https://facebook.com/<?php echo htmlspecialchars($usernameFb); ?>"><i class="bi bi-facebook"></i></a>
        <a href="https://instagram.com/<?php echo htmlspecialchars($usernameIg); ?>"><i class="bi bi-instagram"></i></a>
        <a href="https://wa.me/+62<?php echo htmlspecialchars($noWa); ?>"><i class="bi bi-whatsapp"></i></a>
      </div>

      <div class="footer-copyright mt-3">
      <p>&copy; <?php echo date("Y"); ?> <a href="/" class="text-white">Portal UMKM</a>. All Rights Reserved.</p>      
    </div>
    </div>

  </footer>

  <!-- Scroll Top -->
  <?php if (in_array($noTemplate, [1, 4])): ?>

    <a href="#" id="scroll-top" class="scroll-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>

  <?php elseif (in_array($noTemplate, [2, 5])): ?>

    <a href="#" id="scroll-top" class="scroll-top d-flex align-items-center justify-content-center bg-primary"><i class="bi bi-arrow-up-short"></i></a>

  <?php elseif (in_array($noTemplate, [3, 6])): ?>

    <a href="#" id="scroll-top" class="scroll-top d-flex align-items-center justify-content-center bg-warning"><i class="bi bi-arrow-up-short"></i></a>

  <?php endif; ?>

  <!-- Main JS File -->
  <script src="../../assets/template2/js/main.js"></script>
  <script src="../../assets/template2/js/custom.js"></script>

</body>

</html>