<?php
error_reporting(0);
session_start();
include 'config/database.php';
$search = '';
if(isset($_GET['search'])){
	$search = trim(filter_var(trim($_GET['search'])));
	$data = get_last_item_find($search);
}else{
	$data = get_last_item_all();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>NOTIFY API | @MYBOT</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</head>
<body>
	<nav class="navbar navbar-light bg-light">
	    <a href='index.php' class="navbar-brand">@MYBOT</a>
		<ul class="navbar-nav">
			<li class="nav-item">
				<a class="nav-link" href="index.php">หน้าแรก</a>
			</li>
		</ul>
		<form class="form-inline" action="list.php" method="GET">
		   <input class="form-control mr-sm-2" type="search" name="search" value="<?php echo $search ;?>" placeholder="License OR Encode" aria-label="Search">
		   <button class="btn btn-outline-success my-2 my-sm-0" type="submit">ค้นหา</button>
		</form>
	</nav>
	<div class="container">
		<br>
		<?php foreach ($data as $key => $value): ?>
		<div class="card border-dark mb-3" style="max-width: 18rem;float: left;margin-right: 10px;">
		  <div class="card-header"><?php echo  $value['groupline_name'];?></div>
		  <div class="card-body">
		    <h5 class="card-title">รหัสกลุ่ม <?php echo $value['groupline_encode'];?></h5>
		    <p class="card-text">
		    	<ul style="list-style: none;padding-left: 0;">
		    		<li>วันใช้งานคงเหลือ (<?php echo $value['groupline_countdown'];?>) วัน</li>
		    		<li>วันใช้งานทั้งหมด (<?php echo $value['groupline_alldate'];?>) วัน</li>
		    		<li>License <b><u><?php echo $value['groupline_keycode'];?></u></b></li>
		    	</ul>
		    </p>
		  </div>
		  <div class="card-footer bg-transparent">
		  	<button onclick="modal_renew('<?php echo $value["groupline_api_key"];?>','<?php echo $value["groupline_name"];?>')" class="btn btn-primary">ต่ออายุ</button>
		  	<button onclick="modal_modify('<?php echo $value["groupline_api_key"];?>','<?php echo $value["groupline_name"];?>','<?php echo $value['groupline_countdown'];?>')" class="btn btn-danger">ปรับวัน</button>
		  	<a href="list_detail.php?mid=<?php echo $value["groupline_api_key"]; ?>" class="btn btn-info">ข้อมูล</a>
		  </div>
		</div>
		<?php endforeach; ?>
	</div>

	<script>
		$(document).ready(function(){
			//alert('555');
		});
		function modal_renew(mid,name){ // renew.php
			$('#mid').val(mid);
			$('#name').html(name);
			$('#open_renew').modal();
		}

		function modal_modify(mid,name,countdown){ // renew.php
			$('#mid_modify').val(mid);
			$('#name_modify').html(name);
			$('#countdown_start').val(countdown);
			$('#countdown_end').val(countdown);
			$('#open_modify').modal();
		}
	</script>
	<div class="modal fade" id="open_renew" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <h5 class="modal-title" id="exampleModalLabel">ต่ออายุบอท : <b id="name">....</b></h5>
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
	          <span aria-hidden="true">&times;</span>
	        </button>
	      </div>
	      <div class="modal-body">
			<form action='renew.php' method="GET">
				<input type="hidden" name="mid" id="mid">
				<div class="form-group">
					<label>จำนวนวันที่สมัคร :</label>
					<select class="form-control" name="category">
						<option value="31">คี 1 เดือน(31วัน)</option>
						<option value="93">คี 3 เดือน(93วัน)</option>
						<option value="186">คี 6 เดือน(186วัน)</option>
						<option value="372">คี 1 ปี(372วัน)</option>
						<option value="1">คี 1 วัน(เทสบอท)</option>
						<option value="3">คี 3 วัน(ทดสอบ)</option>
						<option value="7">คี 7 วัน(ฟรี)</option>
					</select>
				</div>	
				<input type="submit" value="ต่ออายุบอท" class="btn btn-danger">
			</form>	
	      </div>
	    </div>
	  </div>
	</div>


	<div class="modal fade" id="open_modify" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <h5 class="modal-title" id="exampleModalLabel">ปรับเพิ่ม ลด วัน : <b id="name_modify">....</b></h5>
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
	          <span aria-hidden="true">&times;</span>
	        </button>
	      </div>
	      <div class="modal-body">
			<form action='modify.php' method="GET">
				<input type="hidden" name="mid" id="mid_modify">
				<div class="form-group">
					<label>จำนวนวันที่มีอยู่ : (วัน)</label>
					<input type="text" class="form-control" disabled name="start" id="countdown_start">
				</div>	
				<div class="form-group">
					<label>ปรับให้เป็น : (วัน)</label>
					<input type="text" class="form-control" name="end" id="countdown_end" >
				</div>					
				<input type="submit" value="ยืนยันการปรับวัน" class="btn btn-danger">
			</form>	
	      </div>
	    </div>
	  </div>
	</div>




</body>
</html>
<?php /*
Array ( [0] => Array ( [groupline_id] => 7395 [groupline_name] => Mornitor BOT By @mybot [groupline_key] => [groupline_api_key] => C4d8502ebaf034b71beb50bdb1b0a9e9d [groupline_key_notify] => 7g62s1GZtlXyojiQG7j3NmHRHpHrRWiSi2Wx86irwiZ [groupline_noyify_version] => [groupline_notify_missing] => ON [groupline_user_key] => [groupline_user_name] => [groupline_keycode] => [**SN***LINE*API**20-01-63***] => [groupline_countdown] => 31 [groupline_alldate] => 31 [**EN***LINE*API**20-01-63***] => [groupline_buy_date] => [groupline_buy_end] => [groupline_create] => 2020-01-21 08:05:43 [groupline_text] => [groupline_status] => stop [groupline_version] => V1 [groupline_access] => padding [groupline_bot_type] => USERBOT [groupline_products] => ALL [groupline_theme] => single [groupline_mode] => 1 [groupline_duration_start] => 1 [groupline_duration_end] => 88 [groupline_date_access] => all [groupline_over_alert] => on [groupline_routing] => off [groupline_block] => OFF [groupline_encode] => 00000000 [groupline_mode_S01] => OFF [groupline_mode_S02] => OFF [groupline_mode_S03] => OFF [groupline_mode_S04] => OFF [groupline_mode_S05] => OFF [groupline_mode_S06] => OFF [groupline_mode_S07] => OFF [groupline_mode_S08] => OFF [groupline_mode_S09] => OFF [groupline_mode_S10] => OFF [groupline_mode_S11] => OFF [groupline_mode_S12] => OFF [groupline_mode_S13] => OFF [groupline_mode_S14] => OFF [groupline_mode_S15] => OFF [groupline_mode_S16] => OFF [groupline_mode_S17] => OFF [groupline_mode_S18] => OFF [groupline_mode_S19] => OFF [groupline_mode_S20] => OFF [groupline_highlight] => OFF [*******LINE*API**********] => [mode_kclub] => ON [mode_kclub_alert] => ON [mode_kclub_mode] => single [mode_kclub_comment] => [mode_kclub_block] => OFF [mode_kclub_reset] => YES [mode_arawan] => OFF [mode_arawan_reset] => YES [mode_newyeekee] => OFF [mode_newyeekee_reset] => YES ) )

/*/ ?>