<?php
	$path="../../";
	include("../../map.php");
	include("../../scripts.php");
 ?>
<?php if($_GET["durum"]=="ok"){?>
	<div class="alert alert-success">
		<?php echo $sdil[212]; //Islem Basariyla Gerçeklestirilmistir !?>
	</div>
<?php }?>
<div class="">
	<div class="col p0">
		<section class="card">
			<header class="card-header">
				<div class="card-actions" id="v-<?php echo $_GET['islem'];?>"></div>
			</header>
			<div class="card-body" style="height:100vh; overflow:auto;">
			<table class="table" style="min-width:800px;">
					<thead>
						<tr>
							<th class="w10 mw12" style="text-align:center;">ID</th>
							<th>Açıklama</th>
							<th class="w8 mw12">Puan</th>
							<th class="w15 mw18">Tarih</th>
							<th class="w5 mw5"></th>
						</tr>
					</thead>
					<tbody>
						<?php $points = json_decode(getpoint($_GET["id"],'list'),true); krsort($points); $i=0;?>
						<form action="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&durum=setpoint" method="post">
							<tr data-id="">
									<td><input type="text" name="EventId" class="form-control" value="p<?php echo generatenumber(4)?>"></td>
									<td><input type="text" class="form-control" name="Desc" value="" placeholder="Açıklama"></td>
									<td><input type="text" class="form-control" name="Point" value="0"></td>
									<td><input type="text" class="form-control" name="" value="<?php echo dtarih(date("Y-m-d"),"gg ka yyyy")?>" readonly></td>
									<td>
										<button class="btn btn-warning"><i class="fa fa-plus" aria-hidden="true"></i></button>
									</td>
								</tr>
						</form>
						<?php foreach($points as $key=>$value){?>
						<form action="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&durum=setpoint" method="post">
							<tr data-id="<?php echo $value["Id"]?>">
								<td><input type="text" name="EventId" class="form-control" value="<?php echo $value["EventId"]?>" readonly></td>
								<td class="cp"><input type="text" class="form-control" name="Desc" value="<?php echo $value["Desc"]?>" readonly></td>
								<td class=""><input type="text" class="form-control" name="Point" value="<?php echo $value["Point"]?>" readonly></td>
								<td class=""><input type="text" class="form-control" name="Date" value="<?php echo dtarih($value["Date"],"gg ka yyyy")?>" readonly></td>
								<td class="">
									<a class="btn btn-danger btn-delete-row" data-href="client_giftcard.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=delpoint&pid=<?php echo $value["Id"]?>"><i class="fa fa-times" aria-hidden="true"></i></a>
								</td>
							</tr>
						</form>
						<?php }?>
						</tbody>
					</table>
				</div>
			</section>
		</div>
	</div>
	<!-- end: page -->
</section>
</div>
<?php
if ($_GET["durum"]=="setpoint"){
	setpoint($_POST["Point"].",".$_POST["Desc"], $_POST["EventId"], $_GET["id"]);
	echo "<script>window.location.href = '?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."';</script>";
}elseif($_GET["durum"]=="delpoint"){
	delpoint($_GET["pid"]);
	echo "<script>window.location.href = '?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."';</script>";
}elseif ($_GET["durum"]=="clear"){
	echo "<script>window.location.href = '?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."';</script>";
}
?>