<?php
/**
 * upgrade.php -- Upgrade page
 */

include '../inc/config.inc.php'; // Configuration

ob_start();
session_start();

//date_default_timezone_set('Africa/Lagos');

error_reporting(E_ALL);
ini_set('display_errors', 1);

if ( !isset($_SESSION['user']) || $_SESSION["loggedin"] !== true || trim($_SESSION['user']) == '' ){
	header('Location: ' . $BASE_URL . 'signin');
	exit;
}

// User Details
$stmt = $db_con->prepare("SELECT * FROM users WHERE id=:user_id");
$stmt->execute(array(":user_id"=>$_SESSION['user']));
$userRow = $stmt->fetch(PDO::FETCH_ASSOC);

// Admin Details
$getAdmin = $db_con->prepare("SELECT * FROM admin WHERE id=2"); // view details for only 2nd admin
$getAdmin->execute();
$adminRow = $getAdmin->fetch(PDO::FETCH_ASSOC);

?>

<!doctype html>
<html lang="en-uk">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="keywords" content="investment, Forex, Trading, Bitcoin, Cryptocurrency, Global investment, Live Trade, Trading class, indics">
    <meta name="author" content="Paul HubWeb & Tech">
    <meta name="theme-color" content="#313131" />
    <!-- Site Properties -->
    <title>Upgrade Account - Criptohopper</title>
    <link rel="shortcut icon" href="../img/Signals-Alert-3.png" type="image/x-icon" />
    <link rel="apple-touch-icon-precomposed" href="../img/Signals-Alert-3.png" />
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Typography CSS -->
    <link rel="stylesheet" href="css/typography.css">
    <!-- Style CSS -->
    <link rel="stylesheet" href="css/style.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="css/responsive.css">
    <style>
        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            font-family: Arial, Helvetica, sans-serif;
        }

        .header {
            overflow: none;
            background-color: none;
            padding: 20px 10px;
            padding-left: 5px;
            position: fixed;
        }

        /*.header a {
            float: center;
            width:30px;
            color: #fff;
            text-align: center;
            padding: 12px;
            text-decoration: none;
            font-size: 18px; 
            line-height: 25px;
            border-radius: 4px;
            background-color:rgb(196, 0, 0);
            border-color: rgb(196, 0, 0);
        }*/

        .header a.logo {
            font-size: 25px;
            font-weight: bold;
        }

        /*.header a:hover {
            background-color:  #010847;
            color: #fff;
        }*/

        /*.header a.active {
            background-color: dodgerblue;
            color: white;
        }*/

        .header-center {
            float: left;
        }

        @media screen and (max-width: 500px) {
            .header a {
                float: none;
                display: block;
                text-align: left;
            }

            .header-right {
                float: none;
            }
        }
    </style>

    <script src="../plugins/sweetalerts/promise-polyfill.js"></script>
    <link href="../plugins/sweetalerts/sweetalert.css" rel="stylesheet" type="text/css" />

    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700" rel="stylesheet" />
    <style>
        /*------ Google Font Style ------ */
        body {font-family:'Roboto'!important;}
    </style>

</head>
<body class="sidebar-main-active right-column-fixed">
    <!-- loader Start -->
    <!--<div id="loading">
        <div id="loading-center">
        </div>
    </div>-->
    <!-- loader END -->
    <!-- Wrapper Start -->
    <div class="wrapper">

        <!-- Page Content  -->
        <div id="content-page" class="content-page">
            <?php include 'navbar2.php' ?>
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-12 col-lg-9">
                        <div class="iq-card">
                            <div class="iq-card">
                                <div class="iq-card-header d-flex justify-content-between">
                                    <div class="iq-header-title">
                                        <h4 class="card-title" style="font-family: 'Roboto'!important;">Account Upgrade</h4>
                                    </div>
                                </div>
                                <div class="iq-card-body">
                                    <p style="font-size:40px;"><b>Upgrade Plan</b></p>
                                    <?php
/*$upgradePlans2 = $db_con->query(
        "SELECT up.up_id, up.plan_name, upfr.upfr_id, upfr.up_id, upfr.user_id, upfr.fee
        FROM user_upgrade_plans up 
        INNER JOIN user_upgrade_plans_feerequest upfr
        ON upfr.user_id='$user_id'"
    );*/
    /*$upgradePlans2 = $db_con->query(
        "SELECT up.up_id, up.plan_name, upfr.upfr_id, upfr.up_id, upfr.user_id, upfr.fee
        FROM user_upgrade_plans up 
        LEFT JOIN user_upgrade_plans_feerequest upfr
        ON up.up_id=upfr.up_id
        WHERE upfr.user_id='$user_id'"
    );*/
                                    ?>
                                    <!--<form action="#" method="post" autocomplete="off" id="withdrawal-form" class="was-validated">-->
                                    <form action="" method="post" autocomplete="off" id="withdrawal-form" class="was-validated" enctype="multipart/form-data">
                                        <div class="form-group">
                                            <label>Upgrade Plans</label>
                                            <select name="upgraderequest" id="upgraderequest" class="form-control" required>
                                            <?php
                                            $upgradePlans = $db_con->query(
                                                "SELECT up.up_id, up.plan_name, upfr.upfr_id, upfr.up_id, upfr.user_id, upfr.fee
                                                FROM user_upgrade_plans up 
                                                LEFT JOIN user_upgrade_plans_feerequest upfr
                                                ON up.up_id=upfr.up_id
                                                WHERE upfr.user_id='".$userRow['id']."' AND publish='Yes'"
                                            );
                                            ?>
                                                <option value="" style="font-size:30px;"><b>---Select Plan---</b></option>
                                            <?php
                                            while ( $plans = $upgradePlans->fetch(PDO::FETCH_ASSOC) ){
                                            ?>
                                                <option value="<?= $plans['up_id']; ?>"><?= $plans['plan_name']; ?> - <?= $userRow['currency'] . number_format($plans['fee'], 2); ?></option>
                                            <?php } ?>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label>Payment Method</label>
                                            <select name="paymentmethod" id="withdrawalMethod" class="form-control" required>
                                                <option value="" style="font-size:30px;"><b>---Select Method---</b></option>
                                                <option value="Bitcoin">Bitcoin</option>
                                                <option value="Ethereum">Ethereum</option>
                                                <option value="Litecoin">USDT</option>
                                                <option value="BitcoinCash">BitcoinCash</option>
                                                <!--<option value="Paypal">Paypal</option>-->
                                            </select>
                                        </div>
                                        <div id="field1" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">Bitcoin Wallet barcode</label><br>
                                            <img src="../wp-admin/uploads/<?= $adminRow['bitcoin_file']; ?>" alt="bitcoin code" style="max-width:40%;">
                                        </div>
                                        <div id="field12" class="mb-3" style="display: None;">
                                            <label for="validationDefault01">BTC Wallet Address</label>
                                            <input type="text" class="form-control" id="validationDefault01" value="<?= $adminRow['bitcoin_address']; ?>" disabled>
                                        </div>
                                        <div id="field2" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">Ethereum Wallet barcode</label><br>
                                            <img src="../wp-admin/uploads/<?= $adminRow['ethereum_file']; ?>" alt="Ethereum code" style="max-width:40%;">
                                        </div>
                                        <div id="field13" class="mb-3" style="display: None;">
                                            <label for="validationDefault01">Ethereum Wallet Address</label>
                                            <input type="text" class="form-control" id="validationDefault01" value="<?= $adminRow['ethereum_address']; ?>" disabled>
                                        </div>
                                        <div id="field3" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">USDT Wallet Barcode</label><br>
                                            <img src="../wp-admin/uploads/<?= $adminRow['litecoin_file']; ?>" alt="LiteCoin code" style="max-width:40%;">
                                        </div>
                                        <div id="field14" class="mb-3" style="display: None;">
                                            <label for="validationDefault01">USDT Wallet Address</label>
                                            <input type="text" class="form-control" id="validationDefault01" value="<?= $adminRow['litecoin_address']; ?>" disabled>
                                        </div>
                                        <div id="field4" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">BitcoinCash Wallet Barcode</label><br>
                                            <img src="../wp-admin/uploads/<?= $adminRow['bitcoincash_file']; ?>" alt="BitcoinCash code" style="max-width:40%;">
                                        </div>
                                        <div id="field15" class="mb-3" style="display: None;">
                                            <label for="validationDefault01">BitcoinCash Wallet Address</label>
                                            <input type="text" class="form-control" id="validationDefault01" value="<?= $adminRow['bitcoincash_address']; ?>" disabled>
                                        </div>
                                        <!--<div id="field5" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">Skrill Email</label>
                                            <input type="text" class="form-control is-invalid" id="address" id="validationTextarea" placeholder="Skrill Email" required>
                                        </div>-->
                                        <div id="field6" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">PayPal Payment</label>
                                            <div id="smart-button-container">
                                                <div style="text-align: center"><label for="description">Deposit </label><input type="text" name="descriptionInput" id="description" maxlength="127" value=""></div>
                                                <p id="descriptionError" style="visibility: hidden; color:red; text-align: center;">Please enter a description</p>
                                                <div style="text-align: center"><label for="amount">input Amount </label><input name="amountInput" type="number" id="amount" value=""><span> GBP</span></div>
                                                <p id="priceLabelError" style="visibility: hidden; color:red; text-align: center;">Please enter a price</p>
                                                <div id="invoiceidDiv" style="text-align: center; display: none;"><label for="invoiceid"> </label><input name="invoiceid" maxlength="127" type="text" id="invoiceid" value=""></div>
                                                <p id="invoiceidError" style="visibility: hidden; color:red; text-align: center;">Please enter an Invoice ID</p>
                                                <div style="text-align: center; margin-top: 0.625rem;" id="paypal-button-container"></div>
                                            </div>
                                            <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=GBP" data-sdk-integration-source="button-factory"></script>
                                            <script>
                                                function initPayPalButton() {
                                                    var description = document.querySelector('#smart-button-container #description');
                                                    var amount = document.querySelector('#smart-button-container #amount');
                                                    var descriptionError = document.querySelector('#smart-button-container #descriptionError');
                                                    var priceError = document.querySelector('#smart-button-container #priceLabelError');
                                                    var invoiceid = document.querySelector('#smart-button-container #invoiceid');
                                                    var invoiceidError = document.querySelector('#smart-button-container #invoiceidError');
                                                    var invoiceidDiv = document.querySelector('#smart-button-container #invoiceidDiv');

                                                    var elArr = [description, amount];

                                                    if (invoiceidDiv.firstChild.innerHTML.length > 1) {
                                                        invoiceidDiv.style.display = "block";
                                                    }

                                                    var purchase_units = [];
                                                    purchase_units[0] = {};
                                                    purchase_units[0].amount = {};

                                                    function validate(event) {
                                                        return event.value.length > 0;
                                                    }

                                                    paypal.Buttons({
                                                        style: {
                                                            color: 'gold',
                                                            shape: 'rect',
                                                            label: 'paypal',
                                                            layout: 'vertical',

                                                        },

                                                        onInit: function(data, actions) {
                                                            actions.disable();

                                                            if (invoiceidDiv.style.display === "block") {
                                                                elArr.push(invoiceid);
                                                            }

                                                            elArr.forEach(function(item) {
                                                                item.addEventListener('keyup', function(event) {
                                                                    var result = elArr.every(validate);
                                                                    if (result) {
                                                                        actions.enable();
                                                                    } else {
                                                                        actions.disable();
                                                                    }
                                                                });
                                                            });
                                                        },

                                                        onClick: function() {
                                                            if (description.value.length < 1) {
                                                                descriptionError.style.visibility = "visible";
                                                            } else {
                                                                descriptionError.style.visibility = "hidden";
                                                            }

                                                            if (amount.value.length < 1) {
                                                                priceError.style.visibility = "visible";
                                                            } else {
                                                                priceError.style.visibility = "hidden";
                                                            }

                                                            if (invoiceid.value.length < 1 && invoiceidDiv.style.display === "block") {
                                                                invoiceidError.style.visibility = "visible";
                                                            } else {
                                                                invoiceidError.style.visibility = "hidden";
                                                            }

                                                            purchase_units[0].description = description.value;
                                                            purchase_units[0].amount.value = amount.value;

                                                            if (invoiceid.value !== '') {
                                                                purchase_units[0].invoice_id = invoiceid.value;
                                                            }
                                                        },

                                                        createOrder: function(data, actions) {
                                                            return actions.order.create({
                                                                purchase_units: purchase_units,
                                                            });
                                                        },

                                                        onApprove: function(data, actions) {
                                                            return actions.order.capture().then(function(details) {
                                                                alert('Transaction completed by ' + details.payer.name.given_name + '!');
                                                            });
                                                        },

                                                        onError: function(err) {
                                                            console.log(err);
                                                        }
                                                    }).render('#paypal-button-container');
                                                }
                                                initPayPalButton();
                                            </script>
                                        </div>
                                        <!--<div id="field7" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">Bank Name</label>
                                            <input type="text" class="form-control is-invalid" id="address" id="validationTextarea" placeholder="Bank Name" required>
                                        </div>
                                        <div id="field8" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">Account Number</label>
                                            <input type="text" class="form-control is-invalid" id="address" id="validationTextarea" placeholder="Account Number" required>
                                        </div>
                                        <div id="field9" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">Country</label>
                                            <input type="text" class="form-control is-invalid" id="address" id="validationTextarea" placeholder="Country" required>
                                        </div>
                                        <div id="field10" class="mb-3" style="display: None;">
                                            <label for="validationTextarea">Swift Code</label>
                                            <input type="text" class="form-control is-invalid" id="address" id="validationTextarea" placeholder="Swift Code" required>
                                        </div>-->
                                        <div class="form-group">
                                            <label>Upload Your Proof of payment:</label>
                                            <input type="file" class="form-control" name="requestProof" accept="image/*" required>
                                        </div>
                                        <div class="mb-3">
                                            <label for="validationTextarea">Description</label>
                                            <textarea class="form-control is-invalid" id="validationTextarea" name="narration" placeholder="Narration" required></textarea>
                                        </div>
                                        <div class="form-group">
                                            <button class="btn btn-primary" name="uprequest" type="submit">Submit form</button>
                                        </div>
                                    </form>
                                    <?php
                                    if ( isset($_POST['uprequest']) ){
                                        error_reporting(E_ALL);

                                        $upgraderequest = $_POST['upgraderequest'];
                                        $paymentmethod = $_POST['paymentmethod'];
                                        $narration = $_POST['narration'];
                                        $time = date('H:i:s');
                                        $date = date('Y/m/d');
                                        $created = date('Y-m-d H:i:s');

                                        /*$checkPlans = $db_con->query(
                                            "SELECT up.up_id, upfr.upfr_id, upfr.up_id, upfr.user_id
                                            FROM user_upgrade_plans up 
                                            INNER JOIN user_upgrade_plans_feerequest upfr
                                            WHERE up.up_id=upfr.up_id AND upfr.user_id='".$userRow['id']."'"
                                        );
                                        $checkPlan = $checkPlans->fetchAll();
                                        if ( $checkPlans->rowCount() > 0 ){*/
                                        $checkPlans = $db_con->query("SELECT up_id, plan_name FROM user_upgrade_plans up WHERE up_id='$upgraderequest'");
                                        $chkPlan = $checkPlans->fetch(PDO::FETCH_ASSOC);
                                        if ( $chkPlan['plan_name'] == $userRow['current_plan'] ){
                                    ?>
                                            <script>
                                                setTimeout(function(){
                                                    noticePop('You can\'t upgrade to the same plan twice.', 'error');
                                                }, 2000);
                                            </script>
                                    <?php
                                        }
                                        else {
                                            $targetDir = "uploads/"; // Directory to save in uploads
                                            $allowedExts = array('jpg', 'jpeg', 'png'); // Allowed File Types

                                            if ( !empty($_FILES['requestProof']['name']) ){
                                                $extRequestProof = pathinfo(basename($_FILES['requestProof']['name']), PATHINFO_EXTENSION); // Get the extension
                                                if ( !in_array(strtolower($extRequestProof), $allowedExts) ){
                                    ?>
                                                    <script>
                                                        setTimeout(function(){
                                                            noticePop('Invalid File Type. Upload an Image.', 'error');
                                                        }, 2000);
                                                    </script>
                                    <?php
                                                } else {
                                                    $newRequestProof = 'up-request_' . randDoc($extRequestProof); // Randomization

                                                    $insert = "INSERT INTO user_transactions(user_id, any_id, fullname, type, method, file, narration, time, date, created) VALUES ('".$userRow['id']."', '$upgraderequest', '".$userRow['fullname']."', 'Upgrade Plan', '$paymentmethod', '$newRequestProof', '$narration', '$time', '$date', '$created')";

                                                    $updateUpFR = $db_con->prepare("UPDATE user_upgrade_plans_feerequest SET payment_method='$paymentmethod', file='$newRequestProof', narration='$narration', status='Pending', requested_datetime='$created' WHERE up_id='$upgraderequest' AND user_id='".$userRow['id']."'");

                                                    /*if ( file_exists($target_dir) ){
                                                        echo 'Dir Exists<br>';
                                                    } else { echo 'Does not exits<br>'; }
                                                    if ( is_writable($target_dir) ){
                                                        echo 'Dir is writable<br>';
                                                    } else { echo 'Dir not writable<br>'; }*/
                                                    if ( move_uploaded_file($_FILES['requestProof']['tmp_name'], $targetDir . $newRequestProof) ){
                                                        $updateUpFR->execute();
                                                        $db_con->exec($insert);

                                                        //$updateUpFR = $db_con->query("UPDATE user_upgrade_plans_feerequest SET payment_method='$paymentmethod', file='$newRequestProof', narration='$narration', requested_datetime='$created' WHERE up_id='$upgraderequest' AND user_id='".$userRow['id']."'");
                                                        //$trans_id = $db_con->lastInsertId();

                                                        //$updateLastDeposit = $db_con->prepare("UPDATE user_last_deposit SET amount='$amount', trans_id='$trans_id', status='Pending' WHERE user_id='".$userRow['id']."'");
                                                        //$updateLastDeposit->execute();
                                    ?>
                                                        <script>
                                                            setTimeout(function(){
                                                                noticePop('Upgrade Request Proof (<?= $paymentmethod; ?>) Has Been Sent. Await Confirmation.', 'success');
                                                            }, 2000);
                                                        </script>
                                    <?php
                                                    } else {
                                    ?>
                                                        <script>
                                                            setTimeout(function(){
                                                                noticePop('Something Went Wrong. Try again.', 'error');
                                                            }, 2000);
                                                        </script>
                                    <?php
                                                    }
                                                }
                                            } else {
                                    ?>
                                                <script>
                                                    setTimeout(function(){
                                                        noticePop('Proof of Payment Must Be Selected for Upload.', 'error');
                                                    }, 2000);
                                                </script>
                                    <?php
                                            }
                                        }
                                    }
                                    ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Wrapper END -->
    <?php include 'footer.php' ?>
    <!-- Optional JavaScript -->
    <script src="../plugins/jquery-3.1.1.min.js"></script>
    <script src="../plugins/sweetalerts/sweetalert2.min.js"></script>
    <script src="https://unpkg.com/@popperjs/core@2/dist/umd/popper.js"></script>

    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="js/jquery.min.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!-- Appear JavaScript -->
    <script src="js/jquery.appear.js"></script>
    <!-- Countdown JavaScript -->
    <script src="js/countdown.min.js"></script>
    <!-- Counterup JavaScript -->
    <script src="js/waypoints.min.js"></script>
    <script src="js/jquery.counterup.min.js"></script>
    <!-- Wow JavaScript -->
    <script src="js/wow.min.js"></script>
    <!-- Apexcharts JavaScript -->
    <script src="js/apexcharts.js"></script>
    <!-- Slick JavaScript -->
    <script src="js/slick.min.js"></script>
    <!-- Select2 JavaScript -->
    <script src="js/select2.min.js"></script>
    <!-- Owl Carousel JavaScript -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- Magnific Popup JavaScript -->
    <script src="js/jquery.magnific-popup.min.js"></script>
    <!-- Smooth Scrollbar JavaScript -->
    <script src="js/smooth-scrollbar.js"></script>
    <!-- lottie JavaScript -->
    <script src="js/lottie.js"></script>
    <!-- am core JavaScript -->
    <script src="js/core.js"></script>
    <!-- am charts JavaScript -->
    <script src="js/charts.js"></script>
    <!-- am animated JavaScript -->
    <script src="js/animated.js"></script>
    <!-- am kelly JavaScript -->
    <script src="js/kelly.js"></script>
    <!-- am maps JavaScript -->
    <script src="js/maps.js"></script>
    <!-- am worldLow JavaScript -->
    <script src="js/worldLow.js"></script>
    <!-- Style Customizer -->
    <script src="js/style-customizer.js"></script>
    <!-- Chart Custom JavaScript -->
    <script src="js/chart-custom.js"></script>
    <!-- Custom JavaScript -->
    <script src="js/custom.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#withdrawalMethod").change(function() {
                if ($(this).val() == "Bitcoin") {
                    $("#field1").fadeIn();
                    $("#field2").hide();
                    $("#field3").hide();
                    $("#field4").hide();
                    $("#field5").hide();
                    $("#field6").hide();
                    $("#field7").hide();
                    $("#field8").hide();
                    $("#field9").hide();
                    $("#field10").hide();
                    $("#field11").hide();
                    $("#field12").fadeIn();
                    $("#field13").hide();
                    $("#field14").hide();
                    $("#field15").hide();
                    $('#wallet-number').attr("placeholder", "Bitcoin");
                    //$('#amount-fees').val('2%')
                } else if ($(this).val() == "Ethereum") {
                    $("#field2").fadeIn();
                    $("#field1").hide();
                    $("#field3").hide();
                    $("#field4").hide();
                    $("#field5").hide();
                    $("#field6").hide();
                    $("#field7").hide();
                    $("#field8").hide();
                    $("#field9").hide();
                    $("#field10").hide();
                    $("#field11").hide();
                    $("#field12").hide();
                    $("#field13").fadeIn();
                    $("#field14").hide();
                    $("#field15").hide();
                    $('#wallet-number').attr("placeholder", "Ethereum");
                    //$('#amount-fees').val('4%')
                } else if ($(this).val() == "Litecoin") {
                    $("#field3").fadeIn();
                    $("#field1").hide();
                    $("#field2").hide();
                    $("#field4").hide();
                    $("#field5").hide();
                    $("#field6").hide();
                    $("#field7").hide();
                    $("#field8").hide();
                    $("#field9").hide();
                    $("#field10").hide();
                    $("#field11").hide();
                    $("#field12").hide();
                    $("#field13").hide();
                    $("#field14").fadeIn();
                    $("#field15").hide();
                    $('#wallet-number').attr("placeholder", "Litecoin");
                    //$('#amount-fees').val('4%')
                } else if ($(this).val() == "BitcoinCash") {
                    $("#field4").fadeIn();
                    $("#field1").hide();
                    $("#field2").hide();
                    $("#field3").hide();
                    $("#field5").hide();
                    $("#field6").hide();
                    $("#field7").hide();
                    $("#field8").hide();
                    $("#field9").hide();
                    $("#field10").hide();
                    $("#field11").hide();
                    $("#field12").hide();
                    $("#field13").hide();
                    $("#field14").hide();
                    $("#field15").fadeIn();
                    $('#wallet-number').attr("placeholder", "BitcoinCash");
                    //$('#amount-fees').val('4%')
                } else if ($(this).val() == "Skrill") {
                    $("#field5").fadeIn();
                    $("#field1").hide();
                    $("#field2").hide();
                    $("#field3").hide();
                    $("#field4").hide();
                    $("#field6").hide();
                    $("#field7").hide();
                    $("#field8").hide();
                    $("#field9").hide();
                    $("#field10").hide();
                    $("#field11").hide();
                    $("#field12").hide();
                    $("#field13").hide();
                    $("#field14").hide();
                    $("#field15").hide();
                    $('#wallet-number').attr("placeholder", "Skrill");
                    //$('#amount-fees').val('3%')
                } else if ($(this).val() == "Paypal") {
                    $("#field6").fadeIn();
                    $("#field1").hide();
                    $("#field2").hide();
                    $("#field3").hide();
                    $("#field4").hide();
                    $("#field5").hide();
                    $("#field7").hide();
                    $("#field8").hide();
                    $("#field9").hide();
                    $("#field10").hide();
                    $("#field11").hide();
                    $("#field12").hide();
                    $("#field13").hide();
                    $("#field14").hide();
                    $("#field15").hide();
                    $('#wallet-number').attr("placeholder", "Paypal");
                    //$('#amount-fees').val('2%')
                } else if ($(this).val() == "Bank Transfer") {
                    $("#field7").fadeIn();
                    $("#field8").fadeIn();
                    $("#field9").fadeIn();
                    $("#field10").fadeIn();
                    $("#field11").fadeIn();
                    $("#field1").hide();
                    $("#field2").hide();
                    $("#field3").hide();
                    $("#field4").hide();
                    $("#field5").hide();
                    $("#field6").hide();
                    $("#field12").hide();
                    $("#field13").hide();
                    $("#field14").hide();
                    $("#field15").hide();
                    $('#wallet-number').attr("placeholder", "Bank Transfer");
                    //$('#amount-fees').val('5%')
                } else {
                    $("#field1").hide();
                    $("#field2").hide();
                    $("#field3").hide();
                    $("#field4").hide();
                    $("#field5").hide();
                    $("#field6").hide();
                    $("#field7").hide();
                    $("#field8").hide();
                    $("#field9").hide();
                    $("#field10").hide();
                    $("#field11").hide();
                    $("#field12").hide();
                    $("#field13").hide();
                    $("#field14").hide();
                    $("#field15").hide();
                }
            });

            /*$("#amount-gram").keyup(function() { 
                //var usd = this.val();
                var usd = $("#amount-gram").val();                
                //var course = '2.0682345991368067';
                var course = '0.00011';
                $("#amount-usd").val( usd * course );
            }); 

            $('#withdrawal-form').on('submit', function (event) {
                
                var totalGgram = $('#total-gram').data('balance'),
                    amountGram = $("#amount-usd").val();
                    console.log(totalGgram + '===' + amountGram);

                if (totalGgram <= amountGram) {
                    event.preventDefault();
                    //$('#notEnough .card-body h2').text('Not enough Gram')
                    //$('#notEnough').modal('toggle');
                    Swal.fire({
                    title: "Error!",
                    text: "Not enough Gram",
                    type: "error",
                    confirmButtonClass: 'btn btn-primary',
                    buttonsStyling: false,
                    });  
                    
                } else {
                    //$('#notEnough .card-body h2').text('Not available')
                    ///$('#notEnough').modal('toggle')
                /* Swal.fire({
                    title: "Error!",
                    text: "Not available",
                    type: "error",
                    confirmButtonClass: 'btn btn-primary',
                    buttonsStyling: false,
                    });  */
                /*}

            });*/
        });
    </script>

    <script>
        function noticePop( value, type ){
            swal({
                html: '<span style="font-size:18px!important;">'+ `${value}` +'</span>',
                type: `${type}`,
                timer: 4000,
                showConfirmButton: false,
                allowOutsideClick: false,
                allowEscapeKey: false,
            }).then(function(){
                window.location.href = 'upgrade';
            });
        }
    </script>

</body>
</html>