<?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.');
}
$getinfo = mysqli_query($conn, "Select * From duatop_setting WHERE ID = '".$_POST['idevent']."'");
?>
<style>
.discount {
    position: absolute;
    margin-left: 30px;
    margin-top: -25px;
    border: 2px solid #f15a21;
    border-radius: 100px 0 0 100px;
    padding: 2px;
    width: 50px;
    height: 23.5px;
}
.discount p {
    background: #f15a21;
    border-radius: 100px 0 0 100px;
    text-align: center;
    line-height: 0!important;
    font-size: .9em!important;
    padding: 7px;
}
.discount span {
    color: #fff;
    font-size: 11px;
    text-align: center;
    display: inline-block;
    font-weight: 700;
}
</style>
        <!-- Modal body -->
		<?php if(mysqli_num_rows($getinfo)) { $acc = true; ?>
        <div class="modal-body">
			<label>Dách sách Vị Trí</label>
                    <table class="table table-bordered" style="width: 100%; margin-bottom: 4rem; background-color: transparent;">
                      <thead>
                        <tr>
                          <th>
                            #
                          </th>
                          <th>
                            Vị Trí Bắt Đầu
                          </th>
                          <th>
                            Vị Trí Kết Thúc
                          </th>
						  <th>
                            Phần Thưởng
                          </th>
                          <th>
                            Chức năng
                          </th>						  
                        </tr>
                      </thead>
                      <tbody id="listitemcode">
<?php
$getitem_code = mysqli_query($conn, "Select * From duatop_vitri WHERE IDTOP = '".$_POST['idevent']."' ORDER BY ID DESC");
if(mysqli_num_rows($getitem_code)){
	$i=0;
	while($row = mysqli_fetch_array($getitem_code, MYSQLI_ASSOC)){
		$i++;
		$phantich = explode(",",$row['PhanThuong']);
		if(!is_numeric($phantich[1])){
			$Name = getnameText($phantich[1]);
		} else {
		$getName = mysqli_fetch_array(mysqli_query($conn, "Select Name From Item_Goods WHERE ItemID = '".$phantich[1]."'"), MYSQLI_ASSOC);
			$Name = $getName['Name'];
		}
		echo '<tr>
                          <td class="font-weight-medium">
                           '.$i.'
                          </td>
                          <td>
                            '.$row['ViTri_A'].'
                          </td>	
                          <td>
                            '.$row['ViTri_B'].'
                          </td>
						  <td>
                            '.$row['PhanThuong'].'
                          </td>							  
                         <td>
                      <div class="ticket-actions">
                        <div class="btn-group dropdown">
                          <button type="button" class="btn btn-success dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            Tùy chọn
                          </button>
                          <div class="dropdown-menu">
                            <a class="dropdown-item" href="javascript:deleventduatop(\''.$_POST['idevent'].'\',\''.$row['ID'].'\');">
                              <i class="fa fa-reply fa-fw"></i>Xóa</a>						  
                          </div>
                        </div>
                      </div>						 
                       </td>						 
                        </tr>';
	}
}
?>
                      </tbody>
                    </table>			
		<? } ?>	
        </div>
        
        <!-- Modal footer -->
<script type="text/javascript">
function loadlistitemcode(){
	$.post('from/panel_list_duatop_vitri.php', {idevent:'<?=$_POST['idevent']?>'}, function(data){
		$('#infoUserLogs').html(data);
	});
}
function deleventduatop(idevent,id){
$.post('ajax/del_quavitri_duatop.php', {idevent:idevent,id:id}, function(data){
		if(data['type'] == 0){
			loadlistitemcode();							
      toastr.success(data['text'], 'Thông Báo');		

		} else {
      toastr.info(data['text'], 'Chú ý');				
			
		}	
},'json');
}
</script>
		   