<?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.');
}
?>
<?php include 'menu.php'; ?>
<div class="row">
            <div class="col-md-6 d-flex align-items-stretch grid-margin">
              <div class="row flex-grow">
                <div class="col-12">
                  <div class="card">
                    <div class="card-body">
                      <h4 class="card-title">Điều chỉnh tỉ lệ Ăn Chia</h4>
					  <?php
					  $get_AA = mysqli_query($conn, "Select * From Config_Lode");
					  $reg_a = 0;
					  $reg_b = 0;					  
					  if(mysqli_num_rows($get_AA)){
						  $get_AA = mysqli_fetch_array($get_AA,MYSQLI_ASSOC);
						  $reg_a = $get_AA['Lo']; 
						  $reg_b = $get_AA['De'];
					  }
					  
					  ?>
                        <div class="form-group">
                          <label for="exampleInputEmail1"><b>[LÔ]</b> Tỉ Lệ Đặt 1 * </label>
                          <input type="text" class="form-control" id="set_lode_lo" value="<?=$reg_a?>">
                        </div>
                        <div class="form-group">
                          <label for="exampleInputEmail1"><b>[ĐỀ]</b> Tỉ Lệ Đặt 1 * </label>
                          <input type="text" class="form-control" id="set_lode_de" value="<?=$reg_b?>">
                        </div>
                        <button type="submit" class="btn btn-success mr-2" onClick="Save_SettingL();">Lưu</button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-12 grid-margin">
              <div class="card">
                <div class="card-body">
                  <h4 class="card-title">Danh sách đặt cược gần đây nhất</h4>
                    </div>
                 <div class="table-responsive">
                    <table class="table table-dark">
                      <thead>
                        <tr>
                          <th>
                            #
                          </th>
                          <th>
                            Máy Chủ
                          </th>
                          <th>
                            Tài khoản
                          </th>
						  <th>
                            Kiểu Chơi
                          </th>
						  <th>
                            Ghi
                          </th>
						  <th>
                            Đặt
                          </th>
						  <th>
                            Kết Quả
                          </th>
						  <th>
                            Thời gian
                          </th>
						  
                        </tr>
                      </thead>
                      <tbody id="boxcodetoday">
					  <?php
					  $gpp_CON = mysqli_query($conn, "Select * From Lode_Logs ORDER BY Timer DESC LIMIT 10");
					  
					  if(mysqli_num_rows($gpp_CON)){
						  $i=0;
						  while($row = mysqli_fetch_array($gpp_CON, MYSQLI_ASSOC)){
							  $i++;
			$phan = 'Lô';
			if($row['Action'] == 2){
				$phan = 'Đề';
			}
				$TinhTrang = '<font color="green">Đang chờ</font>';
			if($row['Status'] == 1){
				$TinhTrang = '<font color="red">Trúng Giải</font>';
			} elseif($row['Status'] == 2){
				$TinhTrang = '<font color="black">Trặc</font>';
			}							  
							  echo '<tr id="giftcodeid-'.$row['ID'].'">
                          <td>
                            '.$i.'
                          </td>
                          <td>
                           '.getServerName($row['Server']).'
                          </td>
						  <td>'.$row['UserName'].'</td>
						  <td>'.$phan.'</td>
						  <td>'.$row['Number'].'</td>
						  <td>'.number_format($row['Money']).' Số dư</td>
						  <td>'.$TinhTrang.'</td>
                          <td>
                          '.$row['Daily'].'
                          </td>							  
                        </tr>';
						  }
					  }
					  ?>


                      </tbody>
                    </table>
                </div>					
                </div>
              </div>
            </div>
          </div>
		  		   