<?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.');
}
// check nhận vật
            // connect sv
            /* ------------------------------------------- CONNECT CHAR SV ------------------------------- */
            $get_Server = mysqli_query($conn, "Select * From config_server WHERE ServerID = '" . $_POST['sv'] . "'");
            if (!mysqli_num_rows($get_Server)) {
                $data['Text'] = 'Lấy thông tin Máy chủ thất bại.';
                echo json_encode($data);
                exit();
            }
            $get_Server = mysqli_fetch_array($get_Server, MYSQLI_ASSOC);
   $conn_char  = @mysqli_connect($get_Server['IPdata'], $get_Server['Userdata'], $get_Server['PassData'], $get_Server['Databases']);
            if ($conn_char->mysqli_connect_errno) {
                $data['Text'] = "Connection failed: " . $conn_char->mysqli_connect_errno;
                echo json_encode($data);
                exit();
            }
            mysqli_query($conn_char, "SET NAMES 'utf8'"); 			
            /* ------------------------------------------- CONNECT CHAR SV ------------------------------- */
            $load = mysqli_query($conn_char, "Select * From kin_data");
            if(mysqli_num_rows($load)){
$return['text'] = '<div class="table-responsive">
<br>
<table class="table table-bordered table-white" style="">
<thead class="thead-white">
        <tr class="bg-black">
  <th scope="col" style=" font-size: 13px; ">ID Bang Hội</th>
  <th scope="col" style=" font-size: 13px; "><center>Tên Bang Hội</center></th>
            </tr>
    </thead>
    <tbody>';
while($row = mysqli_fetch_assoc($load)){
  $return['text'] .= '<tr>
  <td><center><label class="label label-info">'.$row['KinID'].'</label></center></td>
  <td><center><label class="label label-danger">'.$row['KinName'].'</label></center></td>
  
  </tr>';
}
$return['text'] .= '</tbody>
</table>
</div>';
$return['type'] = 0;
            } else {
                $return['type'] = 1;
                $return['text'] = "Chưa có bang hội nào cả";
            }
            echo json_encode($return);