
<?php
    session_start();
    include("include/Functions.php");   
    $db = new Functions();  
    if(empty($_SESSION['userid']))
        header('Location: index.php');

        if(!empty($_POST["companyfk"]) && !empty($_POST["stationname"]) && !empty($_POST["location"])){
        
            $companyfk = $_POST["companyfk"];
            $stationname =  $_POST["stationname"];  
            $location = $_POST["location"];
            
            $db->addStation($companyfk,$stationname, $location);
            $companyfk = ""; 
            $stationname = "";  
            $location = ""; 
        }   





?>
<!DOCTYPE html>
<html lang="en">

<body class="fix-header fix-sidebar">
    <!-- Preloader - style you can find in spinners.css -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
			<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- Main wrapper  -->
    <div id="main-wrapper">
        <?php
        include("include/head.html");   
        ?>
        <!-- End Left Sidebar  -->
        <!-- Page wrapper  -->
        <div class="page-wrapper">
            <!-- Bread crumb -->
            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-primary">Dashboard</h3> </div>
                <div class="col-md-7 align-self-center">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                        <li class="breadcrumb-item active">Dashboard</li>
                    </ol>
                </div>
            </div>
            <!-- End Bread crumb -->
            <!-- Container fluid  -->
            <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row justify-content-center">
                    <div class="col-lg-6">
                        <div class="card">
                            <div class="card-body">
                                <div class="form-validation">
                                    <form class="form-valide" action="" method="post">
                                    <input type="hidden" value="<?php echo  $_SESSION['companyfk'];?>" class="form-control" id="companyfk" name="companyfk">   
                                    <div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-stationname">Station Name <span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                <input type="text" class="form-control" id="val-stationname" name="stationname" placeholder="Enter Station Name" required>
                                            </div>
                                        </div>

                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-location">Location <span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                <input type="text" class="form-control" id="val-location" name="location" placeholder="Enter location" required>
                                            </div>
                                        </div>
                
                                        <div class="form-group row">
                                            <div class="col-lg-8 ml-auto">
                                                <button type="submit" onclick="proccesForm()" class="btn btn-primary">Submit</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <!-- End PAge Content -->
            </div>
            <!-- End Container fluid  -->
            <!-- footer -->
            <footer class="footer"> © 2020 All rights reserved. Template designed by <a href="https://softcom">Meit Systems</a></footer>
            <!-- End footer -->
        </div>
        <!-- End Page wrapper  -->
    </div>
    <!-- End Wrapper -->

    <script>

function proccesForm(){
 var companyfk =document.getElementById("companyfk").value;
 var stationname =document.getElementById("val-stationname").value;
 var location =document.getElementById("val-location").value;
 //alert(companyfk+"|"+stationname+"|"+location);
    $.ajax({
        type: "GET",
        url: "addstations.php",
        data: {companyfk:companyfk,stationname:stationname,location:location},
        complete: function(data){
           // alert("gone");
        }
});

   }
    </script>


    <!-- All Jquery -->
    <script src="js/lib/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="js/lib/bootstrap/js/popper.min.js"></script>
    <script src="js/lib/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="js/jquery.slimscroll.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="js/lib/sticky-kit-master/dist/sticky-kit.min.js"></script>


    <!-- Form validation -->
    <script src="js/lib/form-validation/jquery.validate.min.js"></script>
    <script src="js/lib/form-validation/jquery.validate-init.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.min.js"></script>

</body>

</html>