<?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_Benchmark</title>
    <link rel="shortcut icon" href="images/Files_Download.png" type="image/x-icon"/>
</head>
<style>
    .split.bor{
            margin-left:5%;
            transition: 1s; 
        }
    #nav-toggle:checked ~ .split.bor
    {
        margin-left:20%;
        transition: 1s;  
    }
  
    th,td 
    {
         text-align:center;
    }
    h5
    {
        text-align: center;
    }
 
</style>
<body>
    <?php
        include "Nav.php";  
        include "Connection.php"; 
        date_default_timezone_set('Asia/Kolkata');
        $date =  date('Y-m-d h:i:s');
    ?>

    <br><br><br>
<div class="container split bor">
            <h5>Overall TAT Report</h5>
                <div class="container">
                    <div class="row">
                        <div class="col-md-12"><br>
                            <form  action="" method = "POST" enctype="multipart/form-data">
                                    <div class="form-control" style="background-color:#ffefea">
                                        <label for="Project" class=""><b>Select Project:</b></label>
                                        <select id="Project" name="Project" class="" placeholder="Select-Project" value="">
                                        <option value=""></option>
                                        <?php
                                        $_SESSION['pro'] = $proj;
                                        $q = mysqli_query($con,"SELECT * FROM epb_tbl WHERE PROJECT in ('PL','OPL','CC');");
                                        while($q_row= mysqli_fetch_array($q)) {
                                        ?>
                                        <option>
                                        <?php echo $project = $q_row['PROJECT'];?></option>
                                        <?php
                                        
                                        }
                                        ?>
                                        </select>
                                        <button class="btn btn-success btn-sm" type="submit" name="search" value="Search" style="border-radius:15px;">Search</button>
                                    </div>
                            </form>
                        </div>
                    </div>  
                </div>
     
                <?php
                    include "Connection.php"; 
                    $proj = $_SESSION['proj']; 
                    if(isset($_POST['search'])){ 
                    //  echo $From_date;
                    $Bacth_No            = $_POST['BATCH'];
                    $From_date           = $_POST['dateFrom'];
                    $To_date             = $_POST['dateTo'];
                    $Project             = $_POST['Project'];
                    $up                  = "select * from epb_tbl where Project='$Project'" ;
                    $Query               = mysqli_query($con, $up);
                if(!$Query){
                echo("Failed");
                }else{
                    while($r = mysqli_fetch_array($Query)){ 
                        $D_B = $r['Database'];
                        $S_I = $r['Server_ip'];
                        $U_N = $r['Username'];
                        $P_W = $r['Password'];              
                    } 
                }
            }
            ?> 
            <br>
            <br>
            <div class="container">
                <table class="table table-bordered table-sm">
                    <thead >
                        <tr>
                            <th style=" text-align:center">STATUS</th>  
                            <th style=" text-align:center">COUNT</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                            $server   = $S_I;
                            $user     = $U_N;
                            $password = $P_W;
                            $db       = $D_B ;
                            $connect  = mysqli_connect($server,$user,$password,$db);
                            if($connect->connect_error){
                            die("Connection Failed");
                            }
                            else{
                            }
                        ?>
                        <?php               
                            $up    = "SELECT * from vw_tat_report";
                            $Query = mysqli_query($connect, $up);
                            while ($r = mysqli_fetch_array($Query))
                                {
                        ?>
                            <tr>
                                <th  style=" text-align:center"> <?php echo $r['FinalStatus'] ;?> </th> 
                                <th  style=" text-align:center"> <?php echo $r['Count'] ;?>       </th> 
                            </tr>
                        <?php
                                }
                        ?>
                    </tbody>
                </table> 
            </div>
</div>
</body>
</html>
