JezK
Edit File: addgrades_tostudent.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);//TO GET CLASSES BY CALLING THIS FUNCTION $exam_names=$fun->exam_name_details($school_id,$academic_id);//TO GET EXAM NAMES BY CALLING THIS FUNCTION $sections=$fun->get_sections($_GET['classid'],$academic_id); if(isset($_GET['classid']) && isset($_GET['sec_id'])) { $students=$fun->get_studentsto_grade($_GET['classid'],$_GET['sec_id'],$_GET['exname_id'],$school_id,$academic_id); } 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>"; } } } 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']) { $exmnamesss .= "<option value='{$row['exam_id']}' selected>{$row['exam_name']}</option>"; } else { $exmnamesss .="<option value='{$row['exam_id']}' >{$row['exam_name']}</option>"; } } } ?> <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; } .table.no-border tr td, .table.no-border tr th { border-width: 0; } table, thead, tr, tbody, th, td { text-align: center; } @media screen and (min-width:1600px) { .media_1600 { margin-left:80px!important; } .media1 { margin-left:342px!important; } } @media print { .row123 ,.menuu{display: none;} .no-print { display: none !important; } } </style> <body style="overflow-x: hidden;"> <div class="row row123" 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="exam_schedule.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 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="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 row123" 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/set-grades_Black.png" title ="Set Grades to Students" style="font-size: 24px;"/> Set Grades to Students </div> </div> <form class="form-horizontal" style="margin-top:20px; margin-left:-70px;" method="post" action="addgrade.php"> <div class="box-body entries" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class="clear no-print"> <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:291px; display:none; width:230px;"></div> <!--- end error--> </div> </div> <div class="clear no-print"> <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> <?php echo $classes_list;?> </select> </div> <!-- if there is an error--> <div class="col-md-10 media1" id="err_class" style="color:#990000;margin-left:291px; display:none; width:230px;"></div> <!--- end error--> </div> </div> <div class="clear no-print"> <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> <?php echo $secs;?> </select> </div> <!-- if there is an error--> <div class="col-md-10 media1" id="err_section" style="color:#990000;margin-left:291px; display:none; width:230px;"></div> <!--- end error--> </div> </div> </div> <!--dynamic content Start--> <div class="col-md-10 text-center row123" id="sucmsg"><span style="color:green;padding-top:20px;padding-bottom:20px;"><? if($_GET['resp']=='success') echo "Grades updated successfully";?></span></div> <div class="row row123" style="margin-bottom:20px;"> <div class="col-md-3 col-md-offset-9"> <button onclick="return printData();" class="btn btn-default" style="font-family: Arial, Helvetica, sans-serif; font-size:14px;padding:4px 10px;margin-left:-26%;"> Print </button> </div> </div> <div class="row text-center visible-print" style="display:none;"><h3><?php echo $_SESSION['child']['school_name'];?></h3></div> <div class="row text-left visible-print" style="display:none;margin-left:100px;">Academic Year : <?php echo $_SESSION['child']['choosen_year_name'];?></div> <div class="row text-left visible-print" style="display:none;margin-left:85px;"> <div class="col-md-4"> <span>Exam Name:</span><span id="exmd"></span> </div> <div class="col-md-4"> <span>Class:</span><span id="cld"></span> </div> <div class="col-md-4"> <span>Section:</span><span id="scd"></span> </div> </div> <div class="row no-print"> <div class="col-md-12"> <div class="col-md-3 text-right"><b>Student Rollno</b></div> <div class="col-md-3 text-center"><b>Student Name</b></div> <div class="col-md-3 text-left"><b>Total Secured Marks</b></div> <div class="col-md-3 text-left"><b style="margin-left:-49%;">Set Grade</b></div> </div> </div><br/> <?php $printable='<div class="visible-print" style="display:none;margin-left:80px;margin-top:-100px;"> <table> <tr> <th style="width:200px;">Student Roll Number</th> <th style="width:200px;">Student Name</th> <th style="width:200px;">Total Secured Marks</th> <th style="width:200px;">Grade</th> </tr>'; if($students) { $i = 0; $j=3; foreach($students as $row) { $i = $i + 1; $wx=$j+1; $xx=$j+2; $xy=$j+3; $printable.='<tr><td>'.$row[student_rollno].'</td><td>'.$row[student_name].'</td><td>'.$row[total_secured].'</td><td>'.$row[student_grade].'</td></tr>'; ?> <div class="row no-print" > <div class="col-md-12"> <div class="col-md-3 text-right" style="margin-left: 18px;"> <input type="text" class="time" id="" value="<?php echo $row['student_rollno']?>" readonly style="width:120px!important; height:25px;" tabindex="<?php echo $wx?>"> <input type="hidden" value="<?php echo $row['student_id']?>" name="strollno[]"> </div> <div class="col-md-3 text-center" style="margin-left: 34px;"> <input type="text" class="time" id="<?php echo $row['student_id']?>" value="<?php echo $row['student_name']?>" readonly style="width:200px!important; height:25px;" tabindex="<?php echo $xx?>"> <input type="hidden" name="student[]" value="<?php echo $row['student_id']?>"> </div> <div class="col-md-3 text-left" style="margin-left: -54px;"> <input type="text" style="width:120px!important; height:25px;" tabindex="<?php echo $xy+4;?>" value="<?php echo $row['total_secured'];?>" readonly> <input type="hidden" value="<?php echo $row['student_id']?>" name="strollno[]"> </div> <div class="col-md-3 text-left" > <input type="text" class="add_grade" value="<?php echo $row['student_grade']?>" id="<?php echo 'grade'.$i?>" maxlength="10" onblur="assign_grade(this.id);" name="grade[]" style="width:120px!important; height:25px;margin-left:-48%;" tabindex="<?php echo $xy?>"> <input type="hidden" value="<?php echo $row['student_grade']?>" name="grades<?php echo $row['student_id']?>" > <!-- if there is an error--> <div class="col-md-10 media_1600" id="err_grade<?php echo $i?>" style="color:#990000;margin-left:56px; display:none; width:250px;font-size:12px;"></div> <!--- end error--> </div> </div> </div><br/> <?php $j=$j+4; } } $printable.='</table></div>'; echo $printable; ?> <!--dynamic content End--> </div> </div> <div class="form-group row123"> <div class="col-md-off-set-2" align="center"> <button type="submit" onclick="return validation();" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="<?if($_GET['sec_id']!='') echo $xy+1;else echo '4';?>" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px; ">Update</button> <button type="button" onclick="location.href='addgrades_tostudent.php'" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="<?if($_GET['sec_id']!='') echo $xy+2;else echo '4';?>" 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() { $("#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 x = $(this).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">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() { $("#err_section").text(""); if($("#classes").val() == 0) { $("#err_class").text("Please select Class"); return false; } else if($("#sections").val() == 0) { $("#err_section").text("Please select Section"); $("#err_section").show(); return false; } else if($("#examnames").val() == 0) { $("#err_examnames").text("Please select Exam"); return false; } else { var cls=$("#classes").val(); var sec_id=$("#sections").val(); var enameid=$("#examnames").val(); window.location.href="addgrades_tostudent.php?classid="+cls+"&sec_id="+sec_id+"&exname_id="+enameid; } }); $("#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 sec_id=$("#sections").val(); var enameid=$("#examnames").val(); window.location.href="addgrades_tostudent.php?classid="+cls+"&sec_id="+sec_id+"&exname_id="+enameid; } }); setTimeout(function() { $('#sucmsg').fadeOut('fast'); }, 6000); }); function printData() { var classname=$('#classes').find('option:selected').text(); var secname=$('#sections').find('option:selected').text(); var exm=$('#examnames').find('option:selected').text(); $('#cld').text(classname); $('#scd').text(secname); $('#exmd').text(exm); window.print(); return false; } function validation() { $("#err_class").hide(); $("#err_section").hide(); $("#err_subject").hide(); $("#err_examname").hide(); if($("#examnames").val() == 0) { $("#err_examname").text("Please select Exam"); $("#err_examname").show(); return false; } else 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; } var students = document.getElementsByName("strollno[]"); var grades = document.getElementsByName("grade[]"); var k = 0; var jd = 1; for(var i=0;i<grades.length;i++) { if(grades[i].value!="") { k=1; } } if(k==0) { alert("Please Set Grade for atleast One Student"); return false; } for(var i=0;i<grades.length;i++) { $("#err_grade"+jd).text(""); var regexp = /^[a-zA-Z0-9\-_+ ]+$/; if(grades[i].value!='') { if (!regexp.test(grades[i].value)) { $("#err_grade"+jd).text("Please enter a valid Grade"); $("#err_grade"+jd).show(); return false; } jd++; } } } function assign_grade(grade) { document.getElementById(grade).value=(document.getElementById(grade).value).trim(); $("#"+grade).next('input').val($("#"+grade).val()); } </script> </body> </html>