<?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.');
}
?>
        <!-- Modal Header -->
        <div class="modal-header">
          <h4 class="modal-title">Chuyển Nạp Thẻ</h4>
          <button type="button" class="close" data-dismiss="modal">×</button>
        </div>
        
        <!-- Modal body -->

        <div class="modal-body">
		    <label>Chọn máy chủ</label>
		    <div class="form-group pass_show"> 
               <select id="list_sv" class="form-control" onChange="reloadnv();">
			   <option value="-1">=== Chọn Máy Chủ ===</option>
			    <?php
				$getMayChu = mysqli_query($conn, "Select * From config_server");
				while($row = mysqli_fetch_array($getMayChu, MYSQLI_ASSOC)){
					echo '<option value=\''.$row['ServerID'].'\'>'.$row['ServerName'].'</option>';
				}
				?>
			   </select>
            </div> 
		    <label>Chọn nhân vật</label>
		    <div class="form-group pass_show"> 
               <select id="list_char" class="form-control">
			   </select>
            </div> 		
		    <label>Mệnh giá</label>
		    <div class="form-group pass_show"> 
               <select class="form-control" id="goinap">
			   <option value="50000">50.000VNĐ</option>
			   <option value="100000">100.000VNĐ</option>
			   <option value="200000">200.000VNĐ</option>
			   <option value="500000">500.000VNĐ</option>
			   <option value="1000000">1.000.000VNĐ</option>
			   </select>
            </div> 
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal" onClick="saveInfo();">Chuyển ngay</button>
        </div>
        <Script>
		function saveInfo(){
			$.post('ajax_chuyennap.php', {user:'<?=$_POST['user']?>',id:$('#list_char').val(),sv:$('#list_sv').val(),goinap:$('#goinap').val()}, function(data){
		if(data['type'] == 0){
                Lobibox.notify('success', {
                    size: 'mini',
                    msg: data['text']
                });				
		} else {
                Lobibox.notify('error', {
                    size: 'mini',
                    msg: data['text']
                });				
		}
	},'json');
		}
		function reloadnv(){
	if($('#list_sv').val() != "-1"){
		$.post('ajax_getnv.php', {sv:$('#list_sv').val(),user:'<?=$_POST['user']?>'}, function(data){
			$('#list_char').html(data);
		});
	}
}
		</script>
				   