<?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="card-body">
                  <h4 class="card-title">Quản lý logs_user</h4>
            <div class="col-12 grid-margin">
              <div class="card">
                <div class="card-body">
                    <p class="card-description">
                      Thêm tại đây
                    </p>
                    <div class="row">
                      <div class="col-md-6">
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Vật phẩm</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="add_item">
                          </div>
                        </div>
                      </div>
                      <div class="col-md-6">
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Số Lượng</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="add_count">
                          </div>
                        </div>
                      </div>
                    </div>
					<div class="row">
                      <div class="col-md-6">
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Hình Ảnh</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="image_item">
                          </div>
                        </div>
                      </div>
                      <div class="col-md-6">
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Tiền tệ</label>
                          <div class="col-sm-9">
                            <select id="tiente_item" class="form-control">
							<option value="0">Xu Web</option>
							<option value="1">Tiền Thật</option>
							</select>
                          </div>
                        </div>
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Giá</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="money_item">
                          </div>
                        </div>						
                      </div>
                    </div>
<button type="submit" class="btn btn-success mr-2" style="float:right" onClick="additemshop();">Thêm</button>
                    </div>
                 <div class="table-responsive">
                    <table class="table table-dark">
                      <thead>
                        <tr>
                          <th>
                            #
                          </th>
                          <th>
                           Tên vật phẩm
                          </th>
						  <th>
                           ID vật phẩm
                          </th>
						  <th>
                           File Ảnh
                          </th>
						  <th>
                           Loại tiền tệ
                          </th>
						  <th>
                           Giá
                          </th>
                          <th>
                            Số Lượng
                          </th>
						  <th>
                            Quản lý
                          </th>
                        </tr>
                      </thead>
                      <tbody id="boxshop">
					  <?php
					  $gpp_CON = mysqli_query($conn, "Select * From logs_user");
					  
					  if(mysqli_num_rows($gpp_CON)){
						  $i=0;
						  while($row = mysqli_fetch_array($gpp_CON, MYSQLI_ASSOC)){
							  $i++;
									$images = 'unnamed.png';
									if($row['Images']){
										$images = $row['Images'];
									}	
                            $loaitien = 'Xu Web';
							$loaitiena = $row['Money'];
                            if($row['TienThat'] > 0){
                            $loaitien = 'Số dư';
							$loaitiena = $row['TienThat'];
							}								
							  echo '<tr id="logs_user-'.$row['ID'].'">
                          <td>
                            '.$i.'
                          </td>
                          <td>
                           '.getnameItem($row['ItemID']).'
                          </td>
						  <td>
                           '.$row['ItemID'].'
                          </td>
						  <td>
                           <img src="../images/chitiet/'.$images.'"/>
                          </td>
						  <td>
                           '.$loaitien.'
                          </td>
						  <td>
                           '.number_format($loaitiena).'
                          </td>
                          <td>
                          '.number_format($row['Count']).'
                          </td>		
                          <td>
                          <a href="javascript:xoaitemshop(\''.$row['ID'].'\');"><label class="badge badge-danger">Xóa</label></a>
                          </td>						  
                        </tr>';
						  }
					  }
					  ?>


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