JezK
Edit File: update_examschedule.php
<?php session_start(); include("menuheader.php"); if(!(in_array(4,$access) && in_array(3,$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); $sections=$fun->get_sections($_GET['classid'],$academic_id); $chosen_date=$fun->get_current_academicyear_id($academic_id,$school_id); $aystart=$chosen_date['start_date']; $ayend=$chosen_date['end_date']; $cudate=date('Y-m-d'); $cancelto = 'exam_schedule.php?class_id='.$_GET['classid'].'§ion_id='.$_GET['sec_id'].'&exname_id='.$_GET['exname']; if($sections) { //$secs = "<option value='all' selected>All</option>"; 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']==$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['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(isset($_GET['classid']) && isset($_GET['sec_id']) && isset($_GET['exname'])) { if($_GET['subject_id']!="") { $schedule[]=$fun->loadexam_timetable_subject($_GET['classid'],$_GET['sec_id'],$_GET['subject_id'],$_GET['exname'],$academic_id,$school_id); } else { $schedule=$fun->loadexam_timetable($_GET['classid'],$_GET['sec_id'],$school_id,$academic_id,$_GET['exname']); } } if($_GET['classid']!='' && $_GET['sec_id']!='') { $students=$fun->get_students2($_GET['classid'],$_GET['sec_id'],$school_id,$academic_id); $str = ''; if($students) { foreach($students as $key=>$sval) { $str .= $sval['student_id'].","; } } } ?> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script> <script type="text/javascript" src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min.js"></script> <script type="text/javascript" src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.pt-BR.js"></script> <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; } .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; } @media screen and (min-width:1600px) { .media_1600 { margin-left:51px!important; } .media_16001 { margin-left:15px!important; } .media_16002 { margin-left:25px!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 class="selected" 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 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:10px;"> <div class="col-md-4 text-center" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:14px; color:#000000; font-size:1.4em;"> <i class="glyphicon glyphicon-plus" title ="Update Exam Schedule" style="font-size:16px;"></i> Add/Update Exam Schedule </div> </div> <form class="form-horizontal" style="margin-top:20px; margin-left:-100px;" method="post" action="updateexam_schedule.php"> <input type="hidden" name="acdate" id="enddate" value="<?=$ayend?>"> <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> <!-- if there is an error--> <div class="form-group col-md-8 col-md-offset-3" id="err_examname" style="color:#990000;display:none;">Please select exam name</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; ">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> <!-- if there is an error--> <div class="form-group col-md-8 col-md-offset-3" id="err_class" style="color:#990000;display:none;">Please select the Class</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; ">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="form-group col-md-8 col-md-offset-3" id="err_section" style="color:#990000;display:none;">Please select the Section</div> <!--- end error--> </div> </div> </div> </div> <!--dynamic content start--> <div class="row" style="margin-left:1em;"> <div class="col-md-10 col-md-offset-1"> <div class="col-md-1 text-center1"> </div> <div class="col-md-2 text-center1"><b>Subject</b></div> <div class="col-md-2 text-center1"><b style="/*margin-left:1em;*/">Total Marks</b></div> <div class="col-md-2 text-center1"><b style="/*margin-left:1em;*/">Date</b></div> <div class="col-md-2 text-center1"><b style="/*margin-left:1em;*/">Start Time</b></div> <div class="col-md-2 text-center1"><b style="/*margin-left:4em*/">Duration(Minutes)</b></div> </div> </div><br/> <?php //print_r($schedule); if($schedule) { $i=0; $j=4; foreach($schedule as $row) { $i++; if($row['exam_date']!="") { $originalDate = $row['exam_date']; $newDate = date("d/m/Y", strtotime($originalDate)); } else { $newDate = ''; } if($row['total_marks'] != '') { $validate = "No"; } else { $validate = "Validate"; } $wx=$j+1; $xx=$j+2; $xy=$j+3; $xz=$j+4; $xa=$j+5; ?> <div class="row" style="margin-left:1em;"> <div class="col-md-10 col-md-offset-1"> <div class="col-md-1 text-center1"> </div> <div class="col-md-2 text-center"> <input type="hidden" name="student[]" value="<?=$row['subject_id']?>"> <input type="hidden" name="student_ids_data" value="<?=$str?>"> <input type="text" class="time" value="<?=$row['exam_subject']?>" name="subjects[]" style="width:130px!important; height:28px;/*margin-left:4em;*/" readonly tabindex="<?=$wx?>"><br/><br/> </div> <div class="col-md-2 text-center"> <input type="text" class="total_marks" maxlength="5" id="ajf<?=$i?>" name="marks[]" value="<?=$row['total_marks']?>" style="width:130px!important; height:28px;/*margin-left:4em;*/" tabindex="<?=$xx?>" onblur="trimthisfield(this.id)"><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: 42px;width: 179px;"></div> <!--- end error--> </div> <div class="col-md-2 text-center"> <div id="datetimepicker<? echo $i;?>" class="input-append date"> <input type="text" name="datetimepicker[]" id="datepicker<? echo $i;?>" class="adddate" autocomplete="off" value="<?=$newDate?>" style="height:30px; width:100px;font-size:13px;/*margin-left:4em;*/" tabindex="<?=$xy?>"> <span class="add-on" style="height:30px;" > <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i> </span><br/><br/> </div> <!-- if there is an error--> <div class="col-md-4"></div><div class="col-md-8 media_1600" id="err_date<?=$i?>" style="color: rgb(153, 0, 0);font-size: 12px;margin-top: -15px;text-align: left;margin-left: 42px;width: 179px;"></div> <!--- end error--> <script type="text/javascript"> $('#datetimepicker<? echo $i;?>').datetimepicker({ format: 'dd/MM/yyyy', pickTime: false, }).on('changeDate', function(){ var j = <? echo $i;?>; $(this).datetimepicker('hide'); var nwdate=$("#now_dated").val(); var cudate=nwdate.split("-"); var done= $("#start_dated").val(); var dtwo = $("#end_dated").val(); var dayone = done.split('-'); var daytwo = dtwo.split('-'); var cmp= $('#datepicker<?=$i?>').val(); var dcmp=cmp.split('/'); var mone=dayone[1]-1; var mtwos=daytwo[1]-1; var mcdate=dcmp[1]-1; var mcheck=cudate[1]-1; //alert(JSON.stringify(dcmp)); var dones = new Date(dayone[0],mone,dayone[2]); var dtwos = new Date(daytwo[0],mtwos,daytwo[2]); var cdate= new Date(dcmp[2],mcdate,dcmp[0]); var checkd= new Date(cudate[0],mcheck,cudate[2]); $("#err_date"+j).hide(); if(cdate>=dones && cdate<=dtwos) { if(cdate<checkd) { /*$("#err_date"+j).text('You can not choose a past date'); $("#err_date"+j).show(); $("#datepicker"+j).val(""); return false;*/ } } else { if($('#datepicker<?=$i?>').val()!='') { $("#err_date"+j).text('Please select the Exam date within chosen Academic Year range') //alert("Please select the Exam date within chosen Academic Year range"); $("#err_date"+j).show(); $('#datepicker<?=$i?>').val(""); return false; } } }); </script> </div> <div class="col-md-2 text-center"> <div id="datetimepickerr<? echo $i;?>" class="input-append"> <input data-format="hh:mm:ss" name="timepicker[]" autocomplete="off" class="addtime" type="text" style="height:29px;font-size:13px;width:100px;/*margin-left: 4em;*/ " value="<?=$row['exam_time']?>" tabindex="<?=$xz;?>"> <span class="add-on" style=" height:29px;"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span><br/><br/> </div> <!-- if there is an error--> <div class="col-md-10 media_16001" id="err_starttime<?=$i?>" style="color:#990000;width:200px;font-size:12px;margin-left:2px;margin-top:-20px;" ></div> <!--- end error--> <script type="text/javascript"> $(function() { $('#datetimepickerr<?=$i?>').datetimepicker({ pickDate: false }); }); </script> </div> <div class="col-md-2 text-center"> <input type="text" class="add_duration" maxlength="4" id="durationid=<?=$i?>" name="duration[]" style="width:130px!important;height:28px;/*margin-left:4em;*/" value="<?=$row['exam_duration']?>" tabindex="<?=$xa;?>" onblur="trimthisfield(this.id)"><br/><br/> <!-- if there is an error--> <div class="col-md-10 media_16002" id="err_duration<?=$i?>" style="color:#990000;width:200px;font-size:12px;margin-top:-20px;margin-left:16px;"></div> <!--- end error--> </div> </div> </div> <?php $j=$j+4; } } else if($_GET['sec_id']) { echo '<div class="row"><div class="col-md-10 col-md-offset-4"><p style="align:center;">No subjects have yet been defined for this class category</p></div></div>'; } else { echo '<div class="row"><div class="col-md-10 col-md-offset-4"><p style="align:center;">No data available</p></div></div>'; } ?> <!--dynamic content end--> <input type="hidden" id="start_dated" name="start_dates" value="<?php echo $chosen_date['start_date'];?>" > <input type="hidden" id="end_dated" name="end_dates" value="<?php echo $chosen_date['end_date'];?>" > <input type="hidden" id="now_dated" name="now_dates" value="<?=date('Y-m-d');?>"> <div style="clear:both"></div> <div class="col-md-5"></div> <div class="col-md-5"> <!--<php if($schedule) { ?>--> <button type="submit" onclick="return validation()" class="btn btn-default custom-button-width centered btnclr" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px;" tabindex="<?if($_GET['sec_id']) echo $xa+1;else echo '4';?>">Add/Update</button> <button type="button" onclick="cancelme()" class="btn btn-default custom-button-width .navbar-right btnclr" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:10px;" tabindex="<?if($_GET['sec_id']) echo $xa+1;else echo '5';?>">Cancel</button> <!--< } ?>--> </div> </form> <div class="col-md-1"></div> </div> <div style="height:12em;"></div> <script> $(document).ready(function() { $("#classes").change(function() { $("#err_class").text(""); if($("#classes").val() == 0) { var section_option = '<option value="0" selected>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+")"); var section_option = '<option value="0" selected>Select Section</option>'; //section_option += '<option value="all">All</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); } }); } }); $("#sections").change(function() { $("#err_section").text(""); $("#err_examname").text(""); if($("#sections").val()==0) { $("#err_section").text("Please select Section"); $("#err_section").show(); return false; } else if($("#examnames").val()==0) { $("#err_examname").text("Please select Exam"); $("#err_examname").show(); return false; } else { var cls=$("#classes").val(); var ename=$("#examnames").val(); var sec_id=$("#sections").val(); //alert(sec_id); window.location.href="update_examschedule.php?classid="+cls+"&exname="+ename+"&sec_id="+sec_id; } }); $("#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 && $("#sections").val() != 0 && $("#examnames").val() != 0) { var cls=$("#classes").val(); var ename=$("#examnames").val(); var sec_id=$("#sections").val(); window.location.href="update_examschedule.php?classid="+cls+"&exname="+ename+"&sec_id="+sec_id; } }); }); function cancelme() { window.location.href="<?=$cancelto?>"; } function validation() { var setx=0; var reg=/^[0-9]$/; $("#err_examname").hide(); $("#err_class").hide(); $("#err_section").hide(); if($("#examnames").val() == 0) { $("#err_examname").show(); return false; } else if($("#classes").val() == 0) { $("#err_class").show(); return false; } else if($("#sections").val() == 0) { $("#err_section").show(); return false; } var nwdate=$("#now_dated").val(); var cudate=nwdate.split("-"); var done= $("#start_dated").val(); var dtwo = $("#end_dated").val(); var dayone = done.split('-'); var daytwo = dtwo.split('-'); var subjects = document.getElementsByName("subjects[]"); var mars = document.getElementsByName("marks[]"); var dat = document.getElementsByName("datetimepicker[]"); var time = document.getElementsByName("timepicker[]"); var dur = document.getElementsByName("duration[]"); var k=0; var j=1; for(var i=0;i<subjects.length;i++) { $("#err_marks"+j).text(''); $("#err_date"+j).text(''); $("#err_starttime"+j).text(''); $("#err_duration"+j).text(''); if((dur[i].value!="") || (mars[i].value!="") || (dat[i].value !="") || (time[i].value !="")) { if(mars[i].value=="") { $("#err_marks"+j).text('Please enter Total Marks'); $("#err_marks"+j).show(); return false; } else if(isNaN(mars[i].value)) { $("#err_marks"+j).text('Please enter a valid number for Total Marks'); $("#err_marks"+j).show(); return false; } else if(dat[i].value=="") { $("#err_date"+j).text('Please select Date'); $("#err_date"+j).show(); return false; } else if(time[i].value=="") { $("#err_starttime"+j).text('Please enter Time'); $("#err_starttime"+j).show(); return false; } else if(dur[i].value=="") { $("#err_duration"+j).text('Please enter Duration'); $("#err_duration"+j).show(); return false; } else if(isNaN(dur[i].value)) { $("#err_duration"+j).text('Please enter valid Duration'); $("#err_duration"+j).show(); return false; } else if(xyz(dat[i].id,dat[i].value,j)) { return false; } } else { k=k+1; } j++; if((dur[i].value!="") && (mars[i].value!="") && (dat[i].value !="") && (time[i].value !="")) { setx=1; } } var d = new Date(); var hours = d.getHours(); var minutes = d.getMinutes(); var seconds = d.getSeconds(); var current_time=hours+':'+minutes+':'+ seconds; var marksd=[]; var durationd=[]; var pd=0; var nm=0; if(setx==0) { alert("Please define Exam Schedule for at least one subject"); return false; } if(subjects.length==0) { alert("Please define Exam Schedule for at least one subject"); return false; } } function xyz(id,value,pos) { var nwdate=$("#now_dated").val(); var cudate=nwdate.split("-"); var done= $("#start_dated").val(); var dtwo = $("#end_dated").val(); var dayone = done.split('-'); var daytwo = dtwo.split('-'); var cmp= value; var dcmp=cmp.split('/'); var mone=dayone[1]-1; var mtwos=daytwo[1]-1; var mcdate=dcmp[1]-1; var mcheck=cudate[1]-1; //alert(JSON.stringify(dcmp)); var dones = new Date(dayone[0],mone,dayone[2]); var dtwos = new Date(daytwo[0],mtwos,daytwo[2]); var cdate= new Date(dcmp[2],mcdate,dcmp[0]); var checkd= new Date(cudate[0],mcheck,cudate[2]); if(cdate>=dones && cdate<=dtwos) { /*if(cdate<checkd) { $("#err_date"+j).text('You can not choose a past date'); $("#err_date"+j).show(); $("#datepicker"+j).val(""); return true; }*/ } else { if($('#'+id).val()!='') { //alert("Please select the Exam date within chosen Academic Year range"); $("#err_date"+pos).text('Please select the Exam date within chosen Academic Year range'); $("#err_date"+pos).show(); $('#'+id).val(""); return true; } } return false; } function trimthisfield(id) { var x=document.getElementById(''+id+'').value.trim(); document.getElementById(''+id+'').value=x; } </script> </body> </html>