<?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; $getinfo = mysqli_fetch_array($getinfo, MYSQLI_ASSOC); ?>
        <div class="modal-body">
		    <label>Máy Chủ</label>
		    <div class="form-group pass_show"> 
                                                                <select class="form-control" id="edit_MayChu">
                                                <option value="0">--Chọn Máy Chủ --</option>
                                                    <?php
$get_maychu = mysqli_query($conn, "Select * From config_server");
if(mysqli_num_rows($get_maychu)){
while($row = mysqli_fetch_assoc($get_maychu)){
echo '<option value="'.$row['ServerID'].'">'.$row['ServerName'].'</option>';
}
}
                                                    ?>
                                                    </select>
            </div> 
		       <label></label>
            <div class="form-group pass_show"> 
            <div class="form-group pass_show"> 
                                                <select class="form-control" id="edit_LoaiDuaTop">
                                                <option value="FightPower">-- Lực Chiến --</option>
                                                <option value="Money">-- TOP Nạp --</option>
                                                    </select>
            </div>
            </div>
		       <label>Thời gian bắt đầu</label>
            <div class="form-group pass_show"> 
                <input type="text" value="<?=date('d/m/Y', $getinfo['TimerStart'])?>"  id="edit_coder_timestart" class="form-control datepicker hasDatepicker" placeholder="<?=date('d/m/Y')?>"> 
            </div>
		       <label>Thời gian Kết Thúc</label>
            <div class="form-group pass_show"> 
                <input type="text" value="<?=date('d/m/Y', $getinfo['TimerEnd'])?>"  id="edit_coder_timerend" class="form-control datepicker hasDatepicker" placeholder="<?=date('d/m/Y')?>"> 
            </div>					
        </div>
		<? } else { echo '<hr /> <center>Không tìm thấy Đua TOP này.</center> <hr />';} ?>			
        </div>
        
        <!-- Modal footer -->
		<?php if($acc){ ?>
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" onClick="saveInfo_Edit();">Sữa ngay</button>
        </div>
		<?php } ?>
<script>
function saveInfo_Edit(){
	if($('#edit_MayChu').val() != "" || $('#edit_LoaiDuaTop').val() != "" || $('#edit_coder_timestart').val() != "" || $('#edit_coder_timerend').val() != ""){
		$.post('ajax/ajax_editduatop.php', {
			idevent:'<?=$_POST['idevent']?>',
			sv:$('#edit_MayChu').val(),
			top:$('#edit_LoaiDuaTop').val(),
			timestart:$('#edit_coder_timestart').val(),
			timeend:$('#edit_coder_timerend').val()
			}, function(data){
			if(data['code'] == 0){
                toastr.success(data['text'], 'Thông Báo');			
			} else {
                toastr.info(data['text'], 'Chú ý');			
			}
			texttimkiem();
		},'json');
	} else {
        toastr.info('Vui lòng nhập đầy đủ thông tin.', 'Chú ý');			
			
	}
}
</script>
		   