<?php
include('include/head.php');
include("loginCheck.php");
include('include/header.php');
include('include/menu.php');
requireLogin();

$db = getDB();

$user_id1 = $_GET['user_id'] ?? '';

/* GET USER DETAILS */
$stmt = $db->prepare("SELECT * FROM meddolic_user_details WHERE user_id=? LIMIT 1");
$stmt->execute([$user_id1]);
$val1 = $stmt->fetch();

if (!$val1) {
    echo "<script>alert('Invalid User');window.history.back();</script>";
    exit;
}

$member_id1 = $val1['member_id'];
$walletAddress = $val1['walletAddress'];
$user_id = $val1['user_id'];
$phone = $val1['phone'];
$date_time = $val1['date_time'];
$email_id = $val1['email_id'];
$bank = $val1['bankName'];
$branch = $val1['branchName'];
$account_number = $val1['account_no'];
$ifsc = $val1['ifsc'];
$sponser_id = $val1['sponser_id'];
$password = $val1['password'];
$trnPassword = $val1['trnPassword'];

/* GET SPONSOR DETAILS */
$stmt = $db->prepare("SELECT user_id, walletAddress FROM meddolic_user_details WHERE member_id=? LIMIT 1");
$stmt->execute([$sponser_id]);
$sponsor = $stmt->fetch();

$sponser_name = $sponsor['walletAddress'] ?? '';
$sponser_user_id = $sponsor['user_id'] ?? '';
?>
<div id="main-content">
    <div class="container-fluid">
        <div class="block-header">
            <div class="row">
                <div class="col-lg-5 col-md-8 col-sm-12">
                    <h2><a href="javascript:void(0);" onclick="window.history.back();"
                            class="btn btn-xs btn-link btn-toggle-fullwidth"><i class="fa fa-arrow-left"></i></a> View
                        Member</h2>
                    <ul class="breadcrumb">
                        <li class="breadcrumb-item"><a href="dashboard"><i class="icon-home"></i></a></li>
                        <li class="breadcrumb-item"> Members </a></li>
                        <li class="breadcrumb-item active"> View Member</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row clearfix">
            <div class="col-lg-12">
                <div class="card">
                    <div class="body">
                        <h6>Basic Information</h6>
                        <form method="POST" action="updatePersonalDetails.php"
                            onsubmit="return confirm('Are you sure?')">
                            <div class="row clearfix">
                                <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">User Id * :</label>
                                        <input class="form-control" value="<?= e($user_id) ?>" disabled>
                                        <input type="hidden" name="user_id" value="<?= e($user_id1) ?>">
                                        <input type="hidden" name="member_id1" value="<?= e($member_id1) ?>">
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">wallet Address * :</label>
                                        <input type="text" class="form-control" value="<?= e($walletAddress) ?>"
                                            required name="name">
                                    </div>
                                </div>
                                <!-- <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">Phone * :</label>
                                        <input type="number" class="form-control" value="<?= $phone ?>" required
                                            name="phone" onkeypress="return onlynum(event)" maxlength="10"
                                            onblur="phone_valid(this.value)" id="phone">
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">Email ID * :</label>
                                        <input class="form-control" value="<?= $email_id ?>" name="email_id"
                                            placeholder="Enter EmailID">
                                    </div>
                                </div> -->
                                <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">Sponser Id * :</label>
                                        <input class="form-control" disabled="" value="<?= e($sponser_user_id) ?>"
                                            placeholder="Enter Sponser Id">
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">Date of Joining * :</label>
                                        <input class="form-control" disabled value="<?= e($date_time) ?>"
                                            name="date_time">
                                    </div>
                                </div>
                                <!-- <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">Login Password * :</label>
                                        <input class="form-control" type="text" name="password" required
                                            value="<?= $password ?>" placeholder="Enter Login Password">
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-12">
                                    <div class="form-group">
                                        <label class="control-label">Transaction Password * :</label>
                                        <input class="form-control" type="text" name="trnPassword" required
                                            value="<?= $trnPassword ?>" placeholder="Enter Login Password">

                                    </div>
                                </div> -->
                            </div>
                            <button type="submit" class="btn btn-primary">Update</button> &nbsp;&nbsp;
                            <button class="btn btn-danger" onclick="location.reload()">Cancel</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php include('include/footer.php'); ?>
<script>
    var d = document.getElementById("Members");
    d.className += " active";
    var d = document.getElementById("viewMember");
    d.className += " active";
</script>
</body>

</html>