JezK
Edit File: 2021-09-27updatestudent_marksinfo.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 $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); $subjects=$fun->getsubjects($_GET['class_id'],$school_id,$academic_id); $sections=$fun->get_sections($_GET['class_id'],$academic_id); if(isset($_POST['classes'])&&isset($_POST['sections'])&&isset($_POST['examnames'])&&isset($_POST['subjects'])&&isset($_POST['students'])&&isset($_POST['total'])&&isset($_POST['secured'])&&isset($_POST['status'])) { $kk=0; foreach($_POST['students'] as $studentid) { $secured_marks=$_POST['secured'][$kk]; $status=$_POST['status'][$kk]; if($secured_marks!='') $details123=$fun->adding_student_marks($_POST['examnames'],$_POST['subjects'],$studentid,$secured_marks,$status,$academic_id,$user_id); $kk++; } if($details123==1) { $sucurl = 'marksof_student.php?sec_id='.$_POST['sections'].'&classid='.$_POST['classes'].'&exname_id='.$_POST['examnames']; echo "<script>location.replace('".$sucurl."');</script>"; //echo "<script>location.replace('marksof_student.php');</script>"; } else if($details123==2) { echo "<script>location.replace('updatestudent_marksinfo.php');</script>"; } } if(isset($_GET['class_id'])&&isset($_GET['section_id']) &&isset($_GET['exam_id']) &&isset($_GET['subject_id'])) { $students=$fun->get_students($_GET['class_id'],$_GET['section_id'],$school_id,$academic_id,$_GET['exam_id'],$_GET['subject_id']); } 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) { foreach($sections as $row) { 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>"; } } } if($exam_names) { foreach($exam_names as $row) { if($_GET['exam_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($subjects) { foreach($subjects as $row) { if($_GET['subject_id']==$row['subject_id']) { $subject_list.= "<option value='{$row['subject_id']}' selected>{$row['subject_name']}</option>"; } else { $subject_list.= "<option value='{$row['subject_id']}' >{$row['subject_name']}</option>"; } } } ?> <style> #nav { margin: auto; width:751px !important; padding-left:0; padding-right:0; list-style: none; background: #18b88d; } #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: rgb(54, 120, 102); width:90px; } #nav li.selected { background: rgb(54, 120, 102); } .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; } @media screen and (min-width:1600px) { .media_1600 { margin-left:62px!important; } .media_16001 { margin-left:9px!important; } .media1 { margin-left: 342px!important; } } </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="font-size: 24px;"/> Examinations </div> </div> <br> <div class="menuu"> <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 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: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/add-marks_Black.png" title ="Update Marks Subject Wise" style="font-size: 24px;"/> Update Marks Subject Wise </div> <form class="form-horizontal" style="margin-top:20px; margin-left:-70px;" method="post"> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-right"> <b style="color:#666666; ">Exam Name</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="examnames" name="examnames" style="height:29px; width:295px!important;font-size:12px;" tabindex="1" > <option value='0' selected>Select Exam Name</option> <? echo $exmnamesss;?> </select> </div> <!-- if there is an error--> <div class="col-md-10 media1" id="err_examname" style="color:#990000;margin-left:295px; display:none; width:200px;"></div> <!--- end error--> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-right"> <b style="color:#666666; ">Class</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="classes" name="classes" style="height:29px; width:295px!important;font-size:12px;" tabindex="2" > <option value='0' selected>Select Class</option> <? echo $classes_list;?> </select> </div> <!-- if there is an error--> <div class="col-md-10 media1" id="err_class" style="color:#990000;margin-left:295px; display:none; width:200px;"></div> <!--- end error--> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-right"> <b style="color:#666666; ">Section</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select 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> <? echo $secs;?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_section" style="color:#990000;margin-left:-10px;display:none; width:200px;"></div> <!--- end error--> </div> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-4 col-md-offset-1 text-right"> <b style="color:#666666; ">Subject</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-control" id="subjects" name="subjects" style="height:29px; width:295px!important;font-size:12px;" tabindex="4" > <option value='0' selected>Select Subject</option> <? echo $subject_list;?> </select> </div> <!-- if there is an error--> <div class="col-md-10 media1" id="err_subject" style="color:#990000;margin-left:295px; display:none; width:200px;"></div> <!--- end error--> </div> </div> </div> <!--dynamic content Start--> <div class="row" style="margin-left:3em;"> <div class="col-md-10 col-md-offset-1"> <div class="col-md-2 text-center"><b>Student Name</b></div> <div class="col-md-2 text-center"><b style="margin-left:58px;">Student Roll No</b></div> <div class="col-md-2 text-center"><b>Total Marks</b></div> <div class="col-md-2 text-center"><b style="margin-left:2em;">Secured Marks</b></div> <div class="col-md-2 text-center"><b style="margin-left:-60px;">Status</b></div> </div> </div><br/> <?php if(!empty($students)) { //echo json_encode($students); //$students = $students['data2']; $i=0; $j=4; foreach($students as $value) { $i++; $maxtotal="maxtotal".$i; $securedmark="securedmark".$i; $wx=$j+1; $xx=$j+2; $xy=$j+3; $xz=$j+4; ?> <div class="row" style="margin-left:3em;"> <div class="col-md-10 col-md-offset-1"> <div class="col-md-2 text-center"> <input type="text" class="addt" name="snames[]" value="<?=$value['student_name']?>" style="width:170px!important;height:25px;margin-left:35px;" readonly tabindex="<?=$wx?>"><br/><br/> <input type="hidden" name="students[]" value="<?=$value['student_id']?>"> </div> <div class="col-md-2 text-center"> <input type="text" value="<?=$value['student_rollno']?>" style="width:120px!important;height:25px;margin-left:59px;" readonly tabindex=""><br/><br/> </div> <div class="col-md-2 text-center"> <input type="text" class="addtime" id="<?=$maxtotal?>" name="total[]" value="<?=$value['total_marks']?>" style="width:120px!important;height:25px;margin-left:43px;" readonly tabindex="<?=$xx?>"><br/><br/> </div> <div class="col-md-2 text-center"> <input type="text" class="add_marks" name="secured[]" id="<?=$securedmark?>" onblur="return compare(this.id,'<?=$maxtotal?>');" tabindex="<?=$xy?>" maxlength="5" value="<? if($value['marks_secured']!=0) echo $value['marks_secured'];?>" style="width:100px!important;height:25px;margin-left:2em;"><br/><br/> <!-- if there is an error--> <div class="col-md-4"></div><div class="col-md-8 media_1600" id="err_marks<?=$i?>" style="color: rgb(153, 0, 0);font-size: 12px;margin-top: -15px;text-align: left;margin-left: 43px;width: 179px;"></div> <!--- end error--> </div> <div class="col-md-2 text-center"> <select style="width: 100px!important;height:25px;margin-left:0px;" class="add_status" id="status<?=$i?>" name="status[]" tabindex="<?=$xz?>"> <option value="0" selected>Status</option> <option value="1" <?php if($value['status']=='1'){ echo 'selected';}?> >P</option> <option value="2" <?php if($value['status']=='2'){ echo 'selected';}?> >F</option> </select><br/><br/> <!-- if there is an error--> <div class="col-md-10 media_16001" id="err_status<?=$i?>" style="color:#990000;display:none; width:250px;font-size:12px;margin-left:-8px;margin-top:-15px;"></div> <!--- end error--> </div> </div> </div> <?php $j=$j+3; } } else if($_GET['subject_id']!='') { ?> <tr> <div class="col-md-3 col-md-offset-3" style="margin-top:-5px;">This subject was not part of the chosen Examination</div> </tr> <? } else {?> <tr> <div class="col-md-3 col-md-offset-4" style="margin-top:-3px;">No Data Available</div> </tr> <? }?> <!--dynamic content End--> <div class="form-group"> <div class="col-md-12" align="center"> <input type="submit" class="btn btn-default custom-button-width .navbar-right btnclr" onclick="return validation()" tabindex="<?if($_GET[subject_id]!='') echo $xz+1;else echo '5';?>" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; " value="Update"> <button type="button" onclick="location.href='marksof_student.php'" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="<?if($_GET[subject_id]!='') echo $xz+2;else echo '6';?>" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; " >Cancel</button> </div> </div> </form> <script> $(document).ready(function() { $("#classes").change(function() { if($(this).val() == 0) { var section_option = '<option value="0" selected>Select Section</option>'; $("#sections").html(section_option); var subject_option = '<option value="0" selected>Select Subject</option>'; $("#subjects").html(subject_option); $("#err_class").text("Please Select Class"); $('#err_class').show(); return false; } else { $("#err_class").text(""); //var dbd ='<tr class="odd"><td valign="top" colspan="7" class="dataTables_empty">This subject was not part of the chosen Examination</td></tr>'; //$("#myTable tbody").html(dbd); var x = $(this).val(); var cls=$("#classes").val(); $.ajax({ url: "ajaxcalls_app.php", type:"POST", data:"mode="+"choose_class"+"&data="+x, success: function(result) { var result2 = eval("("+result+")"); //alert(result2[0]); var section_option = '<option value="0" selected>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) { } }); $.ajax({ url: "ajaxcalls_app.php", type:"POST", data:"mode="+"choose_subject"+"&class_id="+cls, success: function(result) { var result2 = eval("("+result+")"); //alert(result2[0]); var subject_option = '<option value="0" selected>Select Subject</option>'; for(var i = 0;i < result2.length;i++) { subject_option += '<option value="'+result2[i].subject_id+'">'+result2[i].subject_name+'</option>'; } $("#subjects").html(subject_option); }, error : function(e) { } }); } }); $("#sections").change(function() { if($("#sections").val()=='0') { $("#err_section").text('Please select Section'); $("#err_section").show(); } else { $("#err_section").text(''); load_data(); } }); $("#examnames").change(function() { if($("#examnames").val()=='0') { $("#err_examname").text('Please select Exam'); $("#err_examname").show(); } else { $("#err_examname").text(''); load_data(); } }); $("#subjects").change(function() { if($("#classes").val() == 0) { $('#err_class').text("Please select Class"); $('#err_class').show(); return false; } else if($("#sections").val() == 0) { $('#err_section').text("Please select Section"); $('#err_section').show(); return false; } else if($("#subjects").val() == 0) { $('#err_subject').text("Please select Subject"); $('#err_subject').show(); return false; } else { var clsid=$("#classes").val(); var sec_id=$("#sections").val(); var sbid=$("#subjects").val(); var exid=$("#examnames").val() window.location.href="updatestudent_marksinfo.php?class_id="+clsid+"§ion_id="+sec_id+"&subject_id="+sbid+"&exam_id="+exid; } }); }); function load_data() { if($("#classes").val() != 0 && $("#sections").val() != 0 && $("#subjects").val() != 0 && $("#examnames").val() != 0) { var clsid=$("#classes").val(); var sec_id=$("#sections").val(); var sbid=$("#subjects").val(); var exid=$("#examnames").val() window.location.href="updatestudent_marksinfo.php?class_id="+clsid+"§ion_id="+sec_id+"&subject_id="+sbid+"&exam_id="+exid; } } function validation() { $("#err_examname").hide(); $("#err_class").hide(); $("#err_section").hide(); $("#err_subject").hide(); if($("#examnames").val() == 0) { $("#err_examname").text("Please select Exam"); $("#err_examname").show(); return false; } if($("#classes").val() == 0) { $('#err_class').text("Please select Class"); $("#err_class").show(); return false; } if($("#sections").val() == 0) { $('#err_section').text("Please select Section"); $("#err_section").show(); return false; } if($("#subjects").val() == 0) { $('#err_subject').text("Please select Subject") $("#err_subject").show(); return false; } var snames = document.getElementsByName("snames[]"); var smarks = document.getElementsByName("secured[]"); var exam_status = document.getElementsByName("status[]"); var k=0; var p=1; for(var i=0;i<snames.length;i++) { if((smarks[i].value!="") || (exam_status[i].value!="0")) { $("#err_marks"+p).text(''); $("#err_status"+p).text(''); if(smarks[i].value=="") { $("#err_marks"+p).text('Please enter Secured Marks'); $("#err_marks"+p).show(); $("#securedmark"+p).focus(); return false; } else if(isNaN(smarks[i].value) && smarks[i].value!='') { $("#err_marks"+p).text('Please enter a valid number for Secured Marks'); $("#err_marks"+p).show(); $("#securedmark"+p).focus(); return false; } else if(exam_status[i].value=="0") { $('#err_status'+p).text("Please select Status"); $("#err_status"+p).show(); document.getElementById(exam_status[i].id).focus(); return false; } } if((smarks[i].value!="") && (exam_status[i].value!="0")) { k=1; } p++; } if(k==0) { alert("Please enter Marks for atleast One Student"); k=0; return false; } } function compare(id1,id2) { var re=/[0-9]/; var id_new = id1.replace('securedmark',""); var val=$('#'+id1).val(); $('#err_marks'+id_new).text(''); if(!re.test(val) && val!='') { $('#err_marks'+id_new).text("Please enter a valid number for Secured Marks"); $('#err_marks'+id_new).show(); //$('#'+id1).val(''); $('#'+id1).focus(); return false; } else if(Number(($('#'+id1).val())) > Number(($('#'+id2).val()))) { alert("Secured marks should be less than total marks"); $('#'+id1).val(""); $('#'+id1).focus(); return false; } } </script> </body> </html>