[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: all-payment.php
<?php include("../functions.php"); if(!isset($_SESSION['thisadmin_Xw211qAAsq4'])){ header("location: login"); } else { if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['addpay'])){ if(!csrf_token_is_valid() || !csrf_token_is_recent()) { $message = "<p class='btn btn-danger'>Sorry, Token Authentication invalid.</p>"; } else { $student = test_input($_POST['student']); $amount = test_input($_POST['amount']); $school = test_input($_POST['school']); $accesscode = test_input($_POST['accesscode']); if(!empty($student)){ $select = mysqli_query($new,"SELECT * FROM stud_payment WHERE indexNumber = '$student'"); if(mysqli_num_rows($select) > 0){ echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Error!', text: 'The student with the selected index number already exist.', icon: 'error', confirmButtonText: 'OK' }); }); </script>"; } else { $timestamp = date("YmdHis"); // Generate a random string for uniqueness $randomString = bin2hex(random_bytes(4)); // Generates 8-character random string // Combine timestamp and random string to create transaction ID $transactionId = "OFF" . $timestamp . $randomString; $date = date("Y-m-d H:i:s"); $priority = 0; $pstatus = "paid"; $stmt = $con->prepare("insert into stud_payment (s_code,indexNumber,amount,pstatus,datepaid,transaction_id,access_code) values(?,?,?,?,?,?,?) "); $stmt->execute(array($school,$student,$amount,$pstatus,$date,$transactionId,$accesscode)); $update = mysqli_query( $new, "UPDATE enrol_generic SET access = '$accesscode' WHERE indexNo = '$student' AND s_code = '$school'" ); echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Success!', text: 'Payment recorded successfully.', icon: 'success', confirmButtonText: 'OK' }); }); </script>"; } } } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Payment | All Payment</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="Premium Multipurpose Admin & Dashboard Template" name="description" /> <meta content="Themesbrand" name="author" /> <!-- App favicon --> <!-- DataTables --> <link href="assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <link href="assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- Responsive datatable examples --> <link href="assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- 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" /> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet" /> <!-- Include Select2 JS --> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script> <style> td { white-space: nowrap; /* Prevents text from wrapping to a new line */ overflow: hidden; /* Hides overflow text */ text-overflow: ellipsis; /* Displays ellipsis (...) for overflowing text */ max-width: 150px; /* Sets the maximum width of the cell */ } td { word-wrap: break-word; /* Allows words to break and wrap to the next line */ max-width: 150px; /* Sets the maximum width of the cell */ } </style> <style> /* Simple spinner styles */ #loadingSpinner { display: flex; justify-content: center; align-items: center; height: 120px; font-size: 1.2rem; font-weight: bold; } .spinner { width: 30px; height: 30px; border: 4px solid #ddd; border-top: 4px solid #007bff; border-radius: 50%; animation: spin 1s linear infinite; margin-right: 10px; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style> </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">payment</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">payment</li> </ol> </div> </div> </div> </div> <!-- end page title --> <div class="row"> <div class="col-12"> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-header"> <button type="button" class="btn btn-primary waves-effect waves-light" data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg">Add new payment</button> </div> <div class="card-body"> <?php // Configuration $per_page = 100; $page = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0 ? (int)$_GET['page'] : 1; $offset = ($page - 1) * $per_page; $search = isset($_GET['q']) ? trim($_GET['q']) : ''; // Base query parts $where_sql = ''; if ($search !== '') { $s = mysqli_real_escape_string($new, $search); $where_sql = " AND (enrol_generic.stud_name LIKE '%$s%' OR stud_payment.indexNumber LIKE '%$s%')"; } $count_sql = " SELECT COUNT(*) AS total_count FROM stud_payment JOIN enrol_generic ON stud_payment.indexNumber = enrol_generic.indexNo WHERE 1 $where_sql "; $count_res = mysqli_query($new, $count_sql); $total_rows = ($count_res && $r = mysqli_fetch_assoc($count_res)) ? (int)$r['total_count'] : 0; $total_pages = max(1, ceil($total_rows / $per_page)); $total_sql = " SELECT SUM(amount) AS grand_total FROM stud_payment JOIN enrol_generic ON stud_payment.indexNumber = enrol_generic.indexNo WHERE 1 $where_sql "; $total_res = mysqli_query($new, $total_sql); $grand_total = ($total_res && $r = mysqli_fetch_assoc($total_res)) ? (float)$r['grand_total'] : 0; $schools = []; $getschools = mysqli_query($new, "SELECT school_code, school_name FROM schools"); while ($sch = mysqli_fetch_assoc($getschools)) { $schools[$sch['school_code']] = $sch['school_name']; } $sql = " SELECT stud_payment.*, enrol_generic.stud_name, enrol_generic.indexNo FROM stud_payment JOIN enrol_generic ON stud_payment.indexNumber = enrol_generic.indexNo WHERE 1 $where_sql ORDER BY stud_payment.pid DESC LIMIT $offset, $per_page "; $res = mysqli_query($new, $sql); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Student Payments</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body class="bg-light"> <div class="container py-4"> <h3 class="text-center mb-4">💳 Student Payment Records</h3> <!-- Search Form --> <form class="row g-2 mb-3"> <div class="col-auto"> <input type="text" name="q" value="<?= htmlspecialchars($search) ?>" class="form-control" placeholder="Search by name or index..."> </div> <div class="col-auto"> <button class="btn btn-primary">Search</button> </div> </form> <!-- Table --> <div class="table-responsive"> <table class="table table-bordered table-striped align-middle"> <thead class="table-dark"> <tr> <th>#</th> <th>Student Name</th> <th>School Name</th> <th>Index Number</th> <th>Access Code</th> <th>Amount (GHS)</th> <th>Date Paid</th> </tr> </thead> <tbody> <?php if ($res && mysqli_num_rows($res) > 0) { $i = $offset + 1; while ($row = mysqli_fetch_assoc($res)) { $schoolName = $schools[$row['s_code']] ?? ''; $amount = (float)$row['amount']; echo "<tr> <td>{$i}</td> <td>".htmlspecialchars($row['stud_name'])."</td> <td>".htmlspecialchars($schoolName)."</td> <td>".htmlspecialchars($row['indexNumber'])."</td> <td>".htmlspecialchars($row['access_code'])."</td> <td>".number_format($amount, 2)."</td> <td>".htmlspecialchars($row['datepaid'])."</td> </tr>"; $i++; } } else { echo '<tr><td colspan="7" class="text-center text-muted">No records found.</td></tr>'; } ?> </tbody> <tfoot class="fw-bold"> <tr> <td colspan="5" class="text-end">GRAND TOTAL:</td> <td><?= number_format($grand_total, 2) ?></td> <td></td> </tr> </tfoot> </table> </div> <!-- Pagination --> <nav> <ul class="pagination justify-content-center"> <?php $baseUrl = strtok($_SERVER["REQUEST_URI"], '?'); $prev = max(1, $page - 1); $next = min($total_pages, $page + 1); echo '<li class="page-item'.($page == 1 ? ' disabled' : '').'"> <a class="page-link" href="?page='.$prev.'&q='.urlencode($search).'">Prev</a> </li>'; $start = max(1, $page - 3); $end = min($total_pages, $page + 3); for ($p = $start; $p <= $end; $p++) { echo '<li class="page-item'.($p == $page ? ' active' : '').'"> <a class="page-link" href="?page='.$p.'&q='.urlencode($search).'">'.$p.'</a> </li>'; } echo '<li class="page-item'.($page == $total_pages ? ' disabled' : '').'"> <a class="page-link" href="?page='.$next.'&q='.urlencode($search).'">Next</a> </li>'; ?> </ul> </nav> <p class="text-center text-muted"> Showing page <?= $page ?> of <?= $total_pages ?> — total records <?= number_format($total_rows) ?>. </p> </div> </body> </html> </div> </div> <!-- end cardaa --> </div> <!-- end col --> </div> <!-- end row --> </div> <!-- container-fluid --> </div> <!-- End Page-content --> <?php include("includes/footer.php");?> </div> <!-- end main content--> </div> <!-- END layout-wrapper --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="myLargeModalLabel">Add new payment</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <!-- Centering the form and limiting its width --> <div class="container"> <div class="row justify-content-center"> <div class="col-md-8 col-lg-6"> <!-- Adjust the column size as needed --> <form method="POST" class="needs-validation mt-4 pt-2" novalidate> <?php echo csrf_token_tag(); ?> <div class="mb-3"> <label for="school-select" class="form-label">School name</label> <select class="form-control select2" id="school-select" name="school" required> <option value="">Select School</option> <?php $select_program = mysqli_query($new,"SELECT DISTINCT school_code, school_name FROM schools ORDER BY school_name ASC"); while ($prog = mysqli_fetch_array($select_program)) { $schoolName = htmlspecialchars(html_entity_decode($prog['school_name'], ENT_QUOTES, 'UTF-8')); echo '<option value="'.htmlspecialchars($prog['school_code']).'">'.$schoolName.'</option>'; } ?> </select> </div> <div class="mb-3"> <label for="student-index" class="form-label">Student index number</label> <input type="text" id="student-search" placeholder="Search student index..." style="width:100%;padding:6px;margin-bottom:5px;"> </select> </div> <div class="mb-3"> <label for="student-index" class="form-label">Student index number</label> <select class="form-control select2" id="student-index" name="student" required> <option value="">--Select Student Index--</option> </select> </div> <div class="mb-3"> <label for="exampleInputPassword1" class="form-label">Access code</label> <input type="text" name="accesscode" class="form-control" required> </select> </div> <div class="mb-3"> <label for="exampleInputPassword1" class="form-label">Amount</label> <input type="number" class="form-control" name="amount" value="30" readonly> </div> <button type="submit" name="addpay" class="btn btn-primary">Submit</button> </form> </div> </div> </div> </div> </div> </div> </div> <script> $(document).ready(function () { $('#school-select').on('change', function () { var schoolId = $(this).val(); // Clear previous student index options $('#student-index').html('<option value="">--Select Student Index--</option>'); $('#student-search').val(''); // Clear search box if (schoolId) { // Make AJAX request to get student index numbers $.ajax({ url: 'get_student_indices.php', // Backend URL to fetch student indices type: 'POST', data: { school_id: schoolId }, success: function (data) { try { var students = JSON.parse(data); // Parse the JSON response if (students.length === 0) { alert('No students found for the selected school.'); } else { $.each(students, function (key, value) { $('#student-index').append('<option value="' + key + '">' + value + '</option>'); }); } } catch (error) { alert('Error parsing student data: ' + error); } }, error: function (jqXHR, textStatus, errorThrown) { alert('AJAX error: ' + textStatus + ' - ' + errorThrown); } }); } }); // LIVE SEARCH functionality $('#student-search').on('keyup', function () { var searchTerm = $(this).val().toLowerCase(); $('#student-index option').each(function () { var text = $(this).text().toLowerCase(); if (text.indexOf(searchTerm) > -1 || $(this).val() === '') { $(this).show(); } else { $(this).hide(); } }); }); }); </script> <!-- 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> </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> <!-- Required datatable js --> <script src="assets/libs/datatables.net/js/jquery.dataTables.min.js"></script> <script src="assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script> <!-- Buttons examples --> <script src="assets/libs/datatables.net-buttons/js/dataTables.buttons.min.js"></script> <script src="assets/libs/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js"></script> <script src="assets/libs/jszip/jszip.min.js"></script> <script src="assets/libs/pdfmake/build/pdfmake.min.js"></script> <script src="assets/libs/pdfmake/build/vfs_fonts.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.html5.min.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.print.min.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.colVis.min.js"></script> <!-- Responsive examples --> <script src="assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script> <script src="assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script> <script src="assets/libs/sweetalert2/sweetalert2.min.js"></script> <!-- Datatable init js --> <script src="assets/js/pages/datatables.init.js"></script> <script src="assets/js/app.js"></script> <script src="assets/js/pages/validation.init.js"></script> <script src="assets/js/pages/modal.init.js"></script> <script> var myModal = document.getElementById('myModal') var myInput = document.getElementById('myInput') myModal.addEventListener('shown.bs.modal', function () { myInput.focus() }) </script> </body> </html>
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.81 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