<?php 
  $link_status4 = "";
  $link_status5 = "";
  $link_status6 = "active";
?>
<?php 
include("includes/top-header.php"); 

if(isset($_POST['request_account'])){
  $requested_account_type = $_POST['account_type'];
      
    // $name = $fname." ".$lname;
    // $email = $em;
    
    // $mail = new PHPMailer;
                      
    // $mail->isSMTP();
    // $mail->SMTPDebug = 0; 
    // $mail->Host = "mail.firstsgbk.com";
    // $mail->SMTPAuth = true;
    // $mail->SMTPSecure = true;
    // //$mail->Port = 25; 
    // $mail->Port = 465; 
    
    // $mail->Username = 'no-reply@firstsgbk.com';
    // $mail->Password = 'fe-XB;AYE-$Y';
    
    
    // $mail->From = 'no-reply@firstsgbk.com';
    // $mail->FromName = 'Guardian Trust - United';
    // $mail->addAddress($email,$name);
    
    // $mail->IsHTML(true);
    // $mail->WordWrap = 50;
    //   $body="<div style=\"padding:10px;background-color:#f5f5f5;border:1px solid #ccc;min-height:300px;\">";
    //   $body.="<h3 style=\"border-bottom:1px solid #ccc;padding:10px;\">Dear ".$name.", </h3><p>Your secure pin is:</p>
    //     <p>
    //       <strong>".$tok."</strong>
    //     </p>
    //     --
    //     <br>
    //     <img src='https://www.firstsgbk.com/wp-content/themes/spring/images/springbank-prime-1.png' style='width: 200px;' alt='Guardian Trust - United'><br>
    //     Phone: +1 (678) 572-0616 <br>
    //     Email: customercare@firstsgbk.com <br>
    //     Website: <a href='https://firstsgbk.com/'>www.firstsgbk.com</a> <hr>
    //     <p style='text-align: center;'>THIS IS AN AUTOMATED RESPONSE. <b>**DO NOT RESPOND TO THIS EMAIL**</b></p>
    //   </div>
    // ";
      
    // $mail->Subject = 'OTP Verification';
    // $mail->Body    = $body;
    // $mail->isHTML(true);
    // if(!$mail->send()){
      
        $sql="update users set pc_status='3' where uID='".$uid."'";
        $rs=mysqli_query($conn, $sql);
          
        if($rs){
          echo '<script>alert("Request sent successfully!")</script>';
          echo '<script>window.location.href = "settings-payment-methods.php";</script>';
        }else{
          echo '<script>alert("Something went wrong, try again later...")</script>';
        }
    // }else{		
        // echo '<script>alert("Something went wrong, try again later...")</script>';
        // echo '<script>window.location.href = "settings-payment-methods.php";</script>';
    // }

    $name=$email=NULL;
}
?> 
  
        
<?php include("includes/header.php"); ?>
        <!-- Left Panel End -->  
        
        <!-- Middle Panel
        ============================================= -->
     <?php
// Process form submissions
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $to = "customerservice@newageunb.com"; // Replace with your company's email address
    $subject = "New Request Notification";
    $clientName = $fname . " " . $lname; // Fetch client name dynamically if available
    $requestDate = date("Y-m-d H:i:s");

    $message = ''; // Initialize the message variable
    
    // Check if the request is for a card or account
    if (isset($_POST['request_card'])) {
        $cardType = $_POST['card_type'];
        $message = "
        <html>
        <head>
            <style>
                body {
                    font-family: 'Arial', sans-serif;
                    background-color: #f9f9f9;
                    color: #333;
                    padding: 20px;
                    margin: 0;
                }
                .container {
                    width: 100%;
                    max-width: 600px;
                    margin: auto;
                    background: #fff;
                    border-radius: 8px;
                    padding: 20px;
                    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
                }
                h1 {
                    color: #4CAF50;
                    text-align: center;
                }
                .details {
                    margin-top: 20px;
                    font-size: 16px;
                    line-height: 1.6;
                }
                .footer {
                    text-align: center;
                    font-size: 14px;
                    color: #777;
                    margin-top: 30px;
                }
                .highlight {
                    color: #333;
                    font-weight: bold;
                }
                .button {
                    display: inline-block;
                    background-color: #4CAF50;
                    color: #fff;
                    padding: 10px 20px;
                    text-decoration: none;
                    border-radius: 5px;
                    margin-top: 20px;
                }
            </style>
        </head>
        <body>
            <div class='container'>
                <h1>New Request for Card</h1>
                <p class='details'>A client has requested a new card. Below are the details:</p>
                <p><span class='highlight'>Client Name:</span> $clientName</p>
                <p><span class='highlight'>Card Type:</span> $cardType</p>
                <p><span class='highlight'>Request Date:</span> $requestDate</p>
                <p>If you have any questions, please reach out to the client.</p>
                <p class='footer'>Thank you for your attention!</p>
            </div>
        </body>
        </html>
        ";
    } elseif (isset($_POST['request_account'])) {
        $accountType = $_POST['account_type'];
        $message = "
        <html>
        <head>
            <style>
                body {
                    font-family: 'Arial', sans-serif;
                    background-color: #f9f9f9;
                    color: #333;
                    padding: 20px;
                    margin: 0;
                }
                .container {
                    width: 100%;
                    max-width: 600px;
                    margin: auto;
                    background: #fff;
                    border-radius: 8px;
                    padding: 20px;
                    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
                }
                h1 {
                    color: #4CAF50;
                    text-align: center;
                }
                .details {
                    margin-top: 20px;
                    font-size: 16px;
                    line-height: 1.6;
                }
                .footer {
                    text-align: center;
                    font-size: 14px;
                    color: #777;
                    margin-top: 30px;
                }
                .highlight {
                    color: #333;
                    font-weight: bold;
                }
                .button {
                    display: inline-block;
                    background-color: #4CAF50;
                    color: #fff;
                    padding: 10px 20px;
                    text-decoration: none;
                    border-radius: 5px;
                    margin-top: 20px;
                }
            </style>
        </head>
        <body>
            <div class='container'>
                <h1>New Request for Bank Account</h1>
                <p class='details'>A client has requested a new bank account. Below are the details:</p>
                <p><span class='highlight'>Client Name:</span> $clientName</p>
                <p><span class='highlight'>Account Type:</span> $accountType</p>
                <p><span class='highlight'>Request Date:</span> $requestDate</p>
                <p>If you have any questions, please reach out to the client.</p>
                <p class='footer'>Thank you for your attention!</p>
            </div>
        </body>
        </html>
        ";
    }

    // Headers for sending HTML email
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    $headers .= "From: no-reply@yourdomain.com\r\n"; // Replace with your domain's email

    // Send the email
    if (mail($to, $subject, $message, $headers)) {
        echo "<script>alert('Request submitted successfully. The company has been notified.');</script>";
    } else {
        echo "<script>alert('Request failed. Please try again later.');</script>";
    }
}
?>



<div class="col-lg-9">
    <!-- Credit or Debit Cards Section -->
    <div class="bg-white shadow-sm rounded p-4 mb-4">
        <h3 class="text-5 fw-400 mb-4">Credit or Debit Cards <span class="text-muted text-4">(for payments)</span></h3>
        <hr class="mb-4 mx-n4">
        <form method="post">
            <div class="row g-3">
                <div class="col-12 col-md-6 col-lg-4">
                    <div class="account-card account-card-primary text-white rounded p-3">
                        <p class="text-4">XXXX-XXXX-XXXX-4151</p>
                        <p class="d-flex align-items-center">
                            <span class="account-card-expire text-uppercase d-inline-block opacity-7 me-2">Valid<br>thru<br></span>
                            <span class="text-4 opacity-9">07/26</span>
                            <span class="badge bg-warning text-dark text-0 fw-500 rounded-pill px-2 ms-auto">Primary</span>
                        </p>
                        <p class="d-flex align-items-center m-0">
                            <span class="text-uppercase fw-500"><?php echo $fname . " " . $lname; ?></span>
                            <img class="ms-auto" src="images/payment/mastercard.png" alt="mastercard" title="">
                        </p>
                    </div>
                </div>
                <div class="col-12 col-md-6 col-lg-4">
                    <label for="card_type" class="form-label">Request New Card</label>
                    <select id="card_type" name="card_type" class="form-select mb-3" required>
                        <option value="" disabled selected>Choose Card Type...</option>
                        <option value="Debit Card">Debit Card</option>
                        <option value="Credit Card">Credit Card</option>
                    </select>
                    <button type="submit" name="request_card" class="btn btn-primary">Submit Card Request</button>
                </div>
            </div>
        </form>
    </div>

    <!-- Bank Accounts Section -->
    <div class="bg-white shadow-sm rounded p-4 mb-4">
        <h3 class="text-5 fw-400 mb-4">Bank Accounts</h3>
        <hr class="mb-4 mx-n4">
        <form method="post">
            <div class="row g-3">
                <?php
                $ssl = "SELECT * FROM account WHERE memID='" . $member_id . "' ORDER BY id ASC";
                $rs_t = $conn->query($ssl);
                while ($row = $rs_t->fetch_assoc()) {
                    echo "
                    <div class='col-12 col-md-6'>
                        <div class='account-card account-card-primary text-white rounded'>
                            <div class='row g-0'>
                                <div class='col-3 d-flex justify-content-center p-3'>
                                    <div class='my-auto text-center'>
                                        <span class='text-13'><i class='fas fa-university'></i></span>
                                        <p class='badge bg-warning text-dark text-0 fw-500 rounded-pill px-2 mb-0'>" . $row['currency'] . " " . $row['aType'] . "</p>
                                    </div>
                                </div>
                                <div class='col-9 border-start'>
                                    <div class='py-4 my-2 ps-4'>
                                        <p class='text-4 fw-500 mb-1'>" . $row['aNum'] . "</p>
                                        <p class='text-4 opacity-9 mb-1'>" . $row['aName'] . "</p>
                                        <p class='m-0'>Approved <span class='text-3'><i class='fas fa-check-circle'></i></span></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>";
                }
                ?>
                <div class="col-12 col-md-6">
                    <label for="account_type" class="form-label">Request New Bank Account</label>
                    <select id="account_type" name="account_type" class="form-select mb-3" required>
                        <option value="" disabled selected>Choose Account Type...</option>
                        <option value="Savings Account">Savings Account</option>
                        <option value="Checking Account">Checking Account</option>
                        <option value="Beneficial Account">Beneficial Account</option>
                    </select>
                    <button type="submit" name="request_account" class="btn btn-primary">Submit Account Request</button>
                </div>
            </div>
        </form>
    </div>
</div>

  <!-- Content end --> 
  
  <!-- Footer
  ============================================= -->
  <?php include("includes/footer.php"); ?>
  <!-- Footer end --> 
  
</div>
<!-- Document Wrapper end --> 

<!-- Back to Top
============================================= --> 
<a id="back-to-top" data-bs-toggle="tooltip" title="Back to Top" href="javascript:void(0)"><i class="fa fa-chevron-up"></i></a> 

<!-- Styles Switcher -->

<!-- Styles Switcher End --> 

<!-- Script --> 
<script src="vendor/jquery/jquery.min.js"></script> 
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> 
<!-- Style Switcher --> 
<script src="js/switcher.min.js"></script> 
<script src="js/theme.js"></script>
</body>
</html>