🚀 Hostinger Optimized
🖥️ Server: LiteSpeed
💻 System: Linux s20058.bom1.stableserver.net 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
👤 User: skhata (1324)
🐘 PHP: 8.4.20
🚫 Disabled: ✨ NONE

💻 Terminal

📁 /home/skhata/chandrasons.com/public
$

📄 leads.php

📁 Path: /home/skhata/excellenteducation.com.np/admin/leads.php
📊 Size: 5.39 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php
require_once __DIR__ . '/../includes/auth.php';
require_login();
$pageTitle = 'Leads Inbox';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && csrf_verify()) {
    $action = $_POST['action'] ?? '';
    if ($action === 'update_status') {
        $stmt = db()->prepare('UPDATE leads SET status = ? WHERE id = ?');
        $stmt->execute([$_POST['status'] ?? 'new', (int) ($_POST['id'] ?? 0)]);
        flash_set('success', 'Lead status updated.');
    } elseif ($action === 'delete') {
        $stmt = db()->prepare('DELETE FROM leads WHERE id = ?');
        $stmt->execute([(int) ($_POST['id'] ?? 0)]);
        flash_set('success', 'Lead deleted.');
    }
    redirect('leads.php');
}

$statusFilter = $_GET['status'] ?? '';
$sql = 'SELECT * FROM leads';
$params = [];
if (in_array($statusFilter, ['new', 'contacted', 'converted', 'closed'], true)) {
    $sql .= ' WHERE status = ?';
    $params[] = $statusFilter;
}
$sql .= ' ORDER BY created_at DESC';
$stmt = db()->prepare($sql);
$stmt->execute($params);
$leads = $stmt->fetchAll();

require __DIR__ . '/partials/header.php';
require __DIR__ . '/partials/sidebar.php';
require __DIR__ . '/partials/topbar.php';
?>

<div class="flex flex-wrap items-center justify-between gap-3 mb-5">
  <div class="flex flex-wrap gap-2">
    <a href="leads.php" class="px-4 py-2 rounded-full text-sm font-medium <?= $statusFilter === '' ? 'bg-brand-black text-white' : 'bg-white border border-gray-300' ?>">All</a>
    <a href="leads.php?status=new" class="px-4 py-2 rounded-full text-sm font-medium <?= $statusFilter === 'new' ? 'bg-brand-black text-white' : 'bg-white border border-gray-300' ?>">New</a>
    <a href="leads.php?status=contacted" class="px-4 py-2 rounded-full text-sm font-medium <?= $statusFilter === 'contacted' ? 'bg-brand-black text-white' : 'bg-white border border-gray-300' ?>">Contacted</a>
    <a href="leads.php?status=converted" class="px-4 py-2 rounded-full text-sm font-medium <?= $statusFilter === 'converted' ? 'bg-brand-black text-white' : 'bg-white border border-gray-300' ?>">Converted</a>
    <a href="leads.php?status=closed" class="px-4 py-2 rounded-full text-sm font-medium <?= $statusFilter === 'closed' ? 'bg-brand-black text-white' : 'bg-white border border-gray-300' ?>">Closed</a>
  </div>
  <a href="leads_export.php?status=<?= e($statusFilter) ?>" class="bg-gradient-to-r from-brand-red to-brand-green text-white text-sm font-semibold px-5 py-2.5 rounded-xl hover:brightness-110 transition">
    <i class="fa-solid fa-file-csv mr-1"></i> Export to Excel (CSV)
  </a>
</div>

<div class="bg-white rounded-2xl shadow-sm overflow-hidden">
  <div class="overflow-x-auto">
    <table class="w-full text-sm">
      <thead class="bg-gray-50"><tr class="text-left text-gray-400">
        <th class="px-5 py-3 font-medium">Name</th>
        <th class="px-5 py-3 font-medium">Contact</th>
        <th class="px-5 py-3 font-medium">Interested In</th>
        <th class="px-5 py-3 font-medium">Message</th>
        <th class="px-5 py-3 font-medium">Source</th>
        <th class="px-5 py-3 font-medium">Date</th>
        <th class="px-5 py-3 font-medium">Status</th>
        <th class="px-5 py-3 font-medium text-right">Actions</th>
      </tr></thead>
      <tbody>
        <?php if (!$leads): ?>
          <tr><td colspan="8" class="px-5 py-8 text-center text-gray-400">No leads found.</td></tr>
        <?php endif; ?>
        <?php foreach ($leads as $lead): ?>
        <tr class="border-t border-gray-100 hover:bg-gray-50/60 align-top">
          <td class="px-5 py-3 font-medium"><?= e($lead['name']) ?></td>
          <td class="px-5 py-3 text-gray-500"><?= e($lead['phone']) ?><br><?= e($lead['email']) ?></td>
          <td class="px-5 py-3 text-gray-500"><?= e($lead['interested_country']) ?><?= $lead['interested_course'] ? '<br>' . e($lead['interested_course']) : '' ?></td>
          <td class="px-5 py-3 text-gray-500 max-w-xs"><?= e(mb_strimwidth((string) $lead['message'], 0, 80, '…')) ?></td>
          <td class="px-5 py-3 text-gray-500"><?= e($lead['source_page']) ?></td>
          <td class="px-5 py-3 text-gray-400 whitespace-nowrap"><?= e(date('d M Y', strtotime($lead['created_at']))) ?></td>
          <td class="px-5 py-3">
            <form method="post" class="inline">
              <?= csrf_field() ?>
              <input type="hidden" name="action" value="update_status">
              <input type="hidden" name="id" value="<?= (int) $lead['id'] ?>">
              <select name="status" onchange="this.form.submit()" class="text-xs rounded-full border border-gray-300 px-2 py-1">
                <?php foreach (['new','contacted','converted','closed'] as $st): ?>
                  <option value="<?= $st ?>" <?= $lead['status'] === $st ? 'selected' : '' ?>><?= ucfirst($st) ?></option>
                <?php endforeach; ?>
              </select>
            </form>
          </td>
          <td class="px-5 py-3 text-right whitespace-nowrap">
            <form method="post" class="inline" onsubmit="return confirm('Delete this lead?');">
              <?= csrf_field() ?>
              <input type="hidden" name="action" value="delete">
              <input type="hidden" name="id" value="<?= (int) $lead['id'] ?>">
              <button type="submit" class="text-brand-red hover:text-red-700"><i class="fa-solid fa-trash"></i></button>
            </form>
          </td>
        </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
  </div>
</div>

<?php require __DIR__ . '/partials/footer.php'; ?>
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨