<?php  
$title = "Donate Today - Wipe Tears Africa (WTA)";
$tagline = "Bringing hope & a future to the African children in Uganda";
$description = "Wipe Tears Africa (WTA) is a nonprofit organization founded in 2010, dedicated to restoring hope and transforming the lives of vulnerable children and families in Uganda.";
$keywords = "Wipe Tears Africa, WTA, Education, Health, Girl Child Empowerment, Skills Development, Counselling & Guidance";
$featured_image = 'https://www.wipetearsafrica.org/assets/images/wipe-tears-africa-uganda1.jpg';
include "includes/header.php";
?>

<?php include "includes/menu.php"; ?>
<section class="header-services" style="background: linear-gradient(to bottom, rgba(46, 178, 23, 0.763), rgba(46, 178, 23, 0.963)), url('assets/images/slides/wipe-tears-africa-4.jpg') no-repeat;background-size: cover;background-position: center;">
    <div class="container">
        <div class="row align-items-center">
            <div class="col text-center" data-aos="fade-up">
                <h1>Donate Today</h1>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="./"></a></li>
                        <li class="breadcrumb-item active" aria-current="page"><li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>
</section>

<section class="home-intro-mid">
  <div class="container">
    <div class="row align-items-center">
      <div class="col-md-6 mb-3">
        <img style="height: 600px;" src="assets/images/donate-to-help-children-wipe-tears-africa.jpg" alt="Wipe Tears Africa" class="iprog img-fluid" data-aos="fade-up">
      </div>
      <div class="col-md-6 mb-3">
       <h5 class="tdeco" data-aos="fade-up">Make your Donation Today</h5>
       <h2 data-aos="fade-up">Your support helps us support the vulnerable children</h2>
       
        <p data-aos="fade-up">
            Your support of $35 a month can change lives at Wipe Tears Africa. Your generous donation will provide a child fees to attend school, school uniforms, scholastic materials, and a dialy meal. Your contribution helps us give hope and a future to children in need. Every donation, big or small, makes a difference.
            
            
        </p>  
        <h4 data-aos="fade-up">Ways to Donate:</h4>
        <ol data-aos="fade-up">
            <li>
               <p><u><strong>Make a direct Deposit </strong> using details belowor or write a check and send it to 107 Dee Dr. Flat Lick KY 40935 </u><br/>
                Bank Name: PNC Bank<br/>
                ACC Name: Wipe Tears Africa <br/>
                ACC No: 3075730466<br/>
                Routing No: 083000108<br/></p>
            </li>
            <li>
                <p>
                    <u><strong> You can also Wire money direct to our account in Uganda </strong></u><br/>
                     Bank Name: Equity Bank Uganda<br>
                    ACC No: 1032201023023<br/>
                    Acc Name: Wipe Tears Africa<br/>
                    Swift Cord BQBLUGKA. Branch: Market Street<br/></p>
                </p>
            </li>
        </ol>
              <!-- Button trigger modal -->
        <button type="button" data-aos="fade-up" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
         
        </button>

        <style>
         /* Custom Close Button */
        .custom-close-btn {
            font-size: 30px;
            font-weight: bold;
            width: 40px;
            height: 40px;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }
        
        .custom-close-btn:hover {
            background-color: lightgreen; 
            border-color: #2EB217;
            color: black;
        }
        </style>
        
        <!-- Modal -->
        <div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
         <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                  <h5 class="modal-title fs-7 tdeco aos-init aos-animate" id="staticBackdropLabel"><i class="fa fa-user-edit me-2"></i>Give A Donation</h5>
                  <button type="button" class="btn custom-close-btn btn-success" data-bs-dismiss="modal" aria-label="Close">
                    &times;
                </button>
              </div>
                <div class="container-fluid">
                    <div class="align-items-center justify-content-center">
                        <form id="donationForm" method="POST">
                            <div id="formErrors" style="display: none; color: red;"></div>

                            <div class="rounded p-2 p-sm-2 my-2 mx-1">
                                <div class="form-floating mb-3">
                                    <input name="fname" class="form-control" id="floatingText" placeholder="Remmy"
                                        type="text" required>
                                    <label for="floatingText">Full Name:</label>
                                </div>
                                 <div class="form-floating mb-3">
                                    <input name="email" class="form-control" id="floatingInput" type="email"
                                        placeholder="name@example.com" required>
                                    <label for="floatingInput">Email:</label>
                                </div>
                                 <div class="form-floating mb-3">
                                    <input name="telno" class="form-control" id="floatingInput" type="number"
                                        placeholder="075699000" required>
                                    <label for="floatingInput">Phone Number:</label>
                                </div>
                                
                                <label>Gender:</label>
                                <input type="radio" id="male" name="gender" value="Male" required>
                                <label for="male">Male</label>
                                <input type="radio" id="female" name="gender" value="Female" required>
                                <label for="female">Female</label>

                               <div class="form-floating mb-3">
                                    <input name="occupation" class="form-control" id="floatingText" placeholder="work"
                                        type="text" required>
                                    <label for="floatingText">Occupation:</label>
                                </div>
                               
                                <div class="form-floating mb-3">
                                    <select name="country" id="countrySelect" class="form-select"
                                        aria-label="Select a country" required>
                                        <option selected disabled>Loading...</option>
                                    </select>
                                    <label for="countrySelect">Country:</label>
                                </div>
                                <div class="form-floating mb-3">
                                    <input name="donate_amount" class="form-control" id="floatingAmount" type="number" step="0.01" placeholder="100.00" required>
                                    <label for="floatingAmount">Donation Amount($):</label>
                                </div>

                                <div class="form-floating mb-3">
                                    <textarea name="message" class="form-control" id="floatingMessage"
                                        placeholder="Your message here" style="height: 100px;" required></textarea>
                                    <label for="floatingMessage">Message:</label>
                                </div>

                                <div style="display:none;">
                                    <label for="website">Website</label>
                                    <input type="text" id="website" name="website">
                                </div>

                                <div class="d-flex justify-content-center align-items-center">
                                    <button type="submit" class="btn btn-success">Donate Now</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
       </div>
      </div>
      
    </div>
  </div>
</section>

<script>
    async function fetchCountries() {
        const select = document.getElementById("countrySelect");
        try {
            const response = await fetch("https://restcountries.com/v3.1/all");
            const countries = await response.json();
            select.innerHTML = '<option selected disabled>Select Country</option>';
            countries.forEach(country => {
                const option = document.createElement("option");
                option.value = country.name.common;
                option.textContent = country.name.common;
                select.appendChild(option);
            });
        } catch (error) {
            console.error("Error fetching countries:", error);
            select.innerHTML = '<option selected disabled>Error loading countries</option>';
        }
    }
    fetchCountries();

    // Handle form submission via AJAX
   document.getElementById("donationForm").addEventListener("submit", async function(e) {
    e.preventDefault();
    console.log("Form submitted"); // Add this to check

    // Clear previous errors
    document.getElementById("formErrors").style.display = "none";
    document.getElementById("formErrors").innerHTML = "";

    const formData = new FormData(this);
    
    try {
        const response = await fetch("donation_server.php", {
            method: "POST",
            body: formData,
        });
        const data = await response.json();
        // console.log(data); // Add this to check the response

        if (data.success) {
            alert("Thank you for your donation! A confirmation email has been sent.");
            $('#staticBackdrop').modal('hide'); // Close modal
        } else {
            document.getElementById("formErrors").style.display = "block";
            document.getElementById("formErrors").innerHTML = data.message;
        }
    } catch (error) {
        console.error("Error submitting form:", error);
        document.getElementById("formErrors").style.display = "block";
        document.getElementById("formErrors").innerHTML = "An error occurred while processing your request. Please try again later.";
    }
});

</script>

<?php include "includes/footer.php"; ?>
