?
| Path : /home/u949514618/domains/drpktiwari.com/public_html/admin/ |
| Current File : /home/u949514618/domains/drpktiwari.com/public_html/admin/lottery_actions.php |
<?php
// Start the session to check if the user is logged in
session_start();
// Check if the user is logged in
if (!isset($_SESSION['centre_id'])) {
// If not logged in, redirect to login page
header("Location: login.php");
exit();
}
include('db.php');
?>
<!DOCTYPE html>
<html
lang="en"
class="light-style layout-menu-fixed"
dir="ltr"
data-theme="theme-default"
data-assets-path="../backend/assets/"
data-template="vertical-menu-template-free"
>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
/>
<title>Dashboard - PK Arogyam</title>
<meta name="description" content="" />
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="../backend/assets/img/brand/favicon.png" />
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
rel="stylesheet"
/>
<!-- Icons. Uncomment required icon fonts -->
<link rel="stylesheet" href="../backend/assets/vendor/fonts/boxicons.css" />
<!-- Core CSS -->
<link rel="stylesheet" href="../backend/assets/vendor/css/core.css" class="template-customizer-core-css" />
<link rel="stylesheet" href="../backend/assets/vendor/css/theme-default.css" class="template-customizer-theme-css" />
<link rel="stylesheet" href="../backend/assets/css/demo.css" />
<!-- Vendors CSS -->
<link rel="stylesheet" href="../backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />
<link rel="stylesheet" href="../backend/assets/vendor/libs/apex-charts/apex-charts.css" />
<!-- Page CSS -->
<!-- Helpers -->
<script src="../backend/assets/vendor/js/helpers.js"></script>
<!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
<!--? Config: Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file. -->
<script src="../backend/assets/js/config.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/2.2.1/css/dataTables.dataTables.css" />
</head>
<body>
<!-- Layout wrapper -->
<div class="layout-wrapper layout-content-navbar">
<div class="layout-container">
<!-- Menu -->
<?php include_once('include/dash_sidebar.php'); ?>
<!-- / Menu -->
<!-- Layout container -->
<div class="layout-page">
<!-- Navbar -->
<?php include_once('include/nav.php'); ?>
<!-- Content wrapper -->
<div class="content-wrapper">
<!-- Content -->
<div class="container-xxl flex-grow-1 container-p-y">
<h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Lottery Entry</span> </h4>
<form id="lotteryForm" class="mb-3" method="post">
<div class="mb-3">
<label for="date" class="form-label">Date</label>
<input type="date" id="date" name="date" class="form-control" required>
</div>
<div class="mb-3">
<label for="time" class="form-label">Time of Entry</label>
<input type="time" id="time" name="time" class="form-control" min="08:00" max="21:00" required>
</div>
<div class="mb-3">
<label for="result_a" class="form-label">Raja Rani Quen</label>
<input type="text" id="result_a" name="result_a" class="form-control" maxlength="2" oninput="validateInput(this)" required>
</div>
<div class="mb-3">
<label for="result_b" class="form-label">Rajshree-A</label>
<input type="text" id="result_b" name="result_b" class="form-control" maxlength="2" oninput="validateInput(this)" required>
</div>
<div class="mb-3">
<label for="result_c" class="form-label">Rajshree-B</label>
<input type="text" id="result_c" name="result_c" class="form-control" maxlength="2" oninput="validateInput(this)" required>
</div>
<div class="mb-3">
<label for="result_d" class="form-label">Rajshree-C</label>
<input type="text" id="result_d" name="result_d" class="form-control" maxlength="2" oninput="validateInput(this)" required>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<!-- Display Data -->
<table class="table" id="example">
<thead>
<tr><th>ID</th><th>Date</th><th>Time</th><th>Raja Rani Queen</th><th>Rajshree A</th><th>Rajshree B</th><th>Rajshree C</th><th>Actions</th></tr>
</thead>
<tbody>
<?php
$result = $conn->query("SELECT * FROM lottery_entries ORDER BY id DESC");
while ($row = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo date("d/m/Y", strtotime($row['entry_date'])); ?></td>
<td><?php echo $row['entry_time']; ?></td>
<td><?php echo $row['result_a']; ?></td>
<td><?php echo $row['result_b']; ?></td>
<td><?php echo $row['result_c']; ?></td>
<td><?php echo $row['result_d']; ?></td>
<td>
<button class="btn btn-danger delete-btn" data-id="<?php echo $row['id']; ?>">Delete</button>
</td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr><th>ID</th><th>Date</th><th>Time</th><th>Raja Rani Queen</th><th>Rajshree A</th><th>Rajshree B</th><th>Rajshree C</th><th>Actions</th></tr>
</tfoot>
</table>
</div>
</div>
<!-- / Content -->
<!-- Footer -->
<footer class="content-footer footer bg-footer-theme">
<div class="container-xxl d-flex flex-wrap justify-content-between py-2 flex-md-row flex-column">
<div class="mb-2 mb-md-0">
©
<script>
document.write(new Date().getFullYear());
</script>
, made with ❤️ by
<a href="#" target="_blank" class="footer-link fw-bolder">Made By Ajay Singh Rathore (+91 9031351333)</a>
</div>
<div>6j
<a href="#" class="footer-link me-4" target="_blank">Privacy Policy</a>
<a href="#" target="_blank" class="footer-link me-4">Terms & Condition</a>
</div>
</div>
</footer>
<!-- / Footer -->
<div class="content-backdrop fade"></div>
</div>
<!-- Content wrapper -->
</div>
<!-- / Layout page -->
</div>
<!-- Overlay -->
<div class="layout-overlay layout-menu-toggle"></div>
</div>
<!-- / Layout wrapper -->
<!-- Core JS -->
<!-- build:js assets/vendor/js/core.js -->
<script src="../backend/assets/vendor/libs/jquery/jquery.js"></script>
<script src="../backend/assets/vendor/libs/popper/popper.js"></script>
<script src="../backend/assets/vendor/js/bootstrap.js"></script>
<script src="../backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
<script src="../backend/assets/vendor/js/menu.js"></script>
<!-- endbuild -->
<!-- Vendors JS -->
<script src="../backend/assets/vendor/libs/apex-charts/apexcharts.js"></script>
<!-- Main JS -->
<script src="../backend/assets/js/main.js"></script>
<!-- Page JS -->
<script src="../backend/assets/js/dashboards-analytics.js"></script>
<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.datatables.net/2.2.1/js/dataTables.js"></script>
<script>
$(document).ready(function () {
// Load entries
$('#example').DataTable({
"order": [[0, "desc"]] // Sort by first column (ID) in descending order
});
// Delete
$('.delete-btn').click(function() {
var entryId = $(this).data('id'); // Get the entry ID
if (confirm("Are you sure you want to delete this entry?")) {
$.ajax({
url: 'delete_entry.php', // PHP file to handle deletion
type: 'POST',
data: { id: entryId },
success: function(response) {
if (response == 'success') {
alert("Entry deleted successfully!");
location.reload(); // Reload the page to update the table
} else {
alert("Failed to delete entry.");
}
},
error: function() {
alert("An error occurred. Please try again.");
}
});
}
});
});
</script>
</body>
</html>