<?php
require("head2Alt.php");
  if(isset($_POST['post']))
    {
   $post=$_POST['post'];
   $carregno="";
   $arrivedon="";
   $arrivedfrom="";
   $departto="";
   $departon="";
   $noguest="";
   $code="";


  require_once("buda_connect.php");
  $con = new connect_class();

  $hnm=$_POST['hiD'];
  $roomid=$_POST['roomNo'];

  $ownID=$_POST['owniD'];
  
  if( isset($_POST['hiD']) && isset($_POST['owniD']))
     {

         $HD=$con->getThisHotel($hnm);
    
      if($HD->rowCount()>0)
        {
          $ro=$HD->fetch();

        }
        $rM=$con->getHotelBookedRoom($hnm,$roomid);
        if($rM->rowCount()>0)
         {

        	$rum=$rM->fetch();


         }
      
    }
    if($post!="Book Now")
    {
    if($post=="Book")
    { 
   $carregno=$_POST['carregno'];
   $arrivedon=$_POST['arrivedon'];
   $arrivedfrom=$_POST['arrivedfrom'];
   $departto=$_POST['departto'];
   $departon=$_POST['departon'];
   $noguest=$_POST['noguest'];
   $code=$_POST['code'];

   if($con->vCode($code) && $con->vRroomid($roomid) && $con->vNoguest($noguest) &&  $con->vDepartto($departto) && $con->vArrivedon($arrivedon)&& $con->vArrivedfrom($arrivedfrom) &&$con->vDeparton($departon))
      {
      	$CD=$con->getConfirmCode($code);
      	if ($CD->rowCount()>0)
      	{
      	  addVisitors($hnm,$roomid,$accountId,$arrivedon,$arrivedfrom,$departon,$departto,$noguest,$payment,$carregno);
      	}
      	else
      	{
      ?>
   <center>
     <div>
       <sup>
          <?php
       echo "Invalid payment code!";
           ?>   
       </sup>
      </div>
   </center> 
         <?php
      	}

      }
   else
      {
      ?>
   <center>
     <div>
       <sup>
          <?php
            echo $con->eCode($code)."<p/>"; 
            echo $con->eCarregno($carregno)."<p/>"; 
            echo $con->eArrivedfrom($arrivedfrom)."<p/>";  
            echo $con->eNoguest($noguest)."<p/>"; 
            echo $con->eDepartto($departto)."<p/>"; 
            echo $con->eDeparton($departon)."<p/>";   
            echo $con->eArrivedon($arrivedon)."<p/>";

     ?>
  </sup>
</div>
</center> 
<?php
            require("bookNowForm.php");
   
}
 }	
 }
    else
    {
    	require("bookNowForm.php");
    }
}
 
require_once('footerIn.php');
?>




