    <?php
        require_once('Connections/conn_ama.php');

        if(!isset($_SESSION)){
            session_start();
        } 

        $colname = -1;

        if(isset($_POST['email'])){
            $colname = $_POST['email'];
            $cfh = $_POST['cfh'];
        }

       /* //Retrieve Category from all categories	
            $query_rsCategory = "SELECT categoryID, category  FROM citizenfeedbackcategories";
            $rsCategory = mysqli_query($conn_ama, $query_rsCategory ) or die(mysqli_error($conn_ama));
            $row_rsCategory = mysqli_fetch_assoc($rsCategory);
            $totalRows_rsCategory = mysqli_num_rows($rsCategory); 
        */
    ?>

    <hr>

   <div class="form-area">
            <form id="new-response-email" method="POST" >
                <div class="row">
                    
                    <div class="col-lg-12 report">
                        <div class="report-wrap">
                            <fieldset>
                                <legend>Response Email</legend>
                               
                                <div class="form-row">
                                    <div class="form-group col-lg-12">
                                        <label for="subject">Reporter's Email</label>
                                        <input type="text" name="MM_email" class="form-control" id="MM_email" value="<?php echo $colname; ?>">
                                    </div>
                                    <div class="form-group col-lg-12">
                                        <label for="subject">Subject</label>
                                        <input type="text" name="subject" class="form-control" id="subject" placeholder="Subject">
                                    </div>
                                </div>
       
                                <div class="form-group">
                                    <label for="msgbody1">Response</label>
                                    <textarea name="msgbody" class="form-control" id="msgbody1"></textarea>
                                </div>

                            </fieldset>
                        </div>
                    </div>
                </div> 
                <hr>
                <div class="col-lg-12">
                
                    <button type="submit" id="response-email" class="btn btn-success">Send</button>
                    <input type="hidden" name="MM_insert" value="send-response-email" />
                    <!-- <input type="hidden" name="MM_email" value="<?php echo $colname; ?>" /> -->
                    <input type="hidden" name="MM_cfh" value="<?php echo $cfh; ?>" />
                
                    <div class="status_msg"></div> 
                </div>
            </form>
   </div>


<!-- TinyMCE -->
        

<script type="text/javascript" src="_/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="_/js/tinymce/jquery.tinymce.min.js"></script>
                
            
<script type="text/javascript">
        $(function(){
            tinymce.init({
            selector: 'textarea#msgbody1',
            //height: 500,
            plugins: "autoresize"
           /*  mobile: {
                    theme: 'mobile',
                    plugins: [ 'autosave', 'lists', 'autolink' ],
                    toolbar: 'undo bold italic styleselect'
                } */
            });
        });
    </script> 
<!-- /TinyMCE -->
<!-- /TinyMCE -->
<script type="text/javascript">
    //(alert("form12121");)
   $(function(){
    ///////////////////////////////////////////////// Send response email ///////////////////////////////////
        $(document).ready(function(){
            $("#new-response-email").validate({

                rules:{
                   
                    email: {
                        //required: true,
                        email: true
                    },

                    subject:{
                        required: true,
                        minlength: 4
                    }, 

                    msgbody:{
                        required: true
                    }, 							
                },

                messages:{
             
                    subject: {
                        required: "Please provide a subject for this email."
                    },

                    msgbody:{
                        required: "Please the email body is empty"
                    }
                },

                submitHandler:function(form){
					
                    var formdata = new FormData(form); //new FormData("#new-citizens-feedback"); //$("#new-news-images").serializeArray();
                    var theurl = "_/components/php/manage-citizens-feedback/php-ajax-calls/send-response-email.inc.php";

                        console.log(formdata);
                    // console.log($("#fileUpload").serializeArray());

                        $.ajax({

                            url:    theurl,
                            type:   "post",
                            data:   formdata,
                            // async: false,
                            cache: false,
                            contentType: false,
                            processData: false,

                            beforeSend: function(){
                                $("#new-response-email #response-email").prop("disabled",true);//attr('disabled','disabled');
                                $("#new-response-email #response-email").append('<img src="img/loading.gif" alt="" style="margin-left: 15px;" />');
                            },

                            success:    function(insert){
                                //var error_msg ="";

                                //$(".error_msg").html(insert); //.delay(5000).fadeOut();

                                $("#response-email img[src='img/loading.gif']").fadeOut(1000);

                            // setTimeout(function(){
                                if($.trim(insert) == 'datasent' )
                                {   
                                        $(".form-area").fadeOut(500,function(){
                                            var newFeedbackAlert = "_/components/php/manage-citizens-feedback/_email-sent-alert.inc.php";
                                            $(this).load(newFeedbackAlert).fadeIn(800).delay(3000).fadeOut(1000,function(){
                                                //$(".form-area").fadeOut(400,function(){
                                                var newFeedbackForm = "_/components/php/citizens-feedback/_citizens-feedback-form.inc.php";
                                                $(this).load(newFeedbackForm).fadeIn(1000);
                                            });
                                        });
                                    /* $( ".status_msg").html("<h3 class='text-success'>Report Lodged successfully.</h3>").delay(3000).fadeOut(1000,function(){
                                        $(".form-area").fadeOut(400,function(){
                                        var newFeedbackForm = "_/components/php/citizens-feedback/_citizens-feedback-form.inc.php";
                                        $(this).load(newFeedbackForm).fadeIn(1000);
                                        });
                                    }); */
                                }
					
                                else if($.trim(insert) == 'notset'){
                                    //error_msg = "<p>Please select the round for the fixture.</p>";
                                    $(".status_msg").html(insert);
                                    $("#new-response-email #response-email").prop("disabled",false);//attr('disabled','disabled');
                                }
                                console.log(insert);
                            //}, 3500);
                            },
                            /* error: function(error){
                                ("#new-news-images #news-images").prop("disabled", false);
                            }, */
                            complete: function(success){
					
                            } 
                        });
                }
            });
        });
   });
</script>

<!-- TinyMCE -->
        
<!-- <script type="text/javascript" src="_/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="_/js/tinymce/jquery.tinymce.min.js"></script> -->
        
        
                
