<!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>
   <?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
               //var_dump($_POST);
               $server = $_POST['server'];
               // Update Databases
               $conn = DB_ENTRY02();
               if(isset($_POST['AD']) && $_POST['AD'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,AD) VALUES ('$server','".substr($_POST['AD'], 0, 20)."') ON DUPLICATE KEY UPDATE AD ='".substr($_POST['AD'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET AD='".substr($_POST['AD'], 0, 20)."' where server = '$server'");
               }
               if(isset($_POST['GLPI']) && $_POST['GLPI'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,GLPI) VALUES ('$server','".substr($_POST['GLPI'], 0, 20)."') ON DUPLICATE KEY UPDATE GLPI ='".substr($_POST['GLPI'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET GLPI='".substr($_POST['GLPI'], 0, 20)."' where server = '$server'");
               }
               if(isset($_POST['FI']) && $_POST['FI'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,FI) VALUES ('$server','".substr($_POST['FI'], 0, 20)."') ON DUPLICATE KEY UPDATE FI ='".substr($_POST['FI'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET FI='".substr($_POST['FI'], 0, 20)."' where server = '$server'");
               }
               if(isset($_POST['SCCM']) && $_POST['SCCM'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,SCCM) VALUES ('$server','".substr($_POST['SCCM'], 0, 20)."') ON DUPLICATE KEY UPDATE SCCM ='".substr($_POST['SCCM'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET SCCM='".substr($_POST['SCCM'], 0, 20)."' where server = '$server'");
               }
               if(isset($_POST['EPO']) && $_POST['EPO'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,EPO) VALUES ('$server','".substr($_POST['EPO'], 0, 20)."') ON DUPLICATE KEY UPDATE EPO ='".substr($_POST['EPO'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET EPO='".substr($_POST['EPO'], 0, 20)."' where server = '$server'");
               }
               if(isset($_POST['NBU']) && $_POST['NBU'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,NBU) VALUES ('$server','".substr($_POST['NBU'], 0, 20)."') ON DUPLICATE KEY UPDATE NBU ='".substr($_POST['NBU'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET NBU='".substr($_POST['NBU'], 0, 20)."' where server = '$server'");
               }  
               if(isset($_POST['SCOM']) && $_POST['SCOM'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,SCOM) VALUES ('$server','".substr($_POST['SCOM'], 0, 20)."') ON DUPLICATE KEY UPDATE SCOM ='".substr($_POST['SCOM'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET SCOM='".substr($_POST['SCOM'], 0, 20)."' where server = '$server'");
               } 
               if(isset($_POST['zabbix']) && $_POST['zabbix'] !==''){
                  $conn->query("INSERT INTO CrossoverExclusions (server,zabbix) VALUES ('$server','".substr($_POST['zabbix'], 0, 20)."') ON DUPLICATE KEY UPDATE zabbix ='".substr($_POST['zabbix'], 0, 20)."'");
                  $conn->query("UPDATE GlobalCrossover SET zabbix='".substr($_POST['zabbix'], 0, 20)."' where server = '$server'");
               }  
               if(isset($_POST['S1']) && $_POST['S1'] !==''){
                $conn->query("INSERT INTO CrossoverExclusions (server,S1) VALUES ('$server','".substr($_POST['S1'], 0, 20)."') ON DUPLICATE KEY UPDATE S1 ='".substr($_POST['S1'], 0, 20)."'");
                $conn->query("UPDATE GlobalCrossover SET S1='".substr($_POST['S1'], 0, 20)."' where server = '$server'");
             }             
            ?>
            <!-- Page Title -->
            <h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;"><?php echo $server ;?></span></h1>
            <br>
            <div class="alert alert-success" role="alert"><h2 class="text-center">Exception(s) enregistrée(s) !</h2></div>
            <!-- <meta http-equiv="refresh" content="3;url=/crossover/Detail.php?server=<?php //echo $server ; ?>" /> -->
            <!-- Main content -->
         </div> 
        <!-- End of main content -->
      </div>
    </div>
</body>

