<?php
$title = 'Wallet Address';
require_once('header-links.php');
// require_once('../admin/lib/table-traits.php'); 
// require_once('../admin/lib/basic-function.php'); 
// require_once('../admin/lib/user-functions.php'); 

$current_pg = 8;

$all_wallet = $basicFunctn->selectWhereDlt($user->user_wallet_tb, 'user_id', $user_logged['unique_id']);


// print_r($user_details);
// die();



?>

<body>
    <!-- BEGIN LOADER -->
    <div id="load_screen">
        <div class="loader">
            <div class="loader-content">
                <div class="spinner-grow align-self-center"></div>
            </div>
        </div>
    </div>
    <!--  END LOADER -->

    <!--  BEGIN NAVBAR  -->
    <?php require_once('header.php'); ?>
    <!--  END NAVBAR  -->

    <!--  BEGIN MAIN CONTAINER  -->
    <div class="main-container" id="container">

        <div class="overlay"></div>
        <div class="search-overlay"></div>

        <!--  BEGIN SIDEBAR  -->
        <?php require_once('sidebar.php'); ?>
        <!--  END SIDEBAR  -->

        <!--  BEGIN CONTENT AREA  -->
        <div id="content" class="main-content">
            <div class="layout-px-spacing">

                <div class="row layout-spacing">
                    <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 layout-top-spacing">
                        <div class="widget-content widget-content-area">
                            <!-- <form id="contact" class="section contact edit_user_form"> -->
                            <div class="info">
                                <h5 class="">Add Wallet Address For Coins</h5>
                                <div class="row">
                                <?php foreach ($all_wallet as $e) { 
                                    $coin = $user->getDataDlt($e['coin_id'],$user->currencies_tb);
                                    ?>
                                    <div class="col-md-11 mx-auto">
                                        <form id="contact" class="section contact <?php print $coin['unique_id']; ?>">
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                    </div>
                                                </div>
                                                <div class="col-md-12">
                                                    <input type="hidden" name="add_wallet_id" value="<?php print $coin['unique_id']; ?>"></input>
                                                    <div class="form-group">
                                                        <label for=""><?php print $coin['name']; ?><span class="text-danger">*</span> </label>
                                                        <input type="text" class="form-control mb-4" name="address" value="<?php print $e['address']; ?>" placeholder="Enter Payment Address For this <?php print $coin['name']; ?>">
                                                    </div>
                                                </div>
                                                <div class="col-md-12 text-right mb-5">
                                                    <button id="<?php print $coin['unique_id']; ?>" class="btn btn-primary add_wallet_btn">Save Address</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                <?php } ?>
                                </div>
                            </div>
                            <!-- </form> -->
                        </div>
                    </div>

                </div>
            </div>
            <?php require_once('footer.php'); ?>
        </div>
        <!--  END CONTENT AREA  -->
    </div>
    <?php require_once('footer-links.php'); ?>
    <script>
        $('.add_wallet_btn').click(async function(e) {
            e.preventDefault();
            let form_id = $(this).attr('id');
            let wallet_form = $('.'+form_id).serializeArray();
            let form_data = set_form_data(wallet_form);
            // console.log(wallet_form);return;
            let returned = await ajaxRequest('ajax.php', form_data);
            // console.log(returned);return;
            throwSweetalert(returned, 'wallet-address', 1);
        });
    </script>