<?php
    include('session.php');

    date_default_timezone_set('Asia/Singapore');
?>


<!DOCTYPE html>
<html lang="en" class="h-100">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, shrink-to-fit=9">
        <meta name="description" content="<?php echo $sitetitle ?>">
        <meta name="author" content="<?php echo $sitetitle ?>">
        <title><?php echo $sitetitle ?></title>
		
		<!-- Favicon Icon -->
        <link rel="icon" type="image/png" href="images/nkn-logo-horizontal.png">
		
        <!-- Stylesheets -->
        <?php include 'plugincss.php' ?>
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css">


	</head>

<body class="d-flex flex-column h-100">

        <!-- Create Coupon Model Start-->
        <div class="modal fade" id="AddRecords" tabindex="-1" aria-labelledby="AddRecordsLabel" aria-hidden="false">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="AddRecordsLabel">Competition Details</h5>
                        <button type="button" class="close-model-btn" data-bs-dismiss="modal" aria-label="Close"><i class="uil uil-multiply"></i></button>
                    </div>
                    <form class="form" method="post" action="">
                        <div class="modal-body">
                            <div class="model-content main-form">
                                <div class="row">
                                        <div class="model-content main-form">
                                            <div class="row">
                                                <div class="col-lg-12 col-md-12">
                                                    <div class="form-group mt-4">
                                                        <label class="form-label">Location</label>
                                                        <input class="form-control h_40" id="location" name="location" type="text">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <input type="hidden" name="action" id="action" value="saveRecord" />
                                    <button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-dismiss="modal"><i class="fa-solid fa-cancel me-3"></i>Close</button>
                                    <button type="submit" class="btn btn-success" id = "saveRecord" name = "saveRecord"><i class="fa-solid fa-save me-3"></i>Save</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    </div>
                    </div>



	<!-- Add Organisation Model End-->
	<!-- Header Start-->
	<header class="header">
        <?php include 'topmenu.php' ?>
	</header>
	<!-- Header End-->
	<!-- Left Sidebar Start -->
	<nav class="vertical_nav">
        <?php include 'sidemenu.php' ?>
	</nav>



	<!-- Left Sidebar End -->
	<!-- Body Start -->
	<div class="wrapper wrapper-body">
		<div class="dashboard-body">
			<div class="container-fluid">
				<div class="row">
					<div class="col-md-12">
						<div class="d-main-title">
							<h3><i class="fa-solid fa-trophy me-3"></i>Competition Records</h3>
						</div>
						<h1></h1>
					</div>
					
                        <div class="event-list">
                            <div class="tab-content">
                                <div class="tab-pane fade show active" id="orders-tab" role="tabpanel">
                                    <div class="table-card mt-4">
                                        <div class="main-table ps-3">
                                            <div class="table-responsive">
                                                <br>
                                                <table id="dataTable" class="table">
                                                    <thead class="thead-dark">
                                                        <tr>
                                                            <th scope="col" style="width: 5%;">#</th>
                                                            <th scope="col" style="width: 70%;">Title</th>
                                                            <th scope="col" style="width: 15%;">Closing Date</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php
                                                                $i=0;

                                                                $sql = "SELECT * FROM $tblcompetition";

                                                                   if($resultrec=mysqli_query($conn,$sql)){
                                                                        while ($rowrec=mysqli_fetch_array($resultrec)){
                                                                            $i=$i+1;
                                                                        
                                                                    ?>
                                                                        <tr>
                                                                            <td align = "left"><?php echo $i?></td>
                                                                            <td align = "left"><?php echo strtoupper($rowrec['Title']) ;?></td>
                                                                            <td align = "left"><?php echo date("d-m-Y", strtotime($rowrec['ClosingDate'])); ?></td>
                                                                           
                                                                            <td align ="left">
                                                                                <button type="button" id = "btnUpdate" name = "btnUpdate" class="btn btn-primary" onclick="window.open('competition-reg-records.php?id=<?php echo $rowrec['AutoIndex']; ?>', '_parent');"><i class="fa-regular fa-eye"></i></button>
                                                                                <button type="button" id = "btnUpdate" name = "btnUpdate" class="btn btn-danger"><i class="fa-regular fa-link"></i></button>
                                                                            </td>
                                                                            </tr>
                                                                    <?php
                                                                    }
                                                                       }

                                                                    ?>

                                                    </tbody>
                                                    <tfoot>
                                                        <tr>
                                                            <th scope="col" style="width: 5%;">#</th>
                                                            <th scope="col" style="width: 70%;">Title</th>
                                                            <th scope="col" style="width: 15%;">Closing Date</th>
                                                            <th scope="col" style="width: 10%;">Action</th>
                                                        </tr>
                                                    </tfoot>

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

                </div>
            </div>
        </div>
    </div>
	
    <div class="copyright-footer">
        <?php echo $copyrights ?>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Include DataTable JS -->
    <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
    <script>
        // Initialize DataTable
        $(document).ready(function() {
          $('#dataTable').DataTable({
                  "ordering": false,
                  "searching": true,
                  "lengthChange": false,
                  "pageLength": 10
              });
        });
    </script>
    
    <script>
        function filterCategory(){
            let category = document.getElementById("filtercat").value;
            window.location.href = "?category=" + encodeURIComponent(category);
        }
    </script>
    
    <script>
        function filterVerified(){
            let verified = document.getElementById("filterver").value;
            window.location.href = "?verified=" + encodeURIComponent(verified);
        }
    </script>

	<!-- Body End -->
    <?php include 'pluginjs.php' ?>

</body>
</html>
