<?php
// header('Content-type: application/json');
include '../config/database.php';
function _command($gid,$product,$version){
	$conn = _connectDB();
	$sql = "SELECT * FROM line WHERE line_gid='".$gid."' AND line_product = '".$product."' AND line_version = '".$version."' ";
	$result = $conn->query($sql);
	$res = [];
	if ($result->num_rows > 0) {
	    while($row = $result->fetch_assoc()) {
			array_push($res,$row);
	    }
	}
	return $res;
}


$data = [];
if(isset($_GET['gid']) AND isset($_GET['product']) AND isset($_GET['version']))	{
	foreach(_command($_GET['gid'],$_GET['product'],$_GET['version']) as $key => $val){
		array_push($data,$val);
	}


$res = base64_decode($data[0]['line_person']);
$res = json_decode($res);

?>

<!DOCTYPE html>
<html>
<head>
	<title>MEMBERS | MONITOR</title>
	<link rel="stylesheet" type="text/css" href="assets/Semantic-UI-CSS/semantic.min.css">
	<script src="https://code.jquery.com/jquery-3.1.1.min.js"  integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="  crossorigin="anonymous"></script>
	<script src="assets/Semantic-UI-CSS/semantic.min.js"></script>
</head>
<body>
	<br><br>
	<div class="ui container">



		<div class="ui three column grid">

			<style>
				.ui.table td {
				    padding: 0em 0em !important;	
				    text-align: inherit;
				}
				.ui.grid>* {
				    padding-left: 0rem;
				    padding-right: 0rem;
				}
			</style>

	
<a href="http://150.95.89.148/api/py/monitor/index2.php">home</a> / 
<a href="http://150.95.89.148/api/py/monitor/groups.php?product=<?php echo $_GET['product']; ?>&version=<?php echo $_GET['version']; ?>"> กลับ </a>
<table class="ui celled table">
  <thead>
    <tr>
      <th colspan="4"><center>กลุ่ม [ <?php echo base64_decode($data[0]['line_name']);?> ] </center></th>
    </tr> 
    <tr>
      <th></th>
      <th><center>UID</center></th>
      <th><center>ชื่อสมาชิก</center></th>
      <th><center>รายละเอียด</center></th>
    </tr>
  </thead>
  <tbody>
<?php $i=0;?>
<?php foreach ($res as $key => $val){ ?>
    <tr>
      <td><img style="width: 30px;" src="http://dl.profile.line-cdn.net/<?php echo $val->picture;?>.jpg"> </td>
      <td style="font-size: 10px;"><?php echo $val->mid;?></td>
      <td><?php echo $val->name;?></td>
      <td><?php echo  mb_substr($val->status, 0, 30, 'UTF-8');?></td>
    </tr>
    <?php $i++;?>
<?php } ?>
	<tr>
      <td colspan="4"> <br><center>จำนวน [<?php echo $i;?>] คน</center><br> </td>
  	</tr>

  </tbody>
</table>




		</div>









	</div>


</body>
</html>

<?php } ?>