JezK
Edit File: teacher_management.php
<?php if (session_id() == '') { session_start(); } include("session_check.php"); include('adm_operations.php'); include("header.php"); $operations = new adm_operations(); include('school_timeout.php'); if (isset($_GET['staff_id']) && $_GET['act_sts'] != '') { $result = $operations->deactivate_teacher_in_School($_GET['staff_id'], $_GET['act_sts']); echo "<script>location.replace('teacher_management.php');</script>"; } if (isset($_GET['staff_id']) && $_GET['act'] == 'delete') { $result = $operations->remove_teacher_from_School($_GET['staff_id'], $_SESSION['child']['choosen_academic_id'], $_GET['ref']); if ($result == 'cannot') echo "<script>alert('You can not delete it as there is data associated with this Teacher')</script>"; else echo "<script>location.replace('teacher_management.php');</script>"; } $myteachers = $operations->getallmyschoolteachers($_SESSION['child']['log_school_id'], $_SESSION['child']['choosen_academic_id']); // print_r($myteachers);exit; $i = 1; ?> <style> select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } .red { color: #ff0000 !important; font-size: 12px; background: none; } .green { color: #0F9B0C !important; font-size: 12px; background: none; } </style> <body style=" overflow-x: hidden;"> <div class="row" style="margin-top: 30px;margin-left:20px;"> <div class="col-md-6 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px; "> <i class="fa fa-pencil" title="Teacher management" style="font-size: 20px;margin: 0px 0px 0px -15px;"></i> Teacher Management </div> <div class="col-md-6 text-center"> <button type="button" onClick="location.href='add_teacher.php'" class="btn btn-outline-secondary" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Add Teacher </button> <button type="button" onClick="location.href='excel_templates/Staff_upload_excel.xls'" class="btn btn-outline-secondary" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Download Excel </button> <button type="button" onClick="location.href='staff_upload.php'" class="btn btn-outline-secondary" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;"> Upload Excel </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;margin-top:30px;"> <table id="myTable" class="table table-condensed table-hover" style="margin-top:-10px;"> <thead> <tr class="info"> <th class="col-md-1 text-center">Sl.No</th> <th>Teacher Name</th> <th>Teacher Email</th> <th>Teacher Phone Number</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <?php if ($myteachers != 'notfound') foreach ($myteachers as $teacher) { if ($teacher['status'] == '1') { $status = 'Active'; $revstatus = 'Deactivate'; $nstate = 'class="red fa fa-ban"'; } else { $status = 'Deactivated'; $revstatus = 'Activate'; $nstate = 'class="green fa-solid fa-circle-check"'; } echo ' <tr> <td class="col-sm-1 text-center" style=" font-size:14px;">' . $i . '</td> <td style=" font-size:14px;">' . $teacher[staff_name] . '</td> <td style=" font-size:14px;">' . $teacher[staff_email] . '</td> <td style="font-size:14px;">' . $teacher[staff_mobile] . '</td> <td style="font-size:14px;">' . $status . '</td> <td class="center"> <a class=" buttonn" href="edit_teacher.php?staff_id=' . $teacher[staff_id] . '" style="margin:4px;text-decoration:none"> <i class="fa fa-pencil" title ="Edit" style="font-size: 14px; color:#01aee6;"></i> </a> <a class=" buttonn" href="teacher_management.php?staff_id=' . $teacher[staff_id] . '&act_sts=' . $teacher[status] . '" style="margin:4px;text-decoration:none" onclick="return delconfirm(' . $teacher[status] . ');"> <i ' . $nstate . ' title="' . $revstatus . '" style="font-size: 14px;color:#01aee6;"></i> </a> <a class=" buttonn" href="teacher_management.php?staff_id=' . $teacher[staff_id] . '&act=delete&ref=' . $teacher[auth_ref] . '" style="margin:4px;text-decoration:none" onclick="return confirm(\'Do you want to delete the Teacher?\')"> <i class=" fa fa-xmark" title="Delete" style="font-size: 14px; color:#01aee6;"></i> </a> </td> </tr>'; $i++; } ?> </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" language="javascript" class="init"> $(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'); */ $('#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: 'Teacher Management<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name] ?><br>', exportOptions: { columns: [0, 1, 2, 3, 4] } }, { extend: 'pdfHtml5', title: '<?php echo $_SESSION['child']['school_name'] ?>', message: 'Teacher Management\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name] ?>\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> <script> function delconfirm(y) { if (y == 1) { if (confirm('Do you want to Deactivate the Teacher ?')) return true; else return false; } else { if (confirm('Do you want to Activate the Teacher ?')) return true; else return false; } } </script> </body> </html>