<?php
$email           = new Employee;
$emp_id          = @Session::getUserID();
$employee_email  = $email->ViewEmployeeEmail($emp_id);
//
//if(isset($_POST['Comments'])){
//
//    
//
//    $EmailTO->setData($_POST)->
//
//}
if(isset($_POST['Comments'])){
    //   die("ohhhhhhh");
    $comment     = $_POST['Comments'];
    $to = 'taha_sayyad@hotmail.com'; 
    mail('taha_sayyad@hotmail.com', 'My Subject', $comment);
    //    $email=  mail($to,null,$comment,null); 
    //    if ($email){
    //        echo 'success';
    //    }
    die("ok");
}
?>
<div class="modal fade stick-up " id="ReportProblem" tabindex="-1" role="dialog" aria-hidden="true" style="width: 40%;margin: 0 auto;">
    <div class="modal-dialog ">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-14"></i></button>
                <h5><span class="semi-bold"><?php print CommonLanguage::getMessage('report_problem');?></span></h5>
            </div>
            <div class="modal-body">
                <br>
                <br>
                <div class="formrow" id="Type">
                    <fieldset>
                        <input type="radio" name="type" value="normal" checked ><?php print CommonLanguage::getMessage('normal');?>
                        <input type="radio" name="type" value="urgent" ><?php print CommonLanguage::getMessage('urgent');?>
                    </fieldset> 
                </div>
                <br>
                <br>
                <input type="hidden" id="Email" value="<?php echo $employee_email[0]['Employee_Email']?>">
                <table>
                    <tr>
                        <td valign="top">
                            <label for="comments"><?php print CommonLanguage::getMessage('comments');?></label>
                        </td>
                        <td valign="top">
                            <textarea class="form-control" id="Comment"  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" >
                            <br>
                            <div style="text-align:left"> <a href="http://trustotech.com/">- Trusto Tech</a></div>
                            <div style="text-align:right"> <button  id="SubmitHelp" class="btn btn-success "><?php print CommonLanguage::getMessage('Save');?></button></div> 
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
    $("#SubmitHelp").on("click",function(){
        var Data={ 
            Email : $("#Email").val(),
            Comments:$("#Comment").val(),
            type : $('input[name=type]:checked').val()                    
        }
        $.ajax({
            url:'Views/HRM/reportproblem.php',
            data:Data,
            method:"POST",
            complete:function(v1,v2){
                if(v2 == 'success'){
                    alert("OK success")
                }
                else{
                    alert("error failed")
                }
            }
        })
    })
</script>
