<?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.');
}
?>
                  <h4 class="card-title">Quản lý & Chỉnh Sửa Event GiftCode</h4>
				             <div class="input-group"  style="width:62%;float:right">
                            <span class="input-group-addon" style="margin-top:5px">Tìm Kiếm Theo ===> &nbsp;</span>
                            <select class="form-control" style="width:200px" id="type_seach">
							<option value="0">Tên hoặc ID Event</option>
							<select>  
                            <input type="text" id="text_seach" value="" class="form-control" placeholder="Nội dung" style="width:120px">
                          <button type="button" class="btn btn-success btn-sm" onClick="$('#fromCreatGiftCode').modal();">
                            Tạo Event
                          </button>							
                        </div>
                  <div class="table-responsive">
				  						<hr />

                    <table class="table table-bordered" style="width: 100%; margin-bottom: 4rem; background-color: transparent;">
                      <thead>
                        <tr>
                          <th>
                            #
                          </th>
                          <th>
                            ID Event
                          </th>
                          <th>
                            Tên Event
                          </th>
                          <th>
                            Số lần được nhận
                          </th>
                          <th>
                            Bắt đầu
                          </th>						  
                          <th>
                            Kết Thúc
                          </th>						  
                          <th>
                            Chức năng
                          </th>						  
                        </tr>
                      </thead>
                      <tbody id="listAccount">
<?php
$get_Code = mysqli_query($conn, "Select * from giftcode");
if(mysqli_num_rows($get_Code)){
	$i=0;
	while($row = mysqli_fetch_array($get_Code, MYSQLI_ASSOC)){
		$i++;
		echo '<tr id="code-'.$row['IDEvent'].'">
                          <td class="font-weight-medium">
                           '.$i.'
                          </td>
                          <td>
                            '.$row['IDEvent'].'
                          </td>
                          <td>
                            '.$row['EventName'].'
                          </td>
                          <td>
                           '.$row['Count_Click'].'
                          </td>
                          <td>
                          '.date('d-m-Y', $row['TimerStart']).'
                          </td>
                          <td>
                          '.date('d-m-Y', $row['TimerEnd']).'
                          </td>	
                         <td>
                      <div class="ticket-actions col-md-2">
                        <div class="btn-group dropdown">
                          <button type="button" class="btn btn-success dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            Xem Tùy chọn
                          </button>
                          <div class="dropdown-menu">
                            <a class="dropdown-item" href="javascript:codefix_change(\''.$row['IDEvent'].'\',\'0\');">
                              <i class="fa fa-reply fa-fw"></i>Sữa Event</a>
                            <div class="dropdown-divider"></div>							  
                            <a class="dropdown-item" href="javascript:codefix_change(\''.$row['IDEvent'].'\',\'1\')">
                              <i class="fa fa-history fa-fw"></i>Quản lý Quà</a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:codefix_change(\''.$row['IDEvent'].'\',\'2\')">
                              <i class="fa fa-check text-success fa-fw" ></i>Quản Lý Code</a>
							  <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:codefix_change(\''.$row['IDEvent'].'\',\'3\')">
                              <i class="fa fa-check text-success fa-fw" ></i>Xóa Event</a>
							  <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:codefix_change(\''.$row['IDEvent'].'\',\'4\')">
                              <i class="fa fa-check text-success fa-fw" ></i>Renew Event</a>
                          </div>
						  <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:codefix_change(\''.$row['IDEvent'].'\',\'5\')">
                              <i class="fa fa-check text-success fa-fw" ></i>Xóa CODE</a>
                          </div>
                        </div>
                      </div>						 
                       </td>						 
                        </tr>';
	}
}
?>
                      </tbody>
                    </table>
                  </div>
				  		   