<?php
session_start();
include_once('../../config/#Config.php');
if(!$_SESSION['UserName']){
die('<script>window.location.href=\''.$config['site']['url'].'index.php\';</script>');
}
$get_AD = mysqli_query($conn, "Select * From config_admin WHERE Account = '".$_SESSION['UserName']."'");
if(!mysqli_num_rows($get_AD)){
	die('Không đủ quyền.');
}
					  $get_AA = mysqli_query($conn, "Select * From config_setting WHERE ID = 1");
					  if(mysqli_num_rows($get_AA)){
						  $row = mysqli_fetch_array($get_AA, MYSQLI_ASSOC);
					  }
?>
<?php include 'menu.php'; ?>
  <div class="modal fade" id="sua_maychu">
    <div class="modal-dialog">
      <div class="modal-content">	
      </div>
    </div>
  </div>	
<div class="row">
                <div class="card-body">
                  <h4 class="card-title">Quản Lý Máy Chủ</h4>
				  <button type="button" class="btn btn-outline-primary" style="float:right" onClick="$('#addADMIN').modal();">Thêm Máy Chủ</button>
				  <br/><br/>
                  <div class="table-responsive">
                    <table class="table table-dark">
                      <thead>
                        <tr>
                          <th>
                            #
                          </th>
                          <th>
                            Server ID
                          </th>
                          <th>
                            Tên Máy Chủ
                          </th>
                          <th>
                            Tên Data
                          </th>
						  <th>
                            IP Máy Chủ
                          </th>
						  <th>
                           Port Gojxhttp
                          </th>
                        </tr>
                      </thead>
                      <tbody>
					  <?php
					  $gpp_CON = mysqli_query($conn, "Select * From config_server");
					  
					  if(mysqli_num_rows($gpp_CON)){
						  $i=0;
						  while($row = mysqli_fetch_array($gpp_CON, MYSQLI_ASSOC)){
							  $i++;
							  echo '<tr>
                          <td>
                            '.$i.'
                          </td>
                          <td>
                           '.$row['ServerID'].'
                          </td>
                          <td>
                           '.$row['ServerName'].'
                          </td>
                          <td>
                          '.$row['Databases'].'
                          </td>
                          <td>
                          '.$row['IpJson'].'
                          </td>
						  <td>
                          '.$row['PortJson'].'
                          </td>		
                          <td>
						  <a href="javascript:loadinfomaychu(\''.$row['ID'].'\');"><label class="badge badge-success">Sửa</label></a>
                          <a href="javascript:del_maychu(\''.$row['ID'].'\');"><label class="badge badge-danger">Xóa</label></a>
                          </td>						  
                        </tr>';
						  }
					  }
					  ?>


                      </tbody>
                    </table>
                </div>
              </div>
  <div class="modal fade" id="addADMIN">
    <div class="modal-dialog">
      <div class="modal-content">
<div class="modal-body">
			<label>Server ID</label>
            <div class="form-group pass_show"> 
                <input type="text" id="add_mc_a" class="form-control"> 
            </div> 
        </div>
		<div class="modal-body">
			<label>Tên Máy Chủ</label>
            <div class="form-group pass_show"> 
                <input type="text"  id="add_mc_b" class="form-control"> 
            </div> 
        </div>
		<div class="modal-body">
			<label>Tên Data</label>
            <div class="form-group pass_show"> 
                <input type="text"  id="add_mc_c" class="form-control"> 
            </div> 
        </div>
		<div class="modal-body">
			<label>IP Máy Chủ</label>
            <div class="form-group pass_show"> 
                <input type="text" id="add_mc_d" class="form-control"> 
            </div> 
        </div>
		<div class="modal-body">
			<label>Port Gojxhttp</label>
            <div class="form-group pass_show"> 
                <input type="text" id="add_mc_e" class="form-control"> 
            </div> 
        </div>	
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" onClick="add_maychu();">Thêm Ngay</button>
        </div>			
      </div>
    </div>
  </div>			  
  		   