<?php
ob_start();
session_start();
date_default_timezone_set("Asia/Jakarta");
include('../../config/koneksi.php');

$sid = session_id();

// SEO
$sql_0 = mysqli_query($conn,"SELECT * FROM tb_seo WHERE cuid = 1");
$s0 = mysqli_fetch_array($sql_0);
$urlweb = $s0['urlweb'];

// USER
if(isset($_SESSION['user'])) {
    $user = mysqli_query($conn,"SELECT * FROM tb_user WHERE username = '".$_SESSION['user']."'");
    $u = mysqli_fetch_array($user);

    $userID = $u['cuid'];

    $sql_balance = mysqli_query($conn,"SELECT * FROM tb_balance WHERE userID = '$userID'");
    $s3 = mysqli_fetch_array($sql_balance);

    $sql_bank = mysqli_query($conn,"SELECT * FROM tb_bank WHERE userID = '$userID'");
    $sbs = mysqli_fetch_array($sql_bank);
}

// CEK TRANSAKSI PENDING
$cekTransaksi = mysqli_query($conn,"SELECT * FROM tb_transaksi WHERE userID = '$userID' AND jenis = 1 AND status = 0");
$ct = mysqli_num_rows($cekTransaksi);

// QRIS
$sql_qris = mysqli_query($conn, "SELECT * FROM tb_qris WHERE id = 1");
$sq = mysqli_fetch_array($sql_qris);

include "../header.php";
?>

<div class="container-wrapper acc" style="background-color:black;">
<div class="container container-box noSidePadding">

<?php if($ct > 0){ ?>
    <div class="alert alert-danger">
        Anda masih memiliki deposit pending, tunggu selesai dulu.
    </div>
<?php } else { ?>

<form action="<?php echo $urlweb; ?>/function2/deposit.php" method="post">

<input type="hidden" name="postID" value="<?php echo $u['cuid']; ?>">

<!-- METODE -->
<div class="form-group">
    <label>Metode</label>
    <input type="text" class="form-control" value="QRIS" readonly>
</div>

<!-- REKENING -->
<div class="form-group">
    <label>Rekening Pengirim</label>
    <select class="form-control" name="pay_from">
        <option value="<?php echo $sbs['cuid']; ?>">
            <?php echo $sbs['akun']; ?> - <?php echo $sbs['no_rek']; ?>
        </option>
    </select>
</div>

<!-- QRIS -->
<div class="form-group text-center">
    <label>QRIS Penerima</label>

    <div style="padding:10px;">
        <img src="<?php echo $sq['gambar']; ?>" 
             style="width:100%; max-width:400px; border-radius:10px;">
    </div>
</div>

<!-- BONUS -->
<div class="form-group">
    <label>Bonus</label>
    <select class="form-control" name="gameid">
        <option value="0">Tanpa Bonus</option>
        <?php
        $sql_bonus = mysqli_query($conn,"SELECT * FROM tb_post WHERE kategori = 0");
        while($b = mysqli_fetch_array($sql_bonus)){
        ?>
        <option value="<?php echo $b['cuid']; ?>">
            <?php echo $b['title']; ?>
        </option>
        <?php } ?>
    </select>
</div>

<!-- NOMINAL -->
<div class="form-group">
    <label>Jumlah Deposit</label>
    <input type="number" class="form-control" name="nominal" min="50000" required>
</div>

<!-- CATATAN -->
<div class="form-group">
    <label>Keterangan</label>
    <input type="text" class="form-control" name="catatan">
</div>

<!-- CHECK -->
<div class="form-group">
    <input type="checkbox" name="termcondition" required> Saya setuju
</div>

<!-- BUTTON -->
<button type="submit" class="btn btn-primary btn-block">LANJUT</button>

</form>

<?php } ?>

</div>
</div>

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