<!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, shrink-to-fit=no">

   <!-- Page Title -->
   <title>Web Infra Reports</title>
   <link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">

   <!-- JQuery -->
   <script src="/js/jquery-3.6.1.min.js"></script>
   <!-- Bootstrap -->
   <link rel="stylesheet" href="/css/bootstrap.min.css">
   <link rel="stylesheet" href="/css/bootstrap-icons/bootstrap-icons.css">
   <link rel="stylesheet" href="/css/preloader.css">
   <script src="/js/bootstrap.bundle.min.js"></script>
   <!-- Bootstrap-tables -->
   <link rel="stylesheet" href="/css/bootstrap-table.min.css">
   <script src="/js/bootstrap-table.min.js"></script>
   <script src="/js/bootstrap-table-fr-FR.min.js"></script>
   <script src="/js/tableExport.min.js"></script>
   <script src="/js/bootstrap-table-export.min.js"></script>
   <script src="/js/libs/js-xlsx/xlsx.core.min.js"></script>
   
</head>

<body class="bg-light text-dark">
   <?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?>  <!-- Database connexion -->
   <div class="container-fluid">
      <div class="row flex-nowrap">
         <!-- Left NAVBAR -->
         <div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
         <?php include $_SERVER['DOCUMENT_ROOT']."/navbar.html" ; ?>  <!-- Left Navbar -->
         </div>
         <!-- Display -->
            <div class="col py-3">
            <?php
               $server = $_GET['server'];
               $conn = DB_ENTRY02();
               $rs = $conn->query("SELECT * FROM GlobalCrossover where Server = '$server'");
               
            ?>
            <!-- Page Title -->
            <h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;"><?php echo $server ;?></span></h1>
            <br>
            <!-- Main content -->
            <div class="container" style="zoom: 80%">
               <!-- Get DATAs --> 
               <form action="/crossover/Detail2.php" method="POST" id="form">
               <?php 
                  while ($row = mysqli_fetch_array($rs)) {
                     echo "<div class='row'>";
                        // OS
                        echo "<div class='col-md-5'>"; 
                           if(!isset($row['OS']) || $row['OS'] ==''){$row['OS']='Unknown';}
                           if(preg_match('(XP|2003|Windows NT|2000|2008|7|Unknown)', $row['OS']) == 1) {
                              echo "<h3><span class='badge text-bg-warning font-weight-bold'>OS : ".$row['OS']."</span></h3>";
                           }else{
                              echo "<h3><span class='badge text-bg-success text-white font-weight-bold'>OS : ".$row['OS']."</span></h3>";
                           }
                        echo "</div>";
                        // Type
                        echo "<div class='col-md-2'>";
                           $typ="Unknown";
                           if($row['virtual'] =='Y'){$typ = 'Virtual';}
                           if($row['virtual'] =='N'){$typ = 'Physical';}
                           echo "<h3><span class='badge text-bg-primary font-weight-bold'>Type : $typ</span></h3>";
                        echo "</div>";
                        // Crit
                        echo "<div class='col-md-2'>";
                           if(isset($row['crit'])){
                              echo "<h3><span class='badge text-bg-primary font-weight-bold'>Crit : ".$row['crit']."</span></h3>";
                           }
                        echo "</div>";
                        // Dpt
                        echo "<div class='col-md-3'>";
                           if(isset($row['dpt'])){
                              echo "<h3><span class='badge text-bg-primary font-weight-bold'>".$row['dpt']."</span></h3>";
                           }
                        echo "</div>";
                        
                     echo "</div><hr style='border-top: 3px solid black'>";
                     
                     // Active Directory 
                     echo "<h3><span class='font-weight-bold'>Active Directory</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['AD'])){
                           if($row['AD']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' disabled value='".$row['AD']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='AD' name ='AD' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        if(isset($row['ADlu'])){
                           echo "<div class='col-md-2 text-end text-bottom'><b>Last Logon</b></div>";
                           $date1=date_create($row['ADlu']);
                           $diff=date_diff($date1,date_create(date("Y-m-d")));
                           if($diff->format("%R%a") > 60){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-danger text-white' disabled value='".$row['ADlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='".$row['ADlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }
                        }else{
                           if(!(isset($row['AD']) && $row['AD'] !=="Y")){
                              echo "<div class='col-md-2 text-end text-bottom'><b>Last Logon</b></div>";
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-warning' disabled value='Missing'></div>";
                           }
                        }
                        echo "<div class='col-md-4'></div>";
                     echo "</div><br>";

                     // GLPI 
                     echo "<h3><span class='font-weight-bold'>GLPI</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['GLPI'])){
                           if($row['GLPI']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white font-weight-bold' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary font-weight-bold' disabled value='".$row['GLPI']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='GLPI' name ='GLPI' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        echo "<div class='col-md-9 text-end'></div>";
                     echo "</div><br>";
                     
                     // Fusion Inventory 
                     echo "<h3><span class='font-weight-bold'>Fusion Inventory</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['GLPIlu']) && $row['GLPIlu'] !== ''){
                           echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                        }else{
                           if(isset($row['FI'])){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' value='".$row['FI']."'></div>";
                           }else{
                             echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='FI' name ='FI' placeholder='Missing' maxlength = '20'></div></div>";
                           }
                        }
                        $date1=date_create($row['GLPIlu']);
                        $diff=date_diff($date1,date_create(date("Y-m-d")));
                        if(isset($row['GLPIlu']) && $row['GLPIlu'] !== ''){
                           echo "<div class='col-md-2 text-end text-bottom'><b>Last Inventory</b></div>";
                           if($diff->format("%R%a") > 7){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-danger text-white' disabled value='".$row['GLPIlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='".$row['GLPIlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }
                        }else{
                           if(!(isset($row['FI']) && $row['FI'] !=="Y")){
                              echo "<div class='col-md-2 text-end text-bottom'><b>Last Inventory</b></div>";
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-warning' disabled value='Missing'></div>";
                           }
                        }
                        echo "<div class='col-md-4'></div>";
                     echo "</div><br>";

                     // SCCM
                     echo "<h3><span class='font-weight-bold'>SCCM</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['SCCM'])){
                           if($row['SCCM']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' disabled value='".$row['SCCM']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control'  id='SCCM' name ='SCCM' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        if(isset($row['SCCMlu'])){
                           echo "<div class='col-md-2 text-end text-bottom'><b>Last Heartbeat</b></div>";
                           $date1=date_create($row['SCCMlu']);
                           $diff=date_diff($date1,date_create(date("Y-m-d")));
                           if($diff->format("%R%a") > 7){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-danger text-white' disabled value='".$row['SCCMlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='".$row['SCCMlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }
                        }else{
                           if(!(isset($row['SCCM']) && $row['SCCM'] !=="Y")){
                              echo "<div class='col-md-2 text-end text-bottom'><b>Last Heartbeat</b></div>";
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-warning' disabled value='Missing'></div>";
                           }
                        }
                        echo "<div class='col-md-4'></div>";
                     echo "</div><br>";

                     // Nessus
                     echo "<h3><span class='font-weight-bold'>Nessus</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['EPO'])){
                           if($row['EPO']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' disabled value='".$row['EPO']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='EPO' name ='EPO' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        echo "<div class='col-md-9'></div>";
                     echo "</div><br>";

                     // NBU
                     echo "<h3><span class='font-weight-bold'>NetBackup</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['NBU'])){
                           if($row['NBU']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' disabled value='".$row['NBU']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='NBU' name ='NBU' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        if(isset($row['NBUlu'])){
                           echo "<div class='col-md-2 text-end text-bottom'><b>Last Backup</b></div>";
                           $date1=date_create($row['NBUlu']);
                           $diff=date_diff($date1,date_create(date("Y-m-d")));
                           if($diff->format("%R%a") > 30){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-danger text-white' disabled value='".$row['NBUlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='".$row['NBUlu']." (".abs($diff->format("%R%a"))." days)'></div>";
                           }
                        }else{
                           if(!(isset($row['NBU']) && $row['NBU'] !=="Y")){
                              echo "<div class='col-md-2 text-end text-bottom'><b>Last Backup</b></div>";
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-warning' disabled value='Missing'></div>";
                           }
                        }
                        echo "<div class='col-md-4'></div>";
                     echo "</div><br>";

                     // SCOM
                     echo "<h3><span class='font-weight-bold'>SCOM</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['SCOM'])){
                           if($row['SCOM']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' disabled value='".$row['SCOM']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='SCOM' name ='SCOM' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        echo "<div class='col-md-9'></div>";
                     echo "</div><br>";

                     // Zabbix
                     echo "<h3><span class='font-weight-bold'>Zabbix</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['zabbix'])){
                           if($row['zabbix']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' disabled value='".$row['zabbix']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='zabbix' name ='zabbix' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        echo "<div class='col-md-9'></div>";
                     echo "</div><br>";

                     // SentinelOne
                     echo "<h3><span class='font-weight-bold'>SentinelOne</span></h3>" ;
                     echo "<div class='row'>";
                        if(isset($row['S1'])){
                           if($row['S1']=="Y"){
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-success text-white' disabled value='OK'></div>";
                           }else{
                              echo "<div class='col-md-3'><input type='text' class='form-control bg-secondary text-white' disabled value='".$row['S1']."'></div>";
                           }
                        }else{
                           echo "<div class='col-md-3'><div class='input-group'><span class='input-group-text'><i class='bi bi-pencil-square text-primary'></i></span><input type='text' class='form-control' id='S1' name ='S1' placeholder='Missing' maxlength = '20'></div></div>";
                        }
                        echo "<div class='col-md-9'></div>";
                     echo "</div><br>";


                  }
               ?>
                   <label for="server"></label><input type='text' class='form-control visually-hidden' name="server" id="server" value='<?php echo $_GET['server']; ?>'>
                  <hr>
                  <div style="text-align: center;"><button id="button" type="submit" class="btn btn-primary btn-lg"><i class="bi bi-arrow-clockwise"></i><b> Submit</b></button></div>
               </form>
         
         </div> 
        <!-- End of main content -->
      </div>
    </div>
  </div>
  <script src="/js/switch.js"></script>

</body>

