PATH:
home
/
u865795251
/
domains
/
whatisnewis.com
/
public_html
/
everestentp
/
admin
/
Editing: dashboard.php
<?php session_start(); require_once __DIR__ . '/../db.php'; if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) { header('Location: login.php'); exit; } $pdo = getDB(); // Initialize category settings table if not exists try { $pdo->exec("CREATE TABLE IF NOT EXISTS category_settings ( category_name VARCHAR(100) PRIMARY KEY, is_enabled TINYINT(1) DEFAULT 1, sort_order INT DEFAULT 0, heading_size VARCHAR(50) DEFAULT '1.8rem', slides_per_view VARCHAR(10) DEFAULT '4.5', mobile_heading_size VARCHAR(50) DEFAULT '1.5rem', mobile_slides_per_view VARCHAR(10) DEFAULT '2.2', product_title_size VARCHAR(50) DEFAULT '1rem', mobile_product_title_size VARCHAR(50) DEFAULT '0.9rem', btn_padding VARCHAR(50) DEFAULT '0.5rem 1.2rem', btn_font_size VARCHAR(50) DEFAULT '0.9rem', mobile_btn_padding VARCHAR(50) DEFAULT '0.4rem 1rem', mobile_btn_font_size VARCHAR(50) DEFAULT '0.8rem' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); // Check and add missing columns for existing tables $columns = $pdo->query("DESCRIBE category_settings")->fetchAll(PDO::FETCH_COLUMN); if (!in_array('mobile_heading_size', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN mobile_heading_size VARCHAR(50) DEFAULT '1.5rem'"); } if (!in_array('mobile_slides_per_view', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN mobile_slides_per_view VARCHAR(10) DEFAULT '2.2'"); } if (!in_array('product_title_size', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN product_title_size VARCHAR(50) DEFAULT '1rem'"); } if (!in_array('mobile_product_title_size', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN mobile_product_title_size VARCHAR(50) DEFAULT '0.9rem'"); } if (!in_array('btn_padding', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN btn_padding VARCHAR(50) DEFAULT '0.5rem 1.2rem'"); } if (!in_array('btn_font_size', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN btn_font_size VARCHAR(50) DEFAULT '0.9rem'"); } if (!in_array('mobile_btn_padding', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN mobile_btn_padding VARCHAR(50) DEFAULT '0.4rem 1rem'"); } if (!in_array('mobile_btn_font_size', $columns)) { $pdo->exec("ALTER TABLE category_settings ADD COLUMN mobile_btn_font_size VARCHAR(50) DEFAULT '0.8rem'"); } } catch(Exception $e) {} // Handle Status Update via AJAX or simple GET trigger if (isset($_GET['action']) && $_GET['action'] === 'update_status' && isset($_GET['id']) && isset($_GET['status'])) { $id = (int)$_GET['id']; $status = $_GET['status']; if (in_array($status, ['pending', 'contacted', 'resolved'])) { $stmt = $pdo->prepare("UPDATE inquiries SET status = ? WHERE id = ?"); $stmt->execute([$status, $id]); } header('Location: dashboard.php'); exit; } $successMsg = ''; $errorMsg = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { if ($_POST['action'] === 'save_setting') { if (isset($_FILES['hero_bg_image']) && $_FILES['hero_bg_image']['error'] === 0) { $uploadDir = __DIR__ . '/../images/'; $fileName = 'hero_bg_' . time() . '_' . basename($_FILES['hero_bg_image']['name']); $targetFile = $uploadDir . $fileName; $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); $validExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp']; if (in_array($imageFileType, $validExtensions)) { if (move_uploaded_file($_FILES['hero_bg_image']['tmp_name'], $targetFile)) { setSetting('hero_bg_image', 'images/' . $fileName); $successMsg = 'Hero background image updated successfully!'; } else { $errorMsg = 'Failed to move uploaded file.'; } } else { $errorMsg = 'Invalid file type. Allowed: ' . implode(', ', $validExtensions); } } } elseif ($_POST['action'] === 'save_general_settings') { setSetting('whatsapp_number', trim($_POST['whatsapp_number'] ?? '')); setSetting('whatsapp_message', trim($_POST['whatsapp_message'] ?? '')); setSetting('call_number', trim($_POST['call_number'] ?? '')); setSetting('admin_email', trim($_POST['admin_email'] ?? '')); setSetting('smtp_host', trim($_POST['smtp_host'] ?? '')); setSetting('smtp_port', trim($_POST['smtp_port'] ?? '')); setSetting('smtp_user', trim($_POST['smtp_user'] ?? '')); setSetting('smtp_pass', str_replace(' ', '', trim($_POST['smtp_pass'] ?? ''))); setSetting('smtp_secure', trim($_POST['smtp_secure'] ?? 'tls')); setSetting('from_email', trim($_POST['from_email'] ?? '')); setSetting('from_name', trim($_POST['from_name'] ?? '')); $successMsg = 'Contact & Email (SMTP) Settings updated successfully!'; } elseif ($_POST['action'] === 'upload_partner_logo') { if (isset($_FILES['logo_file']) && $_FILES['logo_file']['error'] === 0) { $uploadDir = __DIR__ . '/../images/partners/'; if (!is_dir($uploadDir)) mkdir($uploadDir, 0755, true); $fileName = 'logo_' . time() . '_' . basename($_FILES['logo_file']['name']); $targetFile = $uploadDir . $fileName; $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); if (in_array($imageFileType, ['jpg', 'jpeg', 'png', 'gif', 'webp'])) { if (move_uploaded_file($_FILES['logo_file']['tmp_name'], $targetFile)) { $successMsg = 'Client Logo uploaded successfully!'; } else { $errorMsg = 'Failed to save file.'; } } else { $errorMsg = 'Invalid file type.'; } } } elseif ($_POST['action'] === 'upload_seamless_image') { if (isset($_FILES['slide_file']) && $_FILES['slide_file']['error'] === 0) { $uploadDir = __DIR__ . '/../images/seamless/'; if (!is_dir($uploadDir)) mkdir($uploadDir, 0755, true); $fileName = 'slide_' . time() . '_' . basename($_FILES['slide_file']['name']); $targetFile = $uploadDir . $fileName; $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); if (in_array($imageFileType, ['jpg', 'jpeg', 'png', 'gif', 'webp'])) { if (move_uploaded_file($_FILES['slide_file']['tmp_name'], $targetFile)) { $successMsg = 'Seamless Slider image uploaded successfully!'; } else { $errorMsg = 'Failed to save file.'; } } else { $errorMsg = 'Invalid file type.'; } } } elseif ($_POST['action'] === 'delete_file') { $path = $_POST['file_path'] ?? ''; // Security check: only allow deleting from safe folders if (strpos($path, 'images/partners/') === 0 || strpos($path, 'images/seamless/') === 0) { $fullPath = __DIR__ . '/../' . $path; if (file_exists($fullPath) && is_file($fullPath)) { unlink($fullPath); $successMsg = 'File deleted successfully!'; } else { $errorMsg = 'File not found.'; } } else { $errorMsg = 'Invalid deletion path.'; } } elseif ($_POST['action'] === 'add_product') { $prodName = trim($_POST['product_name'] ?? ''); $prodCategory = trim($_POST['product_category'] ?? ''); $newCategory = trim($_POST['new_category'] ?? ''); $imagePosition = $_POST['image_position'] ?? 'center'; $prodImagePath = ''; if (!empty($newCategory)) { $prodCategory = $newCategory; } if (!empty($prodName)) { // Ensure products table exists and has image_position column try { $pdo->exec("CREATE TABLE IF NOT EXISTS products (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, category VARCHAR(100), image_path VARCHAR(255), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); $pdo->exec("ALTER TABLE products ADD COLUMN image_position VARCHAR(50) DEFAULT 'center'"); } catch(Exception $e) {} if (isset($_FILES['product_image']) && $_FILES['product_image']['error'] === 0) { $uploadDir = __DIR__ . '/../images/products/'; if (!is_dir($uploadDir)) mkdir($uploadDir, 0755, true); $fileName = 'prod_' . time() . '_' . basename($_FILES['product_image']['name']); $targetFile = $uploadDir . $fileName; $ext = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); if (in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'webp'])) { if (move_uploaded_file($_FILES['product_image']['tmp_name'], $targetFile)) { $prodImagePath = 'images/products/' . $fileName; } else { $errorMsg = 'Failed to upload product image.'; } } else { $errorMsg = 'Invalid image type.'; } } if (empty($errorMsg)) { try { $stmt = $pdo->prepare("INSERT INTO products (name, category, image_path, image_position) VALUES (?, ?, ?, ?)"); $stmt->execute([$prodName, $prodCategory, $prodImagePath, $imagePosition]); $successMsg = 'Product "' . htmlspecialchars($prodName) . '" added successfully!'; } catch (Exception $e) { $errorMsg = 'DB Error: ' . $e->getMessage(); } } } else { $errorMsg = 'Product name is required.'; } } elseif ($_POST['action'] === 'delete_product') { $prodId = (int)($_POST['product_id'] ?? 0); if ($prodId > 0) { // Also delete its image if stored locally $stmt = $pdo->prepare("SELECT image_path FROM products WHERE id = ?"); $stmt->execute([$prodId]); $row = $stmt->fetch(); if ($row && !empty($row['image_path']) && strpos($row['image_path'], 'images/products/') === 0) { $imgFull = __DIR__ . '/../' . $row['image_path']; if (file_exists($imgFull)) unlink($imgFull); } $stmt = $pdo->prepare("DELETE FROM products WHERE id = ?"); $stmt->execute([$prodId]); $successMsg = 'Product deleted successfully!'; } } elseif ($_POST['action'] === 'edit_product') { $prodId = (int)($_POST['product_id'] ?? 0); $prodName = trim($_POST['product_name'] ?? ''); $prodCategory = trim($_POST['product_category'] ?? ''); $newCategory = trim($_POST['new_category'] ?? ''); $imagePosition = $_POST['image_position'] ?? 'center'; if (!empty($newCategory)) { $prodCategory = $newCategory; } if ($prodId > 0 && !empty($prodName)) { $updateSql = "UPDATE products SET name = ?, category = ?, image_position = ?"; $params = [$prodName, $prodCategory, $imagePosition]; if (isset($_FILES['product_image']) && $_FILES['product_image']['error'] === 0) { $uploadDir = __DIR__ . '/../images/products/'; if (!is_dir($uploadDir)) mkdir($uploadDir, 0755, true); $fileName = 'prod_' . time() . '_' . basename($_FILES['product_image']['name']); $targetFile = $uploadDir . $fileName; $ext = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); if (in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'webp'])) { if (move_uploaded_file($_FILES['product_image']['tmp_name'], $targetFile)) { $updateSql .= ", image_path = ?"; $params[] = 'images/products/' . $fileName; $oStmt = $pdo->prepare("SELECT image_path FROM products WHERE id = ?"); $oStmt->execute([$prodId]); $old = $oStmt->fetch(); if ($old && !empty($old['image_path']) && strpos($old['image_path'], 'images/products/') === 0) { $imgFull = __DIR__ . '/../' . $old['image_path']; if (file_exists($imgFull)) unlink($imgFull); } } else { $errorMsg = 'Failed to upload new product image.'; } } else { $errorMsg = 'Invalid image type.'; } } if (empty($errorMsg)) { $updateSql .= " WHERE id = ?"; $params[] = $prodId; $stmt = $pdo->prepare($updateSql); $stmt->execute($params); $successMsg = 'Product updated successfully!'; } } else { $errorMsg = 'Product ID and Name are required for update.'; } } elseif ($_POST['action'] === 'save_category_manager') { if (isset($_POST['cats']) && is_array($_POST['cats'])) { $stmt = $pdo->prepare("INSERT INTO category_settings (category_name, is_enabled, sort_order, heading_size, slides_per_view, mobile_heading_size, mobile_slides_per_view, product_title_size, mobile_product_title_size, btn_padding, btn_font_size, mobile_btn_padding, mobile_btn_font_size) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE is_enabled=VALUES(is_enabled), sort_order=VALUES(sort_order), heading_size=VALUES(heading_size), slides_per_view=VALUES(slides_per_view), mobile_heading_size=VALUES(mobile_heading_size), mobile_slides_per_view=VALUES(mobile_slides_per_view), product_title_size=VALUES(product_title_size), mobile_product_title_size=VALUES(mobile_product_title_size), btn_padding=VALUES(btn_padding), btn_font_size=VALUES(btn_font_size), mobile_btn_padding=VALUES(mobile_btn_padding), mobile_btn_font_size=VALUES(mobile_btn_font_size)"); foreach ($_POST['cats'] as $cName => $cData) { // Ensure name is passed $name = $cData['name'] ?? $cName; $isEnabled = isset($cData['is_enabled']) ? 1 : 0; $sortOrder = (int)($cData['sort_order'] ?? 0); $headingSize = trim($cData['heading_size'] ?? '1.8rem'); $slidesPerView = trim($cData['slides_per_view'] ?? '4.5'); $mHeadingSize = trim($cData['mobile_heading_size'] ?? '1.5rem'); $mSlidesPerView = trim($cData['mobile_slides_per_view'] ?? '2.2'); $pTitleSize = trim($cData['product_title_size'] ?? '1rem'); $mPTitleSize = trim($cData['mobile_product_title_size'] ?? '0.9rem'); $btnPadding = trim($cData['btn_padding'] ?? '0.5rem 1.2rem'); $btnFontSize = trim($cData['btn_font_size'] ?? '0.9rem'); $mBtnPadding = trim($cData['mobile_btn_padding'] ?? '0.4rem 1rem'); $mBtnFontSize = trim($cData['mobile_btn_font_size'] ?? '0.8rem'); $stmt->execute([$name, $isEnabled, $sortOrder, $headingSize, $slidesPerView, $mHeadingSize, $mSlidesPerView, $pTitleSize, $mPTitleSize, $btnPadding, $btnFontSize, $mBtnPadding, $mBtnFontSize]); } $successMsg = 'Category Carousel settings saved successfully!'; } } } // Filters logic $categoryFilter = $_GET['category'] ?? ''; $statusFilter = $_GET['status'] ?? ''; $where = []; $params = []; if ($categoryFilter) { $where[] = "category = ?"; $params[] = $categoryFilter; } if ($statusFilter) { $where[] = "status = ?"; $params[] = $statusFilter; } $whereClause = $where ? "WHERE " . implode(" AND ", $where) : ""; // Inquiries Pagination $limit = 10; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) $page = 1; $stmtCount = $pdo->prepare("SELECT COUNT(*) FROM inquiries $whereClause"); $stmtCount->execute($params); $totalInquiries = $stmtCount->fetchColumn(); $totalInquiryPages = ceil($totalInquiries / $limit); if ($page > $totalInquiryPages && $totalInquiryPages > 0) $page = $totalInquiryPages; $offset = ($page - 1) * $limit; $stmt = $pdo->prepare("SELECT * FROM inquiries $whereClause ORDER BY created_at DESC LIMIT $limit OFFSET $offset"); $stmt->execute($params); $inquiries = $stmt->fetchAll(); // Get unique categories for filter dropdown list $catStmt = $pdo->query("SELECT DISTINCT category FROM inquiries WHERE category IS NOT NULL AND category != ''"); $categories = $catStmt->fetchAll(PDO::FETCH_COLUMN); // Fetch products for the product manager $productsAdmin = []; $prodDbError = ''; try { // Always ensure table exists first $pdo->exec("CREATE TABLE IF NOT EXISTS products ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, category VARCHAR(100), image_path VARCHAR(255), image_position VARCHAR(50) DEFAULT 'center', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); try { $pdo->exec("ALTER TABLE products ADD COLUMN image_position VARCHAR(50) DEFAULT 'center'"); } catch(Exception $e) {} $prodAdminStmt = $pdo->query("SELECT * FROM products ORDER BY created_at DESC"); // Products Pagination $prodLimit = 10; $prodPage = isset($_GET['prod_page']) ? (int)$_GET['prod_page'] : 1; if ($prodPage < 1) $prodPage = 1; $totalProductsCount = $pdo->query("SELECT COUNT(*) FROM products")->fetchColumn(); $totalProdPages = ceil($totalProductsCount / $prodLimit); if ($prodPage > $totalProdPages && $totalProdPages > 0) $prodPage = $totalProdPages; $prodOffset = ($prodPage - 1) * $prodLimit; $prodAdminStmt = $pdo->prepare("SELECT * FROM products ORDER BY created_at DESC LIMIT $prodLimit OFFSET $prodOffset"); $prodAdminStmt->execute(); $productsAdmin = $prodAdminStmt->fetchAll(); } catch (Exception $e) { $prodDbError = $e->getMessage(); $productsAdmin = []; } // Product categories list $productCategories = ['Eco-friendly','Apparel','Kitchenware','Drinkware','Electronics','Stationery','Awards','Office Utility','Bags','Wellness','General']; try { $catStmt2 = $pdo->query("SELECT DISTINCT category FROM products WHERE category IS NOT NULL AND category != ''"); $dbCats = $catStmt2->fetchAll(PDO::FETCH_COLUMN); $productCategories = array_unique(array_merge($productCategories, $dbCats)); sort($productCategories); } catch (Exception $e) {} ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Inquiries Dashboard - Admin</title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link href="https://fonts.googleapis.com/css2?family=Jost:wght@400;600;700&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> :root { --primary: #d11618; --secondary: #65b03e; --dark: #1a3012; --bg: #f4f6f2; --surface: #ffffff; --border: #e0e6db; } * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Jost', sans-serif; } body { background: var(--bg); color: #333; } /* Sidebar/Navbar setup */ .navbar { background: linear-gradient(135deg, var(--dark), #2a4a1d); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.1); } .navbar .logo { font-size: 1.5rem; font-weight: 800; } .navbar .logo span { color: var(--primary); } .navbar .nav-links a { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.95rem; margin-left: 1.5rem; transition: 0.3s; } .navbar .nav-links a:hover { color: #fff; } .container { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; } .header-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; } .filters { display: flex; gap: 10px; background: var(--surface); padding: 10px 15px; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0,0,0,0.03); align-items: center; } .filters label { font-size: 0.85rem; font-weight: 600; color: #666; } .filters select { padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; font-size: 0.9rem; outline: none; background: #f9f9f9; } .btn-action { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; text-decoration: none; color: #fff; font-weight: 600; font-size: 0.9rem; transition: 0.3s; cursor: pointer; border: none; } .btn-export { background: linear-gradient(135deg, var(--secondary), #4a8a2d); } .btn-export:hover { filter: brightness(1.05); } /* Table Card styles */ .table-card { background: var(--surface); border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 8px 25px rgba(0,0,0,0.04); overflow: hidden; } table { width: 100%; border-collapse: collapse; text-align: left; } th { background: #fafcf9; padding: 15px 18px; font-size: 0.85rem; font-weight: 700; color: #1a1a1a; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.5px; } td { padding: 16px 18px; font-size: 0.92rem; color: #444; border-bottom: 1px solid #f0f4ee; vertical-align: top; } tr:last-child td { border-bottom: none; } tr:hover td { background-color: #fcfdfc; } .lead-info { line-height: 1.4; } .lead-info strong { color: #111; font-weight: 600; font-size: 0.95rem; } .lead-info div { font-size: 0.82rem; color: #666; margin-top: 3px; } .status-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; } .status-pending { background: #fef3c7; color: #d97706; } .status-contacted { background: #dbeafe; color: #2563eb; } .status-resolved { background: #d1fae5; color: #059669; } .actions-dropdown { position: relative; display: inline-block; } .actions-select { padding: 4px 8px; border-radius: 6px; border: 1px solid #ddd; font-size: 0.8rem; background: #fff; cursor: pointer; } .message-box { max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; color: #666; font-size: 0.85rem; } .message-box:hover { color: #111; text-decoration: underline; } .empty-state { padding: 3rem; text-align: center; color: #888; } .empty-state i { font-size: 3rem; color: #c0cbb8; margin-bottom: 1rem; display: block;} /* Settings Card styles */ .settings-card { background: var(--surface); border-radius: 16px; border: 1px solid var(--border); padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 4px 15px rgba(0,0,0,0.03); display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; } .settings-card h4 { font-size: 1.1rem; color: #111; margin-bottom: 0.5rem; } .settings-card .form-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .settings-card input[type="file"] { font-size: 0.85rem; padding: 8px; border: 1px dashed #ccc; border-radius: 8px; background: #fafafa; cursor: pointer; } .alert { padding: 10px 15px; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; font-weight: 600; } .alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; } .alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; } .settings-input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.9rem; margin-top: 5px; outline: none; background: #fdfdfd; transition: border-color 0.2s; } .settings-input:focus { border-color: var(--secondary); background: #fff; } /* Pagination styles */ .pagination { display: flex; gap: 5px; justify-content: flex-end; margin: 20px 18px; flex-wrap: wrap; } .pagination a { padding: 6px 14px; border: 1px solid #e0e6dd; background: #fff; color: #4a7c30; text-decoration: none; border-radius: 6px; font-size: 0.85rem; font-weight: 600; transition: 0.2s; } .pagination a:hover { background: #f0f7ec; border-color: #b5d99c; } .pagination a.active { background: #4a7c30; color: #fff; border-color: #4a7c30; } .pagination .dots { padding: 6px; color: #888; } </style> </head> <body> <nav class="navbar"> <div class="logo">Everest<span>Enterprise</span></div> <div class="nav-links"> <span style="font-size:0.9rem; color: rgba(255,255,255,0.5);">Logged in as <b><?php echo htmlspecialchars($_SESSION['admin_username']); ?></b></span> <a href="logout.php"><i class="fa-solid fa-arrow-right-from-bracket"></i> Logout</a> </div> </nav> <div class="container"> <?php if ($successMsg): ?> <div class="alert alert-success"><i class="fa-solid fa-circle-check"></i> <?php echo $successMsg; ?></div> <?php endif; ?> <?php if ($errorMsg): ?> <div class="alert alert-error"><i class="fa-solid fa-circle-exclamation"></i> <?php echo $errorMsg; ?></div> <?php endif; ?> <div class="settings-card"> <div> <h4><i class="fa-solid fa-image"></i> Update Hero Section Background</h4> <div style="font-size: 0.82rem; color: #666;">Current: <?php echo htmlspecialchars(getSetting('hero_bg_image', 'images/christmas-shopping-composition-with-space-right.jpg')); ?></div> </div> <form method="POST" action="" enctype="multipart/form-data" class="form-group"> <input type="hidden" name="action" value="save_setting"> <input type="file" name="hero_bg_image" accept="image/*" required> <button type="submit" class="btn-action btn-export" style="background:var(--primary);"><i class="fa-solid fa-upload"></i> Upload</button> </form> </div> <!-- Images & Sliders Manager Grid --> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; text-align:left;"> <!-- Partners / Client Logos Section --> <div class="table-card" style="padding: 1.5rem;"> <h4 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 8px;"> <i class="fa-solid fa-gem" style="color: var(--primary);"></i> Client Logos (Brand Slider) </h4> <form method="POST" action="" enctype="multipart/form-data" style="display: flex; gap: 10px; margin-bottom: 1.5rem;"> <input type="hidden" name="action" value="upload_partner_logo"> <input type="file" name="logo_file" accept="image/*" required class="settings-input" style="margin-top:0; padding: 6px;"> <button type="submit" class="btn-action btn-export" style="background:var(--primary); height:38px;"><i class="fa-solid fa-plus"></i> Add</button> </form> <h5 style="font-size: 0.82rem; color: #666; margin-bottom: 0.5rem;">Current Logos:</h5> <div style="display: flex; flex-wrap: wrap; gap: 10px; background: #fafafa; padding: 10px; border-radius: 8px; border:1px solid #eee; min-height: 50px;"> <?php $partnersDir = __DIR__ . '/../images/partners/'; $partnersFiles = is_dir($partnersDir) ? glob($partnersDir . '*') : []; if (empty($partnersFiles)): echo '<div style="font-size:0.8rem; color:#999;">No logos uploaded. Using defaults.</div>'; endif; foreach ($partnersFiles as $file): $path = 'images/partners/' . basename($file); ?> <div style="position: relative; border: 1px solid #ddd; border-radius: 6px; padding: 4px; background: #fff;"> <img src="../<?php echo $path; ?>" style="height: 35px; width: auto; max-width: 80px; object-fit: contain;"> <form method="POST" action="" style="position: absolute; top: -5px; right: -5px;"> <input type="hidden" name="action" value="delete_file"> <input type="hidden" name="file_path" value="<?php echo $path; ?>"> <button type="submit" style="background: #ef4444; color:#fff; border:none; border-radius: 50%; width:18px; height:18px; font-size:10px; cursor:pointer; display:flex; align-items:center; justify-content:center;" onclick="return confirm('Delete this logo?')">× </button> </form> </div> <?php endforeach; ?> </div> </div> <!-- Seamless Gifting Slider Images Section --> <div class="table-card" style="padding: 1.5rem;"> <h4 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 8px;"> <i class="fa-solid fa-photo-film" style="color: var(--primary);"></i> Seamless Gifting Slider </h4> <form method="POST" action="" enctype="multipart/form-data" style="display: flex; gap: 10px; margin-bottom: 1.5rem;"> <input type="hidden" name="action" value="upload_seamless_image"> <input type="file" name="slide_file" accept="image/*" required class="settings-input" style="margin-top:0; padding: 6px;"> <button type="submit" class="btn-action btn-export" style="background:var(--primary); height:38px;"><i class="fa-solid fa-plus"></i> Add</button> </form> <h5 style="font-size: 0.82rem; color: #666; margin-bottom: 0.5rem;">Current Slides:</h5> <div style="display: flex; flex-wrap: wrap; gap: 10px; background: #fafafa; padding: 10px; border-radius: 8px; border:1px solid #eee; min-height: 50px;"> <?php $seamlessDir = __DIR__ . '/../images/seamless/'; $seamlessFiles = is_dir($seamlessDir) ? glob($seamlessDir . '*') : []; if (empty($seamlessFiles)): echo '<div style="font-size:0.8rem; color:#999;">No images uploaded. Using defaults.</div>'; endif; foreach ($seamlessFiles as $file): $path = 'images/seamless/' . basename($file); ?> <div style="position: relative; border: 1px solid #ddd; border-radius: 6px; padding: 4px; background: #fff;"> <img src="../<?php echo $path; ?>" style="height: 35px; width: auto; max-width: 80px; object-fit: contain;"> <form method="POST" action="" style="position: absolute; top: -5px; right: -5px;"> <input type="hidden" name="action" value="delete_file"> <input type="hidden" name="file_path" value="<?php echo $path; ?>"> <button type="submit" style="background: #ef4444; color:#fff; border:none; border-radius: 50%; width:18px; height:18px; font-size:10px; cursor:pointer; display:flex; align-items:center; justify-content:center;" onclick="return confirm('Delete this slide image?')">× </button> </form> </div> <?php endforeach; ?> </div> </div> </div> <!-- ===== PRODUCT MANAGER ===== --> <div id="products-manager" class="table-card" style="padding: 1.5rem; margin-bottom: 2rem; border: 2px solid #e8f5e1;"> <h4 style="margin-bottom: 1.2rem; display: flex; align-items: center; gap: 10px; font-size: 1.15rem !important; text-align:left;"> <i class="fa-solid fa-box-open" style="color: var(--primary); font-size:1.3rem;"></i> Product Cards Manager <span style="font-size:0.8rem; font-weight:400; color:#888; margin-left:auto; background:#f0f4ee; padding:3px 10px; border-radius:20px;"><?php echo count($productsAdmin); ?> product(s)</span> </h4> <?php if (!empty($prodDbError)): ?> <div class="alert alert-error" style="margin-bottom:1rem;"><i class="fa-solid fa-triangle-exclamation"></i> Database Error: <?php echo htmlspecialchars($prodDbError); ?></div> <?php endif; ?> <!-- Add Product Form --> <div style="background: #f4fdf0; padding: 1.2rem; border-radius: 10px; border: 1px dashed #b5d99c; margin-bottom: 1.8rem;"> <h5 id="formHeading" style="font-size: 0.9rem; color: #4a7c30; margin-bottom: 1rem; font-weight: 700; text-align:left;"><i class="fa-solid fa-plus-circle"></i> Add New Product</h5> <form id="productForm" method="POST" action="" enctype="multipart/form-data"> <input type="hidden" name="action" id="formAction" value="add_product"> <input type="hidden" name="product_id" id="formProductId" value=""> <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px;"> <div> <label style="font-size: 0.8rem; font-weight: 600; color: #555; display:block; margin-bottom:4px;">Product Name *</label> <input type="text" name="product_name" id="formProductName" class="settings-input" style="margin-top:0;" placeholder="e.g. Premium Diary Set" required> </div> <div> <label style="font-size: 0.8rem; font-weight: 600; color: #555; display:block; margin-bottom:4px;">Category</label> <div style="display: flex; gap: 8px;"> <select name="product_category" id="formProductCategory" class="settings-input" style="margin-top:0; flex:1;"> <option value="">-- Select Existing --</option> <?php foreach ($productCategories as $pc): ?> <option value="<?php echo htmlspecialchars($pc); ?>"><?php echo htmlspecialchars($pc); ?></option> <?php endforeach; ?> </select> <input type="text" name="new_category" id="formNewCategory" class="settings-input" style="margin-top:0; flex:1;" placeholder="Or type new category..."> </div> </div> </div> <div style="display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;"> <div style="flex:1; min-width:200px;"> <label style="font-size: 0.8rem; font-weight: 600; color: #555; display:block; margin-bottom:4px;">Product Image (optional)</label> <input type="file" name="product_image" accept="image/*" class="settings-input" style="margin-top:0; padding: 6px; width:100%;"> <small id="formProductImageHelp" style="display:none; color:#666; font-size:0.75rem; margin-top:4px;">Leave empty to keep existing image</small> </div> <div style="flex:1; min-width:150px;"> <label style="font-size: 0.8rem; font-weight: 600; color: #555; display:block; margin-bottom:4px;">Image Position</label> <select name="image_position" id="formImagePosition" class="settings-input" style="margin-top:0; width:100%;"> <option value="center">Center (Default)</option> <option value="top">Top</option> <option value="bottom">Bottom</option> <option value="left">Left</option> <option value="right">Right</option> </select> </div> <div style="display: flex; gap: 8px;"> <button type="button" id="formCancelBtn" onclick="cancelEdit()" style="display:none; background: #888; color: #fff; border: none; height: 42px; padding: 0 16px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 0.9rem;"> Cancel </button> <button type="submit" id="formSubmitBtn" class="btn-action btn-export" style="background: var(--secondary); height: 42px; padding: 0 24px; white-space: nowrap; font-size: 1rem;"> <i class="fa-solid fa-plus"></i> Add Product </button> </div> </div> </form> </div> <!-- Products List --> <?php if (empty($productsAdmin)): ?> <div style="text-align: center; padding: 2rem; color: #aaa; background:#fafafa; border-radius:8px; border:1px dashed #eee;"> <i class="fa-solid fa-box-open" style="font-size: 2rem; display:block; margin-bottom:0.5rem; color:#ddd;"></i> No products yet. Add your first product above. </div> <?php else: ?> <div style="overflow-x: auto;"> <table style="width:100%; border-collapse: collapse; font-size: 0.9rem; text-align: left;"> <thead> <tr style="border-bottom: 2px solid #eee;"> <th style="padding: 10px 12px; color: #333; font-weight: 700;">Image</th> <th style="padding: 10px 12px; color: #333; font-weight: 700;">Product Name</th> <th style="padding: 10px 12px; color: #333; font-weight: 700;">Category</th> <th style="padding: 10px 12px; color: #333; font-weight: 700;">Added</th> <th style="padding: 10px 12px; color: #333; font-weight: 700;">Action</th> </tr> </thead> <tbody> <?php foreach ($productsAdmin as $prod): ?> <tr style="border-bottom: 1px solid #f5f5f5;" onmouseover="this.style.background='#fafcf9'" onmouseout="this.style.background=''"> <td style="padding: 10px 12px;"> <?php if (!empty($prod['image_path'])): ?> <img src="../<?php echo htmlspecialchars($prod['image_path']); ?>" style="height: 48px; width: 60px; object-fit: cover; border-radius: 6px; border: 1px solid #eee;" alt=""> <?php else: ?> <div style="height: 48px; width: 60px; background: #f5f5f5; border-radius: 6px; display: flex; align-items: center; justify-content: center; border: 1px solid #eee;"> <i class="fa-solid fa-image" style="color: #ccc;"></i> </div> <?php endif; ?> </td> <td style="padding: 10px 12px; font-weight: 600; color: #111;"><?php echo htmlspecialchars($prod['name']); ?></td> <td style="padding: 10px 12px;"> <?php if (!empty($prod['category'])): ?> <span style="background: #eef6e8; color: #3a7d1a; font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 20px;"><?php echo htmlspecialchars($prod['category']); ?></span> <?php else: ?> <span style="color: #aaa; font-size: 0.8rem;">—</span> <?php endif; ?> </td> <td style="padding: 10px 12px; color: #888; font-size: 0.82rem;"><?php echo date('d M Y', strtotime($prod['created_at'])); ?></td> <td style="padding: 10px 12px;"> <div style="display: flex; gap: 8px;"> <button type="button" onclick="editProduct(<?php echo $prod['id']; ?>, '<?php echo htmlspecialchars(addslashes($prod['name'])); ?>', '<?php echo htmlspecialchars(addslashes($prod['category'] ?? '')); ?>', '<?php echo htmlspecialchars(addslashes($prod['image_position'] ?? 'center')); ?>')" style="background: #3b82f6; color: #fff; border: none; padding: 5px 12px; border-radius: 6px; font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;"> <i class="fa-solid fa-pen"></i> Edit </button> <form method="POST" action="" onsubmit="return confirm('Delete this product?')"> <input type="hidden" name="action" value="delete_product"> <input type="hidden" name="product_id" value="<?php echo $prod['id']; ?>"> <button type="submit" style="background: #ef4444; color: #fff; border: none; padding: 5px 12px; border-radius: 6px; font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;"> <i class="fa-solid fa-trash"></i> Delete </button> </form> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> <!-- Products Pagination UI --> <?php if ($totalProdPages > 1): ?> <div class="pagination"> <?php if ($prodPage > 1): ?> <a href="?prod_page=<?php echo $prodPage - 1; ?>&page=<?php echo $page; ?>#products-manager"><i class="fa-solid fa-chevron-left"></i></a> <?php endif; ?> <?php for ($i = 1; $i <= $totalProdPages; $i++): ?> <?php if ($i == 1 || $i == $totalProdPages || ($i >= $prodPage - 1 && $i <= $prodPage + 1)): ?> <a href="?prod_page=<?php echo $i; ?>&page=<?php echo $page; ?>#products-manager" class="<?php echo ($i == $prodPage) ? 'active' : ''; ?>"><?php echo $i; ?></a> <?php elseif ($i == 2 || $i == $totalProdPages - 1): ?> <span class="dots">...</span> <?php endif; ?> <?php endfor; ?> <?php if ($prodPage < $totalProdPages): ?> <a href="?prod_page=<?php echo $prodPage + 1; ?>&page=<?php echo $page; ?>#products-manager"><i class="fa-solid fa-chevron-right"></i></a> <?php endif; ?> </div> <?php endif; ?> </div> <?php endif; ?> </div> <?php // Fetch all categories for the manager safely to avoid collation UNION errors $allCategories = []; try { $catStmt1 = $pdo->query("SELECT DISTINCT category FROM products WHERE category IS NOT NULL AND trim(category) != ''"); $cats1 = $catStmt1->fetchAll(PDO::FETCH_COLUMN); $catStmt2 = $pdo->query("SELECT category_name FROM category_settings"); $cats2 = $catStmt2->fetchAll(PDO::FETCH_COLUMN); $merged = array_filter(array_merge((array)$cats1, (array)$cats2)); $allCategories = array_unique($merged); sort($allCategories, SORT_NATURAL | SORT_FLAG_CASE); } catch (Exception $e) { $allCategories = []; } // Fetch settings $catSettingsStmt = $pdo->query("SELECT * FROM category_settings"); $catSettingsRaw = $catSettingsStmt->fetchAll(PDO::FETCH_ASSOC); $catSettings = []; foreach ($catSettingsRaw as $c) { $catSettings[$c['category_name']] = $c; } ?> <!-- Category Carousels Manager Box --> <div class="table-card" style="padding: 1.5rem; margin-bottom: 2rem;"> <h4 style="margin-bottom: 1.2rem; display: flex; align-items: center; gap: 8px;"> <i class="fa-solid fa-list-check" style="color: var(--primary);"></i> Category Carousels Manager </h4> <form method="POST" action=""> <input type="hidden" name="action" value="save_category_manager"> <div class="table-container" style="overflow-x: auto;"> <table class="data-table"> <thead> <tr> <th>Category Name</th> <th style="text-align:center;">Enable</th> <th style="text-align:center;">Order</th> <th>Heading Size (D / M)</th> <th>Slides Limit (D / M)</th> <th>Prod Title (D / M)</th> <th>Btn Padding (D / M)</th> <th>Btn Font (D / M)</th> </tr> </thead> <tbody> <?php foreach ($allCategories as $cName): ?> <?php $cSet = $catSettings[$cName] ?? [ 'is_enabled'=>1, 'sort_order'=>0, 'heading_size'=>'1.8rem', 'slides_per_view'=>'4.5', 'mobile_heading_size'=>'1.5rem', 'mobile_slides_per_view'=>'2.2', 'product_title_size'=>'1rem', 'mobile_product_title_size'=>'0.9rem', 'btn_padding'=>'0.5rem 1.2rem', 'btn_font_size'=>'0.9rem', 'mobile_btn_padding'=>'0.4rem 1rem', 'mobile_btn_font_size'=>'0.8rem' ]; $safeCName = htmlspecialchars($cName); ?> <tr> <td style="padding: 6px 10px;"><strong><?php echo $safeCName; ?></strong> <input type="hidden" name="cats[<?php echo $safeCName; ?>][name]" value="<?php echo $safeCName; ?>"> </td> <td style="text-align:center; padding: 6px 10px;"> <input type="checkbox" name="cats[<?php echo $safeCName; ?>][is_enabled]" value="1" <?php echo $cSet['is_enabled'] ? 'checked' : ''; ?> style="width: 20px; height: 20px; cursor: pointer;"> </td> <td style="text-align:center; padding: 6px 10px;"> <input type="number" name="cats[<?php echo $safeCName; ?>][sort_order]" class="settings-input" style="width: 60px; margin:0 auto; padding: 6px; text-align:center;" value="<?php echo (int)$cSet['sort_order']; ?>"> </td> <td style="padding: 6px 10px;"> <input type="text" name="cats[<?php echo $safeCName; ?>][heading_size]" class="settings-input" style="width: 80px; margin-bottom:4px; padding: 6px;" value="<?php echo htmlspecialchars($cSet['heading_size'] ?? '1.8rem'); ?>" title="Desktop"> <input type="text" name="cats[<?php echo $safeCName; ?>][mobile_heading_size]" class="settings-input" style="width: 80px; padding: 6px; background: #f9f9f9;" value="<?php echo htmlspecialchars($cSet['mobile_heading_size'] ?? '1.5rem'); ?>" title="Mobile"> </td> <td style="padding: 6px 10px;"> <input type="text" name="cats[<?php echo $safeCName; ?>][slides_per_view]" class="settings-input" style="width: 80px; margin-bottom:4px; padding: 6px;" value="<?php echo htmlspecialchars($cSet['slides_per_view'] ?? '4.5'); ?>" title="Desktop"> <input type="text" name="cats[<?php echo $safeCName; ?>][mobile_slides_per_view]" class="settings-input" style="width: 80px; padding: 6px; background: #f9f9f9;" value="<?php echo htmlspecialchars($cSet['mobile_slides_per_view'] ?? '2.2'); ?>" title="Mobile"> </td> <td style="padding: 6px 10px;"> <input type="text" name="cats[<?php echo $safeCName; ?>][product_title_size]" class="settings-input" style="width: 80px; margin-bottom:4px; padding: 6px;" value="<?php echo htmlspecialchars($cSet['product_title_size'] ?? '1rem'); ?>" title="Desktop Title Size"> <input type="text" name="cats[<?php echo $safeCName; ?>][mobile_product_title_size]" class="settings-input" style="width: 80px; padding: 6px; background: #f9f9f9;" value="<?php echo htmlspecialchars($cSet['mobile_product_title_size'] ?? '0.9rem'); ?>" title="Mobile Title Size"> </td> <td style="padding: 6px 10px;"> <input type="text" name="cats[<?php echo $safeCName; ?>][btn_padding]" class="settings-input" style="width: 100px; margin-bottom:4px; padding: 6px;" value="<?php echo htmlspecialchars($cSet['btn_padding'] ?? '0.5rem 1.2rem'); ?>" title="Desktop Button Padding"> <input type="text" name="cats[<?php echo $safeCName; ?>][mobile_btn_padding]" class="settings-input" style="width: 100px; padding: 6px; background: #f9f9f9;" value="<?php echo htmlspecialchars($cSet['mobile_btn_padding'] ?? '0.4rem 1rem'); ?>" title="Mobile Button Padding"> </td> <td style="padding: 6px 10px;"> <input type="text" name="cats[<?php echo $safeCName; ?>][btn_font_size]" class="settings-input" style="width: 80px; margin-bottom:4px; padding: 6px;" value="<?php echo htmlspecialchars($cSet['btn_font_size'] ?? '0.9rem'); ?>" title="Desktop Button Font Size"> <input type="text" name="cats[<?php echo $safeCName; ?>][mobile_btn_font_size]" class="settings-input" style="width: 80px; padding: 6px; background: #f9f9f9;" value="<?php echo htmlspecialchars($cSet['mobile_btn_font_size'] ?? '0.8rem'); ?>" title="Mobile Button Font Size"> </td> </tr> <?php endforeach; ?> <?php if(empty($allCategories)): ?> <tr><td colspan="8" style="text-align:center; padding: 20px;">No categories found. Add some products to see them here!</td></tr> <?php endif; ?> </tbody> </table> </div> <div style="margin-top: 1.5rem; display: flex; align-items: center; gap: 15px;"> <button type="submit" class="btn-action btn-export" style="background: var(--primary); padding: 0 24px; font-size: 1rem;"><i class="fa-solid fa-save"></i> Save Category Settings</button> <small style="color: #666; font-size: 0.85rem;">Note: Lower Position number shows first. Uncheck 'Enable' to hide a category completely.</small> </div> </form> </div> <!-- General Settings Box --> <div class="table-card" style="padding: 1.5rem; margin-bottom: 2rem;"> <h4 style="margin-bottom: 1.2rem; display: flex; align-items: center; gap: 8px;"> <i class="fa-solid fa-gear" style="color: var(--primary);"></i> General Contact & Email (SMTP) Settings </h4> <form method="POST" action=""> <input type="hidden" name="action" value="save_general_settings"> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; margin-bottom: 1.5rem; text-align:left;"> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">WhatsApp Number (with country code)</label> <input type="text" name="whatsapp_number" class="settings-input" value="<?php echo htmlspecialchars(getSetting('whatsapp_number', $_ENV['PHONE_NUMBER'] ?? '919167762534')); ?>" placeholder="e.g. 919167762534"> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">WhatsApp Greeting Message</label> <textarea name="whatsapp_message" class="settings-input" rows="2"><?php echo htmlspecialchars(getSetting('whatsapp_message', 'Hi, I\'m interested in corporate gifting options. Please share more details.')); ?></textarea> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">Call / Phone Number</label> <input type="text" name="call_number" class="settings-input" value="<?php echo htmlspecialchars(getSetting('call_number', $_ENV['PHONE_NUMBER'] ?? '+91 9167762534')); ?>"> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">Admin Notification Email</label> <input type="email" name="admin_email" class="settings-input" value="<?php echo htmlspecialchars(getSetting('admin_email', $_ENV['ADMIN_EMAIL'] ?? 'info@tapwell.co.in')); ?>"> </div> </div> <h5 style="margin-bottom: 0.8rem; font-size: 0.95rem; color: #444; border-bottom: 1px solid #f0f0f0; padding-bottom: 5px; text-align:left;">SMTP Setup</h5> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 15px; margin-bottom: 1.5rem; text-align:left;"> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">SMTP Host</label> <input type="text" name="smtp_host" class="settings-input" value="<?php echo htmlspecialchars(getSetting('smtp_host', $_ENV['SMTP_HOST'] ?? '')); ?>" placeholder="smtp.gmail.com"> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">SMTP Port</label> <input type="text" name="smtp_port" class="settings-input" value="<?php echo htmlspecialchars(getSetting('smtp_port', $_ENV['SMTP_PORT'] ?? '587')); ?>"> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">SMTP Secure</label> <select name="smtp_secure" class="settings-input"> <option value="tls" <?php echo getSetting('smtp_secure', 'tls') === 'tls' ? 'selected' : ''; ?>>TLS</option> <option value="ssl" <?php echo getSetting('smtp_secure') === 'ssl' ? 'selected' : ''; ?>>SSL</option> <option value="none" <?php echo getSetting('smtp_secure') === 'none' ? 'selected' : ''; ?>>None</option> </select> </div> </div> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 15px; margin-bottom: 1.5rem; text-align:left;"> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">SMTP Username / Email</label> <input type="text" name="smtp_user" class="settings-input" value="<?php echo htmlspecialchars(getSetting('smtp_user', $_ENV['SMTP_USER'] ?? '')); ?>"> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">SMTP Password</label> <div style="position: relative; margin-top: 5px;"> <input type="password" id="smtp_pass" name="smtp_pass" class="settings-input" style="margin-top: 0; padding-right: 35px;" value="<?php echo htmlspecialchars(getSetting('smtp_pass', $_ENV['SMTP_PASS'] ?? '')); ?>"> <i class="fa-solid fa-eye" onclick="togglePassword('smtp_pass', this)" style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #888; cursor: pointer;"></i> </div> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">From Name</label> <input type="text" name="from_name" class="settings-input" value="<?php echo htmlspecialchars(getSetting('from_name', $_ENV['FROM_NAME'] ?? 'Everest Enterprise')); ?>"> </div> <div> <label style="font-size: 0.82rem; font-weight: 600; color: #555;">From Email</label> <input type="email" name="from_email" class="settings-input" value="<?php echo htmlspecialchars(getSetting('from_email', $_ENV['FROM_EMAIL'] ?? 'noreply@tapwell.co.in')); ?>"> </div> </div> <div style="text-align: left;"> <button type="submit" class="btn-action btn-export" style="background:var(--secondary);"><i class="fa-solid fa-floppy-disk"></i> Save General Settings</button> </div> </form> </div> <div class="header-controls"> <form class="filters" method="GET" action=""> <label>Filter By:</label> <select name="category" onchange="this.form.submit()"> <option value="">All Categories</option> <?php foreach ($categories as $cat): ?> <option value="<?php echo htmlspecialchars($cat); ?>" <?php echo $categoryFilter === $cat ? 'selected' : ''; ?>> <?php echo htmlspecialchars($cat); ?> </option> <?php endforeach; ?> </select> <select name="status" onchange="this.form.submit()"> <option value="">All Statuses</option> <option value="pending" <?php echo $statusFilter === 'pending' ? 'selected' : ''; ?>>Pending</option> <option value="contacted" <?php echo $statusFilter === 'contacted' ? 'selected' : ''; ?>>Contacted</option> <option value="resolved" <?php echo $statusFilter === 'resolved' ? 'selected' : ''; ?>>Resolved</option> </select> </form> <a href="export.php?category=<?php echo urlencode($categoryFilter); ?>&status=<?php echo urlencode($statusFilter); ?>" class="btn-action btn-export"> <i class="fa-solid fa-file-csv"></i> Export to CSV </a> </div> <div id="lead-info" class="table-card"> <?php if (empty($inquiries)): ?> <div class="empty-state"> <i class="fa-solid fa-folder-open"></i> <p>No inquiries found for selected filters.</p> </div> <?php else: ?> <table> <thead> <tr> <th>Lead Info</th> <th>Inquiry Details</th> <th>Requirements</th> <th>Status</th> <th>Date</th> </tr> </thead> <tbody> <?php foreach ($inquiries as $row): ?> <tr> <td> <div class="lead-info"> <strong><?php echo htmlspecialchars($row['name']); ?></strong> <div><i class="fa-solid fa-envelope"></i> <?php echo htmlspecialchars($row['email']); ?></div> <?php if ($row['phone']): ?> <div><i class="fa-solid fa-phone"></i> <?php echo htmlspecialchars($row['phone']); ?></div> <?php endif; ?> <?php if ($row['company']): ?> <div><i class="fa-solid fa-building"></i> <?php echo htmlspecialchars($row['company']); ?></div> <?php endif; ?> </div> </td> <td> <div class="lead-info"> <strong><?php echo htmlspecialchars($row['category'] ?: 'General'); ?></strong> <div>Source: <?php echo htmlspecialchars($row['form_type']); ?></div> </div> </td> <td> <div class="lead-info"> <?php if ($row['quantity']): ?><div>Qty: <?php echo htmlspecialchars($row['quantity']); ?></div><?php endif; ?> <?php if ($row['budget']): ?><div>Budget: <?php echo htmlspecialchars($row['budget']); ?></div><?php endif; ?> <?php if ($row['specs']): ?><div>Specs: <?php echo htmlspecialchars($row['specs']); ?></div><?php endif; ?> <?php if ($row['message']): ?> <div class="message-box" title="<?php echo htmlspecialchars($row['message']); ?>"> Msg: <?php echo htmlspecialchars($row['message']); ?> </div> <?php endif; ?> </div> </td> <td> <div style="display: flex; flex-direction: column; gap: 5px;"> <span class="status-badge status-<?php echo $row['status'] ?: 'pending'; ?>"> <?php echo ucfirst($row['status'] ?: 'pending'); ?> </span> <select class="actions-select" onchange="window.location.href='?action=update_status&id=<?php echo $row['id']; ?>&status='+this.value"> <option value="" disabled selected>Mark as...</option> <option value="pending">Pending</option> <option value="contacted">Contacted</option> <option value="resolved">Resolved</option> </select> </div> </td> <td style="font-size: 0.82rem; color: #888;"> <?php echo date('d M Y', strtotime($row['created_at'])); ?><br> <?php echo date('h:i A', strtotime($row['created_at'])); ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <!-- Inquiries Pagination UI --> <?php if ($totalInquiryPages > 1): ?> <div class="pagination"> <?php $params_str = ""; if($categoryFilter) $params_str .= "&category=".urlencode($categoryFilter); if($statusFilter) $params_str .= "&status=".urlencode($statusFilter); ?> <?php if ($page > 1): ?> <a href="?page=<?php echo $page - 1; ?><?php echo $params_str; ?>&prod_page=<?php echo $prodPage; ?>#lead-info"><i class="fa-solid fa-chevron-left"></i></a> <?php endif; ?> <?php for ($i = 1; $i <= $totalInquiryPages; $i++): ?> <?php if ($i == 1 || $i == $totalInquiryPages || ($i >= $page - 1 && $i <= $page + 1)): ?> <a href="?page=<?php echo $i; ?><?php echo $params_str; ?>&prod_page=<?php echo $prodPage; ?>#lead-info" class="<?php echo ($i == $page) ? 'active' : ''; ?>"><?php echo $i; ?></a> <?php elseif ($i == 2 || $i == $totalInquiryPages - 1): ?> <span class="dots">...</span> <?php endif; ?> <?php endfor; ?> <?php if ($page < $totalInquiryPages): ?> <a href="?page=<?php echo $page + 1; ?><?php echo $params_str; ?>&prod_page=<?php echo $prodPage; ?>#lead-info"><i class="fa-solid fa-chevron-right"></i></a> <?php endif; ?> </div> <?php endif; ?> <?php endif; ?> </div> </div> <script> function togglePassword(inputId, icon) { const input = document.getElementById(inputId); if (input.type === 'password') { input.type = 'text'; icon.classList.remove('fa-eye'); icon.classList.add('fa-eye-slash'); } else { input.type = 'password'; icon.classList.remove('fa-eye-slash'); icon.classList.add('fa-eye'); } } function editProduct(id, name, category, imagePosition) { document.getElementById('formAction').value = 'edit_product'; document.getElementById('formProductId').value = id; document.getElementById('formProductName').value = name; let catSelect = document.getElementById('formProductCategory'); let foundCat = false; for (let i = 0; i < catSelect.options.length; i++) { if (catSelect.options[i].value === category) { catSelect.options[i].selected = true; foundCat = true; break; } } if (!foundCat && category) { document.getElementById('formNewCategory').value = category; catSelect.value = ''; } else { document.getElementById('formNewCategory').value = ''; } document.getElementById('formImagePosition').value = imagePosition || 'center'; document.getElementById('formHeading').innerHTML = '<i class="fa-solid fa-pen"></i> Edit Product'; document.getElementById('formHeading').style.color = '#3b82f6'; let btn = document.getElementById('formSubmitBtn'); btn.innerHTML = '<i class="fa-solid fa-floppy-disk"></i> Save Changes'; btn.style.background = '#3b82f6'; document.getElementById('formCancelBtn').style.display = 'inline-block'; document.getElementById('formProductImageHelp').style.display = 'block'; document.getElementById('formHeading').scrollIntoView({behavior: 'smooth', block: 'center'}); } function cancelEdit() { document.getElementById('productForm').reset(); document.getElementById('formAction').value = 'add_product'; document.getElementById('formProductId').value = ''; document.getElementById('formHeading').innerHTML = '<i class="fa-solid fa-plus-circle"></i> Add New Product'; document.getElementById('formHeading').style.color = '#4a7c30'; let btn = document.getElementById('formSubmitBtn'); btn.innerHTML = '<i class="fa-solid fa-plus"></i> Add Product'; btn.style.background = 'var(--secondary)'; document.getElementById('formCancelBtn').style.display = 'none'; document.getElementById('formProductImageHelp').style.display = 'none'; } </script> </body> </html>
SAVE
CANCEL