File manager - Edit - /home/webapp69.cm.in.th/u69319090039/Shop39/database/app/Views/home/index.php
Back
<div class="container py-4"> <!-- ══════════════════════════════════════════════ --> <!-- HERO / BANNER SECTION --> <!-- ══════════════════════════════════════════════ --> <?php if (!empty($banners)): ?> <div id="heroCarousel" class="carousel slide hero-banner shadow-sm mb-5 rounded-4 overflow-hidden" data-bs-ride="carousel"> <div class="carousel-indicators"> <?php foreach ($banners as $idx => $banner): ?> <button type="button" data-bs-target="#heroCarousel" data-bs-slide-to="<?= $idx ?>" class="<?= $idx === 0 ? 'active' : '' ?>"></button> <?php endforeach; ?> </div> <div class="carousel-inner"> <?php foreach ($banners as $idx => $banner): ?> <div class="carousel-item <?= $idx === 0 ? 'active' : '' ?>"> <?php if (!empty($banner['link_url'])): ?> <a href="<?= Security::e($banner['link_url']) ?>"> <?php endif; ?> <?php $rawBanner = !empty($banner['image_path']) ? ltrim($banner['image_path'], '/') : ''; $bannerSub = (strpos($rawBanner, 'public/') === 0) ? substr($rawBanner, 7) : $rawBanner; $bannerUrl = APP_URL . '/public/' . $bannerSub; ?> <img src="<?= $bannerUrl ?>" class="d-block w-100 object-fit-cover" style="max-height: 420px;" alt="<?= Security::e($banner['title'] ?? 'Banner') ?>"> <?php if (!empty($banner['link_url'])): ?> </a> <?php endif; ?> </div> <?php endforeach; ?> </div> <button class="carousel-control-prev" type="button" data-bs-target="#heroCarousel" data-bs-slide="prev"> <span class="carousel-control-prev-icon"></span> </button> <button class="carousel-control-next" type="button" data-bs-target="#heroCarousel" data-bs-slide="next"> <span class="carousel-control-next-icon"></span> </button> </div> <?php else: ?> <!-- Default Hero Banner --> <div class="card border-0 shadow-sm mb-5 overflow-hidden rounded-4 text-white" style="background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);"> <div class="card-body p-4 p-md-5"> <div class="row align-items-center"> <div class="col-lg-7 text-center text-lg-start"> <span class="badge bg-white text-primary fw-bold px-3 py-2 rounded-pill mb-3 fs-6 shadow-sm"> <i class="bi bi-stars me-1"></i>SHOP 39 MARKETPLACE </span> <h1 class="display-5 fw-bold mb-3">แหล่งรวมสินค้าคุณภาพ ส่งตรงจากร้านค้าทั่วไทย</h1> <p class="lead mb-4 opacity-90">ช้อปสนุก ปลอดภัย มั่นใจได้ 100% มีสินค้าหลากหลายหมวดหมู่ให้เลือกสรรในราคาสุดคุ้ม</p> <div class="d-flex flex-wrap gap-3 justify-content-center justify-content-lg-start"> <a href="<?= APP_URL ?>/products" class="btn btn-light btn-lg text-primary fw-bold px-4 py-2 rounded-pill shadow-sm"> <i class="bi bi-bag-fill me-2"></i>ช้อปเลยตอนนี้ </a> <a href="<?= APP_URL ?>/categories" class="btn btn-outline-light btn-lg fw-bold px-4 py-2 rounded-pill"> <i class="bi bi-grid-fill me-2"></i>ดูหมวดหมู่ทั้งหมด </a> </div> </div> <div class="col-lg-5 text-center d-none d-lg-block"> <div class="d-inline-flex p-4 rounded-circle bg-white bg-opacity-10 shadow-inner"> <i class="bi bi-shop-window text-white" style="font-size: 8rem;"></i> </div> </div> </div> </div> </div> <?php endif; ?> <!-- ══════════════════════════════════════════════ --> <!-- CATEGORIES SECTION --> <!-- ══════════════════════════════════════════════ --> <div class="mb-5"> <div class="d-flex justify-content-between align-items-center mb-3"> <div> <h4 class="fw-bold m-0 text-dark"> <i class="bi bi-grid-3x3-gap-fill text-primary me-2"></i>หมวดหมู่สินค้า </h4> <p class="text-muted small mb-0">เลือกช้อปสินค้าตามหมวดหมู่ที่คุณสนใจ</p> </div> <a href="<?= APP_URL ?>/categories" class="btn btn-outline-primary btn-sm rounded-pill px-3 fw-semibold"> ดูทั้งหมด <i class="bi bi-chevron-right ms-1"></i> </a> </div> <?php $categoryMeta = [ 'beauty-personal-care' => ['icon' => 'bi-heart-fill', 'color' => '#ec4899', 'bg' => '#fce7f3'], 'mens-clothes' => ['icon' => 'bi-person-badge-fill', 'color' => '#2563eb', 'bg' => '#dbeafe'], 'bags' => ['icon' => 'bi-bag-fill', 'color' => '#d97706', 'bg' => '#fef3c7'], 'womens-shoes' => ['icon' => 'bi-handbag-fill', 'color' => '#f43f5e', 'bg' => '#ffe4e6'], 'watches-glasses' => ['icon' => 'bi-stopwatch-fill', 'color' => '#4f46e5', 'bg' => '#e0e7ff'], 'electronics-accessories' => ['icon' => 'bi-headphones', 'color' => '#0891b2', 'bg' => '#cffaff'], 'home-appliances' => ['icon' => 'bi-tv-fill', 'color' => '#0d9488', 'bg' => '#ccfbf1'], 'cameras' => ['icon' => 'bi-camera-fill', 'color' => '#ea580c', 'bg' => '#ffedd5'], 'baby-toys' => ['icon' => 'bi-balloon-fill', 'color' => '#059669', 'bg' => '#d1fae5'], 'pets' => ['icon' => 'bi-emoji-smile-fill', 'color' => '#d97706', 'bg' => '#fef3c7'], 'health-wellness' => ['icon' => 'bi-capsule', 'color' => '#06b6d4', 'bg' => '#cffaff'], 'womens-clothes' => ['icon' => 'bi-gender-female', 'color' => '#e11d48', 'bg' => '#ffe4e6'], 'mens-shoes' => ['icon' => 'bi-boot-fill', 'color' => '#7c3aed', 'bg' => '#ede9fe'], 'fashion-accessories' => ['icon' => 'bi-gem', 'color' => '#9333ea', 'bg' => '#f3e8ff'], 'home-living' => ['icon' => 'bi-house-door-fill', 'color' => '#65a30d', 'bg' => '#ecfccb'], 'mobile-tablets' => ['icon' => 'bi-phone-fill', 'color' => '#2563eb', 'bg' => '#dbeafe'], 'computers-laptops' => ['icon' => 'bi-laptop-fill', 'color' => '#0284c7', 'bg' => '#e0f2fe'], 'food-beverages' => ['icon' => 'bi-cup-hot-fill', 'color' => '#d97706', 'bg' => '#fef3c7'], 'sports-outdoors' => ['icon' => 'bi-dribbble', 'color' => '#0284c7', 'bg' => '#e0f2fe'], 'gaming-accessories' => ['icon' => 'bi-controller', 'color' => '#4f46e5', 'bg' => '#e0e7ff'] ]; ?> <?php if (!empty($categories)): ?> <div class="category-grid-container"> <?php $limitedCategories = array_slice($categories, 0, 8); foreach ($limitedCategories as $cat): $catSlug = $cat['slug'] ?? ''; $meta = $categoryMeta[$catSlug] ?? ['icon' => 'bi-tag-fill', 'color' => '#0d6efd', 'bg' => '#e7f1ff']; ?> <a href="<?= APP_URL ?>/products?category=<?= $cat['id'] ?>" class="category-box-card text-decoration-none"> <div class="category-box-icon" style="background-color: <?= $meta['bg'] ?>; color: <?= $meta['color'] ?>;"> <i class="<?= $meta['icon'] ?>"></i> </div> <span class="category-box-title" title="<?= Security::e($cat['name']) ?>"><?= Security::e($cat['name']) ?></span> </a> <?php endforeach; ?> </div> <?php else: ?> <div class="alert alert-light border text-center py-4 rounded-3"> <i class="bi bi-tags text-muted fs-3 d-block mb-2"></i> <span class="text-muted">ยังไม่มีหมวดหมู่สินค้าในขณะนี้</span> </div> <?php endif; ?> </div> <!-- ══════════════════════════════════════════════ --> <!-- FEATURED PRODUCTS SECTION --> <!-- ══════════════════════════════════════════════ --> <div class="mb-5"> <div class="d-flex justify-content-between align-items-center mb-3"> <div> <h4 class="fw-bold m-0 text-dark"> <i class="bi bi-fire text-danger me-2"></i>สินค้าแนะนำ (Featured Products) </h4> <p class="text-muted small mb-0">สินค้าคุณภาพยอดนิยมที่ได้รับการคัดสรร</p> </div> <a href="<?= APP_URL ?>/products" class="btn btn-outline-primary btn-sm rounded-pill px-3 fw-semibold"> ดูทั้งหมด <i class="bi bi-chevron-right ms-1"></i> </a> </div> <?php if (!empty($featuredProducts)): ?> <div class="row g-3 g-md-4"> <?php foreach ($featuredProducts as $prod): ?> <?php $rawImg = !empty($prod['primary_image']) ? ltrim($prod['primary_image'], '/') : ''; if (!empty($rawImg)) { // Check if path already starts with public/ $subPath = (strpos($rawImg, 'public/') === 0) ? substr($rawImg, 7) : $rawImg; $cacheBust = !empty($prod['updated_at']) ? strtotime($prod['updated_at']) : (!empty($prod['created_at']) ? strtotime($prod['created_at']) : time()); $imgSrc = APP_URL . '/public/' . $subPath . '?v=' . $cacheBust; } else { $imgSrc = APP_URL . '/public/assets/images/sample-headphone.jpg'; } $rating = isset($prod['avg_rating']) ? (float)$prod['avg_rating'] : 5.0; $reviews = isset($prod['review_count']) ? (int)$prod['review_count'] : 0; $hasDiscount = !empty($prod['sale_price']) && $prod['sale_price'] > 0 && $prod['sale_price'] < $prod['price']; $discountPct = $hasDiscount ? round((($prod['price'] - $prod['sale_price']) / $prod['price']) * 100) : 0; ?> <div class="col-6 col-md-4 col-lg-3"> <div class="card border-0 shadow-sm h-100 product-card rounded-3 overflow-hidden position-relative transition-hover"> <!-- Sale Badge --> <?php if ($hasDiscount): ?> <span class="badge bg-danger position-absolute top-0 start-0 m-2 px-2 py-1 rounded-pill fw-bold" style="z-index: 2; font-size: 11px;"> -<?= $discountPct ?>% </span> <?php endif; ?> <!-- Product Image --> <div class="product-img-wrapper position-relative overflow-hidden bg-light" style="padding-top: 100%;"> <a href="<?= APP_URL ?>/product/<?= $prod['slug'] ?>" class="position-absolute top-0 start-0 w-100 h-100 d-flex align-items-center justify-content-center"> <img src="<?= $imgSrc ?>" alt="<?= Security::e($prod['title']) ?>" class="card-img-top w-100 h-100 object-fit-cover" onerror="this.src='https://images.unsplash.com/photo-1505740420928-5e560c06d30e?auto=format&fit=crop&w=400&q=80'"> </a> </div> <!-- Product Info --> <div class="card-body p-3 d-flex flex-column"> <span class="text-secondary small mb-1" style="font-size: 12px;"><?= Security::e($prod['category_name'] ?? 'ทั่วไป') ?></span> <h6 class="card-title fw-bold mb-1 text-truncate" title="<?= Security::e($prod['title']) ?>"> <a href="<?= APP_URL ?>/product/<?= $prod['slug'] ?>" class="text-decoration-none text-dark hover-primary"> <?= Security::e($prod['title']) ?> </a> </h6> <!-- Shop Name --> <div class="small text-muted mb-2 text-truncate" style="font-size: 12px;"> <i class="bi bi-shop me-1 text-primary"></i> <a href="<?= APP_URL ?>/store/<?= Security::e($prod['shop_slug'] ?? '') ?>" class="text-decoration-none text-muted hover-primary"> <?= Security::e($prod['shop_name'] ?? 'ร้านค้า SHOP39') ?> </a> </div> <!-- Rating & Review Count --> <div class="d-flex align-items-center gap-1 mb-2 small text-warning" style="font-size: 12px;"> <i class="bi bi-star-fill"></i> <span class="fw-bold text-dark"><?= number_format($rating, 1) ?></span> <span class="text-muted">(<?= $reviews ?>)</span> </div> <!-- Price & Actions --> <div class="mt-auto pt-2 border-top d-flex align-items-center justify-content-between"> <div> <?php if ($hasDiscount): ?> <div class="fw-bold text-danger fs-5 lh-1">฿<?= number_format($prod['sale_price'], 2) ?></div> <div class="text-decoration-line-through text-muted small" style="font-size: 11px;">฿<?= number_format($prod['price'], 2) ?></div> <?php else: ?> <div class="fw-bold text-primary fs-5 lh-1">฿<?= number_format($prod['price'], 2) ?></div> <?php endif; ?> </div> <div class="d-flex gap-1"> <form action="<?= APP_URL ?>/cart/add" method="POST" class="d-inline ajax-cart-form"> <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>"> <input type="hidden" name="product_id" value="<?= $prod['id'] ?>"> <input type="hidden" name="quantity" value="1"> <button type="submit" class="btn btn-outline-primary btn-sm rounded-circle p-0 d-flex align-items-center justify-content-center" style="width: 32px; height: 32px;" title="เพิ่มลงตะกร้า"> <i class="bi bi-cart-plus"></i> </button> </form> <a href="<?= APP_URL ?>/product/<?= $prod['slug'] ?>" class="btn btn-primary btn-sm rounded-circle p-0 d-flex align-items-center justify-content-center" style="width: 32px; height: 32px;" title="ดูรายละเอียด"> <i class="bi bi-eye"></i> </a> </div> </div> </div> </div> </div> <?php endforeach; ?> </div> <?php else: ?> <div class="card border-0 shadow-sm py-5 text-center rounded-4 bg-white"> <div class="card-body"> <i class="bi bi-box-seam text-muted" style="font-size: 3.5rem;"></i> <h5 class="fw-bold text-dark mt-3 mb-1">ยังไม่มีสินค้าแนะนำในขณะนี้</h5> <p class="text-muted small mb-3">ร้านค้ากำลังทยอยลงสินค้าใหม่ๆ กรุณากลับมาดูอีกครั้งในเร็วๆ นี้</p> <a href="<?= APP_URL ?>/products" class="btn btn-primary btn-sm rounded-pill px-4">ดูสินค้าทั้งหมด</a> </div> </div> <?php endif; ?> </div> <!-- ══════════════════════════════════════════════ --> <!-- NEW ARRIVALS SECTION --> <!-- ══════════════════════════════════════════════ --> <div class="mb-5"> <div class="d-flex justify-content-between align-items-center mb-3"> <div> <h4 class="fw-bold m-0 text-dark"> <i class="bi bi-sparkles text-warning me-2"></i>สินค้าใหม่ล่าสุด (New Arrivals) </h4> <p class="text-muted small mb-0">อัปเดตสินค้ามาใหม่ที่คุณต้องไม่พลาด</p> </div> <a href="<?= APP_URL ?>/products" class="btn btn-outline-primary btn-sm rounded-pill px-3 fw-semibold"> ดูทั้งหมด <i class="bi bi-chevron-right ms-1"></i> </a> </div> <?php if (!empty($newArrivals)): ?> <div class="row g-3 g-md-4"> <?php foreach ($newArrivals as $prod): ?> <?php $rawImg = !empty($prod['primary_image']) ? ltrim($prod['primary_image'], '/') : ''; if (!empty($rawImg)) { $subPath = (strpos($rawImg, 'public/') === 0) ? substr($rawImg, 7) : $rawImg; $cacheBust = !empty($prod['updated_at']) ? strtotime($prod['updated_at']) : (!empty($prod['created_at']) ? strtotime($prod['created_at']) : time()); $imgSrc = APP_URL . '/public/' . $subPath . '?v=' . $cacheBust; } else { $imgSrc = APP_URL . '/public/assets/images/sample-headphone.jpg'; } $rating = isset($prod['avg_rating']) ? (float)$prod['avg_rating'] : 5.0; $reviews = isset($prod['review_count']) ? (int)$prod['review_count'] : 0; $hasDiscount = !empty($prod['sale_price']) && $prod['sale_price'] > 0 && $prod['sale_price'] < $prod['price']; $discountPct = $hasDiscount ? round((($prod['price'] - $prod['sale_price']) / $prod['price']) * 100) : 0; ?> <div class="col-6 col-md-4 col-lg-3"> <div class="card border-0 shadow-sm h-100 product-card rounded-3 overflow-hidden position-relative transition-hover"> <?php if ($hasDiscount): ?> <span class="badge bg-danger position-absolute top-0 start-0 m-2 px-2 py-1 rounded-pill fw-bold" style="z-index: 2; font-size: 11px;"> -<?= $discountPct ?>% </span> <?php endif; ?> <div class="product-img-wrapper position-relative overflow-hidden bg-light" style="padding-top: 100%;"> <a href="<?= APP_URL ?>/product/<?= $prod['slug'] ?>" class="position-absolute top-0 start-0 w-100 h-100 d-flex align-items-center justify-content-center"> <img src="<?= $imgSrc ?>" alt="<?= Security::e($prod['title']) ?>" class="card-img-top w-100 h-100 object-fit-cover" onerror="this.src='https://images.unsplash.com/photo-1505740420928-5e560c06d30e?auto=format&fit=crop&w=400&q=80'"> </a> </div> <div class="card-body p-3 d-flex flex-column"> <span class="text-secondary small mb-1" style="font-size: 12px;"><?= Security::e($prod['category_name'] ?? 'ทั่วไป') ?></span> <h6 class="card-title fw-bold mb-1 text-truncate" title="<?= Security::e($prod['title']) ?>"> <a href="<?= APP_URL ?>/product/<?= $prod['slug'] ?>" class="text-decoration-none text-dark hover-primary"> <?= Security::e($prod['title']) ?> </a> </h6> <div class="small text-muted mb-2 text-truncate" style="font-size: 12px;"> <i class="bi bi-shop me-1 text-primary"></i> <a href="<?= APP_URL ?>/store/<?= Security::e($prod['shop_slug'] ?? '') ?>" class="text-decoration-none text-muted hover-primary"> <?= Security::e($prod['shop_name'] ?? 'ร้านค้า SHOP39') ?> </a> </div> <div class="d-flex align-items-center gap-1 mb-2 small text-warning" style="font-size: 12px;"> <i class="bi bi-star-fill"></i> <span class="fw-bold text-dark"><?= number_format($rating, 1) ?></span> <span class="text-muted">(<?= $reviews ?>)</span> </div> <div class="mt-auto pt-2 border-top d-flex align-items-center justify-content-between"> <div> <?php if ($hasDiscount): ?> <div class="fw-bold text-danger fs-5 lh-1">฿<?= number_format($prod['sale_price'], 2) ?></div> <div class="text-decoration-line-through text-muted small" style="font-size: 11px;">฿<?= number_format($prod['price'], 2) ?></div> <?php else: ?> <div class="fw-bold text-primary fs-5 lh-1">฿<?= number_format($prod['price'], 2) ?></div> <?php endif; ?> </div> <div class="d-flex gap-1"> <form action="<?= APP_URL ?>/cart/add" method="POST" class="d-inline ajax-cart-form"> <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>"> <input type="hidden" name="product_id" value="<?= $prod['id'] ?>"> <input type="hidden" name="quantity" value="1"> <button type="submit" class="btn btn-outline-primary btn-sm rounded-circle p-0 d-flex align-items-center justify-content-center" style="width: 32px; height: 32px;" title="เพิ่มลงตะกร้า"> <i class="bi bi-cart-plus"></i> </button> </form> <a href="<?= APP_URL ?>/product/<?= $prod['slug'] ?>" class="btn btn-primary btn-sm rounded-circle p-0 d-flex align-items-center justify-content-center" style="width: 32px; height: 32px;" title="ดูรายละเอียด"> <i class="bi bi-eye"></i> </a> </div> </div> </div> </div> </div> <?php endforeach; ?> </div> <?php else: ?> <div class="card border-0 shadow-sm py-5 text-center rounded-4 bg-white"> <div class="card-body"> <i class="bi bi-sparkles text-muted" style="font-size: 3.5rem;"></i> <h5 class="fw-bold text-dark mt-3 mb-1">ยังไม่มีสินค้าใหม่ล่าสุด</h5> <p class="text-muted small mb-3">ติดตามสินค้ารายการใหม่ๆ ได้ที่นี่เร็วๆ นี้</p> <a href="<?= APP_URL ?>/products" class="btn btn-primary btn-sm rounded-pill px-4">ดูสินค้าทั้งหมด</a> </div> </div> <?php endif; ?> </div> </div>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings