
<?php 
session_start();
include "config.php";
include "Nav.php";
?>
<?php ?>
<!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</title>
   
</head>
<style>
   input.fileup
   {
      width:75%;
      /* text-transform:unset; */
   }
   .body
   {
      background-image:url("img/124.jpg");
      background-size:cover;
      background-repeat: no-repeat;
      height:100vh;
      /* width:100%; */
      filter: blur(2px);
      }
   #infoi {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}
#infoi {
  z-index: 1;
}
.split.bor{
            margin-left:5%;
            transition: 1s; 
             
        }
    #nav-toggle:checked ~ .split.bor
    {
        margin-left:20%;
        transition: 1s;
        /* margin-right:15%; */
        
    }
  
        th,td {
  text-align:center;
    }
   /* #loader {
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity:100%;
  background-color: #fff;
  z-index: 99;
  background: url('img/Ellipsis-2s-237px.gif') 50% 50% no-repeat rgb(249,249,249);
} */

/* #loading-image {
  z-index: 100;
} */
</style>
<!-- <script type="text/javascript" src="jquery.js"></script> -->


<?php 
   include "link.php"; 
   error_reporting(E_ERROR | E_PARSE);
   ini_set('max_execution_time','600');
?>
<body>

  <br><br><br>
  <div class="container split bor">
<!-- <script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(window).load(function() {
	$(".loader").fadeOut("slow");
})
</script> -->  

<!-- <div class="loader"> </div> -->
<!-- <div class="body"></div>   
   <div id="infoi"> -->
   
   
    
    <div class="row">
        <div class="col-md-4">
               <form action="" method = "POST" enctype="multipart/form-data">
                   <div class="form-group">
                   <label for="Project" class="col--4 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>
                            <?php
                        if(isset($_POST['Project']))
                        $_SESSION['Project'] = $_POST['Project'];
                        $Pro = $_SESSION['Project'];
                        echo $Pro;
                    ?>
                </form>

                <?php
            if(isset($_POST['connect']))
                $id = $_POST['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",
                        "info",
                        {
                           dangerMode: true,
                           buttons: false,
                           closeOnClickOutside: true,
                           timer:5000,
                                 //       })
                                 //       .then(function() {
                                 // window.location = "Nav.php";
                              
                        });
            </script>   -->
             <?php
             } 
                           
            ?>   
         <!-- </div> -->
         <!-- upload excel  -->

         
         </div>
         <div class="col-md-3">
         <div class="container" style="font-weight:500">
         <form class="" action="" method="GET" enctype="multipart/form-data" name="getcd" >
                  <label for="select"> Select Activity:</label>
                   <script type="text/javascript">
                     function submitformcdno()
                     {
                     document.getcd.submit();
                     var getbn = document.getElementsByName("PROJECT").value="<?php echo $_SESSION['PROJECT'] = $_GET['PROJECT'];?>";
                     console.log(getbn);
                     }
                     </script> 
               <select class="form-control " name="PROJECT" id="PROJECT" class="form-control" onchange="return submitformcdno();">
               <!-- <option  value=""></option> -->
                  <option  value=""><?php  //echo $_SESSION['CDNO'];?></option>
                  <?php 
                   $cdno = "SELECT DISTINCT PROJECT FROM `master_process` where PROJECT = '$Pro'";
                     $cdnoquery = mysqli_query($con , $cdno);
                     while($cd = mysqli_fetch_array($cdnoquery))
                     {
                        ?>
                           <option  value="<?php echo $_SESSION['act'] = $cd['PROJECT'];?>"><?php echo $_SESSION['act'] = $cd['PROJECT'];?></option>
                           
                        <?php
                     }
                  ?>
               </select>
              <?php
              $_SESSION['ACT'];
              $ACT=$_SESSION['ACT'];
            //   echo $ACT;
              ?>
                <label for="select"> Select SubActivity:</label>
                <script type="text/javascript">
                     function submitformcdno()
                     {
                     document.getcd.submit();
                     var getbn = document.getElementsByName("SACT").value="<?php echo $_SESSION['SACT'] = $_GET['ACT'];?>";
                     console.log(getbn);
                     }
                     </script>
                <select class="form-control " name="SACT" id="SACT" class="form-control" onchange="return submitformcdno();">
               <!-- <option  value=""></option> -->
                  <option  value=""><?php  //echo $_SESSION['CDNO'];?></option>
                  <?php 
                   $cdno = "SELECT DISTINCT SubActivity FROM `entry_tbl` where Activity = '$ACT'";
                     $cdnoquery = mysqli_query($con , $cdno);
                     while($cd = mysqli_fetch_array($cdnoquery))
                     {
                        ?>
                           <option  value="<?php echo $_SESSION['sact'] = $cd['SubActivity'];?>"><?php echo $_SESSION['sact'] = $cd['SubActivity'];?></option>
                           
                        <?php
                     }
                  ?>
               </select>
               </form>
            </div>
         </div>
         <!-- text monturm upload  -->
        
       
      <!-- Process Button -->  
      
        
      
      </div>
   </div>
   </div>
</body>
</html>


