<?php 
session_start();
include 'spaceship/krypton.php';
require 'sessions.php';

require 'digits.php';

?>
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title><?php include 'name.php'; ?></title>

	<!-- Bootstrap framework -->
	<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
	<!-- jQuery UI theme -->
	<link rel="stylesheet" href="lib/jquery-ui/css/Aristo/Aristo.css" />
	<!-- tooltips-->
	<link rel="stylesheet" href="lib/jBreadcrumbs/css/BreadCrumb.css" />
	<!-- tooltips-->
	<link rel="stylesheet" href="lib/qtip2/jquery.qtip.min.css" />
	<!-- colorbox -->
	<link rel="stylesheet" href="lib/colorbox/colorbox.css" />
	<!-- code prettify -->
	<link rel="stylesheet" href="lib/google-code-prettify/prettify.css" />
	<!-- sticky notifications -->
	<link rel="stylesheet" href="lib/sticky/sticky.css" />
	<!-- aditional icons -->
	<link rel="stylesheet" href="img/splashy/splashy.css" />
	<!-- flags -->
	<link rel="stylesheet" href="img/flags/flags.css" />
	<!-- datatables -->
	<link rel="stylesheet" href="lib/datatables/extras/TableTools/media/css/TableTools.css">

	<!-- main styles -->
	<link rel="stylesheet" href="css/style.css" />
	<!-- theme color-->
	<link rel="stylesheet" href="css/dark.css" id="link_theme" />

	<!-- favicon -->
	<link rel="shortcut icon" href="favicon.ico" />

</head>

<body class="full_width">

	<div class="modal fade" id="updatetheperiode">
		<div class="modal-dialog margintop">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h3 class="modal-title">Update Data Periode</h3>
				</div>

				<div class="modal-body">
					<button class="btn text-primary" onclick="openPeriode('common')">Common</button>
					<button class="btn text-primary" onclick="openPeriode('other')">Other</button>

					<div id="common" class="periode">
						<div class="loadperiode1"></div>
					</div>

					<div id="other" class="periode" style="display:none">
						<div class="loadperiode2"></div>
					</div>


				</div>

			</div>
		</div>
	</div>



	<div id="maincontainer" class="clearfix">
		<header>
			<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
				<div class="navbar-inner">
					<div class="container">
						<a class="brand pull-left" href="dashboard.php"><?php include 'name.php'; ?> System</a>
						<ul class="nav navbar-nav user_menu pull-right">
							<li class="divider-vertical hidden-sm hidden-xs"></li>
							<li>
								<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="img/user_avatar.png" alt="" class="user_avatar"><?php include 'name.php'; ?> Admin</a>
							</li>
							<li><a href="logout.php" class="dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-log-out"></i> Logout</a></li>
						</ul>
					</div>
				</div>
			</nav>
		</header>
		<div id="contentwrapper">
			<div class="main_content">
				<h3>Input Periode Market</h3>
				<hr />
				<div class="row">
					<div class="col">
						<form method="POST">
							<input id="strtdate" name="strtdate" type="text" placeholder="Pilih Tanggal.." class="inputmarket" required />
							<div class="displaynone">
								<input name="p1" id="p1" value="" />
								<input name="p2" id="p2" value="" />
								<input name="p3" id="p3" value="" />
								<input name="speciala1" id="speciala1" value="" />
								<input name="speciala2" id="speciala2" value="" />
								<input name="speciala3" id="speciala3" value="" />
								<input name="speciala4" id="speciala4" value="" />
								<input name="speciala5" id="speciala5" value="" />
								<input name="consola1" id="consola1" value="" />
								<input name="consola2" id="consola2" value="" />
								<input name="consola3" id="consola3" value="" />
								<input name="consola4" id="consola4" value="" />
								<input name="consola5" id="consola5" value="" />
							</div>
							<button type="submit" class="btn btn-primary" name="updtperiode">Add Periode</button>
						</form>

						<!-- Result data -->
						<form action="trashall.php" method="POST">
							<button style="float: right;" type="submit" name="deleteall" class="btn btn-danger" id="removeall">Hapus Semua</button>
							<input type="hidden" name="usesid" value="<?php echo $_SESSION['username']; ?>">
					</div>

				</div>



				<div class="row">
					<div class="col-sm-12 col-md-12">
						<h3 class="heading">Data Periode</h3>
						<table class="table table-striped table-bordered dTableR" id="dt_a">
							<thead>
								<tr>
									<th><input type="checkbox" id="checkAl"></th>
									<th>Hari</th>
									<th>Tanggal</th>
									<th>Jam</th>
									<th>Angka</th>
									<th>Update Oleh</th>
									<th>Action</th>

								</tr>
							</thead>
							<tbody>

								<?php

								if (isset($_GET['pageno'])) {
									$pageno = $_GET['pageno'];
								} else {
									$pageno = 1;
								}
								$no_of_records_per_page = 50;
								$offset = ($pageno - 1) * $no_of_records_per_page;


								$total_pages_sql = "SELECT COUNT(*) FROM justicewonder WHERE trashed = '0'";
								$result = mysqli_query($krypton, $total_pages_sql);
								$total_rows = mysqli_fetch_array($result)[0];
								$total_pages = ceil($total_rows / $no_of_records_per_page);


								$selectdatass = "SELECT * FROM `justicewonder` WHERE trashed = '0' ORDER BY `jam` DESC LIMIT $offset, $no_of_records_per_page";
								$condataper = mysqli_query($krypton, $selectdatass);

								if (mysqli_num_rows($condataper) == 0) {
									echo "<h1 class='text-danger'><i class='icon-warning-sign'></i>Tidak ada Periode</h1>";
								} else {
									while ($marketrow = mysqli_fetch_assoc($condataper)) {
										$strtdate = $marketrow['mulaitgl'];
										$user = $marketrow['update_oleh'];
										$hari = $marketrow['hari'];
										$prize1 = $marketrow['prize1'];
										$prize2 = $marketrow['prize2'];
										$prize3 = $marketrow['prize3'];

										$uploadtime = $marketrow['jam'];
										$showid = $marketrow['id'];
										$periodetime = strtotime($uploadtime);

								?>


										<tr id="<?php echo $showid ?>">
											<td><input type="checkbox" class="selectbox" id="checkItem" name="check[]" value="<?php echo $showid; ?>"></td>
											<td><?php echo $hari; ?></td>
											<td><?php echo $strtdate; ?></td>
											<td><?php echo date("H:i", $periodetime); ?></td>
											<td width="200px">
												<input name="updatenmr" id="updatenmr" value="<?php echo $prize1; ?>" class="inputnmr" disabled /> <a class="btn btnchecklist load" data-id="<?php echo $showid ?>"><i class="glyphicon glyphicon-ok text-success"></i></a>
											</td>
											<td>
												<h5 style="text-transform: uppercase;" class="text-success"><?php echo $user ?></h5>
											</td>
											<td><a data-id="<?php echo $showid ?>" class="blackcolor load"><i class="glyphicon glyphicon-pencil"></i></a> <a href="#" class="blackcolor"><i class="glyphicon glyphicon-trash"></i></a> </td>

										</tr>





								<?php
									}
								}
								?>

							</tbody>

						</table>

						</form> <!-- /Result data -->


						<ul class="pagination">
							<li><a href="?pageno=1">First</a></li>
							<li class="<?php if ($pageno <= 1) {
											echo 'disabled';
										} ?>">
								<a href="<?php if ($pageno <= 1) {
												echo '#';
											} else {
												echo "?pageno=" . ($pageno - 1);
											} ?>">Prev</a>
							</li>
							<li class="<?php if ($pageno >= $total_pages) {
											echo 'disabled';
										} ?>">
								<a href="<?php if ($pageno >= $total_pages) {
												echo '#';
											} else {
												echo "?pageno=" . ($pageno + 1);
											} ?>">Next</a>
							</li>
							<li><a href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
						</ul>

					</div>
				</div>

			</div>
		</div>

	</div>


	<a href="javascript:void(0)" class="sidebar_switch on_switch ttip_r" title="Hide Sidebar">Sidebar switch</a>
	<div class="sidebar">

		<div class="sidebar_inner_scroll">
			<div class="sidebar_inner">
				<form action="index.php?uid=1&amp;page=search_page" class="input-group input-group-sm" method="post">
					<input autocomplete="off" name="query" class="search_query form-control input-sm" size="16" placeholder="Search..." type="text">
					<span class="input-group-btn"><button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button></span>
				</form>
				<div id="side_accordion" class="panel-group">
					<div class="panel panel-default">
						<div class="panel-heading">
							<a href="#collapseOne" data-parent="#side_accordion" data-toggle="collapse" class="accordion-toggle">
								<i class="glyphicon glyphicon-lock"></i> Ubah Password
							</a>
						</div>
						<div class="accordion-body collapse" id="collapseOne">
							<div class="panel-body">
								<ul class="nav nav-pills nav-stacked">
									<li><a href="ubahpass.php">Ubah Password Admin</a></li>
								</ul>
							</div>
						</div>

						<div class="panel panel-default">
							<div class="panel-heading">
								<a href="#collapsetong" data-parent="#side_accordion" data-toggle="collapse" class="accordion-toggle">
									<i class="glyphicon glyphicon-trash"></i> Riwayat Periode
								</a>
							</div>
							<div class="accordion-body collapse" id="collapsetong">
								<div class="panel-body">
									<ul class="nav nav-pills nav-stacked">
										<li><a href="trash.php">Tongsampah</a></li>
									</ul>
								</div>
							</div>


							<div class="panel panel-default">
								<div class="panel-heading">
									<a href="#collapsetwo" data-parent="#side_accordion" data-toggle="collapse" class="accordion-toggle">
										<i class="glyphicon glyphicon-time"></i> Setting Website
									</a>
								</div>
								<div class="accordion-body collapse" id="collapsetwo">
									<div class="panel-body">
										<ul class="nav nav-pills nav-stacked">
											<li><a href="ubahjam.php">Ubah Jam Result Pasaran</a></li>
											<li><a href="contentweb.php">Content Website</a></li>
										</ul>
									</div>
								</div>

							</div>

							<div class="panel panel-default">
								<div class="panel-heading">
									<a href="#tambahanggota" data-parent="#side_accordion" data-toggle="collapse" class="accordion-toggle">
										<i class="glyphicon glyphicon-user"></i> Tambah Anggota
									</a>
								</div>
								<div class="accordion-body collapse" id="tambahanggota">
									<div class="panel-body">
										<ul class="nav nav-pills nav-stacked">
											<li><a href="tambahanggota.php">Tambah Anggota Pasaran</a></li>
										</ul>
									</div>
								</div>


							</div>

							<div class="push"></div>
						</div>

					</div>



				</div>
				<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
				<script src="js/jquery-migrate.min.js"></script>
				<script src="lib/jquery-ui/jquery-ui-1.10.0.custom.min.js"></script>
				<!-- touch events for jquery ui-->
				<script src="js/forms/jquery.ui.touch-punch.min.js"></script>
				<!-- easing plugin -->
				<script src="js/jquery.easing.1.3.min.js"></script>
				<!-- smart resize event -->
				<script src="js/jquery.debouncedresize.min.js"></script>
				<!-- js cookie plugin -->
				<script src="js/jquery_cookie_min.js"></script>
				<!-- main bootstrap js -->
				<script src="bootstrap/js/bootstrap.min.js"></script>
				<!-- bootstrap plugins -->
				<script src="js/bootstrap.plugins.min.js"></script>
				<!-- typeahead -->
				<script src="lib/typeahead/typeahead.min.js"></script>
				<!-- code prettifier -->
				<script src="lib/google-code-prettify/prettify.min.js"></script>
				<!-- sticky messages -->
				<script src="lib/sticky/sticky.min.js"></script>
				<!-- tooltips -->
				<script src="lib/qtip2/jquery.qtip.min.js"></script>
				<!-- lightbox -->
				<script src="lib/colorbox/jquery.colorbox.min.js"></script>
				<!-- jBreadcrumbs -->
				<script src="lib/jBreadcrumbs/js/jquery.jBreadCrumb.1.1.min.js"></script>
				<!-- hidden elements width/height -->
				<script src="js/jquery.actual.min.js"></script>
				<!-- custom scrollbar -->
				<script src="lib/slimScroll/jquery.slimscroll.js"></script>
				<!-- fix for ios orientation change -->
				<script src="js/ios-orientationchange-fix.js"></script>
				<!-- to top -->
				<script src="lib/UItoTop/jquery.ui.totop.min.js"></script>
				<!-- mobile nav -->
				<script src="js/selectNav.js"></script>

				<!-- common functions -->
				<script src="js/gebo_common.js"></script>

				<!-- multi-column layout -->
				<script src="js/jquery.imagesloaded.min.js"></script>
				<script src="js/jquery.wookmark.js"></script>
				<!-- responsive table -->
				<script src="js/jquery.mediaTable.min.js"></script>
				<!-- small charts -->
				<script src="js/jquery.peity.min.js"></script>
				<!-- charts -->
				<script src="lib/flot/jquery.flot.min.js"></script>
				<script src="lib/flot/jquery.flot.resize.min.js"></script>
				<script src="lib/flot/jquery.flot.pie.min.js"></script>
				<!-- calendar -->
				<script src="lib/fullcalendar/fullcalendar.min.js"></script>
				<!-- sortable/filterable list -->
				<script src="lib/list_js/list.min.js"></script>
				<script src="lib/list_js/plugins/paging/list.paging.min.js"></script>
				<!-- dashboard functions -->
				<script src="js/gebo_dashboard.js"></script>

				<script>
					$("#checkAl").click(function() {
						$('input:checkbox').not(this).prop('checked', this.checked);
					});

					//   $(function() {
					//         $(".selectbox").click(function(e) {
					//             $("#removeall").attr("disabled", !e.currentTarget.checked);
					//         });
					//     });

					// var checker = document.getElementsByClassName('selectbox');
					// var sendbtn = document.getElementById('removeall');
					// checker.onchange = function() {
					//   sendbtn.disabled = !!this.checked;
					// };
				</script>



				<script>
					function randomNumber(min, max) {
						min = Math.ceil(min);
						max = Math.floor(max);
						return Math.floor(Math.random() * (max - min + 1)) + min;
					}


					speciala1 = randomNumber(<?php
												if ($number === 4) {
													echo '1119, 9999';
												} else {
													echo '111119, 999999';
												}
												?>);
					speciala2 = randomNumber(<?php
												if ($number === 4) {
													echo '1269, 9999';
												} else {
													echo '121169, 999999';
												}
												?>);
					speciala3 = randomNumber(<?php
												if ($number === 4) {
													echo '1179, 9999';
												} else {
													echo '111179, 999999';
												}
												?>);
					speciala4 = randomNumber(<?php
												if ($number === 4) {
													echo '1239, 9999';
												} else {
													echo '121139, 999999';
												}
												?>);
					speciala5 = randomNumber(<?php
												if ($number === 4) {
													echo '1289, 9999';
												} else {
													echo '121189, 999999';
												}
												?>);
					consola1 = randomNumber(<?php
											if ($number === 4) {
												echo '1419, 9999';
											} else {
												echo '141119, 999999';
											}
											?>);
					consola2 = randomNumber(<?php
											if ($number === 4) {
												echo '1439, 9999';
											} else {
												echo '143119, 999999';
											}
											?>);
					consola3 = randomNumber(<?php
											if ($number === 4) {
												echo '1459, 9999';
											} else {
												echo '145119, 999999';
											}
											?>);
					consola4 = randomNumber(<?php
											if ($number === 4) {
												echo '1489, 9999';
											} else {
												echo '148119, 999999';
											}
											?>);
					consola5 = randomNumber(<?php
											if ($number === 4) {
												echo '1449, 9999';
											} else {
												echo '144119, 999999';
											}
											?>);

					// Function call
					document.getElementById("speciala1").value = speciala1;
					document.getElementById("speciala2").value = speciala2;
					document.getElementById("speciala3").value = speciala3;
					document.getElementById("speciala4").value = speciala4;
					document.getElementById("speciala5").value = speciala5;
					document.getElementById("consola1").value = consola1;
					document.getElementById("consola2").value = consola2;
					document.getElementById("consola3").value = consola3;
					document.getElementById("consola4").value = consola4;
					document.getElementById("consola5").value = consola5;
				</script>

				<script>
					$(document).ready(function() {
						//* jQuery.browser.mobile (http://detectmobilebrowser.com/)
						//* jQuery.browser.mobile will be true if the browser is a mobile device
						(function(a) {
							jQuery.browser.mobile = /android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))
						})(navigator.userAgent || navigator.vendor || window.opera);
						//replace themeforest iframe
						if (jQuery.browser.mobile) {
							if (top !== self) top.location.href = self.location.href;
						}
					});
				</script>



				<script>
					$(document).ready(function() {
						$("#strtdate").datepicker({
							dateFormat: "yy-mm-dd"
						});
						$("#strtdate").focus(function() {
							$("#strtdate").datepicker("show");
						});


					});
				</script>




				<script type="text/javascript">
					$(document).ready(function() {

						$.ajax({
							type: "GET",
							url: "spaceship/showperiode.php",
							dataType: "html", //expect html to be returned
							success: function(response) {
								$("#display_info").html(response);
								//alert(response);
							}

						});
					});
				</script>

				<?php
				if (isset($_POST['updtperiode'])) {

					$strtdate = mysqli_real_escape_string($krypton, $_POST['strtdate']);
					$p1 = mysqli_real_escape_string($krypton, $_POST['p1']);
					$p2 = mysqli_real_escape_string($krypton, $_POST['p2']);
					$p3 = mysqli_real_escape_string($krypton, $_POST['p3']);

					$speciala1 = mysqli_real_escape_string($krypton, $_POST['speciala1']);
					$speciala2 = mysqli_real_escape_string($krypton, $_POST['speciala2']);
					$speciala3 = mysqli_real_escape_string($krypton, $_POST['speciala3']);
					$speciala4 = mysqli_real_escape_string($krypton, $_POST['speciala4']);
					$speciala5 = mysqli_real_escape_string($krypton, $_POST['speciala5']);
					$consola1 = mysqli_real_escape_string($krypton, $_POST['consola1']);
					$consola2 = mysqli_real_escape_string($krypton, $_POST['consola2']);
					$consola3 = mysqli_real_escape_string($krypton, $_POST['consola3']);
					$consola4 = mysqli_real_escape_string($krypton, $_POST['consola4']);
					$consola5 = mysqli_real_escape_string($krypton, $_POST['consola5']);
					$date = $strtdate . date(" H:i:s");
					$uploadday = strftime('%A', strtotime($date));

					$top_prize = round(rand(10000000, 90000000) / 10) * 10;

					$sdays = "SELECT * FROM justicewonder WHERE mulaitgl = '$strtdate' AND trashed = '0'";
					$qdays = mysqli_query($krypton, $sdays);

					if (mysqli_num_rows($qdays) != 0) {
						echo '<script>
			alert("Periode tersebut sudah ditambahkan!!")
			window.setTimeout(function() {
				window.location = "dashboard.php";
			  }, 100);
			</script>';
					} else {

						$q = 'INSERT INTO `justicewonder` (`id`, `hari`, `mulaitgl`, `jam`, `top_prize`, `speciala1`, `speciala2`, `speciala3`, `speciala4`, `speciala5`, `consola1`, `consola2`, `consola3`, `consola4`, `consola5`, `update_oleh`)
			VALUES ("",  "' . $uploadday . '", "' . $strtdate . '", "' . $date . '", "' . $top_prize . '", "' . $speciala1 . '", "' . $speciala2 . '", "' . $speciala3 . '", "' . $speciala4 . '", "' . $speciala5 . '", "' . $consola1 . '", "' . $consola2 . '", "' . $consola3 . '", "' . $consola4 . '", "' . $consola5 . '", "' . $_SESSION['username'] . '")';

						$r = mysqli_query($krypton, $q);
						if ($r) {

							echo '<script>
			alert("Periode Berhasil ditambahkan!!")
			window.setTimeout(function() {
				window.location = "dashboard.php";
			  }, 100);
			</script>';
						} else {

							// Message Error
							echo "<script>alert('Periode Gagal ditambahkan, Silahkan dicoba lagi.');</script>";
						}
					}
				}
				?>

				<script>
					function openPeriode(periodename) {
						var i;
						var x = document.getElementsByClassName("periode");
						for (i = 0; i < x.length; i++) {
							x[i].style.display = "none";
						}
						document.getElementById(periodename).style.display = "block";
					}
				</script>

				<script>
					$(document).ready(function() {

						$('.load').click(function() {

							var userid = $(this).data('id');
							var username = '<?php echo $_SESSION['username'] ?>';

							$.ajax({
								url: 'spaceship/common.php',
								type: 'post',
								data: {
									userid: userid,
									user: username
								},
								success: function(response) {
									// Add response in Modal body
									$('.loadperiode1').html(response);

									// Display Modal
									$('#updatetheperiode').modal('show');
								}
							});
						});
					});
				</script>

				<script>
					$(document).ready(function() {

						$('.load').click(function() {

							var userid = $(this).data('id');
							var username = '<?php echo $_SESSION['username'] ?>';

							$.ajax({
								url: 'spaceship/consolation.php',
								type: 'post',
								data: {
									userid: userid,
									user: username
								},
								success: function(response) {
									// Add response in Modal body
									$('.loadperiode2').html(response);

								}
							});
						});
					});
				</script>


				<script type="text/javascript">
					$(".glyphicon-trash").click(function() {
						var id = $(this).parents("tr").attr("id");
						var userids = '<?php echo $_SESSION['username']; ?>';


						if (confirm('Yakin ingin Hapus Periode ini?')) {
							$.ajax({
								url: 'trashpr.php',
								type: 'GET',
								data: {
									id: id,
									userids: userids
								},
								error: function() {
									alert('Ada masalah Silahkan dicoba lagi');
								},
								success: function(data) {
									$("#" + id).remove();
									alert("Periode Berhasil dihapus");
								}
							});
						}
					});
				</script>

</body>

</html>
