<?php
require_once "common/front_header.php";

if (isset($_POST['btnContact'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $recipient = "info@womankenya.com";
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $status = "unread";


    if ($name != '' && $email != '' && $subject != '' && $message != '') {

        $response = $db->addContact($name, $email, $recipient, $subject, $message, $status);

        if ($response["error"] == false) {
            echo "<script type='text/javascript'>
                swal({
                                title: \"Success!\",
                                text: \"Message Submitted Successfully! We will get back to you\",
                                icon: \"success\",
                                button: \"Thank you!\",
                            });
               </script>";

        } else
            echo "<script type='text/javascript'>
                swal({
                                title: \"Sorry!\",
                                text: \"Error submitting message!\",
                                icon: \"warning\",
                                button: \"Please try again!\",
                            });
            </script>";


        require_once 'libs/mailer/class.phpmailer.php';

        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        $mail->SMTPSecure = "ssl";
        $mail->Host = "creat.co.ke";
        $mail->Port = 465;
        $mail->Username = "uncommon@creat.co.ke";
        $mail->Password = "O6+VLDzLe+jv";
        $mail->SMTPKeepAlive = true;
        $mail->SMTPDebug = 0;
        $mail->SetFrom(EMAIL, WEB_NAME);
        $mail->AddReplyTo(EMAIL, WEB_NAME);

        $message1 = "Dear " . $email . ",<br/><br/>

                        Thank you for contacting Woman Kenya.<br/><br/>

                        We will get back to you.
                        <br/><br/>

                        Regards,
                        <br/><br/>
                        Woman Kenya Team";


        $message2 = "Dear " . EMAIL . ",<br/><br/>

                        You have a message from.<br/><br/>
                        <br/><br/>
                        
                        Name:" . $name . ".<br/><br/>
                        Email:  " . $email . ".<br/><br/>
                        Email:  <strong>" . $message . ".</strong><br/><br/>
                        <br/><br/>
                          
                        Regards,
                        <br/><br/>
                        Woman Kenya Team";


        $subject = "WOMAN KENYA";

        try {
            $mail->addAddress($email);
            $mail->MsgHTML($message1);
            $mail->Subject = $subject;
            $mail->Send();

            $mail->ClearAllRecipients();

            $mail->addAddress(EMAIL);
            $mail->MsgHTML($message2);
            $mail->Subject = $subject;
            $mail->Send();

        } catch (Exception $e) {
            $response["error"] = true;
            $response["message"] = $e->getMessage();
        }

    }
}

?>
<div class="container">

    <div class="row mt-5 mb-5">
        <div class="col-md-4">
            <div class="card p-4 border-0">
                <img src="front_assets/images/contact_photo.jpg" class="card-img-top" alt="...">
                <div class="card-body">
                    <p class="card-text" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b; font-size:13px!important; line-spacing:39px!important">
                        Queenter Mbori is an editor, writer, mentor and woman champion who is passionate about
                        life. Let's connect and talk about women empowerment and much more.
                    <p class="mt-4" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b;font-size:13px!important;">Email: qmbori@gmail.com.
                    </p>
                    <div class="d-inline-flex">
                        <div class="social_icons mt-1">
                            <a href="https://www.facebook.com/WomanKenya/?ref=aymt_homepage_panel&eid=ARAWe2W00TUC-EZiUVuJmSHX5WeEDnlJBuUP0IKki9Hk4o7kkONPPRqb4hNs2VArYkFAQMbwR2YVR76-"
                               target="_blank">
                                <img src="front_assets/images/facebook.png"
                                     style="height: 30px; width: 30px" class="img-fluid ml-2"/>
                            </a>
                            <a href="https://www.instagram.com/queeniembori/" target="_blank">
                                <img src="front_assets/images/instagram.png"
                                     style="height: 30px; width: 30px" class="img-fluid ml-2"/>
                            </a>
                            <a href="https://twitter.com/queeniesaina" target="_blank">
                                <img src="front_assets/images/twitter.png"
                                     style="height: 30px; width: 30px" class="img-fluid ml-2"/>
                            </a>

                            <a href="https://youtu.be/jHs0m6ySMug" target="_blank">
                                <img src="front_assets/images/youtube.png"
                                     style="height: 30px; width: 30px" class="img-fluid ml-2"/>
                            </a>

                        </div>
                    </div>

                </div>
            </div>
        </div>

        <div class="col-md-8 border">
            <!--Section: Contact v.2-->
            <section class="mb-4 pl-5">

                <!--Section heading-->
                <h2 class="h1-responsive font-weight-bold text-center my-3" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b; font-size:18px!important;">Get intouch</h2>
                <!--Section description-->
                <p class="text-center w-responsive mx-auto mb-5" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b; font-size:14px!important; line-spacing:39px!important">
                    Are you passionate about making an impact in the lives of women or do you have a comment or idea you
                    would like to share? Please send us an email and tell us more about it. I will definitely get in
                    touch.
                </p>

                <div class="row mt-5">
                    <!--Grid column-->
                    <div class="col-md-12 mb-md-0 mb-5">
                        <form id="contact-form" name="contact-form" action="contact.php" method="POST">

                            <!--Grid row-->
                            <div class="row">

                                <!--Grid column-->
                                <div class="col-md-6 mt-4">
                                    <div class="md-form mb-0">
                                        <label for="name" class="" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b; font-size:14px!important;">Name</label>
                                        <input type="text" id="name" name="name" class="form-control">
                                    </div>
                                </div>
                                <!--Grid column-->

                                <!--Grid column-->
                                <div class="col-md-6 mt-4">
                                    <div class="md-form mb-0">
                                        <label for="email" class="" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b; font-size:14px!important;">Email</label>
                                        <input type="text" id="email" name="email" class="form-control">
                                    </div>
                                </div>
                                <!--Grid column-->

                            </div>
                            <!--Grid row-->

                            <!--Grid row-->
                            <div class="row">
                                <div class="col-md-12 mt-4">
                                    <div class="md-form mb-0">
                                        <label for="subject" class="" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b; font-size:14px!important;">Subject</label>
                                        <input type="text" id="subject" name="subject" class="form-control">
                                    </div>
                                </div>
                            </div>
                            <!--Grid row-->

                            <!--Grid row-->
                            <div class="row">

                                <!--Grid column-->
                                <div class="col-md-12 mt-4 mb-5">

                                    <div class="md-form">
                                        <label for="message" style="font-family: 'Roboto', sans-serif!important; color: #6f6b6b; font-size:14px!important;">How would you like to help?</label>
                                        <textarea type="text" id="message" name="message" rows="2"
                                                  class="form-control md-textarea"></textarea>
                                    </div>

                                </div>
                            </div>
                            <!--Grid row-->
                            <button type="submit" name="btnContact" class="btn btn-success pull-right" style="font-family: 'Roboto', sans-serif!important; color: #fff; font-size:14px!important;">Submit</button>
                        </form>
                    </div>

                </div>
                <!--Grid column-->

        </div>

        </section>
        <!--Section: Contact v.2-->
    </div>

</div>


</div>
<?php
require_once "common/front_footer.php";
?>
