<!-- <?php
 session_start();
 error_reporting(E_ERROR | E_PARSE);
 error_reporting(0);
//  mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
?> -->

<!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>
    <link rel="shortcut icon" href="images/Files_Download.png" type="image/x-icon"/>
</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%; */
        
    }
        /* table{
    position:absolute; */
    
 

</style>
<body>
<?php
    include "Nav.php";
    include "config.php"; 
    ?>

<?php 
    date_default_timezone_set('Asia/Kolkata');
    $date =  date('Y-m-d h:i:s');
?>
<br><br><br>
<div class="container split bor">
    <div class="container">
        <div class="row">
            <div class="col-md-12"><br>
                <form  action="" method = "POST" enctype="multipart/form-data">
                    <?php  
                        //$proj = $_SESSION['pro']; 
                    ?>
                        <div class="form-control">

                            <label for="PROJECT" class=""><b>Select Project :</b></label>
                            <select id="Project" name="PROJECT" class="" placeholder="Select-Project" value="<?php ?>">
                            <option value="" ></option>
                            <?php
                             $proj = $_SESSION['PROJECT']  ;
                            $q = mysqli_query($con,"SELECT distinct PROJECT FROM master_process");
                            while($q_row= mysqli_fetch_array($q)) {
                            ?>
                            <option>
                            <?php echo $project = $q_row['PROJECT'];?></option>
                            <?php 
                            }
                            ?>
                            </select>
                            

                            <label for="Category" class=""><b>Select Category :</b></label>
                            <select id="CATEGORY" name="CATEGORY" class="" placeholder="Select-Project" value="<?php ?>">
                            <option value="" ></option>
                            <?php
                            $Ctgry = $_SESSION['CATEGORY'];
                            $q = mysqli_query($con,"SELECT distinct CATEGORY FROM master_process where PROJECT ='$proj'");
                            while($q_row= mysqli_fetch_array($q)) {
                            ?>
                            <option>
                            <?php echo $project = $q_row['CATEGORY'];?></option>
                            <?php
                            }
                            ?>
                            </select>


                             <label for="Stage" class=""><b>Select Stage :</b></label>
                            <select id="STAGE" name="STAGE" class="" placeholder="Select-Project" value="<?php ?>">
                            <option value="" ></option>
                            <?php
                            $stg = $_SESSION['STAGE'];
                            $q = mysqli_query($con,"SELECT distinct STAGE FROM master_process");
                            while($q_row= mysqli_fetch_array($q)) {
                            ?>
                            <option>
                            <?php echo $project = $q_row['STAGE'];?></option>
                            <?php
                            
                            }
                            ?>
                           </select>

                           <label for="Process" class=""><b>Select Process:</b></label>
                            <select id="PROCESS" name="PROCESS" class="" placeholder="Select-Project" value="<?php ?>">
                            <option value="" ></option>
                            <?php
                            $prc=$_SESSION['PROCESS'];
                            $q = mysqli_query($con,"SELECT distinct PROCESS FROM master_process");
                            while($q_row= mysqli_fetch_array($q)) {
                            ?>
                            <option>
                            <?php echo $project = $q_row['PROCESS'];?></option>
                            <?php
                            }
                            ?>
                           </select>

                           <label for="subprocess" class=""><b>Select Subprocess:</b></label>
                            <select id="SUBPROCESS" name="SUBPROCESS" class="" placeholder="Select-Project" value="<?php ?>">
                            <option value="" ></option>
                            <?php
                           $sprc=$_SESSION['SUBPROCESS'];
                            $q = mysqli_query($con,"SELECT distinct SUBPROCESS FROM master_process");
                            while($q_row= mysqli_fetch_array($q)) {
                            ?>
                            <option>
                            <?php echo $project = $q_row['SUBPROCESS'];?></option>
                            <?php
                            
                            }
                            ?>
                           </select>

                           <button class="btn btn-success btn-sm" type="submit" name="search" value="Search" style="border-radius:15px;">Search</button>
                     </div>
                   <?php echo $proj;
                  ?>
                   
                </form>

                 
                <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("CATEGORY").value="<?php echo $_SESSION['CATEGORY'] = $_GET['CATEGORY'];?>";
                     window.location("home.php?CATEGORY=<?php echo $_SESSION['CATEGORY'];?>");
                     }
                     </script> 
               <select class="form-control " name="CATEGORY" id="CATEGORY" class="form-control" onchange="return submitformcdno();">
             
                  <option  value=""><?php  //echo $_SESSION['CDNO'];?></option>
                  <?php 
                   echo $cdno = "SELECT DISTINCT CATEGORY FROM `master_process` where PROJECT = 'opl'";
                     $cdnoquery = mysqli_query($con , $cdno);
                     while($cd = mysqli_fetch_array($cdnoquery))
                     {
                        ?>
                           <option  value="<?php echo $_SESSION['category'] = $cd['CATEGORY'];?>"><?php echo $_SESSION['category'] = $cd['CATEGORY'];?></option>
                           
                        <?php
                     }
                  ?>
               </select>
            <?php $CAT=$_SESSION['CATEGORY'];
            echo $CAT;?>
                <label for="select"> Select SubActivity:</label>
                
                <select class="form-control " name="STAGE" id="STAGE" class="form-control" onchange="return submitformstg();">
               <!-- <option  value=""></option> -->
                  <option  value=""><?php  //echo $_SESSION['CDNO'];?></option>
                  <?php 
                  echo  $Stage = "SELECT DISTINCT STAGE FROM `master_process` where CATEGORY = '$CAT'";
                     $stgq = mysqli_query($con , $Stage);
                     while($stg = mysqli_fetch_array($stgq))
                     {
                        ?>
                           <option  value="<?php $CAT; echo $_SESSION['STAGE'] = $stg['STAGE'];?>"><?php echo $_SESSION['STAGE'] = $stg['STAGE'];?></option>
                           
                        <?php
                     }
                  ?>
               </select>
               <script type="text/javascript">
                     function submitformstg()
                     {
                        
                     document.getcd.submit();
                     
                     var getbn = document.getElementsByName("STAGE").value="<?php $cats = $CAT ;echo $_SESSION['STAGE'] = $_GET['STAGE'];?>";
                     window.location("home.php?CATEGORY=<?php echo $cats;?>&STAGE=<?php echo $_SESSION['STAGE'];?>");
                    // const url = new URL(window.location);
                    //     url.searchParams.set('', 'bar');
                    //     var push = window.history.pushState({}, '', url);
                    //     console.log(push);
                     }
                     </script>
               </form>

              <?php
             if(isset($_POST['search'])){
                  $project    = $_POST['PROJECT'];
                $_SESSION['PROJECT']=$project;
                // echo $_SESSION['PROJECT'];
                $Category   = $_POST['CATEGORY'];
                $_SESSION['CATEGORY']=$Category;
                // echo  $_SESSION['CATEGORY'];
                $Stage      = $_POST['STAGE'];
                $_SESSION['STAGE']=$Stage;
                // echo  $_SESSION['STAGE'];
                $Process    = $_POST['PROCESS'];
                $_SESSION['PROCESS']=$Process;
                // echo  $_SESSION['PROCESS'];
                $Subprocess = $_POST['SUBPROCESS'];
                $_SESSION['SUBPROCESS']=$Subprocess;
                // echo  $_SESSION['SUBPROCESS'];
                $in = "SELECT * from master_process";
                $Query = mysqli_query($con,$in) or die(mysqli_error($con));

            if(!$Query){
        
        echo("Failed");
  
    }else{

        while($r = mysqli_fetch_array($Query)){ 
        // echo("Success");       
        } 
    }
  }
              ?>  






</div>
</div>
</div>
</div>
</body>
</html>
