<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<script>
$(document).ready(function(){
  $("#myInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#myTable tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>

 <script>
$(document).ready(function(){
  $("#myInput2").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#myTable2 tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>
<?php
$pgMod = "assign_student";
$pgAct = "view";

if(isset($_POST["update_route"])){

// print_r($_POST);
// die();
    
    if(is_array($_POST["idno"]) && count($_POST["idno"])>0){
        $x = 0;
        foreach($_POST["idno"] as $idno) { 

            $saveAry = array( 
                            "location"  => $_POST["location"][$x], 
                            "old_school"=> $_POST["old_school"][$x],
        				);

            $flgUp=$db->updateAry("student", $saveAry, " where idno='$idno' and session='".$_SESSION["admin"]["session"]."' ");

            $x++;
        }

     if(!is_null($flgUp))
     		{
     			$_SESSION['msg']='update Successfully';
     		}
     		redirect();
    }

}


if(isset($_POST["update_pickup"])){

// print_r($_POST);
// die();
    
    if(is_array($_POST["idno"]) && count($_POST["idno"])>0){
        $x = 0;
        foreach($_POST["idno"] as $idno) {

            $saveAry = array( 
                            "bus"       => $_POST["bus"][$x]
        				);

            $flgUp=$db->updateAry("student", $saveAry, " where idno='$idno' and session='".$_SESSION["admin"]["session"]."' ");

        	$insdata = $db->getRow("select * from installment where idno='$idno' ");

            $busDetail   =   $db->getRow("select fee,installment from bus where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$_POST["bus"][$x]."'");
            $totalFee    =   $busDetail["fee"];
            $installment =   $busDetail["installment"];
            $perFee      =   $totalFee/$installment;

            if($_POST["bus"][$x] == ""){
                    for($i=1;$i<=12;$i++){

                        if($insdata["bp".$i] == ""){
                            $dataBus = array( "b$i"     =>  "",
                                              "bp$i"    =>  ""
                                            );
                            $flgInstall=$db->updateAry("installment",$dataBus,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."'");
                        }

    				}

                    $bustotal=array("bus"=>"");
                    $flgUp=$db->updateAry("installment",$bustotal,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."' and session='".$_SESSION["admin"]["session"]."'");
 
            } else {
                if($totalFee>0 && $installment>0 && $flgUp > 0){
                    for($ii=1;$ii<=$installment;$ii++){
                        // $dataBus["b".$ii]=number_format($perFee, 2, '.', '');;

                        $dataBus = array( "b$ii" => number_format($perFee, 2, '.', '') );
                        $flgInstall=$db->updateAry("installment",$dataBus,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."'");
    				}
                    $bustotal=array("bus"=>$totalFee);
                    $flgUp=$db->updateAry("installment",$bustotal,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."' and session='".$_SESSION["admin"]["session"]."'");
    		    }
            }
            $x++;
        }

     if(!is_null($flgUp))
     		{
     			$_SESSION['msg']='update Successfully';
     		}
     		redirect();
    }

}

if(isset($_POST["update_busroot"])){

// print_r($_POST);
// die();
    
    if(is_array($_POST["idno"]) && count($_POST["idno"])>0){
        $x = 0;
        foreach($_POST["idno"] as $idno) {

            $saveAry = array( 
                            "location"  => $_POST["location"][$x], 
                            "old_school"=> $_POST["old_school"][$x],
        				);

            $flgUps=$db->updateAry("student", $saveAry, " where idno='$idno' and session='".$_SESSION["admin"]["session"]."' ");

            $saveAry = array( 
                            "bus"       => $_POST["bus"][$x]
        				);

            $flgUp=$db->updateAry("student", $saveAry, " where idno='$idno' and session='".$_SESSION["admin"]["session"]."' ");

        	$insdata = $db->getRow("select * from installment where idno='$idno' ");

            $busDetail   =   $db->getRow("select fee,installment from bus where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$_POST["bus"][$x]."'");
            $totalFee    =   $busDetail["fee"];
            $installment =   $busDetail["installment"];
            $perFee      =   $totalFee/$installment;

            if($_POST["bus"][$x] == ""){
                    for($i=1;$i<=12;$i++){

                        if($insdata["bp".$i] == ""){
                            $dataBus = array( "b$i"     =>  "",
                                              "bp$i"    =>  ""
                                            );
                            $flgInstall=$db->updateAry("installment",$dataBus,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."'");
                        }

    				}

                    $bustotal=array("bus"=>"");
                    $flgUp=$db->updateAry("installment",$bustotal,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."' and session='".$_SESSION["admin"]["session"]."'");
 
            } else {
                if($totalFee>0 && $installment>0 && $flgUp > 0){
                    for($ii=1;$ii<=$installment;$ii++){
                        // $dataBus["b".$ii]=number_format($perFee, 2, '.', '');;

                        $dataBus = array( "b$ii" => number_format($perFee, 2, '.', '') );
                        $flgInstall=$db->updateAry("installment",$dataBus,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."'");
    				}
                    $bustotal=array("bus"=>$totalFee);
                    $flgUp=$db->updateAry("installment",$bustotal,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."' and session='".$_SESSION["admin"]["session"]."'");
    		    }
            }
            $x++;
        }

     if(!is_null($flgUp))
     		{
     			$_SESSION['msg']='update Successfully';
     		}
     		redirect();
    }

}


//     if(isset($_POST["update_busroot"])){

// print_r($_POST);
// // die();
    
//     if(is_array($_POST["idno"]) && count($_POST["idno"])>0){
//         $x = 0;
//         foreach($_POST["idno"] as $idno) {

//         $saveAry = array( 
//                         "location"  => $_POST["location"][$x], 
//                         "old_school"=> $_POST["old_school"][$x],
//                         "bus"       => $_POST["bus"][$x]
//     				);

//         	if($_POST["bus"][$x]!=""){
//                 $flgUp=$db->updateAry("student", $saveAry, " where idno='$idno' and session='".$_SESSION["admin"]["session"]."' ");
//         	}
        	
//         	$insdata = $db->getRow("select * from installment where idno='$idno' ");
        	
//         // 	print_r($insdata);
 
//                 $busDetail   =   $db->getRow("select fee,installment from bus where school_id='".$_SESSION["admin"]["school_id"]."' and id='".$_POST["bus"][$x]."'");
//                 $totalFee    =   $busDetail["fee"];
//                 $installment =   $busDetail["installment"];
//                 $perFee      =   $totalFee/$installment;
             
//                 if($totalFee>0 && $installment>0){
//                     for($ii=1;$ii<=$installment;$ii++){
//                         if($_POST["bus"][$x]==""){
                            
//                             if($insdata["bp$ii"] > 0){
                                
//                             } else {
//                                 $dataBus["b".$ii]  = "";
//                                 $dataBus["bp".$ii] = "";
//                                 // $dataBus["bus"]    = "";
//                                 $flgInstall=$db->updateAry("installment",$dataBus,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."'");
//                             }
                            
//                         } else {
//                             $dataBus["b".$ii]=number_format($perFee, 2, '.', '');;
//                             $flgInstall=$db->updateAry("installment",$dataBus,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."'");
//                         }
//     				}
    
//                     $bustotal=array("bus"=>$totalFee);
//                     $flgUp=$db->updateAry("installment",$bustotal,"where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."' and session='".$_SESSION["admin"]["session"]."'");
//     		    }

//             //}
//             $x++;
//         }

//         die();

//      if(!is_null($flgUp))
//      		{
//      			$_SESSION['msg']='update Successfully';
//      		}
//     }

// }
?>

<style>.top-bar-minimize{display:none;}
thead, tfoot {display: table-header-group;}
.top-bar+.well,.accordion .accordion-heading+.accordion-body{display: inline-block !important;width: 100% !important;overflow: inherit !important;} 
</style>
<?php

if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
	?>
	<div class="alert alert-success">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-thumbs-up-alt"></i> <b>Notice</b><?php echo $_SESSION['msg'] ?></i>
	</div>
	<?php
	unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
	?>
	<div class="alert alert-error">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-warning-sign"></i> <b>Notice</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}
	?>
    <form method="get" action="">
    <input type="hidden" name="src" value="Transport" />
    <input type="hidden" name="page_id" value="<?php echo $pgMod; ?>" />
	<div class="row-fluid">
            <div class="span12">
            	<div class="top-bar">
					<h3><i class="icon-cog"></i>Search Student Record</h3>
                    <div>
                        <!--<button type="submit" name="add_route" class="btn btn-primary">Add Route</button>-->
                        <!--<button type="submit" name="add_pickup" class="btn btn-primary">Add Pickup</button>-->
                        <button type="submit" name="update_root" class="btn btn-primary">Update Bus Route</button>
					</div>
				</div>
				<div class="well no-padding">
                	<div class="controls controls-row">
                        
                        <div class="control-group span4">
                            <label class="control-label" for="class">Class</label>
                            <div class="controls">
                                <select name="class" id="class">
                                    <option value="">Class</option>
                                    <?php 
                                        $class=$db->getRows("select * from class where school_id='".$_SESSION["admin"]["school_id"]."' ");
                                        foreach($class as $cla){
                                            ?>
                                            <option <?php if($cla["class"]==$_GET["class"])echo 'selected';?> value="<?php echo $cla["class"] ?>">
                                                <?php echo $cla["class"] ?>
                                            </option>
                                            <?php
                                        }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="control-group span4">
                            <label class="control-label" for="class">Section</label>
                            <div class="controls">
                         <select name="section" id="section" >
                <option value="">Section</option>
                <?php 
                    $class=$db->getRows("select * from section where school_id='".$_SESSION["admin"]["school_id"]."'");
                    foreach($class as $cla){
                        ?>
                        <option <?php if($cla["name"]==$_GET["section"])echo 'selected';?> value="<?php echo $cla["name"] ?>">
                            <?php echo $cla["name"] ?>
                        </option>
                        <?php
            
                    }
                ?>
            </select>
                            </div>
                        </div>
                       
                    </div>
                    <br>
				</div>
				<!-- / Forms: Content -->
			</div>
    </div>
    </form>
	<?php
	$where=array();
	$qry="";


    if(isset($_GET["add_route"])){

		?><form method="post" action="">
		<div class="row-fluid">
            <div class="span12">
            	<div class="top-bar">
					<h3><i class="icon-cog"></i>Add Result of students</h3>
                    <div>
						<button type="submit" name="update_route" class="btn btn-primary"> Save</button>
					</div>
				</div>
				<div class="well no-padding">
                	<div class="controls controls-row">
		<center><input class="form-control" id="myInput" type="text" placeholder="Search.."></center>
		<?php
		$whereC=array();
		if(isset($_GET["class"]) && $_GET["class"]!="")
			$whereC[]=" class='".$_GET["class"]."' ";
		
		if(isset($_GET["section"]) && $_GET["section"]!="")
			$whereC[]=" section='".$_GET["section"]."' ";
		$whereM="";
		if(is_array($whereC) && count($whereC)>0)
			$whereM=" where ".implode(" and ",$whereC);
		
		$allstudent=$db->getRows("select * from student $whereM and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and issue_TC=0 and status=1 order by name ");
		
		if(is_array($allstudent) && count($allstudent)>0){
			?>
			<table class="table table-bordered table-striped">
    		    <thead> 
        			<tr>
                        <td>SNo.</td>
                        <td>Student</td>
                        <td>Father Name</td>
                        <td>Address</td>
                        <td>Route</td>
                        <td>Vehicle</td>
                    </tr>
                </thead>
            <tbody id="myTable">
			<?php $i=0;
			foreach($allstudent as $stu){ $i++;
			
				$aryInstall=$db->getRow("select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$stu["idno"]."' and session='".$_SESSION["admin"]["session"]."'");

				$totalbuspayfee=0;
				for($ii=1;$ii<=12;$ii++){
    							$iip    =   "bp".$ii;
								$totalbuspayfee+=   $aryInstall[$iip];
							}
                $totalbuspayfee;  

			
				?>
				<tr>
                	<td><?php echo $i; ?></td>
                	<td><?php echo $stu["name"]; ?></td>
					<td><?php echo $stu["fname"]; ?></td>
					<td><?php echo $stu["address"]; ?></td>

               <?php
                	$routes = $db->getRows("select DISTINCT(name), id from location WHERE pickup_point='' ");
            	?>
                <td>
                    <input type="hidden" name="idno[]" required  value="<?php echo $stu["idno"] ?>" readonly="readonly" />

                        <select name="location[]" id="route_<?php echo $stu['idno'] ?>" >
                        	<option value="">Select Route</option>
                        	<?php if(is_array($routes) && count($routes)>0){
    							foreach($routes as $loc){ ?>
    								<option <?php if($loc["id"]==$stu["location"])echo 'selected'; ?> value="<?php echo $loc["id"] ?>"><?php echo $loc["name"] ?></option><?php
    							}
    						} ?>
                        </select>
                </td>

                <?php
                	$wherebus   =   "";
                	if($stu['location']!=''){
                	    $wherebus = " and route='$stu[location]' ";
                	}

                	$drivers    =   $db->getRows("select * from bus_detail where school_id='".$_SESSION["admin"]["school_id"]."'  ");

            	?>
               <td>
                   <div id="vehicle_<?php echo $stu['idno']; ?>">
                        <select name="old_school[]"  >
                        	<option value="">Select Bus</option>
                        	<?php if(is_array($drivers) && count($drivers)>0){
    							foreach($drivers as $driver){
    								?><option <?php if($driver["id"]==$stu["old_school"])echo 'selected'; ?>  value="<?php echo $driver["id"] ?>"><?php echo $driver["name"] ?></option><?php
    							}
    						} ?>
                        </select>
                    </div>
                </td>
 
                </tr>
				<?php
			}
			?></tbody></table><?php
		}
		?></div></div></div></div></form>
		
		<?php
	}

if(isset($_GET["add_pickup"])){

		?><form method="post" action="">
		<div class="row-fluid">
            <div class="span12">
            	<div class="top-bar">
					<h3><i class="icon-cog"></i>Add Result of students</h3>
                    <div>
						<button type="submit" name="update_pickup" class="btn btn-primary"> Save</button>
					</div>
				</div>
				<div class="well no-padding">
                	<div class="controls controls-row">
		<center><input class="form-control" id="myInput" type="text" placeholder="Search.."></center>
		<?php
		$whereC=array();
		if(isset($_GET["class"]) && $_GET["class"]!="")
			$whereC[]=" class='".$_GET["class"]."' ";
		
		if(isset($_GET["section"]) && $_GET["section"]!="")
			$whereC[]=" section='".$_GET["section"]."' ";
		$whereM="";
		if(is_array($whereC) && count($whereC)>0)
			$whereM=" where ".implode(" and ",$whereC);
		
		$allstudent=$db->getRows("select * from student $whereM and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and issue_TC=0 and status=1 order by name ");
		
		if(is_array($allstudent) && count($allstudent)>0){
			?>
			<table class="table table-bordered table-striped">
    		    <thead> 
        			<tr>
                        <td>SNo.</td>
                        <td>Student</td>
                        <td>Father Name</td>
                        <td>Address</td>
                        <td>Pickup</td>
                    </tr>
                </thead>
            <tbody id="myTable">
			<?php $i=0;
			foreach($allstudent as $stu){ $i++;
			
				$aryInstall=$db->getRow("select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$stu["idno"]."' and session='".$_SESSION["admin"]["session"]."'");
				//echo $ss="select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$stu["idno"]."' and session='".$_SESSION["admin"]["session"]."'";

				$totalbuspayfee=0;
				for($ii=1;$ii<=12;$ii++){
    							$iip    =   "bp".$ii;
								$totalbuspayfee+=   $aryInstall[$iip];
							}
                $totalbuspayfee;  

			
				?>
				<tr>
                	<td><?php echo $i; ?></td>
                	<td><?php echo $stu["name"]; ?></td>
					<td><?php echo $stu["fname"]; ?></td>
					<td><?php echo $stu["address"]; ?></td>

               <?php 
                   	$wherepickup   =   "";
                	if($stu['location']!=''){
                	    $name = $db->getVal("select name from location where id='$stu[location]' ");
                	    $wherepickup = " and name='$name' ";
                	}
                    $routes = $db->getRows("select * from bus ");
            	?>
               <td>
                   <input type="hidden" name="idno[]" required  value="<?php echo $stu["idno"] ?>" readonly="readonly" />
                   <div id="pickup_<?php echo $stu['idno']; ?>">
                       <?php if(empty($totalbuspayfee)){ ?> 
                    <select name="bus[]">
                    	<option value="">Select Pickup</option>
                    	<?php  if(is_array($routes) && count($routes)>0){
							foreach($routes as $loc){
								?><option <?php if($loc["id"]==$stu["bus"])echo 'selected'; ?>  value="<?php echo $loc["id"] ?>"><?php echo $loc["root"]; ?></option><?php
							} 
						}  ?>
                    </select>
                    <?php } else {
                        ?>
                    <select name="bus[]" >
                    	<option value="">Select Pickup</option>
                    	<?php if(is_array($routes) && count($routes)>0){
							foreach($routes as $loc){
								?><option <?php if($loc["id"]==$stu["bus"])echo 'selected'; ?>  value="<?php echo $loc["id"] ?>"><?php echo $loc["root"]; ?></option><?php
							}
						} ?>
                    </select>
                    <span style="color:red;float:right;font-size:11px;">Paid</span>
                    <?php
                    }?>
                    </div>
                </td>

                </tr>
				<?php
			}
			?></tbody></table><?php
		}
		?></div></div></div></div></form>
		
		<?php
	}

if(isset($_GET["update_root"])){

		?><form method="post" action="">
		<div class="row-fluid">
            <div class="span12">
            	<div class="top-bar">
					<h3><i class="icon-cog"></i>Add Result of students</h3>
                    <div>
						<button type="submit" name="update_busroot" class="btn btn-primary"> Save</button>
					</div>
				</div>
				<div class="well no-padding">
                	<div class="controls controls-row">
		<center><input class="form-control" id="myInput" type="text" placeholder="Search.."></center>
		<?php
		$whereC=array();
		if(isset($_GET["class"]) && $_GET["class"]!="")
			$whereC[]=" class='".$_GET["class"]."' ";
		
		if(isset($_GET["section"]) && $_GET["section"]!="")
			$whereC[]=" section='".$_GET["section"]."' ";
		$whereM="";
		if(is_array($whereC) && count($whereC)>0)
			$whereM=" where ".implode(" and ",$whereC);
		
		$allstudent=$db->getRows("select * from student $whereM and school_id='".$_SESSION["admin"]["school_id"]."' and session='".$_SESSION["admin"]["session"]."' and issue_TC=0 and status=1 order by name ");
		
		if(is_array($allstudent) && count($allstudent)>0){
			?>
			<table class="table table-bordered table-striped">
    		    <thead> 
        			<tr>
                        <td>SNo.</td>
                        <td>Student</td>
                        <td>Father Name</td>
                        <td>Address</td>
                        <td>Route</td>
                        <td>Vehicle</td>
                        <td>Pickup</td>
                    </tr>
                </thead>
            <tbody id="myTable">
			<?php $i=0;
			foreach($allstudent as $stu){ $i++;
			
				$aryInstall=$db->getRow("select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$stu["idno"]."' and session='".$_SESSION["admin"]["session"]."'");
				//echo $ss="select * from installment where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$stu["idno"]."' and session='".$_SESSION["admin"]["session"]."'";

				$totalbuspayfee=0;
				for($ii=1;$ii<=12;$ii++){
    							$iip    =   "bp".$ii;
								$totalbuspayfee+=   $aryInstall[$iip];
							}
                $totalbuspayfee;  

			
				?>
				<tr>
                	<td><?php echo $i; ?></td>
                	<td><?php echo $stu["name"]; ?></td>
					<td><?php echo $stu["fname"]; ?></td>
					<td><?php echo $stu["address"]; ?></td>

               <?php
                	$routes = $db->getRows("select DISTINCT(name), id from location WHERE pickup_point='' ");
            	?>
                <td>
                    <input type="hidden" name="idno[]" required  value="<?php echo $stu["idno"] ?>" readonly="readonly" />
                    <?php /* if(empty($totalbuspayfee)){ ?>
                    <select name="location[]" id="route_<?php echo $stu['idno'] ?>" onchange="getvehicle(this.value, <?php echo $stu["idno"] ?>)">
                    	<option value="">Select Route</option>
                    	<?php if(is_array($routes) && count($routes)>0){
							foreach($routes as $loc){ ?>
								<option <?php if($loc["id"]==$stu["location"])echo 'selected'; ?>  value="<?php echo $loc["id"] ?>"><?php echo $loc["name"] ?></option><?php
							}
						} ?>
                    </select>
                    <?php } else {*/
                        ?>
                        <select name="location[]" id="route_<?php echo $stu['idno'] ?>" >
                        	<option value="">Select Route</option>
                        	<?php if(is_array($routes) && count($routes)>0){
    							foreach($routes as $loc){ ?>
    								<option <?php if($loc["id"]==$stu["location"])echo 'selected'; ?> value="<?php echo $loc["id"] ?>"><?php echo $loc["name"] ?></option><?php
    							}
    						} ?>
                        </select>
                        <?php
                    //}?>
                </td>

                <?php
                	$wherebus   =   "";
                	if($stu['location']!=''){
                	    $wherebus = " and route='$stu[location]' ";
                	}

                	$drivers    =   $db->getRows("select * from bus_detail where school_id='".$_SESSION["admin"]["school_id"]."'  ");

            	?>
               <td>
                   <div id="vehicle_<?php echo $stu['idno']; ?>">
                   <?php /* if(empty($totalbuspayfee)){ ?>
                    <select name="old_school[]"  onchange="getpickup(<?php echo $stu["idno"] ?>)">
                    	<option value="">Select Bus</option>
                    	<?php  if(is_array($drivers) && count($drivers)>0){
							foreach($drivers as $driver){
								?><option <?php if($driver["id"]==$stu["old_school"])echo 'selected'; ?>  value="<?php echo $driver["id"] ?>"><?php echo $driver["name"] ?></option><?php
							}
						} ?>
                    </select>
                    <?php } else { */
                        ?>
                        <select name="old_school[]"  >
                        	<option value="">Select Bus</option>
                        	<?php if(is_array($drivers) && count($drivers)>0){
    							foreach($drivers as $driver){
    								?><option <?php if($driver["id"]==$stu["old_school"])echo 'selected'; ?>  value="<?php echo $driver["id"] ?>"><?php echo $driver["name"] ?></option><?php
    							}
    						} ?>
                        </select>
                        <?php
                    //}?>
                    </div>
                </td>
 
               <?php 
                   	$wherepickup   =   "";
                	if($stu['location']!=''){
                	    $name = $db->getVal("select name from location where id='$stu[location]' ");
                	    $wherepickup = " and name='$name' ";
                	}
                // 	$routes = $db->getRows("select * from location where pickup_point!='' $wherepickup ");
                $routes = $db->getRows("select * from bus ");
            	?>
               <td>
                   <div id="pickup_<?php echo $stu['idno']; ?>">
                       <?php if(empty($totalbuspayfee)){ ?> 
                    <select name="bus[]">
                    	<option value="">Select Pickup</option>
                    	<?php  if(is_array($routes) && count($routes)>0){
							foreach($routes as $loc){
							 //   $pickupname = $db->getVal("select root from bus where id='$loc[pickup_point]' ");
							 //$pickupname = $db->getVal("select root from bus ");
								?><option <?php if($loc["id"]==$stu["bus"])echo 'selected'; ?>  value="<?php echo $loc["id"] ?>"><?php echo $loc["root"]; ?></option><?php
							} 
						}  ?>
                    </select>
                    <?php } else {
                        ?>
                    <select name="bus[]" >
                    	<option value="">Select Pickup</option>
                    	<?php if(is_array($routes) && count($routes)>0){
							foreach($routes as $loc){
							 //   $pickupname = $db->getVal("select root from bus where id='$loc[pickup_point]' ");
								?><option <?php if($loc["id"]==$stu["bus"])echo 'selected'; ?>  value="<?php echo $loc["id"] ?>"><?php echo $loc["root"]; ?></option><?php
							}
						} ?>
                    </select>
                    <span style="color:red;float:right;font-size:11px;">Paid</span>
                    <?php
                    }?>
                    </div>
                </td>

                </tr>
				<?php
			}
			?></tbody></table><?php
		}
		?></div></div></div></div></form>
		
		<?php
	}

	?>
</body>
</html>	
<script type="text/javascript">
// Material Select Initialization
$(document).ready(function() {
$('.mdb-select').materialSelect();
});
    
    
    
    function filterRecord(){
 alert();
 var classname = document.getElementById("class").value;
 var subject = document.getElementById("mySelect1").value;
 var subsubject = document.getElementById("subSubjectid").value;  
 var chapter = document.getElementById("chapter").value;   

  document.getElementById('filterdata').innerHTML = 'hee';

   // $.post( "Notice/ajax.php", { type: "filterRecord" ,classname: classname ,subject: subject ,subsubject: subsubject , chapter: chapter} , function( data ) {
//alert(data);
  //document.getElementById('filterdata').innerHTML = data;
  //  });
}

	//$(document).ready(function() {
    //$('#example').DataTable();
//} );

function getvehicle(route, idno){
    $.post( "Transport/ajax.php", { type: "getvehicle" ,route: route,  idno:idno} , function( data ) {
        $("#vehicle_"+idno).html(data);
    });
    
}

function getpickup(idno){
    var route = document.getElementById('route_'+idno).value;
 
    $.post( "Transport/ajax.php", { type: "getpickup" ,route: route,  idno:idno} , function( data ) {
        $("#pickup_"+idno).html(data);
    });

}

</script>