<!DOCTYPE html>
<html lang="en">
<head>
<?php

include "header.php";

$id = $_GET['id'];

$user_query = mysqli_query($link, "SELECT * FROM user WHERE id = '$id' ");
$uqr = mysqli_fetch_array($user_query);

$user = new user($uqr['email'], $link);

if($user->getAccount_status() == "Active"){
    $account_status = "<span class='badge badge-success'> ".$user->getAccount_status()."</span>";
}else{
    $account_status = "<span class='badge badge-danger'> ".$user->getAccount_status()."</span>";
}

if($user->getTrade_mode() == "On"){
    $trade_mode = "<span class='badge badge-success'> ".$user->getTrade_mode()."</span>";
}else{
    $trade_mode = "<span class='badge badge-danger'> ".$user->getTrade_mode()."</span>";
}

if($user->getKyc() == "Not Verified Yet"){
    $kyc = "<span class='badge badge-danger'>".$user->getKyc()."</span>";
}else{
    $kyc = "<span class='badge badge-success'>".$user->getKyc()."</span>"; 
}
if($user->getAccount_status() == "Blocked"){
$handle = "<a class='dropdown-item' href='unblock_acc.php?id=".$user->getEmail()."'>Un-Block</a>";
            }elseif($user->getTrade_mode() == "On"){
                $handle = "<a class='dropdown-item' href='block_acc.php?id=".$user->getEmail()."'>Block</a>
            <a class='dropdown-item' href='turn_off.php?id=".$user->getEmail()."&type=Off'>Turn off trade</a> ";
            }else{
                $handle = "<a class='dropdown-item' href='block_acc.php?id=".$user->getEmail()."'>Block</a>
            <a class='dropdown-item' href='turn_off.php?id=".$user->getEmail()."&type=On'>Turn on trade</a> ";
            }
            
            if($user->getUpgrade() == "no-upgrade"){
$handles = "<a class='dropdown-item' href='upgrade_r.php?id=".$user->getEmail()."&type=on'>Turn Upgrade On</a>";
            }elseif($user->getUpgrade() == "upgrade"){
                $handles = "<a class='dropdown-item' href='upgrade_r.php?id=".$user->getEmail()."&type=off'>Turn Upgrade Off</a>";
            }
            

?>
</head>
<body data-background-color="dark">
    <div id="app">
        
        <!--/PayPal-->
            
        <!--Start of Tawk.to Script-->
        <script type="text/javascript">
        {tawk to codess}
        </script>
        <!--End of Tawk.to Script-->
		<div class="wrapper">
			    <div class="main-header">
    <!-- Logo Header -->
<div class="logo-header" data-background-color="blue">
        <a href="/" class="logo" style="font-size: 27px; color:#fff;">
            P.S.M
        </a>
    <button class="ml-auto navbar-toggler sidenav-toggler" type="button" data-toggle="collapse" data-target="collapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon">
                <i class="icon-menu "></i>
            </span>
        </button>
        <button class="topbar-toggler more"><i class="icon-options-vertical "></i></button>
        <div class="nav-toggle">
            <button class="btn btn-toggle toggle-sidebar">
                <i class="icon-menu "></i>
            </button>
        </div>
        
    </div>
    <!-- End Logo Header -->

    <!-- Navbar Header -->
    <nav class="navbar navbar-header navbar-expand-lg" data-background-color="blue">
        
        <div class="container-fluid">
            <div class="collapse" id="search-nav">
                
                <script>
                    document.getElementById('searchform').addEventListener('subit' searchuser);
                   function searchuser(){
                       console.log('ddj');
                       let url = "https://platinumsignalmarket.com/trader/admin/dashboard/manageusers";
                       window.location.href = url;
                   }
               </script>
            </div>
            <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">
                <li>
                    <form action="javascript:void(0)" method="post" id="styleform">
                        <div class="form-group">
                            <label class="style_switch">
                                <input name="style" id="style" type="checkbox" value="true" class="modes">
                                <span class="slider round"></span>
                            </label>
                        </div> 
                                                <input type="hidden" name="_token" value="yK4ImZn4tFp3FCzhv1hy9ADjxOMulCa9eCDdVVZt">
                    </form>
                    
                </li>
                                <li class="nav-item dropdown hidden-caret">
                    <a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false">
                        <i class="text-white fas fa-user"></i>
                    </a>
                   
                    <ul class="dropdown-menu dropdown-user animated fadeIn">
                        <div class="dropdown-user-scroll scrollbar-outer">
                            <li>
                                <a class="dropdown-item" href="adminchangepassword.php">Change Password</a>
                                <div class="dropdown-divider"></div>
                                <a class="dropdown-item" href="logout.php">
                                Logout
                                </a>
                            </li>
                        </div>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
    <!-- End Navbar -->
</div>


<script type="text/javascript">
    //create investment
        $("#styleform").on('change',function(){
        $.ajax({
            url: "https://platinumsignalmarket.com/trader/admin/dashboard/changestyle",
            type: 'POST',
            data:$("#styleform").serialize(),
            success: function (data) {
				location.reload(true);
            },
            error: function (data) {
                console.log('Something went wrong');
            },

        });
    });
    
</script>
    <!-- Stored in resources/views/child.blade.php -->

<!-- Sidebar -->
<?php

    include "sidebar.php";

?>
<!-- End Sidebar -->
    <div class="main-panel">
    <div class="content bg-light">
        <div class="page-inner">
            <div>
    </div>            <div>
    </div>            <!-- Beginning of  Dashboard Stats  -->
            <div class="row">
                <div class="col-md-12">
                    <div class="p-3 card bg-light">
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12 ">
                                    <h1 class="d-inline text-primary"><?php echo $user->getFullname(); ?></h1><span></span>
                                    <div class="d-inline">
                                        <div class="float-right btn-group">
                                            <a class="btn btn-primary btn-sm" href="manageusers.php"> <i class="fa fa-arrow-left"></i> back</a> &nbsp;
                                            <button type="button" class="btn btn-secondary dropdown-toggle btn-sm" data-toggle="dropdown" data-display="static" aria-haspopup="true" aria-expanded="false">
                                              Actions
                                            </button>
                                            <div class="dropdown-menu dropdown-menu-lg-right">
                                                                                                <?php
                                                                                                
                                                          echo $handle;                                      
                                                                                                ?>
                                                                                                                                                
                                                                                                <a href="#"  data-toggle="modal" data-target="#topupModal" class="dropdown-item">Credit/Debit</a>
                                                <a href="#" data-toggle="modal" data-target="#clearacctModal" class="dropdown-item">Clear Account</a>
                                                <a href="#" data-toggle="modal" data-target="#TradingModal" class="dropdown-item">Upgrade Account</a>
                                                <?php
                                                                                                
                                                          echo $handles;                                      
                                                                                                ?>
                                                                                                
                                                <a href="#" data-toggle="modal" data-target="#sendmailtooneuserModal" class="dropdown-item">Send Email</a>
                                                <a href="#" data-toggle="modal" data-target="#sendmailtooneuserModal2" class="dropdown-item">Trade Percentage</a>
                                                <a href="#" data-toggle="modal" data-target="#switchuserModal"  class="dropdown-item text-success">Login as <?php echo $user->getFullname(); ?></a>
                                                <a href="#" data-toggle="modal" data-target="#deleteModal" class="dropdown-item text-danger">Delete <?php echo $user->getFullname(); ?></a>
                                                
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="p-3 mt-4 border rounded row text-dark">
                                <div class="col-md-3">
                                    <h5 class="text-bold">Account Balance</h5>
                                    <p>$<?php echo $user->getBalance(); ?></p>
                                </div>
                                <div class="col-md-3">
                                    <h5>Profit</h5>
                                    <p>$<?php echo $user->getProfit(); ?> </p>
                                </div>
                                <div class="col-md-3">
                                    <h5>Referral Bonus</h5>
                                    <p>$<?php echo $user->getReferral(); ?></p>
                                </div>
                                <div class="col-md-3">
                                    <h5>Bonus</h5>
                                    <p>$<?php echo $user->getBonus(); ?></p>
                                </div>
                                <div class="col-md-3">
                                    <h5>User Account Status</h5>
                                                                        <?php
                                                                        
                                                                        echo $account_status
                                                                        
                                                                        ?>
                                                                    </div>
                                <div class="col-md-3">
                                    <h5>Invested</h5>
                                    
                                                                            <p>$<?php echo $user->getInvested(); ?></p>
                                                                        
                                </div>
                                <div class="col-md-3">
                                    <h5>KYC</h5>
                                                                        <?php
                                                                        
                                                                        echo $kyc
                                                                        
                                                                        ?>
                                                                    </div>
                                <div class="col-md-3">
                                    <h5>Trade Mode</h5>
                                                                        <?php
                                                                        
                                                                        echo $trade_mode
                                                                        
                                                                        ?>
                                                                    </div>
                          
                     
                            </div>
                            <div class="mt-3 row text-dark">
                                <div class="col-md-12">
                                    <h5>USER INFORMATION</h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Fullname</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getFullname(); ?></h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Email Address</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getEmail(); ?></h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Username</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getUsername(); ?></h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Password</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getPassword(); ?></h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Trade Percentage</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getTrade(); ?>%</h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Mobile Number</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getPhone(); ?></h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Nationality</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getCountry(); ?></h5>
                                </div>
                            </div>
                                                        <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>OTP CODE</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getQ1(); ?></h5>
                                </div>
                            </div>
                              
                            
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Registered</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getReg_date(); ?></h5>
                                </div>
                            </div>
                            <div class="p-3 border row text-dark">
                                <div class="col-md-4 border-right">
                                    <h5>Wallet Address</h5>
                                </div>
                                <div class="col-md-8">
                                   <h5><?php echo $user->getWallet(); ?></h5>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Top Up Modal -->
    <div id="topupModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    <h4 class="modal-title text-dark">Credit/Debit <?php echo $user->getFullname(); ?> account.</strong></h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light">
                    <form method="post" action="acc_request.php?type=cr/dr&id=<?php echo $id; ?>">
                        <input type="hidden" name="_token" value="yK4ImZn4tFp3FCzhv1hy9ADjxOMulCa9eCDdVVZt">                        <div class="form-group">
                            <input class="form-control bg-light text-dark" placeholder="Enter amount" type="text" name="amount" required>
                        </div>
                        <div class="form-group">
                            <h5 class="text-dark">Select where to Credit/Debit</h5>
                            <select class="form-control bg-light text-dark" name="type" required>
                                <option value="" selected disabled>Select Column</option>
                                <option value="Bonus">Bonus</option>
                                <option value="Profit">Profit</option>
                                <option value="Ref_Bonus">Ref_Bonus</option>
                                <option value="balance">Account Balance</option>
                                <option value="Deposit">Deposit</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <h5 class="text-dark">Select credit to add, debit to subtract.</h5>
                            <select class="form-control bg-light text-dark" name="t_type" required>
                                <option value="">Select type</option>
                                <option value="Credit">Credit</option>
                                <option value="Debit">Debit</option>
                            </select>
                            <small> <b>NOTE:</b> You cannot debit deposit</small>
                        </div>
                        <div class="form-group">
                            <input type="hidden" name="user_id" value="101">
                            <input type="submit" class="btn btn-dark" value="Submit">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /deposit for a plan Modal -->


    <!-- send a single user email Modal-->
    <div id="sendmailtooneuserModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    <h4 class="modal-title text-dark">Send Email</h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light">
                    <p class="text-dark">This message will be sent to <?php echo $user->getFullname(); ?></p>
                    <form style="padding:3px;" role="form" method="post" action="sendmail.php?email=<?php echo $user->getEmail(); ?>&id=<?php echo $user->getId(); ?>">
                        <input type="hidden" name="_token" value="yK4ImZn4tFp3FCzhv1hy9ADjxOMulCa9eCDdVVZt">                        <div class=" form-group">
                            <input type="text" name="subject" class="form-control bg-light text-dark" placeholder="Subject" required>
                        </div>
                        <div class=" form-group">
                            <textarea placeholder="Type your message here" class="form-control bg-light text-dark" name="message" row="8" placeholder="Type your message here" required></textarea>
                        </div>
                        <div class=" form-group">
                            <input type="hidden" name="user_id" value="101">
                            <input type="submit" class="btn btn-dark" value="Send">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /Trading History Modal -->
            
    <div id="TradingModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    <h4 class="modal-title text-dark">Upgrade Account for <?php echo $user->getFullname();  ?>  </h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light">
                    <form role="form" method="post" action="acc_request.php?type=plan&id=<?php echo $user->getId(); ?>">
                        <input type="hidden" name="_token" value="yK4ImZn4tFp3FCzhv1hy9ADjxOMulCa9eCDdVVZt">                        <div class="form-group">
                            <h5 class=" text-dark">Select Investment Plan</h5>
                            <select class="form-control bg-light text-dark" name="plan">
                                <option value="" selected disabled>Select Plan</option>
                                <option value="Starter">Starter</option>   
                                <option value="Basic">Basic</option>
                                 <option value="Standard">Standard</option>
                                                            <option value="Premium">Premium</option>
                                                            <option value="Gold">Gold</option>
                                                            
                                                        </select>
                        </div>
                       
                        <div class="form-group">
                            <input type="submit" class="btn btn-dark" value="Upgrade Account">
                            <input type="hidden" name="user_id" value="101"> 
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /send a single user email Modal -->

<!-- Edit user Modal -->
    <div id="edituser" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    <h4 class="modal-title text-dark">Edit Aldo Garcia details.</strong></h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light">
                    <form role="form" method="post" action="https://platinumsignalmarket.com/trader/admin/dashboard/edituser">
                        <div class="form-group">
                            <h5 class=" text-dark">Username</h5>
                            <input class="form-control bg-light text-dark" id="input1" value="Aldo Garcia" type="text" name="username" required> 
                             <small>Note: same username should be use in the referral link.</small>
                        </div>
                        <div class="form-group">
                            <h5 class=" text-dark">Fullname</h5>
                            <input class="form-control bg-light text-dark" value="Aldo Garcia" type="text" name="name" required>  
                        </div>
                        <div class="form-group">
                            <h5 class=" text-dark">Email</h5>
                            <input  class="form-control bg-light text-dark" value="moisesrenan21@gmail.com" type="text" name="email" required> 
                        </div>
                        <div class="form-group">
                            <h5 class=" text-dark">Phone Number</h5>
                            <input class="form-control bg-light text-dark" value="59162491502" type="text" name="phone" required> 
                        </div>
                        <div class="form-group">
                            <h5 class=" text-dark">Country</h5>
                            <input class="form-control bg-light text-dark" value="Bolivia" type="text" name="country">
                        </div>
                        <div class="form-group">
                            <h5 class=" text-dark">Referral link</h5>
                            <input class="form-control bg-light text-dark" value="https://platinumsignalmarket.com/ref/Aldo Garcia" type="text" name="ref_link" required>
                        </div>
                        <div class="form-group">
                            <input type="hidden" name="_token" value="yK4ImZn4tFp3FCzhv1hy9ADjxOMulCa9eCDdVVZt">
                            <input type="hidden" name="user_id" value="101">
                            <input type="submit" class="btn btn-dark" value="Update">
                        </div>
                    </form>
                </div>
                <script>
                    $('#input1').on('keypress', function(e) {
                        return e.which !== 32;
                    });
                </script>
            </div>
        </div>
    </div>
    <!-- /Edit user Modal -->
    
    <div id="sendmailtooneuserModal2" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-dark">
                    <h4 class="modal-title text-light">Send Email</h4>
                    <button type="button" class="close text-light" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-dark">
                    <p class="text-light">This Trading Percentage Will Be Set For <?php echo $user->getFullname(); ?></p>
                    <form style="padding:3px;" role="form" method="post" action="tp.php?email=<?php echo $user->getEmail(); ?>&id=<?php echo $user->getId(); ?>">
                        <input type="hidden" name="_token" value="yK4ImZn4tFp3FCzhv1hy9ADjxOMulCa9eCDdVVZt">                        <div class=" form-group">
                            <input type="number" name="tp" class="form-control bg-dark text-light" placeholder="Trade Percentage" required>
                        </div>
                        <div class=" form-group">
                            <input type="hidden" name="user_id" value="101">
                            <input type="submit" class="btn btn-dark" value="Send">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Reset user password Modal -->
    <div id="resetpswdModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    <h4 class="modal-title text-dark">Reset Password</strong></h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light">
                    <p class="text-dark">Are you sure you want to reset password for Aldo Garcia to <span class="text-primary font-weight-bolder">user01236</span></p>
                    <a class="btn btn-dark" href="https://platinumsignalmarket.com/trader/admin/dashboard/resetpswd/101">Reset Now</a>
                </div>
            </div>
        </div>
    </div>
    <!-- /Reset user password Modal -->
    
    <!-- Switch useraccount Modal -->
    <div id="switchuserModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    <h4 class="modal-title text-dark">You are about to login as <?php echo $user->getFullname(); ?>.</strong></h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light">
                    <form method="POST" action="../process2.php">
                        <input name="name" value="<?php echo $user->getEmail(); ?>" hidden>
                        <input name="password" value="<?php echo $user->getPassword(); ?>" hidden>
                        <button class="btn btn-success">Proceed</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /Switch user account Modal -->

    <!-- Clear account Modal -->
    <div id="clearacctModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    <h4 class="modal-title text-dark">Clear Account</strong></h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light">
                    <p class="text-dark">You are clearing account for <?php echo $user->getFullname(); ?> to $0.00</p>
                    <a class="btn btn-dark" href="turn_off.php?id=<?php echo $user->getEmail(); ?>&type=clear">Proceed</a>
                </div>
            </div>
        </div>
    </div>
    <!-- /Clear account Modal -->

    <!-- Delete user Modal -->
    <div id="deleteModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header bg-light">
                    
                    <h4 class="modal-title text-dark">Delete User</strong></h4>
                    <button type="button" class="close text-dark" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body bg-light p-3">
                    <p class="text-dark">Are you sure you want to delete <?php echo $user->getFullname(); ?> Account? Everything associated with this account will be loss.</p>
                    <a class="btn btn-danger" href="del_user.php?id=<?php echo $user->getEmail(); ?>">Yes i'm sure</a>
                </div>
            </div>
        </div>
    </div>
    <!-- /Delete user Modal --> 				<footer class="footer bg-dark text-light">
					<div class="container-fluid">
						<div class="text-center row copyright text-align-center">
							<p>All Rights Reserved &copy; P.S.M 2022</p>
						</div>
					</div>
				</footer>
			</div>
		</div>
	</div>

				<!--   Core JS Files   -->
                <?php

include "footer.php";

?>
<?php
        mysqli_close($link);
        if (isset($_SESSION['error']) AND $_SESSION['error'] != ""){
            echo "<script>alert('".$_SESSION['error']."')</script>";
            unset($_SESSION['error']);
        }

    ?>
</body>
</html>


