JezK
Edit File: exam_schedule.php
<?php if (session_id() == "") { session_start(); } include("menuheader.php"); if (!(in_array(4, $access) && in_array(4, $allow))) echo "<script>location.replace('dashboard.php');</script>"; include_once("school_admin_access_app.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); $exam_names = $fun->exam_name_details($school_id, $academic_id); // print_r($exam_names);exit; $sections = $fun->get_sections($_GET['class_id'], $academic_id); if (isset($_GET['class_id']) && isset($_GET['section_id']) && isset($_GET['exname_id'])) { $class_ids = $_GET['class_id']; $section_ids = $_GET['section_id']; $exname_ids = $_GET['exname_id']; $schedule = $fun->exam_timetable($_GET['class_id'], $_GET['section_id'], $school_id, $academic_id, $_GET['exname_id']); } if (isset($_GET['class_id']) && isset($_GET['section_id']) && isset($_GET['exname_id']) && isset($_GET['time_table_id'])) { $class_id = $_GET['class_id']; $section_id = $_GET['section_id']; $exam_id = $_GET['exname_id']; $sucurl = 'exam_schedule.php?section_id=' . $section_id . '&class_id=' . $class_id . '&exname_id=' . $exam_id; //echo "<script>alert('Exam schedule');</script>"; $delete_exam_schedul = $fun->delete_exam_schedule($_GET['time_table_id'], $_GET['class_id'], $_GET['section_id'], $_GET['exname_id']); if ($delete_exam_schedul == 1) { //echo "<script>alert('Exam Schedule Deleted Successfully ');</script>"; echo "<script>location.replace('" . $sucurl . "');</script>"; } else if ($delete_exam_schedul == 3) { echo "<script>alert('You can not delete this Exam Schedule as it is associated with some data ');</script>"; } } // print_r($exam_names);exit; if ($exam_names) { foreach ($exam_names as $row) { if ($_GET['exname_id'] == $row['exam_id']) { $exmnamesss .= "<option value='{$row['exam_id']}' selected>{$row['exam_name']}</option>"; } else { $exmnamesss .= "<option value='{$row['exam_id']}' >{$row['exam_name']}</option>"; } } } if ($details) { foreach ($details as $row) { if ($_GET['class_id'] == $row['class_id']) { $classes_list .= "<option value='{$row['class_id']}' selected>{$row['class_name']}</option>"; } else { $classes_list .= "<option value='{$row['class_id']}' >{$row['class_name']}</option>"; } } } if ($sections) { //$secs = "<option value='all' selected>All</option>"; foreach ($sections as $row) { //if($_GET['section_id']== "all"){ if ($_GET['section_id'] == $row['section_id']) { $secs .= "<option value='{$row['section_id']}' selected>{$row['section_name']}</option>"; } else { $secs .= "<option value='{$row['section_id']}' >{$row['section_name']}</option>"; } } } ?> <style> #nav { margin: auto; width: 751px; padding-left: 0; padding-right: 0; list-style: none; background: rgb(51, 93, 220) none repeat scroll 0% 0%; } #nav li { display: inline-block; margin: 0 auto; text-align: center; } #nav li a { display: inline-block; padding: 7px 0; text-align: center; text-decoration: none; color: #FFFFFF; margin: auto; } #nav li:hover, li:active { background-color: #0b287b; width: 90px; } #nav li.selected { background-color: #0b287b; } .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; } select { width: 62px !important; background-color: #FFF; border: 1px solid #CCC; } </style> <body style="overflow-x: hidden;"> <div class="row" style="margin-top: 30px;"> <div class="col-md-8 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px; margin-left:20px;"> <img src="images/exams-black.png" title=" Examinations" style="font-size: 24px;" /> Examinations </div> <div class="col-md-3 text-center"> <button type="button" onClick="location.href='update_examschedule.php'" class="btn btn-outline-secondary" style="font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;" data-toggle="modal" data-target="#pwdModal"> Add/Update Exam Schedule </button> </div> </div> <br> <div class="menuu d-flex"> <ul id="nav" class="margn_auto"> <li style="border-right:1px solid #FFFFFF;width:150px; text-align:center;margin-left:-3px;font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="examination_management.php"><img src="images/exam-nemes_white.png" title="Exam Names" style="margin-right:5px;" />Exam Names</a></li> <li class="selected" style="border-right:1px solid #FFFFFF;width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="exam_schedule.php"><img src="images/exam-schedule_white.png" title="Exam Schedule" style="margin-right:5px;" />Exam Schedule</a></li> <li style="border-right:1px solid #FFFFFF; width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="marksof_student.php"><img src="images/add-marks_white.png" title="Add Marks" style="margin-right:5px;" />Add Marks</a></li> <li style="border-right:1px solid #FFFFFF; width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="addgrades_tostudent.php"><img src="images/set-grades_white.png" title="Set Grades/Ranks" style="margin-right:5px;" />Set Grades/Ranks</a></li> <li style="width:150px; text-align:center; margin-left:-3px; font-family:Arial, Helvetica, sans-serif;font-style:normal; font-size:14px;"><a href="Report_card.php"><img src="images/report-card_white.png" title="Report Card" style="margin-right:5px;" />Report Card</a></li> </ul> </div> <div class="row" style="margin-top: 30px;"> <div class="col-md-9 text-left" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:20px; margin-left:20px;"><img src="images/exam-schedule_black.png" title=" Exam Schedule" style="font-size: 24px;" /> Exam Schedule </div> </div> <form class="form-horizontal" style="margin-top:20px;"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class=""> <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; ">Exam Name</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="examnames" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option value='0' selected>Select Exam Name</option> <?php echo $exmnamesss; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_examname" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> <div class=""> <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; ">Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7 "> <select class="form-select" id="classes" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option value='0' selected>Select Class</option> <?php echo $classes_list; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_class" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> <div class=""> <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; ">Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="sections" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option value='0' selected>Select Section</option> <?php echo $secs; ?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_section" style="color:#990000;"></div> <!--- end error--> </div> </div> </div> </div> </form> <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>Subject Name</th> <th>Total Marks</th> <th>Date</th> <th>Start Time</th> <th>Duration</th> <th>Actions</th> </tr> </thead> <tbody> <?php $i = 1; if ($schedule) { //$schedulecount = count($schedule); foreach ($schedule as $row) { $sub = $row['subject_id']; $sec = $row['section_id']; $url = "update_examschedule.php?classid=" . $class_ids . "&sec_id=" . $sec . "&subject_id=" . $sub . "&exname=" . $exname_ids; $originalDate = $row['exam_date']; $newDate = date("d/m/Y", strtotime($originalDate)); ?> <tr> <td class="col-sm-1 text-center" style=" font-size:14px;"><?= $i ?></td> <td style=" font-size:14px;"><?= $row['exam_subject'] ?><input type="hidden" id="sub" name="sub" value="<?= $row['subject_id'] ?>"></td> <td style=" font-size:14px;"><?= $row['total_marks'] ?></td> <td style=" font-size:14px;"><?= $newDate ?></td> <td style=" font-size:14px;"><?= $row['exam_time'] ?></td> <td style=" font-size:14px;"><?= $row['exam_duration'] ?></td> <td class="center"> <a class=" buttonn" href="<?= $url; ?>" style="margin:4px;"> <i class="fa-solid fa-pencil" title="Edit" style="font-size: 14px; color:#01aee6;"></i> </a> <a class=" buttonn" onclick="confirmDelete( <?php echo $row['timetable_id']; ?>, <?php echo $row['class_id']; ?>,<?php echo $row['section_id']; ?>, <?php echo $row['exam_id']; ?>)" href="#" style="margin:4px;"> <i class="fa-solid fa-xmark" title="Delete" style="font-size: 14px; color:#01aee6;"></i> </a> </td> </tr> <?php $i++; } } ?> </tbody> <input type="hidden" id="schedulecount" value="<?php echo $schedulecount; ?>"> </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, 5] }, { "sExtends": "pdf", "sPdfOrientation": "landscape", "mColumns": [0, 1, 2, 3, 4, 5] }, { "sExtends": "print", "mColumns": [0, 1, 2, 3, 4, 5] } ] } }); $('div.dataTables_filter input').attr('placeholder', 'Search'); if($("#schedulecount").val() == 0) { $('div.dataTables').attr('tableTools', ""); } */ var classname = $('#classes').find('option:selected').text(); var secname = $('#sections').find('option:selected').text(); var ndt = $('#examnames').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: 'Exam Schedule<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name] ?>   Class:' + classname + '   Section:' + secname + '   Exam Name:' + ndt + '<br>', exportOptions: { columns: [0, 1, 2, 3, 4, 5] } }, { extend: 'pdfHtml5', title: '<?php echo $_SESSION['child']['school_name'] ?>', message: 'Exam Schedule\nAcademic Year:<?php echo $_SESSION[child][choosen_year_name] ?>\t Class:' + classname + '\tSection:' + secname + '\t Exam Name:' + ndt + '\n', exportOptions: { columns: [0, 1, 2, 3, 4, 5] } }, { extend: 'excelHtml5', title: '<?php echo $_SESSION['child']['school_name'] ?>', exportOptions: { columns: [0, 1, 2, 3, 4, 5] } } ] }); $("#classes").change(function() { $("#err_class").text(""); if ($(this).val() == 0) { var section_option = '<option value="0" >Select Section</option>'; $("#sections").html(section_option); $("#err_class").text("Please select Class"); $("#err_class").show(); return false; } else { var dbd = '<tr class="odd"><td valign="top" colspan="7" class="dataTables_empty">No data available in table</td></tr>'; //---------------------------------------------------------- $("#myTable tbody").html(dbd); //---------------------------------------------------------- var x = $(this).val(); $.ajax({ url: "ajaxcalls_app.php", type: "POST", data: "mode=" + "choose_class" + "&data=" + x, success: function(result) { var result2 = eval("(" + result + ")"); var section_option = '<option value="0" >Select Section</option>'; //section_option += '<option value="all" >All</option>'; //var section_option; for (var i = 0; i < result2.length; i++) { section_option += '<option value="' + result2[i].section_id + '" >' + result2[i].section_name + '</option>'; } $("#sections").html(section_option); }, error: function(e) { alert(e); } }); } }); $("#examnames").change(function() { $("#err_examname").text(""); if ($("#examnames").val() == 0) { $("#err_examname").text("Please select Exam"); $("#err_examname").show(); return false; } else if ($("#classes").val() != 0 && $("#examnames").val() != 0 && $("#sections").val() != 0) { var cls = $("#classes").val(); var ename = $("#examnames").val(); var sec_id = $("#sections").val(); window.location.href = "exam_schedule.php?class_id=" + cls + "&exname_id=" + ename + "§ion_id=" + sec_id; } }); $("#sections").change(function() { $("#err_section").text(""); if ($("#sections").val() == 0) { $("#err_section").text("Please select Section"); $("#err_section").show(); return false; } else if ($("#classes").val() != 0 && $("#examnames").val() != 0 && $("#sections").val() != 0) { var cls = $("#classes").val(); var ename = $("#examnames").val(); var sec_id = $("#sections").val(); window.location.href = "exam_schedule.php?class_id=" + cls + "&exname_id=" + ename + "§ion_id=" + sec_id; } }); }); function confirmDelete(exmid, class_id, section_id, exam_id2) { var res = confirm("Do you want to delete the Exam Schedule?"); if (res) { window.location.href = "exam_schedule.php?class_id=" + class_id + "&exname_id=" + exam_id2 + "§ion_id=" + section_id + "&time_table_id=" + exmid; /*$.ajax({ url: "ajaxcalls_app.php", type:"POST", data:"mode="+"delete_exam_schedule"+"&exam_timetable_id="+exmid+"&exam_id="+exam_id2+"&class_id="+class_id+"§ion_id="+section_id, success: function(result) { alert(result); if(result==1) { alert("Exam Schedule Deleted Successfully "); //location.replace('exam_schedule.php'); window.location.href="exam_schedule.php?class_id="+class_id+"&exname_id="+exam_id2+"§ion_id="+section_id; } else if(result==3) { alert("You can not delete this Exam Schedule as it is associated with some data"); window.location.href="exam_schedule.php?class_id="+class_id+"&exname_id="+exam_id2+"§ion_id="+section_id; } }, error : function(e) { alert(e); } });*/ } } </script> <script> $(document).ready(function() { $('#myTable').dataTable(); }); </script> </body> </html>