<?php
include_once("include/main.inc.php");
$admin_sql = mysqli_query($dbconn, "select * from admin_details");
$admin_res = mysqli_fetch_array($admin_sql);
$referer = $_SERVER['HTTP_REFERER'];
$ip = $_SERVER['REMOTE_ADDR'];
?>

<div class="about-right-part" id="homeproductID">
    <div class="appointment-form form-wraper">
        <div class="title">Send Enquiry</div>
        <form name="contact-form" method="post" id="Service_form">
        <div id="mail-status2"></div>
            <div class="form-group">
                <select class="form-control" name="home_services" id="home_services">
                    <option value="">Select Services</option>
                    <option value="Smile Design Dental Treatment">Smile Design Dental Treatment</option>
                    <option value="Root Canal Treatment">Root Canal Treatment </option>
                    <option value="Dental Implants">Dental Implants</option>
                    <option value="Full Mouth Rehabilitation">Full Mouth Rehabilitation</option>
                    <option value="Orthodontic Treatments">Orthodontic Treatments</option>
                    <option value="Complete & Removable Partial Dentures">Complete & Removable Partial Dentures</option>
                    <option value="Restorative Dentistry">Restorative Dentistry</option>
                    <option value="E-Max Restoration">E-Max Restoration</option>
                    <option value="Teeth Cleaning">Teeth Cleaning</option>
                    <option value="Gum Surgeries">Gum Surgeries</option>
                    <option value="Teeth Whitening">Teeth Whitening</option>
                    <option value="Teeth Extraction">Teeth Extraction</option>
                    <option value="Crown & Bridge">Crown & Bridge</option>
                    <option value="Child Dentistry">Child Dentistry</option>
                    <option value="Cosmetic Dentistry">Cosmetic Dentistry</option>
                    <option value="Preventive Dental Treatments">Preventive Dental Treatments</option>
                    <option value="Prosthodontic Treatments">Prosthodontic Treatments</option>
                    <option value="Endodontic Treatments">Endodontic Treatments</option>
                    <option value="Periodontic Treatments">Periodontic Treatments</option>
                    <option value="Traumatic Dental Injuries">Traumatic Dental Injuries</option>
                    <option value="Sports Appliances">Sports Appliances</option>
                    <option value="Night Guards">Night Guards</option>
                    <option value="Pit & Fissure Sealants">Pit & Fissure Sealants</option>
                    <option value="Dental Jewellery">Dental Jewellery</option>
                    <option value="Microscopic Dental Treatments">Microscopic Dental Treatments</option>
                    <option value="Laser Dentistry">Laser Dentistry</option>
                </select>
            </div>
            <div class="form-group">
                <input type="text" class="form-control" name="homeuser_name" id="homeuser_name" value="" placeholder="Your Name" onkeypress="return ValidateAlpha(event)" required>
            </div>
            <div class="form-group">
                <input type="email" class="form-control" name="homeemail_address" id="homeemail_address" value="" placeholder="Email ID" required>
            </div>

            <div class="form-group">
                <input type="text" class="form-control" name="homephone_no" id="homephone_no" value="" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" placeholder="Phone Number" maxlength="10" required>
            </div>
            <div class="form-group">
                <textarea class="form-control" name="home_message" id="home_message" placeholder="Your Message*" required></textarea>

            </div>
            <button type="submit" name="submit" id="home_submit" class="read_more_1 bg_btn_1">Submit</button>
        </form>
    </div>
</div>

<script>
    $(document).ready(function() {
        $('#home_submit').click(function(e) {
            e.preventDefault();
            if ($("#home_services").val() != '' && $("#homeuser_name").val() != '' && $(
                    "#homeemail_address").val() != '' && $("#homephone_no")
                .val() != '' && $("#home_message").val() != '') {
                jQuery.ajax({
                    url: "<?= site_url; ?>/ajaxEnquiryhome.php",
                    data: $('#Service_form').serialize(),
                    type: "POST",
                    success: function(data) {
                        var data = data.trim();
                        if (data == 'success') {
                            $("#mail-status2").html(
                                '<div class="alert alert-success alert-dismissible show">Your Enquiry has been sent successfully.  Our Team will contact you shortly!<button type="button" class="close" data-bs-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>'
                            );
                            $('#homeproductID').trigger('reset');

                        } else {
                            $("#mail-status2").html(data).css('color', 'red');
                        }
                    },
                    error: function() {}
                });
            } else {
                $("#mail-status2").html(
                    '<div class="alert alert-danger alert-dismissible show"><strong>Asterisk(*) Marked fields are Mandatory!<button type="button" class="close" data-bs-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>'
                );
            }

        })

    })
</script>