
<?php

$url="http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

  if(strpos($url, 'error') == true){


 echo '<script>
    setTimeout(function() {
        swal({
            title: "Error!",
            text: "Error Occured",
            type: "error"
        }, function() {
            window.location = "#0";
        });
    }, 1000);
  </script>';
  

    }elseif (strpos($url, 'updated') == true) {
        
 echo '<script>
    setTimeout(function() {
        swal({
            title: "Success!",
            text: "Data Updated successfully",
            type: "success"
        }, function() {
            window.location = "#0";
        });
    }, 1000);
</script>';

    } elseif (strpos($url, 'saved') == true) {
        
 echo '<script>
    setTimeout(function() {
        swal({
            title: "Success!",
            text: "Passport updated successfully",
            type: "success"
        }, function() {
            window.location = "#0";
        });
    }, 1000);
</script>';

    }




?>



<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Add Transaction</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome CSS -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">

  <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
</head>

<body>

    <style>
    .content {
        width: 80%;
        padding: 50px 5%;
        /* border: 1px solid gray; */
        border-radius: 10px;
        margin: 50px auto;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    </style>
        <div class="content">
        <a href="index.php" class="btn btn-secondary mb-3">Go Back</a>
        <!-- Modal content -->
        <div class="modal-content">
            
            <div style="margin: 0 auto; padding:20px 0;">
                
                

            </div>

            
            <h2 class='text-center text-primary'>ADD NEW USER</h2>
            <!--details -->
            <form id="modalForm" action="./addnew/addtransaction.php" method="post" enctype="multipart/form-data">

            <div class="form-group col-md-12  py-2">
                        <label for="email_address">User Email</label>
                        <select id="email_address" class="form-control" name="email_address" required>
                            <option selected>Choose...</option>
                            <?php
                            include_once '../secure/dbconn.php';
                                // Fetch data from the table
                                $sql = "SELECT email_address, id, username FROM users";
                                $result = $conn->query($sql);
                                
                                
                                // Check if there are any rows returned
                                if ($result->num_rows > 0) {
                                    // Output data of each row
                                    while($row = $result->fetch_assoc()) {
                                        $user_email=$row["email_address"];
                                        echo "<option value='" . $user_email . "'>" . $user_email . "</option>";
                                        
                                    }
                                } else {
                                    echo "<option value=''>No data available</option>";
                                }
                                                    
                            ?>
                            
                        </select>
                        
                <!--hidden inputs-->
                

                    </div>
                    <div class="form-group col-md-6">
                        <label for="from">From/To</label>
                        <input type="text" class="form-control" id="from" name="from" required
                            placeholder="From/To">
                    </div>
                    <div class="form-group col-md-6">
                        <label for="date">Date</label>
                        <input type="date" class="form-control" id="date" name="date" required>
                    </div>
                </div>
                <div class="form-row row py-2">

                    <div class="form-group col-md-6">
                        <label for="amount">Amount</label>
                        <input type="text" class="form-control" id="amount" name="amount" value=""
                            required placeholder="Amount">
                    </div>
                    
                    <div class="form-group col-md-6">
                        <label for="status">Gender</label>
                        <select id="status" class="form-control" name="status" required>
                            <option selected>Choose...</option>
                            <option>Received</option>
                            <option>Sent</option>
                        </select>
                    </div>
                </div>

                <button type="submit" class="btn btn-success px-4 mt-4" name="addtrans">Add</button>
            </form>
        </div>
    </div>
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
    <!-- jQuery Library -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Font Awesome JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/js/all.min.js"></script>
</body>

</html>