<?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">Tùy chỉnh Đăng ký</h4>
					  <?php
					  $get_AA = mysqli_query($conn, "Select * From Config_Register WHERE Close = 0");
					  $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['TienThat']; 
						  $reg_b = $get_AA['Money'];
					  }
					  
					  ?>
                        <div class="form-group">
                          <label for="exampleInputEmail1">Số dư['Tặng']</label>
                          <input type="text" class="form-control" id="set__reg_sodu" value="<?=$reg_a?>">
                        </div>
                        <div class="form-group">
                          <label for="exampleInputPassword1">Xu Web['Tặng'] </label>
                          <input type="text" class="form-control" id="set__reg_xuweb" value="<?=$reg_b?>">
                        </div>
                        <button type="submit" class="btn btn-success mr-2" onClick="Save_SettingR();">Lưu</button>
                    </div>
                  </div>
                </div>
                <div class="col-12 stretch-card">
                  <div class="card">
                    <div class="card-body">
                      <h4 class="card-title">Thiếp Lập Website</h4>
					  <?php
					  $get_AA = mysqli_query($conn, "Select * From config_setting WHERE ID = 1");
					  if(mysqli_num_rows($get_AA)){
						  $get_AA = mysqli_fetch_array($get_AA,MYSQLI_ASSOC);
					  }
					  
					  ?>					  
                        <div class="form-group row">
                          <label for="exampleInputEmail2" class="col-sm-3 col-form-label">Địa chĩ Web</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="set__web_a" value="<?=$get_AA['Url']?>">
                          </div>
                        </div>
                        <div class="form-group row">
                          <label for="exampleInputPassword2" class="col-sm-3 col-form-label">Tiêu Đề index</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="set__web_b" value="<?=$get_AA['Title_Index']?>">
                          </div>
                        </div>
						<div class="form-group row">
                          <label for="exampleInputPassword2" class="col-sm-3 col-form-label">Giới thiệu index</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="set__web_c" value="<?=$get_AA['Des_Index']?>">
                          </div>
                        </div>
						<div class="form-group row">
                          <label for="exampleInputPassword2" class="col-sm-3 col-form-label">Mô Tả index</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="set__web_d" value="<?=$get_AA['Key_Index']?>">
                          </div>
                        </div>
						<div class="form-group row">
                          <label for="exampleInputPassword2" class="col-sm-3 col-form-label">ID Google Any</label>
                          <div class="col-sm-9">
                            <input type="text" class="form-control" id="set__web_e" value="<?=$get_AA['Google_ID']?>">
                          </div>
                        </div>
                        <div class="form-group row">
                          <label for="exampleInputPassword2" class="col-sm-3 col-form-label">Nạp thẻ Tự động</label>
                          <div class="col-sm-9">
                            <select id="enableAutoCharge" class="form-control">
                              <option value="0" <?=$get_AA['enable_autocharge'] == 0 ? 'selected' : '';?>>Tắt</option>
                              <option value="1" <?=$get_AA['enable_autocharge'] == 1 ? 'selected' : '';?>>Bật</option>
                            </select>
                          </div>
                        </div>
                        <button type="submit" class="btn btn-success mr-2" onClick="Save_SettingW('0');">Lưu</button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="col-md-6 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
                  <h4 class="card-title">Thiếp Nạp API Nạp Thẻ</h4>
                  <p class="card-description">
                    ReCard.VN
                  </p>
                    <div class="form-group">
                      <label for="exampleInputName1">ID Tài Khoản</label>
                      <input type="text" class="form-control" id="recard_a" value="<?=$get_AA['recard_id']?>">
                    </div>
                    <div class="form-group">
                      <label for="exampleInputEmail3">Mã Bí Mật</label>
                      <input type="email" class="form-control" id="recard_b" value="<?=$get_AA['recard_ma']?>">
                    </div>
                  <p class="card-description">
                    Ken.ShopDoiThe.Com
                  </p>
                    <div class="form-group">
                      <label for="exampleInputName1">Merchant ID</label>
                      <input type="text" class="form-control" id="sdt_a" value="<?=$get_AA['sdt_id']?>">
                    </div>
                    <div class="form-group">
                      <label for="exampleInputEmail3">Merchant User</label>
                      <input type="email" class="form-control" id="sdt_b" value="<?=$get_AA['sdt_user']?>">
                    </div>
					<div class="form-group">
                      <label for="exampleInputEmail3">Merchant Password</label>
                      <input type="email" class="form-control" id="sdt_c" value="<?=$get_AA['sdt_pass']?>">
                    </div>

                    <button type="submit" class="btn btn-success mr-2" onClick="saveAPI();">Lưu </button>
                  </form>
                </div>
              </div>
            </div>
            <div class="col-12 grid-margin">
              <div class="card">
                <div class="card-body">
                  <h4 class="card-title">Quản lý danh sách vật phẩm [CODE HÀNG NGÀY]</h4>
                    <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_itemcode">
                          </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_countcode">
                          </div>
                        </div>
                      </div>
                    </div>
<button type="submit" class="btn btn-success mr-2" style="float:right" onClick="additemcode();">Thêm</button>
                    </div>
                 <div class="table-responsive">
                    <table class="table table-dark">
                      <thead>
                        <tr>
                          <th>
                            #
                          </th>
                          <th>
                            Vật phẩm
                          </th>
                          <th>
                            Số Lượng
                          </th>
						  <th>
                            Quản lý
                          </th>
                        </tr>
                      </thead>
                      <tbody id="boxcodetoday">
					  <?php
					  $gpp_CON = mysqli_query($conn, "Select * From config_codetoday");
					  
					  if(mysqli_num_rows($gpp_CON)){
						  $i=0;
						  while($row = mysqli_fetch_array($gpp_CON, MYSQLI_ASSOC)){
							  $i++;
							  echo '<tr id="giftcodeid-'.$row['ID'].'">
                          <td>
                            '.$i.'
                          </td>
                          <td>
                           '.$row['Item'].'
                          </td>
                          <td>
                          '.number_format($row['Count']).'
                          </td>		
                          <td>
                          <a href="javascript:xoaCodetoday(\''.$row['ID'].'\');"><label class="badge badge-danger">Xóa</label></a>
                          </td>						  
                        </tr>';
						  }
					  }
					  ?>


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