JezK
Edit File: examination_management.php
<?php 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 $admin_id=$_SESSION['child']['auth_id'];//user_id $edit_name=$_POST['editex']; if(isset($_POST['exam'])) { $exname=trim($_POST['exam']); if (ctype_space($exname)) { //alert('Please enter a valid Exam name'); echo "<script> alert('Please enter a valid Exam name');</script>" ; } else { $details12=$fun->adding_exam_names($school_id,$academic_id,$exname,$admin_id); } if($details12==1) { echo "<script>alert('Exam name already exists please enter another exam');</script>" ; } else if($details12==2) { //echo "<script>alert('Exam name added successfully');</script>" ; } else if($details12==3) { //echo "<script>alert('Exam name not added');</script>"; } } $details=$fun->view_examname($school_id,$academic_id); $length=count($details); if(!empty($_POST['exam_id'])) { $exam_id=$_POST['exam_id']; $data=$fun->edit_exam_names($edit_name,$admin_id,$exam_id,$school_id,$academic_id); if($data == 1) { echo "<script>location.replace('examination_management.php');</script>" ; } else if($data == 0) { echo "<script>alert('Exam Name not updated');</script>" ; } else if($data == 2) { echo "<script>alert('Exam Name already exists ');</script>" ; echo "<script>location.replace('examination_management.php');</script>" ; } } ?> <style> #nav { margin: auto; width:751px !important; 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; } .modal fade { height: 50%; /* Set your own height: percents, ems, whatever! */ width: 50%; /* Set your own width: percents, ems, whatever! */ overflow: auto; /* Recommended in case content is larger than the container */ margin: auto; /* Center the item vertically & horizontally */ position: absolute; /* Break it out of the regular flow */ top: 0; left: 0; bottom: 0; right: 0; /* Set the bounds in which to center it, relative to its parent/container */ } body.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom { margin-right: 0; } .modal { left: 50%; bottom: auto; right: auto; z-index: 1050; padding: 0; width: 520px; margin-left: -250px; background-color: #ffffff; border: 1px solid #999999; border: 1px solid rgba(0, 0, 0, 0.2); border-radius: 6px; -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); background-clip: padding-box; } .modal.container { max-width: none; } .modal-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1040; } </style> <body style="overflow-x: hidden;"> <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:24px; margin-left:20px;"> <img src="images/exams-black.png" title =" Examinations" style="margin: -6px 0px 0px 0px;"/>Examinations </div> <div class="col-md-2 text-center" style="float:right;"> <button class="btn btn-default" onclick="countexam()" id="add_btn" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;" data-toggle="modal" data-target="#pwdModal"> Add Exam Name </button> </div> </div> <br> <div class="menuu"> <ul id="nav" class="margn_auto"> <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="examination_management.php"><img src="images/exam-nemes_white.png" title ="Exam Names" style="margin-right:5px;"/>Exam Names</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="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:148px; 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; margin-top:-5px;"> <img src="images/exam-nemes_black.png" style=" font-size:25px;" title ="Exam Names" /> Exam Names </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>Exam Name</th> <th>Actions</th> </tr> </thead> <tbody> <?php $i=0; if($details) { foreach($details as $value) { $i++; ?> <tr> <td class="col-sm-1 text-center" style=" font-size:14px;"><?=$i?> <input type="hidden" name="stdid" id="<?=$value['exam_id']?>"> </td> <td style=" font-size:14px;"><?=$value['exam_name']?></td> <td class="center"> <a class=" buttonn" href="javascript:void(0)" onclick="edit(<?php echo $value['exam_id'];?>,'<?php echo $value['exam_name'];?>')" style="margin:4px;"> <i class="glyphicon glyphicon-pencil" title ="Edit" style="font-size: 14px; color:#01aee6;" data-toggle="modal" data-target="#pwdModal1"></i> </a> <a class=" buttonn" href="javascript:void(0)" onclick="confirmDelete(<?php echo $value['exam_id'];?>)" style="margin:4px;" > <i class="glyphicon glyphicon-remove" 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] }, { "sExtends": "pdf", "sPdfOrientation": "landscape", "mColumns": [0, 1] }, { "sExtends": "print", "mColumns": [0, 1] } ] } }); $('div.dataTables_filter input').attr('placeholder', 'Search'); });*/ $(document).ready(function() { $('#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: 'Examinations<br>Academic Year:<?php echo $_SESSION[child][choosen_year_name]?>', exportOptions: { columns: [ 0, 1 ] } }, { extend: 'pdfHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', message: 'Examinations\n Academic Year:<?php echo $_SESSION[child][choosen_year_name]?>', exportOptions: { columns: [ 0, 1 ] } }, { extend: 'excelHtml5', title:'<?php echo $_SESSION['child']['school_name']?>', exportOptions: { columns: [ 0, 1 ] } } ] } ); } ); </script> <script type="text/javascript"> function confirmDelete(exmid) { var res=confirm("Do you want to delete this Exam Name?"); if(res) { $.ajax({ url: "ajaxcalls_app.php", type:"POST", data:"mode="+"delete_exam"+"&exam_id="+exmid, success: function(result) { if(result==1) { location.replace('examination_management.php'); } else if(result==2) { alert("You cannot delete this Exam Name as there is some data associated with it."); } else { } }, error : function(e) { //alert(e); } }); } } function edit(a,b) { document.getElementById("exam_id").value=a; document.getElementById("gettext").value=b; } function validation() { //var x=/^[a-zA-Z\d\s]*$/; //var x=/^[0-9a-zA-Z]+$/; $('#err_examname').text(''); var x = /^[ A-Za-z0-9_./+-]*$/; var a=document.getElementById("exam").value; var val = a.replace(/^\s+|\s+$/,''); if(a =="") { $('#err_examname').text('Please enter Exam Name'); $('#err_examname').show(); document.getElementById('exam').focus(); return false; } if(val.length == 0) { $('#err_examname').text('Please enter Exam Name'); $('#err_examname').show(); document.getElementById('exam').focus(); return false; } if(!x.test(a)) { $('#err_examname').text('Please enter a valid Exam Name'); $('#err_examname').show(); document.getElementById('exam').focus(); return false; } b=document.getElementById('count').value; if(b>=6) { alert("You can not add more than six Exam names"); return false; } } function update_validation() { var x = /^[ A-Za-z0-9_./+-]*$/; var b=document.getElementById("gettext").value; if(b =="") { $('#err_examname_edit').show(); return false; } if(!x.test(b)) { $('#err_examname_edit').show(); $( "#err_examname_edit" ).text( "Please enter a valid Exam name" ); document.getElementById('gettext').focus(); return false; } } function refresh() { document.getElementById('exam').value=""; } function countexam() { a=document.getElementById('count').value; if(a>=6) { alert("You can not add more than six exams"); $('#add_btn').attr("data-target",''); return false; } } </script> <script> $(document).ready(function() { $('#myTable').dataTable(); }); </script> <!--MODAL FOR ADD EXAM NAME--> <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" data-width="760"> <div class="modal-body"> <div class="col-md-12"> <p style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:14px; margin-right:30px;margin-bottom:10px; margin-top:20px;">Add Exam</p> </div> <div class="col-md-12" style="overflow:hidden;"> <div class="col-md-4 col-md-offset-1 "> <b style="color:#666666;">Exam Name</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <form method="post"> <div class="col-md-7" style="margin-left:-30px;"> <input type="text" maxlength="50" name="exam" class="form-control" id="exam" style="height:29px;font-size:13px;" tabindex="2" autofocus> <input type="hidden" id="count" value="<?php echo $length;?>"> <!-- if there is an error--> <div class="col-md-7" id="err_examname" style="color:#990000;margin-left:-15px; display:none; width:250px;"></div> <!--- end error--> </div> </div> </div> <div class="modal-footer" style="background:#FFFFFF;"> <button type="submit" onclick=" return validation()" name="examsubmit" class="btn btn-default custom-button-width .navbar-right" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; " value="Add">Add</button> <button type="button" data-dismiss="modal" class="btn" onclick=" return refresh()">Close</button> </div> </div> </form> <!--MODAL FOR EDIT EXAM NAME--> <div id="pwdModal1" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" data-width="760"> <div class="modal-body"> <div class="col-md-12"> <p style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:14px; margin-right:30px;margin-bottom:10px; margin-top:20px;">Edit Exam Name</p> </div> <div class="col-md-12" style="overflow:hidden;"> <div class="col-md-4 col-md-offset-1 "> <b style="color:#666666;">Exam Name</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <form method="post"> <div class="col-md-7" style="margin-left:-30px;"> <input type="text" maxlength="50" name="editex" class="form-control" id="gettext" style="height:29px;font-size:13px;" tabindex="2" autofocus> <input type="hidden" name="exam_id" id="exam_id"> <!-- if there is an error--> <div class="col-md-7" id="err_examname_edit" style="color:#990000;margin-left:-15px; display:none; width:250px;">Please Enter Exam Name</div> <!--- end error--> </div> </div> </div> <div class="modal-footer" style="background:#FFFFFF;"> <button type="submit" name="editexam" onclick=" return update_validation()" class="btn btn-default custom-button-width .navbar-right" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; " value="Add/Update">Add/Update</button> <button type="button" data-dismiss="modal" class="btn">Close</button> </div> </div> </form> </body> </html>