<?php
require_once __DIR__ . '/mj_v304_bootstrap.php';
$userId = mjv304_current_user_id();
if ($userId > 0):
$newLeads = (int)mjv304_fetch_value("SELECT COUNT(*) FROM seller_leads WHERE seller_user_id=? AND status='new'", [$userId]);
$followDue = (int)mjv304_fetch_value("SELECT COUNT(*) FROM seller_leads WHERE seller_user_id=? AND followup_at IS NOT NULL AND followup_at<=NOW() AND status NOT IN ('converted','closed','spam')", [$userId]);
$reviewsPending = (int)mjv304_fetch_value("SELECT COUNT(*) FROM mj_admin_review_queue WHERE user_id=? AND status='pending'", [$userId]);
$notifications = (int)mjv304_fetch_value("SELECT COUNT(*) FROM mj_notifications WHERE user_type='user' AND user_id=? AND is_read=0", [$userId]);
?>
<link rel="stylesheet" href="assets/css/mj-v304.css?v=304">
<div class="mj-v304-wrap" style="padding-left:0;padding-right:0;">
  <div class="mj-grid mj-grid-4">
    <div class="mj-card"><h3>New Leads</h3><div class="num"><?php echo $newLeads; ?></div><a class="mj-btn mj-btn-sm" href="my-leads.php?status=new">View Leads</a></div>
    <div class="mj-card"><h3>Follow-up Due</h3><div class="num"><?php echo $followDue; ?></div><a class="mj-btn mj-btn-sm" href="my-leads.php?status=followup">Follow Up</a></div>
    <div class="mj-card"><h3>Pending Reviews</h3><div class="num"><?php echo $reviewsPending; ?></div><span class="mj-muted">Old live version remains active</span></div>
    <div class="mj-card"><h3>Unread Notifications</h3><div class="num"><?php echo $notifications; ?></div><span class="mj-muted">Payment, review, enquiry alerts</span></div>
  </div>
  <div class="mj-card" style="margin-top:14px;">
    <div class="mj-actions">
      <a class="mj-btn mj-btn-primary" href="add-listing.php">Add Listing</a>
      <a class="mj-btn" href="add-company.php">Add Company</a>
      <a class="mj-btn" href="add-deal.php">Add Deal</a>
      <a class="mj-btn" href="my-leads.php">CRM / Leads</a>
      <a class="mj-btn" href="billing-payments.php?tab=overview">Billing</a>
      <a class="mj-btn" href="wallet.php">Wallet Top-up</a>
    </div>
  </div>
</div>
<?php endif; ?>
