JezK
Edit File: edit_studentmarks.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"); include_once("examclass.php"); $fun = new adminaccess(); $exa = new examaccess(); $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); $cancelto = 'marksof_student.php?sec_id=' . $_GET['sec_id'] . '&classid=' . $_GET['classid'] . '&exname_id=' . $_GET['exname_id'] . '&student_id=' . $_GET['student_id']; if (isset($_GET['classid']) && isset($_GET['sec_id'])) { $sections = $fun->get_sections($_GET['classid'], $academic_id); $students_list = $fun->get_students2($_GET['classid'], $_GET['sec_id'], $school_id, $academic_id); } if (count($students_list) > 0) { foreach ($students_list as $row) { if ($_GET['student_id'] == $row['student_id']) //student_id { $student .= "<option value='{$row['student_id']}' selected>{$row['student_name']}</option>"; } else { $student .= "<option value='{$row['student_id']}' >{$row['student_name']}</option>"; } } } if ($sections) { foreach ($sections as $row) { if ($_GET['sec_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>"; } } } if ($exam_names) { foreach ($exam_names as $row) { if ($_GET['exname_id'] == $row['exam_id']) { $notifyexam = $row['exam_name']; $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['classid'] == $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>"; } } } $subjs = $fun->add_students_marks_edit($_GET['marks_id'], $_GET['classid'], $_GET['sec_id'], $school_id, $academic_id, $_GET['exname_id'], $_GET['student_id']); $grade = $fun->getthisStudentgrade($_GET['classid'], $_GET['sec_id'], $_GET['exname_id'], $_GET['student_id'], $school_id, $academic_id); if ($_POST['action'] == "update") { $result = $fun->update_student_marks_byid($_POST, $user_id, $academic_id); $grades = $fun->addgrade_students($_GET['exname_id'], $_GET['student_id'], $_POST['grade'], $academic_id, $user_id); if ($result == 1) { $sucurl = 'marksof_student.php?sec_id=' . $_GET['sec_id'] . '&classid=' . $_GET['classid'] . '&exname_id=' . $_GET['exname_id'] . '&student_id=' . $_GET['student_id']; echo "<script>location.replace('" . $sucurl . "');</script>"; } } ?> <style> #nav { margin: auto; width: 751px; padding-left: 0; padding-right: 0; list-style: none; background: #66CEF0; } #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: #01749a; width: 90px; } #nav li.selected { background: #01749a; } .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; } table, thead, tr, tbody, th, td { text-align: center; } </style> <body style="overflow-x: hidden;"> <div class="row" style="margin-top: 30px;"> <div class="col-md-9 text-start" 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> <div class="menuu" style="margin-top:15px;"> <ul id="nav"> <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-nemes_white.png" title="Exam Names" style="margin-right:5px;" />Exam Names</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="exam_schedule.php"><img src="images/exam-schedule_white.png" title="Exam Schedule" style="margin-right:5px;" />Exam Schedule</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="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;margin-bottom:10px;"> <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/add-marks_Black.png" title="Update Marks Student Wise" style="font-size: 24px;" /> Update Marks Student Wise </div> <div class="col-md-2 text-center"> <!--<button type="button" onClick="location.href='#'" class="btn btn-default" style="margin-right:20px;font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;" data-toggle="modal" data-target="#pwd </div>Modal"> Upload </button>--> </div> <form class="form-horizontal" style="margin-top:20px; " method="post"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class="clearfix"> <div class="form-group col-md-6 row" style="margin-bottom:1.0%;"> <div class="col-md-4 offset-md-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 disabled class="form-select" id="examnames" name="examnames" style="height:29px; width:295px!important;font-size:12px;" tabindex="1"> <option value='0' selected>Select Exam Name</option> <?php echo $exmnamesss; ?> </select> </div> <!-- if there is an error--> <div class="col-md-10" id="err_examname" style="color:#990000;margin-left:295px; display:none; width:200px;">Please Enter Exam name</div> <!--- end error--> </div> </div> <div class="clearfix"> <div class="form-group col-md-6 row" style="margin-bottom:1.0%;"> <div class="col-md-4 offset-md-1 text-md-end"> <b style="color:#666666; ">Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select disabled class="form-select" id="classes" name="classes" style="height:29px; width:295px!important;font-size:12px;" tabindex="2"> <option value='0' selected>Select Class</option> <?php echo $classes_list; ?> </select> </div> <!-- if there is an error--> <div class="col-md-10" id="err_class" style="color:#990000;margin-left:295px; display:none; width:200px;">Please Enter class</div> <!--- end error--> </div> </div> <div class="clearfix"> <div class="form-group col-md-6 row" style="margin-bottom:1.0%;"> <div class="col-md-4 offset-md-1 text-md-end"> <b style="color:#666666; ">Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select disabled class="form-control" id="sections" name="sections" style="height:29px; width:295px!important;font-size:12px;" tabindex="3"> <option value='0' selected>Select Section</option> <?php echo $secs; ?> </select> </div> <!-- if there is an error--> <div class="col-md-10" id="err_section" style="color:#990000;margin-left:295px; display:none; width:200px;">Please Enter Section</div> <!--- end error--> </div> </div> <div class="clearfix"> <div class="form-group col-md-6 row" style="margin-bottom:1.0%;"> <div class="col-md-4 offset-md-1 text-md-end"> <b style="color:#666666; ">Student </b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select disabled class="form-select" id="student" name="stdid" style="height:29px; width:295px!important;font-size:12px;" tabindex="4"> <option value='0' selected>Select Student</option> <?php echo $student; ?> </select> </div> <!-- if there is an error--> <div class="col-md-10" id="err_student" style="color:#990000;margin-left:295x; display:none; width:200px;">Please Enter Student</div> <!--- end error--> </div> </div> <div class="clearfix"> <div class="form-group col-md-6 row " style="margin-bottom:1.0%;"> <div class="col-md-4 offset-md-1 text-md-end"> <b style="color:#666666; ">Set Grade/Rank</b><span style="color:#FF0000; margin:2px;"></span> </div> <div class="col-md-7"> <input type=" text" class="form-control" id="grade" name="grade" maxlength="10" style="height:29px; width:295px!important;font-size:12px;" value="<?php if ($grade != '0') echo $grade; ?>" tabindex="5"> <!-- if there is an error--> <div class="col-md-10" id="err_grade" style="color:#990000;margin-left:295x; display:none; width:200px;">Please Enter Student</div> <!--- end error--> </div> </div> </div> </div> <!--dynamic content Start--> <div class="row"> <div class="col-md-10 offset-md-1 text-md-end d-md-flex"> <div class="col-md-2 text-md-center"><b>Subject Name</b></div> <div class="col-md-2 text-md-center"><b>Total Marks</b></div> <div class="col-md-2 text-md-center"><b>Secured Marks</b></div> <div class="col-md-2 text-md-center"><b>Status</b></div> </div> </div><br /> <?php if ($subjs) { $i = 0; $countmarks = 0; foreach ($subjs as $row) { $i++; $maxtotal = "maxtotal" . $i; $securedmark = "securedmark" . $i; if (!empty($row['marks_secured'])) { $totmarks = $row['marks_secured']; } else { $totmarks = 0; } $countmarks = $countmarks + $totmarks; ?> <div class="row"> <div class="col-md-10 offset-md-1 d-md-flex"> <div class="col-md-2 text-md-center"> <input type="hidden" name="student[]" value="<?php echo $row['subject_id'] ?>"> <input type="text" class="time" value="<?php echo $row['subject_name'] ?>" name="subjects" readonly style="width:130px!important; height:25px;margin-left:3em;" tabindex="6"> </div> <div class="col-md-2 text-md-center"> <input type="text" class="time" id="tmark" value="<?php echo $row['total_marks'] ?>" style="width:120px!important; height:25px;margin-left:3em;" readonly tabindex="7"> </div> <div class="col-md-2 text-md-center"> <input type="text" class="add_marks" maxlength="5" value="<?php echo $row['marks_secured'] ?>" name="marks" id="smark" tabindex="8" style="width:120px!important;height:25px;margin-left:3em;"> <!-- if there is an error--> <div class="col-md-10" id="err_marks" style="color:#990000;margin-left:-2px; display:none; width:250px;font-size:12px;">Please enter Secured Marks</div> <!--- end error--> </div> <div class="col-md-2 text-md-center"> <select style="width: 140px!important;margin-left:4em;height:25px;" class="add_status" id="status" name="status" tabindex="9"> <option value="0" selected>--Select Status--</option> <option value="1" <?php if ($row['status'] == 'P') { echo 'selected'; } ?>>P</option> <option value="2" <?php if ($row['status'] == 'F') { echo 'selected'; } ?>>F</option> </select> <!-- if there is an error--> <div class="col-md-10" id="err_status" style="color:#990000;margin-left:-12px; display:none; width:250px;font-size:12px;">Please enter Status</div> <!--- end error--> </div> </div> </div> <?php } } ?> <!--dynamic content End--> <div class="col-md-1"></div> </div> <div class="form-group"> <div class="col-md-12" align="center"> <!--< if($subjs) { ?>--> <button type="submit" onclick="return validation();" class="btn btn-outline-secondary custom-button-width .navbar-right" tabindex="11" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; ">Update </button> <button type="button" onclick="location.href='<?php echo $cancelto ?>'" class="btn btn-outline-secondary custom-button-width .navbar-right" tabindex="12" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; ">Cancel</button> <!--< } ?>--> </div> </div> <input type="hidden" name="examination_name" value="<?php echo $notifyexam ?>"> <input type="hidden" name="student_id" value="<?php echo $row['student_id'] ?>"> <input type="hidden" name="exam_id" value="<?php echo $row['exam_id'] ?>"> <input type="hidden" name="marks_id" id="marks_id" value="<?php echo $_GET['marks_id'] ?>"> <input type="hidden" name="action" id="action" value="update"> </form> <script type="text/javascript" language="javascript" src="Excel/media/js/jquery.js"></script> <script type="text/javascript" language="javascript" src="Excel/media/js/jquery.dataTables.js"></script> <script type="text/javascript" language="javascript" src="Excel/js/dataTables.tableTools.js"></script> <script type="text/javascript" language="javascript" src="Excel/examples/resources/syntax/shCore.js"></script> <script type="text/javascript" language="javascript" src="Excel/examples/resources/demo.js"></script> <script type="text/javascript" language="javascript" class="init"> $(document).ready(function() { $('#myTable').DataTable({ dom: 'T<"clear">lfrtip', "oLanguage": { "sSearch": "" }, tableTools: { "aButtons": [ "xls", { "sExtends": "pdf", "sPdfOrientation": "landscape", "sPdfMessage": "Your custom message would go here." }, "print" ] } }); $('div.dataTables_filter input').attr('placeholder', 'Search'); $("#classes").change(function() { if ($(this).val() == 0) { $("#sections").val(0); alert("Select Class"); return false; } else { 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>'; 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) { } }); } }); $("#sections").change(function() { if ($("#classes").val() == 0) { alert("Select Class"); return false; } else { if ($("#sections").val() == 0) { alert("Select Section"); return false; } else { var cls = $("#classes").val(); var sec_id = $("#sections").val(); var stud_id = $("#student").val(); var exam_id = $("#examnames").val(); $.ajax({ url: "ajaxcalls_app.php", type: "POST", data: "mode=" + "students" + "&class_id=" + cls + "§ion_id=" + sec_id, success: function(result) { var result2 = eval("(" + result + ")"); var section_option = '<option value="0" selected="selected">Select Student</option>'; for (var i = 0; i < result2.length; i++) { section_option += '<option value="' + result2[i].student_id + '">' + result2[i].student_name + '</option>'; } $("#student").html(section_option); }, error: function(e) { } }); } } }); $("#student").change(function() { if ($("#classes").val() == 0) { alert("Select Class"); return false; } else if ($("#sections").val() == 0) { alert("Select Section"); return false; } else if ($("#examnames").val() == 0) { alert("Select exam"); return false; } else { var cls = $("#classes").val(); var sec_id = $("#sections").val(); var stud_id = $("#student").val(); var exam_id = $("#examnames").val(); window.location.href = "updatemarks_by_student.php?classid=" + cls + "&exname_id=" + exam_id + "&sec_id=" + sec_id + "&student_id=" + stud_id; } }); $("#examnames").change(function() { load_data(); }); }); function load_data() { if ($("#classes").val() != 0 && $("#sections").val() != 0 && $("#student").val() != 0 && $("#examnames").val() != 0) { var cls = $("#classes").val(); var sec_id = $("#sections").val(); var stud_id = $("#student").val(); var exam_id = $("#examnames").val(); window.location.href = "updatemarks_by_student.php?classid=" + cls + "&exname_id=" + exam_id + "&sec_id=" + sec_id + "&student_id=" + stud_id; } } function validation() { $("#err_examname").hide(); $("#err_class").hide(); $("#err_section").hide(); $("#err_subject").hide(); $("#err_student").hide(); $("#err_status").hide(); $("#err_marks").hide(); $("#err_grade").text(""); var status = document.getElementById("status").value; var marks = document.getElementById("smark").value; var tmark = document.getElementById('tmark').value; var regexp = /^[a-zA-Z0-9-_+ ]+$/; var grd = document.getElementById("grade").value; if (grd != '') { if (!regexp.test(grd)) { $("#err_grade").text("Please enter a valid Grade"); $("#err_grade").show(); return false; } } var letters = /^[A-Za-z0-9+-]+$/; if ($("#examnames").val() == 0) { $("#err_examname").show(); return false; } if ($("#classes").val() == 0) { $("#err_class").show(); return false; } if ($("#sections").val() == 0) { $("#err_section").show(); return false; } if ($("#subjects").val() == 0) { $("#err_subject").show(); return false; } if ($("#student").val() == 0) { $("#err_student").show(); return false; } if (marks == '') { $("#err_marks").text("Please enter Secured Marks"); $("#err_marks").show(); return false; } if (isNaN(marks)) { $("#err_marks").text(""); $("#err_marks").text("Please enter a valid number for Secured Marks"); $("#err_marks").show(); return false; } if (Number(marks) > Number(tmark)) { alert("Secured marks should be less than Total marks"); document.getElementById("smark").value = ''; return false; } if (status == 0) { $("#err_status").show(); return false; } } </script> <script> $(document).ready(function() { $('#myTable').dataTable(); }); </script> </body> </html>