38350-vm/matching.php
2026-02-11 08:19:17 +00:00

145 lines
8.0 KiB
PHP

<?php
include 'header.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
require_once 'db/config.php';
$user_id = $_SESSION['user_id'];
$order_id = $_GET['order_id'] ?? null;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['type'])) {
$type = $_POST['type'];
$amount = $_POST['amount'];
$currency = $_POST['currency'] ?? 'USDT';
// Create order
$stmt = db()->prepare("INSERT INTO fiat_orders (user_id, amount, currency, status, created_at) VALUES (?, ?, ?, 'pending', CURRENT_TIMESTAMP)");
$stmt->execute([$user_id, $amount, $currency]);
$order_id = db()->lastInsertId();
// Notify CS via messages table
$msg = "New deposit order #$order_id: $amount $currency. Please provide bank account details.";
$stmt = db()->prepare("INSERT INTO messages (user_id, sender, message) VALUES (?, 'user', ?)");
$stmt->execute([$user_id, $msg]);
header("Location: matching.php?order_id=" . $order_id);
exit;
}
if (!$order_id) {
header("Location: deposit.php");
exit;
}
// Fetch order
$stmt = db()->prepare("SELECT * FROM fiat_orders WHERE id = ? AND user_id = ?");
$stmt->execute([$order_id, $user_id]);
$order = $stmt->fetch();
if (!$order) {
header("Location: deposit.php");
exit;
}
// Handle Proof Upload
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['proof'])) {
$file = $_FILES['proof'];
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
$filename = 'proof_' . $order_id . '_' . time() . '.' . $ext;
$target = 'assets/images/proofs/' . $filename;
if (!is_dir('assets/images/proofs/')) mkdir('assets/images/proofs/', 0775, true);
if (move_uploaded_file($file['tmp_name'], $target)) {
$stmt = db()->prepare("UPDATE fiat_orders SET proof_image = ?, status = 'submitting' WHERE id = ?");
$stmt->execute(['assets/images/proofs/' . $filename, $order_id]);
header("Location: matching.php?order_id=" . $order_id);
exit;
}
}
?>
<main style="padding: 40px 20px; background: #0b0e11; min-height: calc(100vh - 64px);">
<div style="max-width: 800px; margin: 0 auto;">
<div style="background: var(--card-bg); padding: 40px; border-radius: 24px; border: 1px solid var(--border-color); text-align: center;">
<?php if (!$order['bank_account_info']): ?>
<div id="matching-spinner">
<div style="width: 80px; height: 80px; border: 4px solid rgba(0,82,255,0.1); border-top-color: var(--primary-color); border-radius: 50%; margin: 0 auto 30px; animation: spin 1s linear infinite;"></div>
<h2 style="margin-bottom: 10px;"><?php echo __('matching_account', 'Matching Payment Account...'); ?></h2>
<p style="color: var(--text-muted);"><?php echo __('matching_desc', 'Our system is matching a secure local account for your deposit. Please wait a moment.'); ?></p>
<div style="margin-top: 30px; font-size: 14px; color: var(--primary-color);">
<i class="fas fa-info-circle"></i> Tip: You can also contact <a href="chat.php" style="color: var(--primary-color); font-weight: bold;">Online Support</a> for faster processing.
</div>
</div>
<script>
setInterval(() => {
fetch('api/check_order_status.php?order_id=<?php echo $order_id; ?>')
.then(r => r.json())
.then(data => {
if (data.bank_account_info) {
location.reload();
}
});
}, 3000);
</script>
<?php elseif ($order['status'] === 'pending'): ?>
<div style="text-align: left;">
<div style="display: flex; align-items: center; gap: 15px; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid var(--border-color);">
<div style="width: 50px; height: 50px; background: rgba(14,203,129,0.1); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--success-color); font-size: 20px;">
<i class="fas fa-check-circle"></i>
</div>
<div>
<h2 style="margin: 0;">Account Matched Successfully</h2>
<p style="margin: 5px 0 0; color: var(--text-muted); font-size: 14px;">Please complete the transfer to the following account.</p>
</div>
</div>
<div style="background: #161a1e; padding: 25px; border-radius: 16px; margin-bottom: 30px; border: 1px solid var(--border-color);">
<div style="font-size: 14px; color: var(--text-muted); margin-bottom: 20px;">BANK ACCOUNT DETAILS</div>
<?php echo nl2br(htmlspecialchars($order['bank_account_info'])); ?>
</div>
<div style="background: rgba(240,185,11,0.05); padding: 20px; border-radius: 12px; border: 1px solid rgba(240,185,11,0.2); margin-bottom: 30px;">
<h4 style="color: #f0b90b; margin: 0 0 10px;"><i class="fas fa-exclamation-triangle"></i> Important Instructions</h4>
<ul style="margin: 0; padding-left: 20px; font-size: 13px; color: #ccc; line-height: 1.8;">
<li>Please transfer the exact amount: <strong><?php echo $order['amount']; ?> <?php echo $order['currency']; ?></strong></li>
<li>Include your UID <strong><?php echo $_SESSION['uid']; ?></strong> in the transfer remarks.</li>
<li>Take a screenshot of the successful transfer.</li>
</ul>
</div>
<form method="POST" enctype="multipart/form-data">
<label style="display: block; margin-bottom: 15px; font-weight: bold;">Upload Payment Voucher</label>
<div style="border: 2px dashed var(--border-color); padding: 30px; border-radius: 16px; text-align: center; cursor: pointer; transition: 0.2s;" onmouseover="this.style.borderColor='var(--primary-color)'" onmouseout="this.style.borderColor='var(--border-color)'" onclick="document.getElementById('proof-file').click()">
<i class="fas fa-cloud-upload-alt" style="font-size: 40px; color: var(--text-muted); margin-bottom: 15px;"></i>
<div style="color: var(--text-muted); font-size: 14px;">Click to select or drag and drop image</div>
<input type="file" name="proof" id="proof-file" accept="image/*" style="display: none;" onchange="this.form.submit()">
</div>
</form>
</div>
<?php else: ?>
<div style="padding: 40px 0;">
<i class="fas fa-clock" style="font-size: 64px; color: var(--gold-color); margin-bottom: 20px;"></i>
<h2 style="margin-bottom: 15px;">Deposit Under Review</h2>
<p style="color: var(--text-muted); line-height: 1.6;">Your payment proof has been submitted successfully. Our team will verify the transaction and update your balance within 30 minutes.</p>
<div style="margin-top: 40px; display: flex; gap: 15px; justify-content: center;">
<a href="profile.php" class="btn-primary" style="padding: 12px 30px; border-radius: 8px;">Back to Assets</a>
<a href="chat.php" class="btn-primary" style="background: #2b3139; padding: 12px 30px; border-radius: 8px;">Contact Support</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
</main>
<style>
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
</style>
<?php include 'footer.php'; ?>