<?php include("../templates/header.php"); ?>

<div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="panel-title">แสดงรายการเลขวิ่ง</h3>
  </div>
  <div class="panel-body">

  <a href='number-c.php' class='btn btn-success'><span class='glyphicon glyphicon-bitcoin'></span> ซื้อเลข</a><br><br>

  <table class="table table-bordered">
    <thead>
      <tr>
        <th><center>ลำดับ</th>
        <th><center>เลขที่ซื้อ</th>
        <th><center>เลขวิ่งบน</th>
        <th><center>เลขวิ่งล่าง</th>
        <th><center>วันที่ซื้อ</th>
        <th><center>จัดการ</th>
      </tr>
    </thead>
    <tbody>

	<?php

	include("../config/mysql_connect.php");

  $strSQL = "SELECT * FROM setting_default";
  $objQuery = mysqli_query($link,$strSQL);
  $Result = mysqli_fetch_array($objQuery);
  $def_status = $Result['def_status'];

 	$sql = "select * from tb_number where acc_id='$session_id' and num_type='c' and num_clear='No'"; 
 	$Query = mysqli_query($link,$sql);
		
	$count = 0;

  while($Result = mysqli_fetch_array($Query)){
  $num_id = $Result['num_id'];
  $num_buy = $Result['num_buy'];
  $num_one = $Result['num_one'];
  $num_two = $Result['num_two'];
  $num_created = $Result['num_created'];

  $count = $count+1;

  $button_del = "";

  if($def_status == 'Off'){
    $button_del = "<a href='#' class='btn btn-warning btn-xs disabled'><span class='glyphicon glyphicon-exclamation-sign'></span> ระบบปิด</a>";
  }else{
    $button_del = "<a href='delete_num.php?id=$num_id' class='btn btn-danger btn-xs'><span class='glyphicon glyphicon-trash'></span> ลบทิ้ง</a>";
  }

	echo"<tr>
        <td align='center'>$count</td>
        <td align='center'>$num_buy</td>
        <td align='center'>$num_one</td>
        <td align='center'>$num_two</td>
        <td align='center'>$num_created</td>
        <td align='center'>$button_del</td>
      </tr>";

	}

	?>

    </tbody>
  </table>

  </div>
</div>

<?php include("../templates/footer.php"); ?>