 <?php 
   require_once("head2Alt.php");
   if(isset($_POST['post']))

  { 
  	  $post=$_POST['post'];
  	  $hnm=$_POST['hiD']; 
      $ownID=$_POST['owniD'];

      //HOTEL NAVIGATION LINKS-->
      require_once("my_hotel_main_nav_link.php");
     //-MAIN NAVIGATION LINK END-->
  	if ($post=="Update"){

        
        $start=$_POST['start']; 
        $rlength =$_POST['rlength'];
        $via =$_POST['via'];  
        $end =$_POST['end'];
        $ldistance =$_POST['ldistance']; 
        $routeId =$_POST['routeId'];
   
   if($con->vVia($via) && $con->vStart($start) && $con->vRlength($rlength) && $con->vEnd($end) && $con->vDistance($ldistance) && $con->vRouteId($routeId))
      {

      	  ?>

     <center>
   
     <label id="succ">
     <?php  
      
       echo  $con->UpdateRoute($start,$rlength,$routeId,$end,$ldistance,$via,$hnm);
     ?>
   
     </label>
     </center> 

    <?php

      }
   else
      {
	     ?>
    <center>
    <div>
    <sup>
    <?php 
    echo  $con->eVia($via)."<p/>";
    echo  $con->eStart($start)."<p/>";
    echo  $con->eRlength($rlength)."<p/>";
    echo  $con->eEnd($end)."<p/>";
    echo  $con->eDistance($ldistance)."<p/>";
    echo  $con->eRouteId($routeId)."<p/>";
    
     ?>
     </sup>
     </div>
    </center> 

     <?php
      }
  	}
if ($post=="Delete") {

     $routeId =$_POST['routeId'];

      	  ?>

     <center>
   
     <label id="succ">
     <?php  
      
       echo  $con->DeleteRoute($routeId,$hnm);
     ?>
   
     </label>
     </center> 

    <?php
}

     if( isset($_POST['hiD']) && isset($_POST['owniD']))
     { 
        $HD=$con->getMyOperationHotel($ownID,$hnm);
    
        if($HD->rowCount()>0)
        {
          $ro=$HD->fetch();

        }
      
    }

  }
?> 
<ul>
      <li id="liL">
                  <form action="addRouteForm.php" method="post">

                     <input class="hi" type="hidden" name="owniD"  value="<?php echo  $ownID;?>">


                      <input class="hi" type="hidden" name="hiD"  value="<?php echo  $hnm;?>">

                      <input class="pos" type="submit" value="New route" name="post"  >

                   </form>
                        
        </li>
    </ul> 
 
<center> 
       <table  width="80%" id="table_border">
	    <tr> 
	        <td colspan="3" id="td_height" valign="top">
	    	<label id="main_lab"> ROUTE TO <?php echo $ro['hname'];?></label>
	        </td>

	     </tr>

	     

	      <?php
	      $rT=$con->getRouteToHotel($hnm);
	      if($rT->rowCount()<=0){

	      	?>
	      	<tr  class="tr2"><td colspan="3" id="td_height">Currently there is no route uploaded!..</td></tr>
	      <?php }else{
           $rU=$rT->fetchAll();
           ?>
         <tr  class="tr1">

	     <td width="20%" id="td_height"><label id="min_lab"> FROM </label></td>

	     <td width="10%" id="td_height"><label id="min_lab"> ROUTE LENGTH </label></td>


	     <td width="20%" id="td_height"><label id="min_lab"> VIA  </label> </td>
 

	     <td width="20%" id="td_height"><label id="min_lab"> DESTINATION </label></td>



	     <td width="20%" id="td_height"><label id="min_lab">DESTINATION DISTANCE</label> </td>
      
        <td colspan="2">
        	

        </td>


	     </tr>
           <?php
           foreach ($rU as $key => $route) {
           	?>
           	<tr  class="tr2">

	     <td id="td_height"><?php echo $route["startStation"];?></td>

	     <td id="td_height"><?php echo $route["estimatedDistance"];?></td>

	     <td id="td_height"><?php echo $route["via"];?></td>

	     <td id="td_height"><?php echo $route["lastStation"];?></td>


	     <td id="td_height"><?php echo $route["ldistance"];?></td>
	     
       <td align="right">
                  

                   <form action="editRouteToHotelForm.php" method="POST">

                       <input type="hidden" value="<?php echo $route["routeId"];?>" name="routeId" class="hi">

                       <input type="hidden" value="<?php echo $hnm;?>" name="hiD" class="hi">

                       <input type="hidden"  value="<?php echo $ownID;?>" name="owniD" class="hi">

                       <input type="submit" id="edit" name="post" value="Edit">

                   </form>
            </td> 
            <td align="right">
                         

                     <form action="hotelRoutePage.php" method="POST">

                       <input type="hidden" value="<?php echo $route["routeId"];?>" name="routeId" class="hi">

                       <input type="hidden" value="<?php echo $hnm;?>" name="hiD" class="hi">

                       <input type="hidden"  value="<?php echo $ownID;?>" name="owniD" class="hi">

                       <input type="submit"   name="post" value="Delete" class="edit">

                   </form>
                    

    </td>  
	     </tr>
	     <?php
           }

	      }
	      ?>

	     


	</table></center>
  <?php
require_once('footerIn.php');
?>
