<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Emp_Prod_Benchmark</title>
    <link rel="shortcut icon" href="images/Files_Download.png" type="image/x-icon"/>
</head>
<style>
    .split.bor{
            margin-left:10%;
            transition: 1s;  
        }
    #nav-toggle:checked ~ .split.bor
    {
        margin-left:18%;
        transition: 1s; 
    }
    
    form{
     font-family:'Times New Roman', Times, serif;
    }
    h4{
      text-align:center;
    }

    b{
        font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
    }
    .container-table{
        height: 500px;
        width: 800px;
        overflow-y: scroll;
        background-color:#ffefea;
        border-radius: 10px;
    }
  th{
      color: #73191e;
  }
  td{
      color:black;
      font-weight:600;
  }
  input.form-control
{
    box-shadow:none;
    /* color: red; */
    border:2px solid #ced4da;
    border-radius:15px 0px 15px 0px; 
    padding:1%;
}
input.form-control:focus
{
    box-shadow:none;
    /* color: red; */
    border:2px solid #ced4da;
    border-radius:15px 0px 15px 0px; 
    padding:1%;
}
</style>
 <body>
    <?php
    include ("Nav.php");
    include "Connection.php"; 
    if(isset($_POST['submit'])){
        $Project               = $_POST['PROJECT'];
        $Category              = $_POST['CATEGORY'];
        $Process               = $_POST['PROCESS'];
        $Benchmark             = $_POST['BENCHMARK'];
      

        // $Query = mysqli_query($con, "INSERT INTO epb_tbl (Project,`Database`,Server_ip,Username,`Password`,created_at) VALUES ('$Project','$Database',' $Server_ip','$username','$password','$curdt')");

        $Query = mysqli_query($con, "INSERT INTO master_process_copy (PROJECT,CATEGORY,PROCESS,BENCHMARK) VALUES ('$Project','$Category','$Process','$Benchmark')");
        
        if($Query){            
        //   echo "<script>alert('Record is successfully inserted!')</script>";
          ?>
          <script>
               
          swal("Record is successfully inserted",
                "....",
                   "success",
                   {
                      dangerMode: true,
                      buttons: false,
                      closeOnClickOutside: true,
                      timer:5000,
                           
                         
                   });
       </script>
        <?php
        }else{
        ?>
 <script>
               swal("Sorry an error occured",
                     "....",
                        "error",
                        {
                           dangerMode: true,
                           buttons: false,
                           closeOnClickOutside: true,
                           timer:5000,
                                 //       })
                                 //       .then(function() {
                                 // window.location = "Nav.php";
                                                      });
            </script>

          <?php
        }
        }

        ?>
 
    <br>
    <br><br><br>
<!-- content -->

<div class="container split bor">                                                                                                   
    <div class="container-fluid p-0 m-0">
       <div class="row">
           <div class="col-md-3" >
                 <form class=""  role="form" method="POST" enctype="multipart/form-data" action="" onsubmit="return valid_details();">
                 
                    <div class="form-control m-1" style="background-color:#ffefea;">
                        <h4 style="color:#73191e">Add New Project</h4>
                        <div class="form-group">
                        <label class="control-label"><b>Add Project:</b></label>
                        <input class="form-control" type="text" name="PROJECT" placeholder="e.g Finbo_Saving" value=""  required autofocus>
                        </div>
                        <div class="form-group">
                        <label class="control-label"><b>Add Category:</b></label>
                        <input class="form-control" type="text"  name="CATEGORY" placeholder="e.g Digital Or Physical " value="" >
                        </div>
                        
                        <div class="form-group">
                        <label class=" control-label"><b>Add Process:</b></label>
                        <input class="form-control" type="text"  name="PROCESS" placeholder="e.g Login" value="" >
                        </div>
                     
                        <div class="form-group">
                        <label class=" control-label"><b>Set Benchmark:</b></label>
                        <input class="form-control" type="text" name="BENCHMARK" placeholder="In second e.g 180" value="" max="10" pattern="{0-9,}"required >
                        </div>
<br>
                    <center>
                    <button class="btn btn-success btn-sm btn-block" type="submit" name="submit" style="border-radius:10px 0px 10px 0px;">Submit</button> 
                    </center>
 </div>
            </form> 
            </div>
        <div class="col-md-8">
        <div class="container-table " >
   <?php
                    // Include config file
                    require_once "Connection.php";
                    
                    // Attempt select query execution
                    $sql = "SELECT * FROM master_process_copy";
                    if($result = mysqli_query($con, $sql)){
                        if(mysqli_num_rows($result) > 0){
                            echo '<table class="table table-bordered table-striped" >';
                                echo "<thead>";
                                    echo "<tr>";
                                        // echo "<th>#</th>";
                                        echo "<th>Project</th>";
                                        echo "<th>Category</th>";
                                        echo "<th>Process</th>";
                                        echo "<th>Benchmark</th>";
                                        echo "<th>Action</th>";
                                    echo "</tr>";
                                echo "</thead>";
                                echo "<tbody>";
                                while($row = mysqli_fetch_array($result)){
                                    echo "<tr>";
                                        // echo "<td>" . $row['ID'] . "</td>";
                                        echo "<td>" . $row['PROJECT'] . "</td>";
                                        echo "<td>" . $row['CATEGORY'] . "</td>";
                                        echo "<td>" . $row['PROCESS'] . "</td>";
                                        echo "<td>" . $row['BENCHMARK'] . "</td>";
                                        echo "<td>";
                                        echo '<a href="read.php?ID='. $row['ID'] .'" class="mr-3" title="View Record" data-toggle="tooltip"><span class="fa fa-eye"></span></a>';
                                        echo '<a href="update.php?ID='. $row['ID'] .'" class="mr-3" title="Update Record" data-toggle="tooltip"><span class="fa fa-pencil" style="color:green"></span></a>';
                                        echo '<a href="delete.php?ID='. $row['ID'] .'" title="Delete Record" data-toggle="tooltip"><span class="fa fa-trash " style="color:red"></span></a>';
                                        echo "</td>";
                                    echo "</tr>";
                                }
                                echo "</tbody>";                            
                            echo "</table>";
                            // Free result set
                            mysqli_free_result($result);
                        } else{
                            echo '<div class="alert alert-danger"><em>No records were found.</em></div>';
                        }
                    } else{
                        echo "Oops! Something went wrong. Please try again later.";
                    }
 
                    // Close connection
                    mysqli_close($con);
                    ?>
                    </div>
                </div>
        </div>
        </div>
    </div>
  
    
   