38751-vm/views/auth/profile.php
Flatlogic Bot 4f61082b27 Aslam vbru
2026-02-24 22:45:41 +00:00

165 lines
8.9 KiB
PHP

<?php include __DIR__ . '/../header.php'; ?>
<div class="container py-5">
<div class="row">
<div class="col-lg-4">
<div class="card shadow border-0 rounded-4 mb-4">
<div class="card-body text-center p-5">
<div class="bg-success text-white rounded-circle d-inline-flex align-items-center justify-content-center mb-4" style="width: 80px; height: 80px;">
<i class="bi bi-person-fill fs-1"></i>
</div>
<h3 class="fw-bold mb-0"><?php echo $user['username']; ?></h3>
<p class="text-muted">Member since <?php echo date('M Y', strtotime($user['created_at'])); ?></p>
<hr>
<div class="row g-0">
<div class="col-6 border-end">
<h4 class="fw-bold text-success mb-0"><?php echo $user['points']; ?></h4>
<small class="text-muted text-uppercase">Points</small>
</div>
<div class="col-6">
<h4 class="fw-bold text-primary mb-0"><?php echo $user['total_referrals']; ?></h4>
<small class="text-muted text-uppercase">Referrals</small>
</div>
</div>
</div>
</div>
<div class="card shadow border-0 rounded-4 mb-4">
<div class="card-body p-4 text-center bg-light">
<h6 class="text-uppercase text-muted fw-bold mb-2">Current Balance</h6>
<h2 class="fw-bold text-success mb-3">Rp <?php echo number_format($user['balance'], 0, ',', '.'); ?></h2>
<button class="btn btn-success btn-lg px-5 rounded-pill" data-bs-toggle="modal" data-bs-target="#withdrawModal">
<i class="bi bi-wallet2 me-2"></i> Withdraw
</button>
<p class="small text-muted mt-3 mb-0">Min. withdraw: Rp 10.000</p>
</div>
</div>
</div>
<div class="col-lg-8">
<?php if (isset($success)): ?>
<div class="alert alert-success border-0 rounded-4 mb-4"><?php echo $success; ?></div>
<?php endif; ?>
<?php if (isset($error)): ?>
<div class="alert alert-danger border-0 rounded-4 mb-4"><?php echo $error; ?></div>
<?php endif; ?>
<div class="card shadow border-0 rounded-4 mb-4">
<div class="card-header bg-white py-3">
<h5 class="m-0 fw-bold">My Referral Code</h5>
</div>
<div class="card-body p-4">
<p>Share your referral link to earn <b>Rp 500</b> for every download.</p>
<div class="input-group mb-3">
<input type="text" class="form-control bg-light" id="refLink" value="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . '/register?ref=' . $user['referral_code']; ?>" readonly>
<button class="btn btn-outline-success" type="button" onclick="copyText('refLink')">Copy Link</button>
</div>
<div class="small text-muted">Example APK referral link:</div>
<div class="input-group">
<input type="text" class="form-control bg-light" value="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . '/apk/example-slug?ref=' . $user['referral_code']; ?>" readonly>
</div>
</div>
</div>
<div class="card shadow border-0 rounded-4">
<div class="card-header bg-white py-3 d-flex justify-content-between align-items-center">
<h5 class="m-0 fw-bold">Withdrawal History</h5>
<span class="badge bg-light text-dark">Recent activities</span>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="bg-light">
<tr>
<th class="ps-4">Date</th>
<th>Amount</th>
<th>Method</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php if (empty($withdrawals)): ?>
<tr>
<td colspan="4" class="text-center py-5 text-muted">No withdrawal history yet.</td>
</tr>
<?php endif; ?>
<?php foreach ($withdrawals as $wd): ?>
<tr>
<td class="ps-4"><?php echo date('d M Y, H:i', strtotime($wd['created_at'])); ?></td>
<td class="fw-bold text-success">Rp <?php echo number_format($wd['amount'], 0, ',', '.'); ?></td>
<td><?php echo $wd['method']; ?></td>
<td>
<?php
$statusClass = 'secondary';
if ($wd['status'] === 'pending') $statusClass = 'warning';
if ($wd['status'] === 'approved') $statusClass = 'success';
if ($wd['status'] === 'rejected') $statusClass = 'danger';
?>
<span class="badge bg-<?php echo $statusClass; ?>">
<?php echo ucfirst($wd['status']); ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Withdraw Modal -->
<div class="modal fade" id="withdrawModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content border-0 rounded-4 overflow-hidden">
<div class="modal-header bg-success text-white py-4 border-0">
<h5 class="modal-title fw-bold">Request Withdrawal</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="/withdraw" method="POST">
<div class="modal-body p-4">
<div class="mb-3">
<label class="form-label fw-bold">Amount to Withdraw (IDR)</label>
<div class="input-group">
<span class="input-group-text">Rp</span>
<input type="number" class="form-control" name="amount" min="10000" max="<?php echo (int)$user['balance']; ?>" step="1000" placeholder="Min 10.000" required>
</div>
</div>
<div class="mb-3">
<label class="form-label fw-bold">Payment Method</label>
<select class="form-select" name="method" required>
<option value="">Select method...</option>
<option value="DANA">DANA</option>
<option value="OVO">OVO</option>
<option value="GOPAY">GoPay</option>
<option value="ShopeePay">ShopeePay</option>
<option value="BANK">Bank Transfer</option>
</select>
</div>
<div class="mb-0">
<label class="form-label fw-bold">Account Details</label>
<textarea class="form-control" name="details" rows="3" placeholder="Enter phone number or bank account number with name" required></textarea>
</div>
</div>
<div class="modal-footer border-0 p-4 pt-0">
<button type="button" class="btn btn-light px-4 rounded-pill" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-success px-4 rounded-pill">Submit Request</button>
</div>
</form>
</div>
</div>
</div>
<script>
function copyText(id) {
var copyText = document.getElementById(id);
copyText.select();
copyText.setSelectionRange(0, 99999);
navigator.clipboard.writeText(copyText.value);
alert("Referral link copied to clipboard!");
}
</script>
<?php include __DIR__ . '/../footer.php'; ?>