JezK
Edit File: edit_staffroute.php
<?php session_start(); include("menuheader.php"); if(!(in_array(5,$access) && in_array(5,$allow))) echo "<script>location.replace('dashboard.php');</script>"; $operations1=new adm_operations(); $schid=$_SESSION['child']['log_school_id']; $academic_id=$_SESSION['child']['choosen_academic_id']; $op=$operations1->getroutes2schid($schid,$academic_id); $res=$operations1->getstaffroutebystaffid($_GET['stfrid']); $get_route_stops=$operations1->getroute_stops_lists($res['route_id'],$academic_id); if(empty($op)) { $routes.='<option>--Select Route--</option>'; } if(count($op)>0) { foreach($op as $opp) { if($res['route_id']==$opp['route_id']) $routes.='<option value='.$opp['route_id'].' selected>'.$opp['route_number'].' ('.$opp['source_name'].'-'.$opp['destination_name'].')</option>'; else $routes.='<option value='.$opp['route_id'].'>'.$opp['route_number'].' ('.$opp['source_name'].'-'.$opp['destination_name'].')</option>'; } } /*if($get_route_stops) { foreach($get_route_stops as $stpid) { if($res['route_stop_id']==$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>"; } } }*/ if(isset($_POST['edtroute'])) { $run=$operations1->edit_staffroute($_POST['rcid'],$_POST['route'],$_POST['stf'],$academic_id,$_POST['stftyp']); if($run=='multiple') { echo "<script>alert('One route can not be assigned more than one driver');</script>"; } else if($run=='same') { echo "<script>alert('Given route was already assigned to the same staff');</script>"; } else { $goto='transport_management.php?route_id='.$_POST[route]; echo "<script>location.replace('".$goto."');</script>"; } } ?> <body style="overflow-y:scroll; overflow-x: hidden;"> <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 Staff Route " style="font-size: 20px;"></i>Edit Staff 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="route" name="route" style="height:29px; font-size:12px; width:300px !important;" tabindex="1"> <option selected="selected" value='0'>--Select Route--</option> <?php echo $routes;?> </select> <!-- if there is an error--> <div class="col-md-10" id="err_route" style="color:#990000;margin-left:-15px;"></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="stop" name="stop" style="height:29px; font-size:13px; width:300px!important; " tabindex="2" > </select> <div class="col-md-10" id="err_stop" style="color:#990000;margin-left:-15px;"></div> </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;">Staff Name</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="3" value="<?php echo $res['staff_name'];?>" > <input type="hidden" name="rcid" value="<?php echo $_GET[stfrid]?>"> <input type="hidden" name="stf" value="<?php echo $res[staff_id]?>"> <input type="hidden" name="stftyp" value="<?php echo $res[staff_type]?>"> </div> </div> </div> </div> <div class="form-group"> <div class="col-md-9" align="center"> <button type="submit" name="edtroute" 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; " onclick="return checkfields();">Update</button> <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="canceledit();">Cancel</button> </div> </div> </form> <!--</form> --> <script> function fetchstops(val) { $('#err_route').text(""); if(val==0) { $('#err_route').text("Please select Route"); $('#err_route').show(); } $.post("getstops.php",{id:val},function(data){document.getElementById("stop").innerHTML=data;}); } function canceledit() { var rt=$('#route').val(); if(rt!=0) window.location.href="transport_management.php?route_id="+rt; } function checkfields() { $('#err_route').text(""); $('#err_stop').text(""); if($('#route').val()==0) { $('#err_route').text("Please select Route"); $('#err_route').show(); return false; } else if($('#stop').val()==0) { $('#err_stop').text("Please select Stop"); $('#err_stop').show(); return false; } } </script> </body> </html>