<?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 account_web WHERE Account = '".$_POST['user']."'");
?>        
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
        <!-- Modal body -->
		<?php if(mysqli_num_rows($getinfo)) {
			$info_get = mysqli_fetch_array($getinfo, MYSQLI_ASSOC);
$getinfo_money = mysqli_fetch_assoc(mysqli_query($conn, "Select * From account_web_money WHERE Account = '".$_POST['user']."' and ServerID = '".$_POST['sv']."'"));			
			?>
        <div class="modal-body">
		<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
  <li class="nav-item" role="presentation">
    <button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="true">Thông Tin</button>
  </li>
  <li class="nav-item" role="presentation">
    <button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">Quản Lý Số Dư</button>
  </li>
</ul>
<div class="tab-content" id="pills-tabContent">
  <div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
  <label>Tên tài khoản</label>
		    <div class="form-group pass_show"> 
                <input type="text" disabled value="<?=$info_get['Account']?>" class="form-control" placeholder="Không sữa nên để mặc định."> 
            </div> 
		       <label>Mật khẩu</label>
            <div class="form-group pass_show"> 
                <input type="text" value=""  id="info_pass" class="form-control" placeholder="Không sữa nên để mặc định."> 
            </div> 
			 <label>ID Nhân Vật Chính</label>
            <div class="form-group pass_show"> 
                <input type="text" value="<?=$info_get['CharID_Auth']?>"  id="info_nvc" class="form-control" placeholder="Nhập ID Nhân Vật Chính Cần Thay Đổi."> 
            </div> 
		       <label>Mật Khẩu Rương</label>
            <div class="form-group pass_show"> 
                <input type="text" value="<?=$info_get['PasswordBag']?>"  id="info_pass2" class="form-control" placeholder="Không sữa nên để mặc định."> 
            </div> 
		       <label>EMail</label>
            <div class="form-group pass_show"> 
                <input type="text" value="<?=$info_get['Email']?>"  id="info_email" class="form-control" placeholder="Không sữa nên để mặc định."> 
            </div> 
		       <label>Số điện thoại</label>
            <div class="form-group pass_show"> 
                <input type="text" value="<?=$info_get['Phone']?>"  id="info_phone" class="form-control" placeholder="Không sữa nên để mặc định."> 
            </div> 
		       <label>IP Đăng Ký</label>
            <div class="form-group pass_show"> 
                <input type="text" disabled value="<?=$info_get['IP_Reg']?>" class="form-control" placeholder="Không sữa nên để mặc định."> 
            </div>				
			
  </div>
  <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
  		       <label>Linh Thạch : <?=number_format($getinfo_money['LinhThach'])?></label>
            <div class="form-group pass_show"> 
            <div style="width:10%;float:right;">
            <select name="" id="calc" class="form-control" style="height: 33px;">
                    <option value="1">+</option>
                    <option value="2">-</option>
                </select>
            </div>
            <div style="width:90%;">
                <input type="text"  id="info_money" class="form-control" placeholder="Nhập Số Linh Thạch Muốn Cộng."> 
            </div>
			</div>
		       <label>Xu Máy Chủ : <?=number_format($getinfo_money['TienThat'])?> VNĐ</label>
            <div class="form-group pass_show"> 
            <div style="width:10%;float:right;">
            <select name="" id="calc" class="form-control" style="height: 33px;">
                    <option value="1">+</option>
                    <option value="2">-</option>
                </select>
            </div>
            <div style="width:90%;">
            <input type="text"  id="info_tieenthat" class="form-control" placeholder="Không sửa nên để mặc định."> 
            </div>
                
            </div> 	
</div>
					
		<? } else { echo 'Không tìm thấy thông tin tài khoản này.';} ?>			
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
		<?php if($info_get['Block'] == 1){ ?>
          <button type="button" class="btn btn-success" data-dismiss="modal" onClick="BlockAccount('<?=$info_get['Account']?>','0');">Mở Khóa Tài Khoản</button>		
		<?php } else { ?>
          <button type="button" class="btn btn-warning" data-dismiss="modal" onClick="BlockAccount('<?=$info_get['Account']?>','1');">Khóa Tài Khoản</button>
		<?php } ?>
          <button type="button" class="btn btn-danger" data-dismiss="modal" onClick="saveInfo();">Lưu ngay</button>
        </div>
        <Script>
function BlockAccount(account, type) {
    $.post('ajax/ajax_blockacc.php', { user: account, type: type }, function(data) {
        if (data['type'] == 0) {
            toastr.success(data['text'], 'Thông Báo', {timeOut: 5000});	
		} else {			
            toastr.info(data['text'], 'Thông Báo', {timeOut: 5000});			
        }
    }, 'json');
}
		function saveInfo(){
			$.post('ajax/ajax_infouser.php', {user:'<?=$_POST['user']?>',sv:'<?=$_POST['sv']?>',TienThat:$('#info_tieenthat').val(),calc:$('#calc').val(),pass:$('#info_pass').val(),pass2:$('#info_pass2').val(),email:$('#info_email').val(),CharID_Auth:$('#info_nvc').val(),phone:$('#info_phone').val(),money:$('#info_money').val()}, function(data){
		if(data['type'] == 0){
            toastr.success(data['text'], 'Thông Báo', {timeOut: 5000});			
		} else {
            toastr.info(data['text'], 'Lỗi', {timeOut: 5000});
			
        }
        return false;
	},'json');
		}
		</script>
				   