[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: manage-programme-allocation.php
<?php error_reporting(0); include("../functions.php"); if(!isset($_SESSION['dbmail_Xw211qAAsq4'])){ header("location:../auth-login"); } else { $s_code = $_SESSION['s_code_Xw2119904']; $uname = $_SESSION['name_Xw2119904']; $stmt = $con->prepare("SELECT * FROM schools WHERE user_name = ? AND school_code = ?"); $stmt->execute(array($uname, $s_code)); $userstatus = $stmt->fetchAll(); // Initialize $namee to prevent potential errors $namee = null; foreach ($userstatus as $sta) { $namee = $sta['user_name']; $userid = $sta['id']; $school_name = $sta['school_name']; } $stmt = $con->prepare("Select * from schools where school_code = ?"); $stmt->execute(array($s_code)); $row = $stmt->fetch(); $logo = $row['logo']; if(empty($logo)){ header("Location:complete-process"); } else { $message = ""; if (isset($_POST['assignclass'])) { $classIDs = $_POST['classID']; // Get the selected class IDs from the form $indexNumbers = $_POST['indexNo']; // Get the index numbers from the hidden input fields // Debugging: Check the values retrieved from the form // echo "<pre>"; // print_r($_POST); // echo "</pre>"; // Loop through the selected class IDs and corresponding index numbers foreach ($classIDs as $key => $classID) { if (!empty($classID)) { $indexNo = $indexNumbers[$key]; // Get the corresponding index number $updateQuery = mysqli_query($new,"UPDATE enrol_details SET class_id = '$classID' WHERE index_no = '$indexNo'"); echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Success!', text: 'Class assign Successfully', icon: 'success', confirmButtonText: 'OK' }); }); </script>"; } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Admission setup | Admission setup </title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="eliosof" name="author" /> <!-- App favicon --> <!-- <link rel="shortcut icon" href="assets/images/favicon.ico"> --> <!-- preloader css --> <link rel="stylesheet" href="assets/css/preloader.min.css" type="text/css" /> <!-- Bootstrap Css --> <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" /> <!-- Icons Css --> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <!-- App Css--> <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" /> <link href="assets/libs/sweetalert2/sweetalert2.min.css" rel="stylesheet" type="text/css" /> </head> <body> <!-- <body data-layout="horizontal"> --> <!-- Begin page --> <div id="layout-wrapper"> <?php include("includes/header.php");?> <?php include("includes/sidebar.php");?> <div class="main-content"> <div class="page-content"> <div class="container-fluid"> <!-- start page title --> <div class="row"> <div class="col-12"> <div class="page-title-box d-sm-flex align-items-center justify-content-between"> <h4 class="mb-sm-0 font-size-18">ASSIGN PROGRAMME TO STUDENT</h4> <div class="page-title-right"> <ol class="breadcrumb m-0"> <li class="breadcrumb-item"><a href="javascript: void(0);">Home</a></li> <li class="breadcrumb-item active">PROGRAMME ALLOCATION</li> </ol> </div> </div> </div> </div> <!-- end page title --> <div class="row"> </div> <div class="col-xl-12"> <div class="card-body"> <div class="table-responsive"> <div class="mb-3"> <input type="text" id="tableSearch" class="form-control" placeholder="Search by name, index number, or class..."> </div> <table id="studentTable" class="table table-bordered mb-0 borded"> <thead> <tr> <th>#</th> <th>Student</th> <th>Student ID</th> <th>Class</th> <th>Programme</th> <th>Action</th> </tr> </thead> <tbody> <form method="POST"> <?php // Fetch classes $classname = []; $hres = mysqli_query($new, "SELECT cid, class_name FROM class WHERE s_code = '$s_code' ORDER BY class_name"); if ($hres) { while ($hrow = mysqli_fetch_assoc($hres)) { $classname[] = $hrow; } } // Fetch students $does = mysqli_query($new, "SELECT index_no, student_name, class_id,unique_student_code FROM enrol_details WHERE s_code = '$s_code' ORDER BY id DESC"); if (!$does) { die("Query failed: " . mysqli_error($new)); } $cnt = 1; while ($getInfo = mysqli_fetch_array($does)) { $ciss = $getInfo['class_id']; ?> <tr id="row-<?php echo $getInfo['index_no']; ?>"> <th><?php echo $cnt++; ?></th> <td><?php echo htmlspecialchars($getInfo['student_name']); ?></td> <td><?php echo htmlspecialchars($getInfo['unique_student_code']); ?></td> <td class="housename"> <?php $getresident = mysqli_query($new, "SELECT class_name FROM class WHERE cid = '$ciss' AND s_code = '$s_code'"); $className = 'Not Assigned'; if ($getresident && mysqli_num_rows($getresident) > 0) { $seall = mysqli_fetch_assoc($getresident); $className = $seall['class_name']; } echo htmlspecialchars($className); ?> </td> <td class="housename"> <?php $getresident = mysqli_query($new, "SELECT class_name FROM class WHERE cid = '$ciss' AND s_code = '$s_code'"); $className = 'Not Assigned'; if ($getresident && mysqli_num_rows($getresident) > 0) { $seall = mysqli_fetch_assoc($getresident); $className = $seall['class_name']; } echo htmlspecialchars($className); ?> </td> <td> <button type="button" class="btn btn-sm btn-primary edit-class-btn" data-index="<?php echo htmlspecialchars($getInfo['index_no']); ?>" data-student="<?php echo htmlspecialchars($getInfo['student_name']); ?>" data-class="<?php echo (int)$getInfo['class_id']; ?>" >Edit</button> </td> </tr> <?php } ?> </form> </tbody> </table> <script> // 🔍 Live search functionality document.getElementById('tableSearch').addEventListener('keyup', function() { const filter = this.value.toLowerCase(); const rows = document.querySelectorAll('#studentTable tbody tr'); let visibleCount = 0; rows.forEach(row => { const name = row.cells[1].textContent.toLowerCase(); const index = row.cells[2].textContent.toLowerCase(); const currentClass = row.cells[3].textContent.toLowerCase(); if (name.includes(filter) || index.includes(filter) || currentClass.includes(filter)) { row.style.display = ''; visibleCount++; } else { row.style.display = 'none'; } }); }); </script> <script> const HOUSES = <?php echo json_encode($classname, JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS|JSON_HEX_QUOT); ?>; const S_CODE = <?php echo json_encode($s_code); ?>; </script> <!-- Edit Class Modal --> <div class="modal fade" id="editClassModal" tabindex="-1" aria-hidden="true"> <div class="modal-dialog"> <form id="editClassForm"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Change programme of <span id="modalStudentName"></span></h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <input type="hidden" id="modalIndexNo" name="index_no"> <div class="mb-3"> <label for="modalClassSelect" class="form-label">Choose Class</label> <select id="modalClassSelect" name="class_id" class="form-control" required> <option value="0">-- SELECT CLASS --</option> </select> </div> <div class="mb-3"> <label for="modalClassSelect" class="form-label">Choose programme</label> <select id="modalClassSelect" name="progid" class="form-control" required> <option value="0">-- SELECT PROGRAMME --</option> <?php $getpro = mysqli_query($new,"SELECT program_name,progid FROM programme WHERE s_code = '$s_code'"); while($fetchall = mysqli_fetch_array($getpro)){?> <option value="<?php echo $fetchall['progid'];?>"><?php echo $fetchall['program_name'];?></option> <?php }?> </select> </div> <div id="modalAlert" style="display:none;" class="alert"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary">Save changes</button> </div> </div> </form> </div> </div> <script> document.addEventListener("DOMContentLoaded", function () { const searchInput = document.getElementById("tableSearch"); const rows = Array.from(document.querySelectorAll("#studentTable tbody tr")); // Cache row text once to avoid expensive DOM reads on every search const rowTextCache = rows.map(row => row.innerText.toLowerCase()); let timeout; searchInput.addEventListener("keyup", function () { clearTimeout(timeout); timeout = setTimeout(() => { const filter = this.value.toLowerCase(); rows.forEach((row, index) => { row.style.display = rowTextCache[index].includes(filter) ? "" : "none"; }); }, 200); // 200ms debounce }); }); </script> <script> document.addEventListener('DOMContentLoaded', function() { function buildClassOptions(selectedId) { let html = '<option value="0">-- SELECT CLASS --</option>'; for (const h of HOUSES) { const sel = (parseInt(h.cid) === parseInt(selectedId)) ? ' selected' : ''; html += `<option value="${h.cid}"${sel}>${h.class_name}</option>`; } return html; } // open modal when Edit clicked document.querySelectorAll('.edit-class-btn').forEach(btn => { btn.addEventListener('click', function() { const index = this.dataset.index; const student = this.dataset.student; const classId = this.dataset.class || 0; document.getElementById('modalStudentName').textContent = student; document.getElementById('modalIndexNo').value = index; document.getElementById('modalClassSelect').innerHTML = buildClassOptions(classId); document.getElementById('modalAlert').style.display = 'none'; const editModal = new bootstrap.Modal(document.getElementById('editClassModal')); editModal.show(); }); }); // handle submit document.getElementById('editClassForm').addEventListener('submit', function(e) { e.preventDefault(); const index_no = document.getElementById('modalIndexNo').value; const class_id = document.getElementById('modalClassSelect').value; const alert = document.getElementById('modalAlert'); if (!index_no || !class_id || parseInt(class_id) === 0) { alert.className = 'alert alert-warning'; alert.innerText = 'Please select a valid class.'; alert.style.display = 'block'; return; } fetch('update_class.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ index_no, class_id, s_code: S_CODE }) }) .then(r => r.json()) .then(resp => { if (resp.success) { const row = document.querySelector(`#row-${CSS.escape(index_no)}`); if (row) { const cell = row.querySelector('.housename'); if (cell) cell.textContent = resp.class_name; } alert.className = 'alert alert-success'; alert.innerText = resp.message; alert.style.display = 'block'; setTimeout(() => { const editModalEl = document.getElementById('editClassModal'); const modal = bootstrap.Modal.getInstance(editModalEl); modal.hide(); }, 700); } else { alert.className = 'alert alert-danger'; alert.innerText = resp.message || 'Update failed.'; alert.style.display = 'block'; } }) .catch(err => { alert.className = 'alert alert-danger'; alert.innerText = 'Request error: ' + err.message; alert.style.display = 'block'; }); }); }); </script> </div> </div> </div> <!-- End Page-content --> <?php include("includes/footer.php");?> </div> <!-- end main content--> </div> <!-- END layout-wrapper --> <!-- Right Sidebar --> <div class="right-bar"> <div data-simplebar class="h-100"> <div class="rightbar-title d-flex align-items-center p-3"> <h5 class="m-0 me-2">Theme Customizer</h5> <a href="javascript:void(0);" class="right-bar-toggle ms-auto"> <i class="mdi mdi-close noti-icon"></i> </a> </div> <!-- Settings --> <hr class="m-0" /> <div class="p-4"> <h6 class="mb-3">Layout</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout" id="layout-vertical" value="vertical"> <label class="form-check-label" for="layout-vertical">Vertical</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout" id="layout-horizontal" value="horizontal"> <label class="form-check-label" for="layout-horizontal">Horizontal</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Mode</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-mode" id="layout-mode-light" value="light"> <label class="form-check-label" for="layout-mode-light">Light</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-mode" id="layout-mode-dark" value="dark"> <label class="form-check-label" for="layout-mode-dark">Dark</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Width</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-width" id="layout-width-fuild" value="fuild" onchange="document.body.setAttribute('data-layout-size', 'fluid')"> <label class="form-check-label" for="layout-width-fuild">Fluid</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-width" id="layout-width-boxed" value="boxed" onchange="document.body.setAttribute('data-layout-size', 'boxed')"> <label class="form-check-label" for="layout-width-boxed">Boxed</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Position</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-position" id="layout-position-fixed" value="fixed" onchange="document.body.setAttribute('data-layout-scrollable', 'false')"> <label class="form-check-label" for="layout-position-fixed">Fixed</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-position" id="layout-position-scrollable" value="scrollable" onchange="document.body.setAttribute('data-layout-scrollable', 'true')"> <label class="form-check-label" for="layout-position-scrollable">Scrollable</label> </div> <h6 class="mt-4 mb-3 pt-2">Topbar Color</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="topbar-color" id="topbar-color-light" value="light" onchange="document.body.setAttribute('data-topbar', 'light')"> <label class="form-check-label" for="topbar-color-light">Light</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="topbar-color" id="topbar-color-dark" value="dark" onchange="document.body.setAttribute('data-topbar', 'dark')"> <label class="form-check-label" for="topbar-color-dark">Dark</label> </div> <h6 class="mt-4 mb-3 pt-2 sidebar-setting">Sidebar Size</h6> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-default" value="default" onchange="document.body.setAttribute('data-sidebar-size', 'lg')"> <label class="form-check-label" for="sidebar-size-default">Default</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-compact" value="compact" onchange="document.body.setAttribute('data-sidebar-size', 'md')"> <label class="form-check-label" for="sidebar-size-compact">Compact</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-small" value="small" onchange="document.body.setAttribute('data-sidebar-size', 'sm')"> <label class="form-check-label" for="sidebar-size-small">Small (Icon View)</label> </div> <h6 class="mt-4 mb-3 pt-2 sidebar-setting">Sidebar Color</h6> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-light" value="light" onchange="document.body.setAttribute('data-sidebar', 'light')"> <label class="form-check-label" for="sidebar-color-light">Light</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-dark" value="dark" onchange="document.body.setAttribute('data-sidebar', 'dark')"> <label class="form-check-label" for="sidebar-color-dark">Dark</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-brand" value="brand" onchange="document.body.setAttribute('data-sidebar', 'brand')"> <label class="form-check-label" for="sidebar-color-brand">Brand</label> </div> <h6 class="mt-4 mb-3 pt-2">Direction</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-direction" id="layout-direction-ltr" value="ltr"> <label class="form-check-label" for="layout-direction-ltr">LTR</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-direction" id="layout-direction-rtl" value="rtl"> <label class="form-check-label" for="layout-direction-rtl">RTL</label> </div> </div> </div> <!-- end slimscroll-menu--> </div> <!-- /Right-bar --> <!-- Right bar overlay--> <div class="rightbar-overlay"></div> <!-- JAVASCRIPT --> <script src="assets/libs/jquery/jquery.min.js"></script> <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="assets/libs/metismenu/metisMenu.min.js"></script> <script src="assets/libs/simplebar/simplebar.min.js"></script> <script src="assets/libs/node-waves/waves.min.js"></script> <script src="assets/libs/feather-icons/feather.min.js"></script> <!-- pace js --> <script src="assets/libs/pace-js/pace.min.js"></script> <script src="assets/libs/sweetalert2/sweetalert2.min.js"></script> <script src="assets/js/app.js"></script> </body> </html> <?php } }?>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.75 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002