JezK
Edit File: transport_management.php
<?php session_start(); include("menuheader.php"); if (!(in_array(5, $access) && in_array(5, $allow))) echo "<script>location.replace('dashboard.php');</script>"; include_once("school_admin_access_file.php"); $fun = new adminaccess(); $school_id = $_SESSION['child']['log_school_id']; //school_id $academic_id = $_SESSION['child']['choosen_academic_id']; // academic_year_id $user_id = $_SESSION['child']['auth_id']; //user_id $details = $fun->get_classes($school_id, $academic_id); $routes = $fun->school_students_routes($school_id, $academic_id); //$exam_names=$fun->exam_name_details($school_id,$academic_id); if (isset($_GET['route_id'])) { $school_routes_info = $fun->school_students_routes_info($_GET['route_id'], $academic_id); $staff_routes_inf = $fun->staff_routes_info($_GET['route_id'], $school_id, $academic_id); } if ($routes) { foreach ($routes as $row) { if ($_GET['route_id'] == $row['route_id']) { $routes_info .= "<option value='{$row['route_id']}' selected>{$row['route_name']}</option>"; } else { $routes_info .= "<option value='{$row['route_id']}' >{$row['route_name']}</option>"; } } } ?> <style> select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } .table-condensed>thead>tr>th, .table-condensed>tbody>tr>th, .table-condensed>tfoot>tr>th, .table-condensed>thead>tr>td, .table-condensed>tbody>tr>td, .table-condensed>tfoot>tr>td { padding: 3px; } </style> <body style="overflow-x: hidden;"> <div class="row " style="margin-top: 30px; "> <div class="d-md-flex justify-content-between"> <div class=" text-start" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px;"> <img src="images/transport-black.png" title=" Transport Management" style="margin: -6px 0px 0px 20px;" /> Transport Management </div> <div class=" "> <button type="button" onClick="location.href='trip_history.php'" class="btn btn-outline-secondary mx-3" style="font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Trip history</button> <button type="button" onClick="location.href='add_studenttoroute.php'" class="btn btn-outline-secondary mx-3" style="font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Add Students to Route </button> </div> </div> </div> <form class="form-horizontal"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; margin-top:20px;"> <div class="clearfix"> <div class="form-group row col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-md-end"> <b style="color:#666666; ">Select Route</b> <span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="routes" style="height:29px; font-size:12px; width:215px !important;" tabindex="1"> <option value='0' selected>--Select Route--</option> <?php echo $routes_info; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_route" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> </div> <div class="col-md-12 mx-3 "> <span style=" font-family:Arial, Helvetica, sans-serif;font-size:18px;font-style:normal; font-weight:bold;"> Students Info</span> </div> <div class="row mx-3" style="margin-left:10px;margin-right:10px;"> <div class="col-md-12 centered" style="font-family: Arial, Helvetica, sans-serif;"> <table id="myTable" class="table table-condensed table-hover" style="margin-top:-10px;"> <thead> <tr class="info"> <th class="col-md-1 text-center">Student Roll No</th> <th>Student Name</th> <th>Class</th> <th>Section</th> <th>Pickup/Drop</th> <th>Actions</th> </tr> </thead> <tbody> <?php if ($school_routes_info) { $i = 0; foreach ($school_routes_info as $value) { $i++; ?> <tr> <td class="col-sm-1 text-center" style=" font-size:14px;"><?= $i ?></td> <td style="font-size:14px;"><?= $value['student_name'] ?></td> <td style="font-size:14px;"><?= $value['class_name'] ?></td> <td style="font-size:14px;"><?= $value['section_name'] ?></td> <td style="font-size:14px;"><?= $value['route_stop_name'] ?></td> <td class="center"> <a class=" buttonn" href="edit_studentroute.php?student_id=<?= $value['student_id'] ?>&class_name=<?= $value['class_name'] ?>§ion_name=<?= $value['section_name'] ?>&student_name=<?= $value['student_name'] ?>&route_id=<?= $_GET['route_id'] ?>&stpid=<?= $value['route_stop_id'] ?>&refid=<?= $value['student_route_id'] ?>" style="margin:4px;"> <i class="fa-solid fa-pencil" title="Edit" style="font-size: 14px; color:#01aee6;"></i> </a> <a class=" buttonn" href="javascript:void(0)" style="margin:4px;" onclick="return delete_route(<?php echo $value['student_route_id']; ?>);"> <i class="fa-solid fa-xmark" title="Delete" style="font-size: 14px; color:#01aee6;"></i> </a> </td> </tr> <?php } } ?> </tbody> </table> </div> </div> </form> <div class="d-md-flex justify-content-between mt-4"> <div class="col-md-9 mx-3"> <span style=" font-family:Arial, Helvetica, sans-serif;font-size:18px;font-style:normal; font-weight:bold;"> Staff Info</span> </div> <div class="col-md-3 text-center"> <button type="button" onClick="location.href='add_stafftoroute.php'" class="btn btn-outline-secondary" style="margin-bottom:6%;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Add Staff to Route </button> </div> </div> <div class="row" style="margin-left:10px;margin-right:10px;"> <div class="col-md-12 centered" style="font-family: Arial, Helvetica, sans-serif;"> <table id="myTable1" class="table table-condensed table-hover" style="margin-top:-10px;"> <thead> <tr class="info"> <th class="col-md-1 text-center">Staff Id</th> <th>Staff Name</th> <th>Staff Address</th> <th>Staff Phone Number</th> <th>Staff Type</th> <th>Actions</th> </tr> </thead> <tbody> <?php if ($staff_routes_inf) { $i = 0; foreach ($staff_routes_inf as $value) { $i++; ?> <tr> <td class="col-sm-1 text-center" style=" font-size:14px;"><?= $i ?></td> <td style=" font-size:14px;"><?= $value['staff_name'] ?></td> <td style=" font-size:14px;"><?= $value['staff_address'] ?></td> <td style="font-size:14px;"><?= $value['staff_mobile'] ?></td> <td style="font-size:14px;"><?= $value['staff_type'] ?></td> <td class="center"> <a class=" buttonn" style="margin:4px;" href="edit_staffroute.php?stfrid=<?= $value['staff_route_id'] ?>"> <i class="fa-solid fa-pencil" title="Edit" style="font-size: 14px; color:#01aee6;"></i> </a> <a class="buttonn" href="javascript:void(0)" style="margin:4px;" onclick="return delete_staff_route(<?= $value['staff_route_id'] ?>);"> <i class="fa-solid fa-xmark" title="Delete" style="font-size: 14px; color:#01aee6;"></i> </a> </td> </tr> <?php } } ?> </tbody> </table> </div> </div> <script src="//code.jquery.com/jquery-1.12.0.min.js"></script> <script src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.1.2/js/dataTables.buttons.min.js"></script> <script src="//cdn.datatables.net/buttons/1.1.2/js/buttons.print.min.js"></script> <script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script> <script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script> <script src="//cdn.datatables.net/buttons/1.1.2/js/buttons.html5.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> <script type="text/javascript"> $(document).ready(function() { /* $('#myTable').DataTable({ "pageLength":100, stateSave: true, dom: 'T<"clear">lfrtip', "oLanguage": { "sSearch": "" }, tableTools: { "aButtons": [ { "sExtends": "xls", "mColumns": [0, 1, 2, 3, 4] }, { "sExtends": "pdf", "sPdfOrientation": "landscape", "mColumns": [0, 1, 2, 3, 4] }, { "sExtends": "print", "mColumns": [0, 1, 2, 3, 4] } ] } }); $('div.dataTables_filter input').attr('placeholder', 'Search'); */ var rts = $('#routes').find('option:selected').text(); $('#myTable').DataTable({ dom: 'B<"clear">lfrtip', "iDisplayLength": 100, stateSave: true, buttons: [{ extend: 'print', title: '<center><h3><?php echo $_SESSION['child']['school_name'] ?></h3></center>', message: 'Transport Management- Student Info<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name] ?>   Route:' + rts + '<br>', exportOptions: { columns: [0, 1, 2, 3, 4] } }, { extend: 'pdfHtml5', title: '<?php echo $_SESSION['child']['school_name'] ?>', message: 'Transport Management- Student Info\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name] ?>\t Route:' + rts + '\n', exportOptions: { columns: [0, 1, 2, 3, 4] } }, { extend: 'excelHtml5', title: '<?php echo $_SESSION['child']['school_name'] ?>', exportOptions: { columns: [0, 1, 2, 3, 4] } } ] }); $("#routes").change(function() { var route = $("#routes").val(); $("#err_route").text(""); if (route == 0) { $("#err_route").text("Please select Route"); $("#err_route").show(); return false; } else window.location.href = "transport_management.php?route_id=" + route; }); }); function delete_route(student_id) { if (confirm('Do you want to delete the Student from the Route ?')) $.ajax({ url: "ajaxcalls_app.php", type: "POST", data: "mode=" + "delete_student_route" + "&student_id=" + student_id, success: function(result) { //alert(result); if (result == 1) { //alert("Student Deleted From the Route"); location.reload(); } else { alert("Student not Deleted From the Route"); } }, error: function(e) { } }); } function delete_staff_route(stff) { if (confirm('Do you want to delete the Staff from the Route ?')) $.ajax({ url: "ajaxcalls_app.php", type: "POST", data: "mode=" + "delete_stf_route" + "&stf_id=" + stff, success: function(result) { //alert(result); if (result == 1) { //alert("Student Deleted From the Route"); location.reload(); } else { alert("Staff not Deleted From the Route"); } }, error: function(e) { } }); } </script> <script> $(document).ready(function() { var rts = $('#routes').find('option:selected').text(); $('#myTable1').DataTable({ dom: 'B<"clear">lfrtip', "iDisplayLength": 100, stateSave: true, buttons: [{ extend: 'print', title: '<center><h3><?php echo $_SESSION['child']['school_name'] ?></h3></center>', message: 'Transport Management- Staff Info<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name] ?>   Route:' + rts + '<br>', exportOptions: { columns: [0, 1, 2, 3, 4] } }, { extend: 'pdfHtml5', title: '<?php echo $_SESSION['child']['school_name'] ?>', message: 'Transport Management- Staff Info\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name] ?>\t Route:' + rts + '\n', exportOptions: { columns: [0, 1, 2, 3, 4] } }, { extend: 'excelHtml5', title: '<?php echo $_SESSION['child']['school_name'] ?>', exportOptions: { columns: [0, 1, 2, 3, 4] } } ] }); }); </script> </body> </html>