<?php session_start();

error_reporting(E_ERROR | E_PARSE);
?>
<!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"/>
    <!-- <link rel="stylesheet" href="style.css">  -->
</head>
<style>
    .split.bor{
            margin-left:5%;
            transition: 1s; 
             /* margin-right:;  */
            /* margin-top:-15px; */ 
        }
    #nav-toggle:checked ~ .split.bor
    {
        margin-left:20%;
        transition: 1s;
        /* margin-right:15%;*/ 
    }
    
        th, td {
  text-align: center;
 
}
#form1 {
overflow:hidden;
display:block; 
padding: 5px 5px;
 /* border-radius: 3px; */
 /* font-size: 8.5pt;  */
 width:500px ;
  /* background-color: #E7FCCA;  */
  font-weight: bold; 
}      
</style>


<body>
    <?php
    include "Nav.php";
    include "Connection.php"; 
    ?>
    
    <br>
    <br><br><br>
<!-- search -->
<div class="container split bor">
    <div class="row">
        <div class="col-md-6">
            <form action="" method = "GET" enctype="multipart/form-data" >
               <div class="form-group">
               <label for="Project" class="col-sm-6 control-label"><b>Select Process:</b></label>
            
                <select id="Project" name="Project" class="form-control" placeholder="Select-Process" value="" >
                <option value="" ></option>
                <?php
                $q = mysqli_query($con,"SELECT distinct Project FROM epb_tbl") or die(mysqli_error($con));
                while($q_row= mysqli_fetch_array($q)) {
                ?>
                <option>
                <?php echo $project = $q_row['Project'];?></option>
                <?php
                }
                ?>
                </select>
                </div> <button class="btn btn-warning btn-sm" type="submit" name="connect" id="formButton"   style="border-radius:15px;">Connect</button>
                </form>
               
                <?php
        
                    if(isset($_GET['connect']))
                        {
                            $id = $_GET['Project']; 
                            $_SESSION['proj'] = $id;
                            echo "<br>";
                            $query = mysqli_query($con, "SELECT * FROM epb_tbl WHERE Project = '$id'");
                            $fetch = mysqli_fetch_array($query);
                            $db = $_SESSION['db'] = $fetch['Database'];
                            $serv = $fetch['Server_ip'];
                            $UN = $fetch['Username'];
                            $Pass = $fetch['Password'];
                            $conn = mysqli_connect($serv,$UN,$Pass,$db);

                        if(!$conn)
                        {
                            //   echo "<script>alert('Sorry an error occured!')</script>";
                            ?>
                            <!-- <script>
                        
                        swal("Opps!!Sorry an error occured!",
                                "Failed To Connect Database",
                                    "error",
                                    {
                                    dangerMode: true,
                                    buttons: false,
                                    closeOnClickOutside: true,
                                    timer:5000,
                                            //       })
                                            //       .then(function() {
                                            // window.location = "Nav.php";
                                        
                                    });
                        </script> -->
                            <?php
                            }
                        else
                        {
                            
                            //  echo  "<script>alert('Connected To Database!')</script>";
                            ?>
                            <script>
                        
                        swal("Connected To Database!",
                                "Successfully",
                                    "success",
                                    {
                                    dangerMode: true,
                                    buttons: false,
                                    closeOnClickOutside: true,
                                    timer:5000,
                                            //       })
                                            //       .then(function() {
                                            // window.location = "Nav.php";
                                        
                                    });
                        </script> 
                       
                <div class="form">
                <div class="class">
                            <p>You Are Currently Connected to <?php echo $_SESSION['proj']; ?> process</p>
                        </div>
                <form id="form1" role="form" method="POST" enctype="multipart/form-data" action="action_post.php" onsubmit="return valid_details();">
                <?php  $proj = $_SESSION['proj']; ?>
                    <div class="form-group">
                        <label for="process" class="col-sm-6 control-label"><b>Add Activity Here:</b></label>
                        <div class="col-lg-6">
                        <input  type="text" class="form-control" name="Activity" placeholder="Add Activity">
                   </div></div>

                    <div class="form-group">
                        <label for="process" class="col-sm-6 control-label"><b>Add Sub Activity Here:</b></label>
                        <div class="col-lg-6">
                        <input  type="text" class="form-control" name="SubActivity" placeholder="Add SubActivity">
                    </div></div>
                    <div class="form-group">
                        <label class="col-lg-6 control-label"><b>Time:</b></label>
                        <div class="col-lg-6">
                        <input  type="number" class="form-control" name="Time" placeholder="Expected Time">
                    </div></div>
                <button class="btn btn-success btn-sm" type="submit" name="submit"  style="border-radius:15px;">Submit</button>
                </div>
      </form>
    </div> </div>
                 <?php
            }
             
            } 
                           
        ?>
        
    </div>

 <!-- <table  class="table table-bordered " id=""  width="50%"> -->
        <!-- <table id="example" class="table table-striped table-bordered table-sm" width="50%" cellspacing="0"> -->
 <!-- <thead>
  <tr>
   <th >Process Name</th>
   <th >Activity Name</th>
   <th >Sub  Activity Name</th>
   <th >Time</th> 

  </tr>
  <thead>
 <tbody> -->
  <?php
// $Show = mysqli_query($con, "SELECT * FROM entry_tbl");
// while($r = mysqli_fetch_array($Show)): 
?> 
    <!-- <tr>
     <td ><?php //echo $r['pro']; ?></td>
     <td><?php //echo $r['Activity']; ?></td>
     <td><?php //echo $r['SubActivity']; ?></td>
     <td><?php //echo $r['Time']; ?></td>
    </tr> -->
    <?php //endwhile; ?>

 <!-- </tbody>
 </table>  -->
 </div>
        <div class="col-md-4">
        <!-- <div class="container" style="padding: left 60px;"> -->
        </div>
        <div class="col-md-4"></div>

</body>
</html>