<?php
/**
 * Created by PhpStorm.
 * User: jedi
 * Date: 12/27/18
 * Time: 4:46 AM
 */
?>
    <div class="container-fluid">

        <!-- Breadcrumbs-->
        <ol class="breadcrumb">
            <li class="breadcrumb-item">
                <a href="#">Dashboard</a>
            </li>
            <li class="breadcrumb-item active">Feature Request</li>
        </ol>

        <div id="alertmessage" class="collapse alert alert-danger" role="alert">
            This is a danger alert—check it out!
        </div>


        <div id="successmessage" class="collapse alert alert-success" role="alert">
            A simple success alert—check it out!
        </div>

        <!-- Area Chart Example-->
        <div class="card mb-3">
            <div class="card-header">
                <i class="fas fa-plus"></i>
                Add Feature Request
            </div>
            <div class="card-body">
                <form id="request_form" method="POST" action="/action.php?action=lost">
                    <div class="form-group">
                        <label for="title_field">Title</label>
                        <input type="text" class="form-control" placeholder="title" name="title" id="title_field">
                    </div>
                    <div class="form-group">
                        <label for="desc_field">Description</label>
                        <textarea class="form-control" id="desc_field" name="desc" rows="5"></textarea>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="form-control btn btn-primary" placeholder="description" onclick="testajax(); return false;">Submit</button>
                    </div>
                </form>
            </div>
            <!--div class="card-footer small text-muted">Updated yesterday at 11:59 PM</div-->
        </div>

    </div>
    <!-- /.container-fluid -->

<script>

    function testajax(){
        $.post( "/ajax.php?action=add_featurerequest", $( "#request_form" ).serialize() ).done(function( data ) {;
            reply = JSON.parse(data);
            if(reply.status == "ok"){
                $( "#request_form" ).trigger("reset");
                $("#alertmessage").collapse('hide');
                $("#successmessage").html(reply.message).collapse('show');
            }else{
                $("#successmessage").collapse('hide');
                $("#alertmessage").html(reply.message).collapse('show');
            }
        }).fail(function() {
            $("#successmessage").collapse('hide');
            $("#alertmessage").html("error").collapse('show');
        });

    }

</script>


<!-- Bootstrap core JavaScript-->
<script src="/vendor/jquery/jquery.min.js"></script>
<script src="/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Core plugin JavaScript-->
<script src="/vendor/jquery-easing/jquery.easing.min.js"></script>

<!-- Page level plugin JavaScript-->
<script src="/vendor/chart.js/Chart.min.js"></script>

<!-- Custom scripts for all pages-->
<script src="/js/sb-admin.min.js"></script>

<!-- Demo scripts for this page-->
<script src="/js/demo/chart-area-demo.js"></script>
<script src="/js/demo/chart-bar-demo.js"></script>
<script src="/js/demo/chart-pie-demo.js"></script>