JezK
Edit File: edit_studentroute.php
<?php session_start(); include("menuheader.php"); if(!(in_array(5,$access) && in_array(5,$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 $routes=$fun->school_students_routes($school_id,$academic_id); $get_route_stops=$fun->route_stops($_GET['route_id'],$academic_id); if(isset($_POST['updateroute'])) { $update_studentroute=$fun->update_student_onroute($_POST['stdidvalue'],$_POST['routes'],$_POST['pickup'],$school_id,$academic_id,$user_id); if($update_studentroute==1) { echo "<script>location.replace('transport_management.php?route_id=".$_POST['routes']."');</script>"; } } if($routes) { foreach($routes as $row) { if($_GET['route_id']==$row['route_id']) { $route_info .= "<option value='{$row['route_id']}' selected>{$row['route_name']}</option>"; } else { $route_info .="<option value='{$row['route_id']}' >{$row['route_name']}</option>"; } } } if($get_route_stops) { foreach($get_route_stops as $stpid) { if($_GET['stpid']==$stpid['route_stop_id']) { $stop_info .= "<option value='{$stpid['route_stop_id']}' selected>{$stpid['route_stop_name']}</option>"; } else { $stop_info .="<option value='{$stpid['route_stop_id']}' >{$stpid['route_stop_name']}</option>"; } } } ?> <script> function validation() { $("#err_route").text(""); $("#err_stop").text(""); if($("#routes").val()==0) { $("#err_route").text("Please Select The Route "); $("#err_route").show(); return false; } else if($("#pickup").val()==0) { $("#err_stop").text("Please Select The Stop "); $("#err_stop").show(); return false; } } </script> <div class="row" style="margin-top: 30px; margin-left:20px;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;"> <i class="glyphicon glyphicon-pencil" title ="Edit Student" style="font-size: 20px;"></i> Edit Student Route </div> </div> <form class="form-horizontal" 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-5 col-md-offset-1 text-right"> <b style="color:#666666; ">Select Route</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-6"> <select class="form-control" id="routes" name="routes" style="height:29px; font-size:12px; width:300px !important;" tabindex="1" > <option value='0' selected>--Select Route--</option> <? echo $route_info;?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_route" style="color:#990000;margin-left:-12px;"></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-5 col-md-offset-1 text-right"> <b style="color:#666666; ">Pickup/Drop</b> <span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-6"> <select class="form-control" id="pickup" name="pickup" style="height:29px; font-size:13px; width:300px!important; " tabindex="2" > <option value='0' selected>--Select Pickup/Drop--</option> <? echo $stop_info;?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_stop" style="color:#990000;margin-left:-12px;"></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-5 col-md-offset-1 text-right "> <b style="color:#666666;">Student Name</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-6"> <input type="hidden" id="stdidvalue" name="stdidvalue" value="<?php echo $_REQUEST['refid']?>"/> <input type="text" class="form-control" readonly id="text" style="height:29px;font-size:13px; width:300px!important;" tabindex="3" value="<?php echo $_REQUEST['student_name']?>"> </div> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-5 col-md-offset-1 text-right "> <b style="color:#666666;">Class</b> <span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-6"> <input type="text" class="form-control" readonly id="text" style="height:29px;font-size:13px; width:300px!important;" tabindex="4" value="<?php echo $_REQUEST['class_name']?>"> </div> </div> </div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-5 col-md-offset-1 text-right "> <b style="color:#666666;">Section</b> <span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-6"> <input type="text" class="form-control" readonly id="text" style="height:29px;font-size:13px; width:300px!important;" tabindex="5" value="<?php echo $_REQUEST['section_name']?>" > </div> </div> </div> </div> <div class="form-group"> <div class="col-md-9" align="center"> <input type="submit" onclick="return validation();" class="btn btn-default custom-button-width .navbar-right" tabindex="19" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:20px; " name="updateroute" value="Update"> <button type="button" class="btn btn-default custom-button-width .navbar-right" tabindex="20" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:20px;" onclick="location.href='transport_management.php?route_id=<?=$_GET[route_id]?>'" >Cancel</button> </div> </div> </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> $(document).ready(function() { $("#routes").change(function() { if($(this).val() == 0) { $("#err_route").text("Please Select The Route "); $("#err_route").show(); var section_option = '<option value="0">select Stop</option>'; $("#pickup").html(section_option); } else { var x = $(this).val(); $.ajax({ url: "ajaxcalls_app.php", type:"POST", data:"mode="+"route"+"&route_id="+x, success: function(result) { var result2 = eval("("+result+")"); //alert(result2[0]); var section_option = '<option value="0">select Stop</option>'; for(var i = 0;i < result2.length;i++) { section_option += '<option value="'+result2[i].route_stop_id+'">'+result2[i].route_stop_name+'</option>'; } $("#pickup").html(section_option); }, error : function(e) { } }); } }); $("#pickup").change(function() { if($(this).val() == 0) { $("#err_stop").text("Please Select The Stop "); $("#err_stop").show(); } }); }); </script> </body> </html>