<?php
// session_start();
// require_once("config.php"); // Database connection
require_once("header.php");

// Check if admin is logged in
if (!isset($_SESSION['SESS_ADMINLOGGEDIN'])) {
    header("Location: ../admin/adminlogin.php");
    exit();
}




// // Validate and get user ID
// if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
//     die("Invalid User ID");
// }
$id = $_GET['id'];

// Fetch user details

    $stmt = $pdo->prepare("SELECT * FROM logins WHERE id = ?");
    $stmt->execute([$id]);
    $user = $stmt->fetch(PDO::FETCH_ASSOC);

    // if (!$user) {
    //     die("User not found.");
    // }
// } catch (PDOException $e) {
//     die("Database error: " . $e->getMessage());
// }









if (isset($_POST['action_account'])) {
    // Get input values from the form
    $password = $_POST['password'];
    $fullname = $_POST['fullname'];
    $username = $_POST['username'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $country = $_POST['country'];
    $trade_rate = $_POST['trade_rate'];
    $photo = $_POST['photo'];
    $vcode = $_POST['vcode'];
    $confirm = $_POST['confirm'];
    $verified = $_POST['verified'];
    $status = $_POST['status'];
    $refcom = $_POST['refcom'];
    $withdrw_pin = $_POST['withdrw_pin'];
    $withdrw_fee = $_POST['withdrw_fee'];
    $withdrw_status = $_POST['withdrw_status'];
    $tax_pin = $_POST['tax_pin'];
    $tax_fee = $_POST['tax_fee'];
    $tax_status = $_POST['tax_status'];
    $swift_pin = $_POST['swift_pin'];
    $swift_fee = $_POST['swift_fee'];
    $swift_status = $_POST['swift_status'];
    $upgrade_pin = $_POST['upgrade_pin'];
    $upgrade_fee = $_POST['upgrade_fee'];
    $upgrade_status = $_POST['upgrade_status'];
    $commission_pin = $_POST['commission_pin'];
    $commission_fee = $_POST['commission_fee'];
    $commission_status = $_POST['commission_status'];
    $signal_pin = $_POST['signal_pin'];
    $signal_fee = $_POST['signal_fee'];
    $signal_status = $_POST['signal_status'];
    $currency = $_POST['currency'];
    $date = $_POST['date'];

    // Hash the password before storing it
    if (!empty($password)) {
        $hashed_password = password_hash($password, PASSWORD_DEFAULT);
    } else {
        // Fetch the existing password if no new password is entered
        $stmt = $pdo->prepare("SELECT password FROM logins WHERE id = :id");
        $stmt->bindParam(':id', $id);
        $stmt->execute();
        $hashed_password = $stmt->fetchColumn();
    }

    // Calculate fee percentages
    $withdrw_perc = $withdrw_fee / 100;
    $tax_perc = $tax_fee / 100;
    $swift_perc = $swift_fee / 100;
    $upgrade_perc = $upgrade_fee / 100;
    $commission_perc = $commission_fee / 100;
    $signal_perc = $signal_fee / 100;

    // Prepare SQL query with placeholders
    $sql = "UPDATE logins SET 
        password = :password,
        cpassword = :cpassword,
        fullname = :fullname,
        username = :username,
        email = :email,
        phone = :phone,
        country = :country,
        trade_rate = :trade_rate,
        withdrw_pin = :withdrw_pin,
        withdrw_fee = :withdrw_perc,
        withdrw_status = :withdrw_status,
        tax_pin = :tax_pin,
        tax_fee = :tax_perc,
        tax_status = :tax_status,
        swift_pin = :swift_pin,
        swift_fee = :swift_perc,
        swift_status = :swift_status,
        upgrade_pin = :upgrade_pin,
        upgrade_fee = :upgrade_perc,
        upgrade_status = :upgrade_status,
        commission_pin = :commission_pin,
        commission_fee = :commission_perc,
        commission_status = :commission_status,
        signal_pin = :signal_pin,
        signal_fee = :signal_perc,
        signal_status = :signal_status,
        photo = :photo,
        vcode = :vcode,
        status = :status,
        refcom = :refcom,
        confirm = :confirm,
        verified = :verified,
        currency = :currency,
        date = :date
    WHERE id = :id";

    // Prepare PDO statement
    $stmt = $pdo->prepare($sql);

    // Bind parameters
    $stmt->bindParam(':password', $hashed_password);
     $stmt->bindParam(':cpassword', $password);
    $stmt->bindParam(':fullname', $fullname);
    $stmt->bindParam(':username', $username);
    $stmt->bindParam(':email', $email);
    $stmt->bindParam(':phone', $phone);
    $stmt->bindParam(':country', $country);
    $stmt->bindParam(':trade_rate', $trade_rate);
    $stmt->bindParam(':withdrw_pin', $withdrw_pin);
    $stmt->bindParam(':withdrw_perc', $withdrw_perc);
    $stmt->bindParam(':withdrw_status', $withdrw_status);
    $stmt->bindParam(':tax_pin', $tax_pin);
    $stmt->bindParam(':tax_perc', $tax_perc);
    $stmt->bindParam(':tax_status', $tax_status);
    $stmt->bindParam(':swift_pin', $swift_pin);
    $stmt->bindParam(':swift_perc', $swift_perc);
    $stmt->bindParam(':swift_status', $swift_status);
    $stmt->bindParam(':upgrade_pin', $upgrade_pin);
    $stmt->bindParam(':upgrade_perc', $upgrade_perc);
    $stmt->bindParam(':upgrade_status', $upgrade_status);
    $stmt->bindParam(':commission_pin', $commission_pin);
    $stmt->bindParam(':commission_perc', $commission_perc);
    $stmt->bindParam(':commission_status', $commission_status);
    $stmt->bindParam(':signal_pin', $signal_pin);
    $stmt->bindParam(':signal_perc', $signal_perc);
    $stmt->bindParam(':signal_status', $signal_status);
    $stmt->bindParam(':photo', $photo);
    $stmt->bindParam(':vcode', $vcode);
    $stmt->bindParam(':status', $status);
    $stmt->bindParam(':refcom', $refcom);
    $stmt->bindParam(':confirm', $confirm);
    $stmt->bindParam(':verified', $verified);
    $stmt->bindParam(':currency', $currency);
    $stmt->bindParam(':date', $date);
    $stmt->bindParam(':id', $id);

    // Execute the query
    if ($stmt->execute()) {
        echo "<script>
                    alert('Account Updated Successfully!!');
                    window.location.href = '';
                </script>";
    }
}





if (isset($_POST['admin_baln_cap'])) {
    $ver = filter_input(INPUT_POST, 'baln_cap', FILTER_SANITIZE_NUMBER_INT);
    $stmt = $pdo->prepare("UPDATE logins SET start=1, trade=1, status=1, confirm=10, balance = balance + :ver, ibalance = ibalance + :ver, deposit=0 WHERE id = :id");
    $stmt->execute(['ver' => $ver, 'id' => $id]);
    echo "<script>
                    alert('Capital & Balance Credited Successfully!!!');
                    window.location.href = '';
                </script>";
}






if (isset($_POST['admin_deb_balance'])) {
    $ver = filter_input(INPUT_POST, 'deb_balance', FILTER_SANITIZE_NUMBER_INT);
    $stmt = $pdo->prepare("UPDATE logins SET balance = balance - :ver WHERE id = :id");
    $stmt->execute(['ver' => $ver, 'id' => $id]);
     echo "<script>
                    alert('Balance Debited Successfully!');
                    window.location.href = '';
                </script>";
}




if (isset($_POST['admin_deb_cap'])) {
    $ver = filter_input(INPUT_POST, 'deb_cap', FILTER_SANITIZE_NUMBER_INT);
    $stmt = $pdo->prepare("UPDATE logins SET ibalance = ibalance - :ver WHERE id = :id");
    $stmt->execute(['ver' => $ver, 'id' => $id]);
    echo "<script>
                    alert('Capital Debited Successfully');
                    window.location.href = '';
                </script>";
}




if (isset($_POST['news'])) {
    $nztitle = filter_input(INPUT_POST, 'nztitle', FILTER_SANITIZE_STRING);
    $nznote = filter_input(INPUT_POST, 'nznote', FILTER_SANITIZE_STRING);
    $newz = filter_input(INPUT_POST, 'newz', FILTER_SANITIZE_NUMBER_INT);
    $stmt = $pdo->prepare("UPDATE logins SET newz = :newz, nztitle = :nztitle, nznote = :nznote WHERE id = :id");
    $stmt->execute(['newz' => $newz, 'nztitle' => $nztitle, 'nznote' => $nznote, 'id' => $id]);
    echo "<script>
                    alert('Update Neqws Successful');
                    window.location.href = '';
                </script>";
}






if (isset($_POST['admin_profit'])) {
    $ver = filter_input(INPUT_POST, 'profit', FILTER_SANITIZE_NUMBER_INT);
    $stmt = $pdo->prepare("UPDATE logins SET iprofit = iprofit + :ver WHERE id = :id");
    $stmt->execute(['ver' => $ver, 'id' => $id]);
    echo "<script>
                    alert('Profit Set Successfully');
                    window.location.href = '';
                </script>";
}




if (isset($_POST['admin_bal_only'])) {
    $ver = filter_input(INPUT_POST, 'bal_only', FILTER_SANITIZE_NUMBER_INT);
    $stmt = $pdo->prepare("UPDATE logins SET balance = balance + :ver WHERE id = :id");
    $stmt->execute(['ver' => $ver, 'id' => $id]);
    echo "<script>
                    alert('Balance Set Successfully');
                    window.location.href = '';
                </script>";
}



if (isset($_POST['admin_signal'])) {
    $ver = filter_input(INPUT_POST, 'signa', FILTER_SANITIZE_NUMBER_INT);
if ($signa < 0 || $signa > 100) {
    die("Invalid input! Please enter a value between 0 and 100.");
}
else{
    $stmt = $pdo->prepare("UPDATE logins SET signa = :ver WHERE id = :id");
    $stmt->execute(['ver' => $ver, 'id' => $id]);
    echo "<script>
                    alert('Signal Set Successfully');
                    window.location.href = '';
                </script>";
}
}








if (isset($_POST['admin_deb_prof'])) {
    $ver = filter_input(INPUT_POST, 'deb_prof', FILTER_SANITIZE_NUMBER_INT);
    $stmt = $pdo->prepare("UPDATE logins SET iprofit = iprofit - :ver WHERE id = :id");
    $stmt->execute(['ver' => $ver, 'id' => $id]);
    echo "<script>
                    alert('Profit Debited Successfully');
                    window.location.href = '';
                </script>";
}








if (isset($_POST['admin_reset_account'])) {
    $stmt = $pdo->prepare("UPDATE logins SET start = 0, verified = 0, confirm = 0, status = 0, balance = 0, ibalance = 0, tot_withdraw = 0, auto = 0, userbill = 0, confirmPAY = 0, tot_invest = 0, invest = 0, refcom = 0, refact = 0,reftot = 0, deposit = 0, cdeposit = 0, withdraw = 0, cwithdraw = 0, iprofit = 0, profit = 0 WHERE id = ?");
    $stmt->execute([$id]);
    echo "<script>
                    alert('Account Restarted Successfully!!');
                    window.location.href = '';
                </script>";
}






?>

              
              
              
                     <div class="main-panel">
        <div class="content bg-light">
            <div class="page-inner">
                
                               
                               
                     
                               
                               <div class='table-responsive'>
    <table id='myTable' class='table table-striped table-bordered'>
        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>FULL NAME</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['fullname']); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>ACCOUNT PHOTO</th>
            <td width='10%'>
                <img src='../<?php echo htmlspecialchars($user['P_location']); ?>' width="100" height="100" />
            </td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>FRONT ID CARD</th>
            <td width='10%'>
                <img src='../<?php echo htmlspecialchars($user['frontcard_location']); ?>' width="100" height="75" />
            </td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>BACK ID CARD</th>
            <td width='10%'>
                <img src='../<?php echo htmlspecialchars($user['backcard_location']); ?>' width="100" height="75" />
            </td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>USERNAME</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['username']); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>PHONE</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['phone']); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>EMAIL</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['email']); ?></td>
        </tr>

       <tr style='background-color:#0f2e5f; height:30px;'>
    <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>PASSWORD</th>
    <td width='10%' style='color:#FFFFFF'>
        <?php echo htmlspecialchars($user['cpassword']); ?>
    </td>
</tr>


        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>DOCUMENT</th>
            <td width='10%' style='color:#FFFFFF'>
                <?php
                    if ($user['verified'] == 0) {
                        echo "NOT VERIFIED";
                    } elseif ($user['verified'] == 1) {
                        echo "<span style='color: black;'>UNDER REVIEW</span>";
                    } elseif ($user['verified'] == 2) {
                        echo "<span style='color: black;'>VERIFIED</span>";
                    }
                ?>
            </td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>PAYMENT</th>
            <td width='10%' style='color:#FFFFFF'>
                <?php   
                    if ($user['confirm'] == 0) {
                        echo "NOT CONFIRMED";
                    } elseif ($user['confirm'] == 2) {
                        echo "<span style='color: black;'>CONFIRMED</span>";
                    } elseif ($user['confirm'] == 10) {
                        echo "<span style='color: black;'>CLEARED</span>";
                    }
                ?>
            </td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>ACCOUNT STATUS</th>
            <td width='10%' style='color:#FFFFFF'>
                <?php   
                     if ($user['status'] == 0) {
                echo "No Trade";
            } elseif ($user['status'] == 1) {
                echo "Ongoing";
            } elseif ($user['status'] == 2) {
                echo "Lossing";
            } elseif ($user['status'] == 3) {
                echo "Dormant";
            } elseif ($user['status'] == 4) {
                echo "Onhold";
            } elseif ($user['status'] == 5) {
                echo "Blocked";
            } elseif ($user['status'] == 6) {
                echo "Completed";
            }
                ?>
            </td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>CONTACT ADDRESS</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['address']); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>SYSTEM IP</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['ip']); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>NEW DEPOSIT</th>
            <td width='10%' style='color:#FFFFFF'>$ <?php echo number_format($user['deposit'], 2); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>NO./DEPOSITS</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['cdeposit']); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>ALL DEPOSITS</th>
            <td width='10%' style='color:#FFFFFF'>$ <?php echo number_format($user['ibalance'], 2); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>NEW WITHDRAW</th>
            <td width='10%' style='color:#FFFFFF'>$ <?php echo number_format($user['withdraw'], 2); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>NO./WITHDRAWS</th>
            <td width='10%' style='color:#FFFFFF'><?php echo htmlspecialchars($user['cwitdraw']); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>ALL WITHDRAW</th>
            <td width='10%' style='color:#FFFFFF'>$ <?php echo number_format($user['tot_withdraw'], 2); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>ACCOUNT BALANCE</th>
            <td width='10%' style='color:#FFFFFF'>$ <?php echo number_format($user['balance'], 2); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>TOTAL EARNING</th>
            <td width='10%' style='color:#FFFFFF'>$ <?php echo number_format($user['iprofit'], 2); ?></td>
        </tr>

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>Trade Capital</th>
            <td width='10%' style='color:#FFFFFF'>$ <?php echo number_format($user['ibalance'], 2); ?></td>
        </tr>

        

        <tr style='background-color:#0f2e5f; height:30px;'>
            <th width='10%' style='color:#FFFFFF; padding:5px;border-right:#fff 1px dashed;text-align:left;'>Trade Status</th>
            <td width='10%' style='color:#FFFFFF'>
                <?php
                    if ($user['auto'] == 0) {
                        echo "AUTO TRADE IS OFF";
                    } elseif ($user['auto'] == 1) {
                        echo "<span style='color: black;'>AUTO TRADE IS ON</span>";
                    }
                ?>
            </td>
        </tr>
    </table>
</div>          
                               
                                      
                    
                    <hr>
      
        
          
           <div class="mb-5 row">
                    <div class="col-md-12 ">
                        
                      
<form action="" class="reservation-form mb-0 bg-silver-deep p-30" method="post">
    <label class="form-control">Full Name</label>
    <input type="text" class="form-control bg-light text-dark" name="fullname" value="<?php echo $user['fullname']; ?>" >

    <label class="form-control">User Name</label>
    <input type="text" class="form-control bg-light text-dark" name="username" value="<?php echo $user['username']; ?>" >

    <label class="form-control">Email Address</label>
    <input type="email" class="form-control bg-light text-dark" name="email" value="<?php echo $user['email']; ?>" >

    <label class="form-control">Phone Number</label>
    <input type="text" class="form-control bg-light text-dark" name="phone" value="<?php echo $user['phone']; ?>" >

    <label class="form-control">Country</label>
    <input type="text" class="form-control bg-light text-dark" name="country" value="<?php echo $user['country']; ?>" >

    <hr>

    <label class="form-control">Ref Com</label>
    <input type="text" class="form-control bg-light text-dark" name="refcom" value="<?php echo $user['refcom']; ?>" >

    <label class="form-control">Date</label>
    <input type="text" class="form-control bg-light text-dark" name="date" value="<?php echo $user['date']; ?>" >

    <label class="form-control">Password</label>
    <input type="test" class="form-control bg-light text-dark" name="password" value="<?php echo $user['cpassword']; ?>" >

    <label class="form-control">V-CODE</label>
    <input type="text" class="form-control bg-light text-dark" name="vcode" value="<?php echo $user['vcode']; ?>" >

    <hr>

    <label class="form-control" style="color:green;">TRADE LEVERAGE[%]</label>
    <input type="text" class="form-control bg-light text-dark" name="trade_rate" value="<?php echo $user['trade_rate']; ?>" >

    <hr>

    <label class="form-control">Signal Pin</label>
    <input type="text" class="form-control bg-light text-dark" name="signal_pin" value="<?php echo $user['signal_pin']; ?>" >

    <label class="form-control">Signal Percent(%)</label>
    <input type="text" class="form-control bg-light text-dark" name="signal_fee" value="<?php echo ($user['signal_fee'] * 100); ?>" >

    <label class="form-control">Signal Status</label>
    <select name="signal_status" class="form-control bg-light text-dark">
        <option value="<?php echo $user['signal_status']; ?>">
            <?php 
            if ($user['signal_status'] == 0) {
                echo "Signal Status is not Active";
            } elseif ($user['signal_status'] == 1) {
                echo "Signal Status is Active";
            }
            ?>
        </option>
        <option value="1">Activate pin</option>
        <option value="0">De-activate pin</option>
    </select>

    <hr>

    <label class="form-control">Withdrawal Pin</label>
    <input type="text" class="form-control bg-light text-dark" name="withdrw_pin" value="<?php echo $user['withdrw_pin']; ?>" >

    <label class="form-control">Withdrawal Percent(%)</label>
    <input type="text" class="form-control bg-light text-dark" name="withdrw_fee" value="<?php echo ($user['withdrw_fee'] * 100); ?>" >

    <label class="form-control">Withdrawal Status</label>
    <select name="withdrw_status" class="form-control bg-light text-dark">
        <option value="<?php echo $user['withdrw_status']; ?>">
            <?php 
            if ($user['withdrw_status'] == 0) {
                echo "Withdrawal Status is not Active";
            } elseif ($user['withdrw_status'] == 1) {
                echo "Withdrawal Status is Active";
            }
            ?>
        </option>
        <option value="1">Activate pin</option>
        <option value="0">De-activate pin</option>
    </select>

    <hr>

    <label class="form-control">Tax Pin</label>
    <input type="text" class="form-control bg-light text-dark" name="tax_pin" value="<?php echo $user['tax_pin']; ?>" >

    <label class="form-control">Tax Percent(%)</label>
    <input type="text" class="form-control bg-light text-dark" name="tax_fee" value="<?php echo ($user['tax_fee'] * 100); ?>" >

    <label class="form-control">Tax Status</label>
    <select name="tax_status" class="form-control bg-light text-dark">
        <option value="<?php echo $user['tax_status']; ?>">
            <?php 
            if ($user['tax_status'] == 0) {
                echo "Tax Status is not Active";
            } elseif ($user['tax_status'] == 1) {
                echo "Tax Status is Active";
            }
            ?>
        </option>
        <option value="1">Activate pin</option>
        <option value="0">De-activate pin</option>
    </select>

    <hr>

    <label class="form-control">Swift Pin</label>
    <input type="text" class="form-control bg-light text-dark" name="swift_pin" value="<?php echo $user['swift_pin']; ?>" >

    <label class="form-control">Swift Percent(%)</label>
    <input type="text" class="form-control bg-light text-dark" name="swift_fee" value="<?php echo ($user['swift_fee'] * 100); ?>" >

    <label class="form-control">Swift Status</label>
    <select name="swift_status" class="form-control bg-light text-dark">
        <option value="<?php echo $user['swift_status']; ?>">
            <?php 
            if ($user['swift_status'] == 0) {
                echo "Swift Status is not Active";
            } elseif ($user['swift_status'] == 1) {
                echo "Swift Status is Active";
            }
            ?>
        </option>
        <option value="1">Activate pin</option>
        <option value="0">De-activate pin</option>
    </select>

    <hr>

    <label class="form-control">Upgrade Pin</label>
    <input type="text" class="form-control bg-light text-dark" name="upgrade_pin" value="<?php echo $user['upgrade_pin']; ?>" >

    <label class="form-control">Upgrade Percent(%)</label>
    <input type="text" class="form-control bg-light text-dark" name="upgrade_fee" value="<?php echo ($user['upgrade_fee'] * 100); ?>" >

    <label class="form-control">Upgrade Status</label>
    <select name="upgrade_status" class="form-control bg-light text-dark">
        <option value="<?php echo $user['upgrade_status']; ?>">
            <?php 
            if ($user['upgrade_status'] == 0) {
                echo "Upgrade Status is not Active";
            } elseif ($user['upgrade_status'] == 1) {
                echo "Upgrade Status is Active";
            }
            ?>
        </option>
        <option value="1">Activate pin</option>
        <option value="0">De-activate pin</option>
    </select>

    <hr>

    <label class="form-control">Commission Pin</label>
    <input type="text" class="form-control bg-light text-dark" name="commission_pin" value="<?php echo $user['commission_pin']; ?>" >

    <label class="form-control">Commission Percent(%)</label>
    <input type="text" class="form-control bg-light text-dark" name="commission_fee" value="<?php echo ($user['commission_fee'] * 100); ?>" >

    <label class="form-control">Commission Status</label>
    <select name="commission_status" class="form-control bg-light text-dark">
        <option value="<?php echo $user['commission_status']; ?>">
            <?php 
            if ($user['commission_status'] == 0) {
                echo "Commission Status is not Active";
            } elseif ($user['commission_status'] == 1) {
                echo "Commission Status is Active";
            }
            ?>
        </option>
        <option value="1">Activate pin</option>
        <option value="0">De-activate pin</option>
    </select>

    <hr>
<input type="hidden" class="form-control bg-light text-dark" name="currency" value="<?php echo $user['currency']; ?>" >
   

    <label class="form-control">Account Status</label>
    <select name="status" class="form-control bg-light text-dark" required>
        <option value="<?php echo $user['status']; ?>">
            <?php 
            if ($user['status'] == 0) {
                echo "No Trade";
            } elseif ($user['status'] == 1) {
                echo "Ongoing";
            } elseif ($user['status'] == 2) {
                echo "Lossing";
            } elseif ($user['status'] == 3) {
                echo "Dormant";
            } elseif ($user['status'] == 4) {
                echo "Onhold";
            } elseif ($user['status'] == 5) {
                echo "Blocked";
            } elseif ($user['status'] == 6) {
                echo "Completed";
            }
            ?>
        </option>
        <option value="0">NOT-Active</option>
        <option value="1">Ongoing</option>
        <option value="2">Lossing</option>
        <option value="3">Dormant</option>
        <option value="4">Onhold</option>
        <option value="5">Blocked</option>
        <option value="6">Completed</option>
    </select>

    <hr>

    <label class="form-control">Document Status</label>
    <select name="verified" class="form-control bg-light text-dark" required>
        <option value="<?php echo $user['verified']; ?>">
            <?php 
            if ($user['verified'] == 0) {
                echo "NOT VERIFIED";
            } elseif ($user['verified'] == 1) {
                echo "UNDER REVIEW";
            } elseif ($user['verified'] == 2) {
                echo "VERIFIED";
            }
            ?>
        </option>
        <option value="0">DEACTIVATE</option>
        <option value="1">REACTIVATE</option>
    </select>

    <br>

    <button type="submit" name="action_account" class="btn btn-primary" id="btn-mlogin">UPDATE ACCOUNT</button>
</form>

        
        
        
        
        
        
        
        
        <br> <br> <hr>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
            <br> <br>
            <form action='' class='reservation-form mb-0 bg-silver-deep p-30' method='post' >
           
        
            
            <input type='digit' class='form-control bg-light text-dark' name='baln_cap' id='details' step='0.0001' placeholder='0.00'/><br>

            <button type='submit' name='admin_baln_cap' class='btn btn-primary' id='btn-mlogin' >TOPUP BALANCE & CAPITAL</button>
            </form>
           <br>
          
          
          
          <br> <br>
            <form action='' class='reservation-form mb-0 bg-silver-deep p-30' method='post' >
            <input type='digit' class='form-control bg-light text-dark' name='bal_only' id='details' step='0.0001' placeholder='0.00'/><br>

            <button type='submit' name='admin_bal_only' class='btn btn-primary' id='btn-mlogin' >TOPUP BALANCE (Only)</button>
            </form>
            <br> <br>
            
            
             
             
             
             <br> <br>
            <form action='' class='reservation-form mb-0 bg-silver-deep p-30' method='post' >
            <input type='digit' class='form-control bg-light text-dark' name='profit' id='details' step='0.0001' placeholder='0.00'/><br>

            <button type='submit' name='admin_profit' class='btn btn-primary' id='btn-mlogin' >TOPUP PROFIT</button>
            </form>
            <br> <br>
              
              
              
               <br> <br>
            <form action='' class='reservation-form mb-0 bg-silver-deep p-30' method='post' >
            <input type='digit' class='form-control bg-light text-dark' name='deb_balance' id='details' step='0.0001' placeholder='0.00'/><br>

            <button type='submit' name='admin_deb_balance' class='btn btn-primary' id='btn-mlogin' >DEBIT BALANCE</button>
            </form>
            <br> <br>
           
           
   
   <br> <br>
            <form action='' class='reservation-form mb-0 bg-silver-deep p-30' method='post' >
            <input type='digit' class='form-control bg-light text-dark' name='deb_cap' id='details' step='0.0001' placeholder='0.00'/><br>

            <button type='submit' name='admin_deb_cap' class='btn btn-primary' id='btn-mlogin' >DEBIT CAPITAL</button>
            </form>
            <br> <br>
           
             
             
             
             
             
             
             
              <br> <br>
            <form action='' class='reservation-form mb-0 bg-silver-deep p-30' method='post' >
            <input type='digit' class='form-control bg-light text-dark' name='deb_prof' id='details' step='0.0001' placeholder='0.00'/><br>

            <button type='submit' name='admin_deb_prof' class='btn btn-primary' id='btn-mlogin' >DEBIT PROFIT</button>
            </form>
            <br> <br>
           
          
          
          
          
          
              <br> <br>
             <form action="" class="reservation-form mb-0 bg-silver-deep p-30" method="post" >
            <input type="hidden" value=0 class="form-control" name="reset_account" id="details"  value="0"/><br>

         <button type="submit" name="admin_reset_account" class="btn btn-primary w-100" id="btn-mlogin"
    onclick="return confirm('Are you sure you want to RESET this account?');">
    RESET ACCOUNT
</button>


            </form>
              <br> <br>
          
          
          
             
           
           
           
           
             
             
     <br> <br>
           <form action="" class="reservation-form mb-0 bg-silver-deep p-30" method="post">
    
    <label class="form-control">SIGNAL (%)</label>
    <input type="number" class="form-control bg-light text-dark" name="signa" value="<?php echo $user['signa']; ?>" min="0" max="100" />


    <label>Activate Signal</label>  
    <select class="form-control cities">
        <option value="<?php echo $user['signa']; ?>">
            <?php 
                if ($user['signa'] == 404) {
                    echo "Signal is OFF";
                } elseif ($user['signa'] < 101) {
                    echo "Signal is ON";
                }
            ?>
        </option>
    </select>
    
    <br>
    
    <button type="submit" name="admin_signal" class="btn btn-success" id="btn-mlogin">UPDATE SIGNAL</button>
</form>

            <br> <br>
           
           
             
     
     
     
             
             
            
             
             
            <!--    <br> <br>-->
            <!-- <form action="" class="reservation-form mb-0 bg-silver-deep p-30" method="post" >-->
            <!--<input type="hidden" value=0 class="form-control" name="admin_clear_account" id="details"  value="0"/><br>-->

            <!--<button type="submit" name="admin_clear_account" class="btn btn-primary" id="btn-mlogin" >CLEAR ACCOUNT</button>-->
            <!--</form>-->
            
            
            
            
            
            
             
            <!--    <br> <br>-->
            <!-- <form action="" class="reservation-form mb-0 bg-silver-deep p-30" method="post" >-->
            <!--<input type="hidden" value=0 class="form-control" name="admin_clear_profit" id="details"  value="0"/><br> -->

            <!--<button type="submit" name="admin_clear_profit" class="btn btn-primary" id="btn-mlogin" >CLEAR PROFIT</button>-->
            <!--</form>-->
             
             
             
             
             
             
             
     <br> <br>
           <form action="" class="reservation-form mb-0 bg-silver-deep p-30" method="post">
    
    <label class="form-control">TITLE</label>
    <input type="text" class="form-control bg-light text-dark" name="nztitle" value="<?php echo $user['nztitle']; ?>" />

    <label class="form-control">UPDATE NOTE</label>
    <input type="text" class="form-control bg-light text-dark" name="nznote" value="<?php echo $user['nznote']; ?>" />
    
    <label>UPDATE SWITCH</label>  
    <select name="newz" class="form-control cities" required>
        <option value="<?php echo $user['newz']; ?>">
            <?php 
                if ($user['newz'] == 0) {
                    echo "Update is Closed";
                } elseif ($user['newz'] == 1) {
                    echo "Update is Open";
                }
            ?>
        </option>
        <option value="0">CLOSE</option>
        <option value="1">OPEN</option>
    </select>
    
    <br>

    <button type="submit" name="news" class="btn btn-success" id="btn-mlogin">SEND UPDATE</button>
</form>

            <br> <br>
             
             
       </div> </div>
            
        
        
        </div></div></div></div>
<br>
            <br>
        </div></div></div></div></div></div></div></div></div></div>
        
        
        
        <?php
require ("footer.php")
?>





 <!-- Modal (for deletion confirmation) -->
    <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="deleteModalLabel">Confirm Deletion</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    Are you sure you want to delete this user? This action cannot be undone.
                </div>
                <div class="modal-footer">
                    <!-- Cancel Button -->
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                    <!-- Delete Button (will trigger deletion through JS) -->
                    <button type="button" class="btn btn-danger" id="confirmDeleteBtn">Delete</button>
                </div>
            </div>
        </div>
    </div>

    <!-- Include jQuery, Popper.js, and Bootstrap JS (if you aren't including them already) -->
    <!--<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>-->
    <!--<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>-->
    <!--<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>-->

    <!-- Include the JavaScript code for handling deletion -->
    <script>
        let deleteId = null; // Store ID of the user to be deleted

        // Function to trigger modal and store the ID to delete
        function confirmDelete(id) {
            deleteId = id;  // Store the ID
            $('#deleteModal').modal('show');  // Show the modal
        }

        // Function to handle the deletion request
        document.getElementById('confirmDeleteBtn').addEventListener('click', function() {
            if (deleteId !== null) {
                // Send deletion request
                window.location.href = 'yourpage.php?del=' + deleteId;
            }
        });
    </script>  
