<?php require ("header.php")?>

                <!-- main header @e -->
                <!-- content @s -->

                     <div class="nk-content ">
        <div class="container-fluid">
            <div class="nk-content-inner">
                <div class="nk-content-body">
                    <div class="nk-block-head nk-block-head-sm">
                       
                   <div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
              <div class="bg-gradient-primary shadow-primary border-radius-lg pt-4 pb-3">
                <h4 class="text-white text-capitalize ps-3"><img src="icon/ibft.png" height="40" width="40" > MANAGE ACCOUNTS</h4> 
              </div>
            </div>
            <!--<div class="card-body px-0 pb-2">      -->
                       
                       <style>
 
.topnav {
  overflow: hidden;
  background-color: black;
}

.topnav a {
  float: left;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
  font-weight:700;
}

.topnav a:hover {
  background-color: #d13e16;
  color: white;
}

.topnav a.active {
  background-color: black;
  color: white;
}
</style>
 

<div class="topnav">
  <a class="active" href="edit_profile.php" target="_self">Edit Profile</a>
  <a href="change-password.php" target="_self">Change Password</a>
  <a href="change_photo.php" target="_self">Update Photo</a>
  <!--<a href="change_email.php" target="_self">Email</a>-->
  <a href="change-transaction-pin.php" target="_self">Security Pin</a>
</div>
                        
                        
                        
                        
                        
                        
                        
                        

                        <div class="container-fluid">
                                                    </div>

                    </div><!-- .nk-block-head -->
                    <div class="nk-block">
                        <div class="row gy-5">
                            <div class="col-lg-5">
                                <div class="nk-block-head">
                                    <div class="nk-block-head-content">
                                        <h5 class="nk-block-title title">User Info</h5>
                                    </div>
                                </div><!-- .nk-block-head -->

                              <?php


// Fetch user by ID using prepared statement
$stmt = $pdo->prepare("SELECT * FROM logins WHERE id = :id");
$stmt->execute(['id' => $id]);
$userrow = $stmt->fetch(PDO::FETCH_ASSOC);

if ($userrow) {
    ?>
    <div class="card">
        <div class="card-inner-group">
            <div class="card-inner">
                <div class="user-card user-card-s2 mb-2">
                    <div class="user-avatar sq xl bg-primary">
                        <?php
                        // Check and display photo
                        if ($userrow['photo'] == 0) {
                            echo "<img class='profile-user-img img-responsive img-circle' src='upload/photo/default.png' style='width:100px;height:100px' alt='" . htmlspecialchars($userrow['username']) . "'>";
                        } elseif ($userrow['photo'] == 1) {
                            echo "<img class='profile-user-img img-responsive img-circle' src='../" . htmlspecialchars($userrow['P_location']) . "' style='width:100px;height:100px' alt='" . htmlspecialchars($userrow['username']) . "'>";
                        }
                        ?>
                    </div>
                    <div class="user-info">
                        <h5><?php echo htmlspecialchars($userrow['firstname']) . ' ' . htmlspecialchars($userrow['lastname']); ?></h5>
                        <span class="sub-text">
                            <?php
                            // Account type text
                            $accTypes = [
                                1 => "Savings Account",
                                2 => "Current Account",
                                3 => "MPower Business Account",
                                4 => "Checking Account",
                                5 => "Money Market Accounts",
                                6 => "Certificates of Deposit",
                                7 => "Brokerage Accounts",
                                8 => "Individual Retirement Accounts"
                            ];
                            echo isset($accTypes[$userrow['acc_type']]) ? $accTypes[$userrow['acc_type']] : "Unknown Account Type";
                            ?>
                        </span>
                    </div>
                </div>
            </div><!-- .card-inner -->

            <div class="card-inner">
                <div class="aside-wg">
                    <h6 class="overline-title-alt mb-2">User Information</h6>
                    <ul class="user-contacts">
                        <li>
                            <em class="icon ni ni-mail"></em><span><?php echo htmlspecialchars($userrow['email']); ?></span>
                        </li>
                        <li>
                            <em class="icon ni ni-call"></em><span><?php echo htmlspecialchars($userrow['phone']); ?></span>
                        </li>
                        <li>
                            <em class="icon ni ni-map-pin"></em><span><?php echo htmlspecialchars($userrow['address']); ?></span>
                        </li>
                    </ul>
                </div>
            </div><!-- .card-inner -->
        </div>
    </div>
<?php
} else {
    echo "<p>User not found.</p>";
}
?>

                                
                                
                                
                                
                                
                                
                                
                                
                                

                            </div><!-- .col -->

                            <div class="col-lg-7">
                              
                              
                              
                              
                                <div class="nk-block-head">
                                    <div class="nk-block-head-content">
                                        <h5 class="nk-block-title title">Edit User Information</h5>
                                    </div>
                                </div>
                              
                              
                              
                              
                              
                                <div class="card card-bordered">





                                           
         			<?php


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

// Optional extra query if needed for different mappings (e.g., marital status, acc_type)
$numrow = $ordrow; // use the same array if all values are from the same table

$success_confirm = $_POST['success_confirm'] ?? null;
$success2_confirm = $_POST['success2_confirm'] ?? null;
$failed_confirm = $_POST['failed_confirm'] ?? null;
?>

<form action="" method="post">
    <?php 
    if (isset($success_confirm)) {
        echo $success_confirm;
    } elseif (isset($success2_confirm)) {
        echo $success2_confirm;
    } elseif (isset($failed_confirm)) {
        echo $failed_confirm;
    }
    ?>

    <input type="hidden" name="date" value="<?php echo date("jS F Y g.iA"); ?>" readonly>

    <table width="100%" border="0" cellspacing="2" cellpadding="0" style="font-size:12px;">
        <tr class='rowtab'>
            <td colspan='2' style='padding:2px 5px; background:#014E72; color:#fff; text-align:center; font-style:italic;'>ACCOUNT DETAILS</td>
        </tr>

        <tr class='rowtab'>
            <td>Gender: <span class='style5'>*</span></td>
            <td>
                <input class='form-control' name='sex' type='text' value='<?php echo ($ordrow['sex'] == 1 ? "Male" : "Female"); ?>' readonly/>
            </td>
        </tr>

        <tr class='rowtab2'>
            <td>Marital Status: <span class='style5'>*</span></td>
            <td>
                <input class='form-control' name='m_status' type='text' value='<?php 
                     if($ordrow['m_status'] == 1) {
      echo 'SINGLE';
    }
    
    elseif($ordrow['m_status'] == 2) {
      echo 'MARRIED';
    }
     elseif($ordrow['m_status'] == 3) {
      echo 'DIVORCE';
    }
                ?>' readonly/>
            </td>
        </tr>

        <tr class='rowtab'><td>User Name: *</td><td><input type='text' name='username' class='form-control' value='<?= $ordrow['username'] ?>' readonly/></td></tr>
        <tr class='rowtab'><td>First Name: *</td><td><input type='text' name='firstname' class='form-control' value='<?= $ordrow['firstname'] ?>' readonly/></td></tr>
        <tr class='rowtab'><td>Last Name: *</td><td><input type='text' name='lastname' class='form-control' value='<?= $ordrow['lastname'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Email: *</td><td><input type='email' name='email' class='form-control' value='<?= $ordrow['email'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Phone: *</td><td><input type='text' name='phone' class='form-control' value='<?= $ordrow['phone'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Date of Birth: *</td><td><input type='text' name='dob' class='form-control' value='<?= $ordrow['dob'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Country: *</td><td><input type='text' name='country' class='form-control' value='<?= $ordrow['country'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Address: *</td><td><input type='text' name='address' class='form-control' value='<?= $ordrow['address'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>State: *</td><td><input type='text' name='state' class='form-control' value='<?= $ordrow['state'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>City: *</td><td><input type='text' name='city' class='form-control' value='<?= $ordrow['city'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Occupation: *</td><td><input type='text' name='occupation' class='form-control' value='<?= $ordrow['occupation'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Company Name: *</td><td><input type='text' name='company' class='form-control' value='<?= $ordrow['company'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Annual Income: *</td><td><input type='text' name='ann_incom' class='form-control' value='<?= $ordrow['ann_incom'] ?>' readonly/></td></tr>
        <tr class='rowtab2'><td>Transfer Limit: *</td><td><input type='text' name='tr_limit' class='form-control' value='<?= $ordrow['tr_limit'] ?>' readonly/></td></tr>

        <tr class='rowtab2'>
            <td>Account Type: *</td>
            <td>
                <input class='form-control' name='acc_type' type='text' value='<?php 
                    if($ordrow['acc_type'] == 1) {
      echo "Savings Account.";
    }
       elseif($ordrow['acc_type'] == 2) {
        echo "Current Account";
    }
    
     elseif($ordrow['acc_type'] == 3) {
        echo "MPower Business Account";
    }
    
     elseif($ordrow['acc_type'] == 4) {
        echo "Checking account";
    }
    
     elseif($ordrow['acc_type'] == 5) {
        echo "Money market accounts";
    }
    
    
     elseif($ordrow['acc_type'] == 6) {
        echo "Certificates of deposit";
    }
    
    
     elseif($ordrow['acc_type'] == 7) {
        echo "Brokerage accounts";
    }
    
    
     elseif($ordrow['acc_type'] == 8) {
        echo "Individual retirement accounts";
    }
  
      
                ?>' readonly/>
            </td>
        </tr>

        <tr class='rowtab2'>
            <td>ID TYPE: *</td>
            <td>
                <input class='form-control' name='id_type' type='text' value='<?php 
if($ordrow['id_type'] == 1) {
      echo 'International Passport';
    }
    
    elseif($ordrow['id_type'] == 2) {
      echo 'Drivers Licence';
    }
     elseif($ordrow['id_type'] == 3) {
      echo 'National ID Card';
    }
     elseif($ordrow['id_type'] == 4) {
      echo 'Others';
    }
      
                ?>' readonly/>
            </td>
        </tr>

        <tr class='rowtab2'><td>My BTC Wallet: *</td><td><input type='text' name='mybtc' class='form-control' value='<?= $ordrow['mybtc'] ?>' readonly/></td></tr>

        <tr class='rowtab2'>
            <td></td>
            <td>
                <br>
                
                
                
               <?php

// Prepare and execute the query
$stmt = $pdo->query("SELECT * FROM settings ORDER BY id DESC");

// Loop through all results
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    echo "
    <input type='hidden' class='form-control' name='cname' value='" . htmlspecialchars($row['domain_name']) . "'>
    <input type='hidden' class='form-control' name='cemail' value='" . htmlspecialchars($row['email2']) . "'>
    <input type='hidden' class='form-control' name='cphone' value='" . htmlspecialchars($row['phone']) . "'>
    <input type='hidden' class='form-control' name='caddress' value='" . htmlspecialchars($row['address']) . "'>
    ";
}
?>
 
                
                
                
                
                <a href='change_photo.php' class="btn btn-primary submit_btn">VIEW PHOTO</a>
            </td>
        </tr>
    </table>
</form>

       
                    
            
       
       
      
      

      
                                    
                                    
                                    
                                    
                                    
                                    
                                </div>

                            </div><!-- .col -->
                        </div><!-- .row -->
                    </div><!-- .nk-block -->
                </div>
            </div>
        </div>
    </div>

                <!-- content @e -->

             <?php require ("footer.php")?>