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

  {

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

        $hnm=$_POST['hiD'];
        $ownID=$_POST['owniD'];  
       //HOTEL NAVIGATION LINKS-->
        require_once("my_hotel_main_nav_link.php");
       //-MAIN NAVIGATION LINK END-->
      
    }
    $arrived_on="";
    $edate="";

    $post=$_POST['post'];
    if ($post=="Date of arrival")
    {
       if (isset($_POST['sdate'])) {
         
           $arrived_on=($_POST['sdate']); 
           $V=$con->getHotelVisitorsReceiptByDate($hnm,$arrived_on);
       }
    }

     if ($post=="Range of arrival date")
    {
       if (isset($_POST['sdate']) && isset($_POST['edate'])) {
         
           $arrived_on=($_POST['sdate']);
           $edate=($_POST['edate']); 
           $V=$con->getHotelVisitorsReceiptByDateRange($hnm,$arrived_on,$edate);
       }
    }

    if ($post=="View receipt" || $post=="Visitors"){
       
      $V=$con->getHotelVisitorsReceipt($hnm);

    }
      
 
     }
     ?>
 

  <ul><li id="liL"><label id="main_lab"> VISITORS RECEPTION</label></li></ul>

   <ul>
       	
    <li id="liL">
                          
               <form action="addHotelVistorsForm.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 visitor" name="post"  >

                        </form>
                        </li>

                        <li id="liL">
                            <form action="visitorsReport.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="Visitors report" name="post"  >

                        </form>
                        </li>


       </ul>
 <center>

       <fieldset id="new_visitors_reg_form">
       <center>

           <sup>
               <?php
               if ($post=="Range of arrival date")
                {
                  if($arrived_on=="" ||  $edate=="")
                  {
                  echo "Date range required!";
                  }
               }


                if ($post=="Date of arrival")
                {
                  if($arrived_on=="")
                  {
                  echo "Date required!";
                  }
               }
               ?>
            </sup>
        </center>
          <form action="hotelVisitors.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;?>">

                              <label id="main_lab">Select date:</label>

                              <input  type="date" name="sdate" value="<?php echo $arrived_on;?>" >


                              <label style="padding-left:24%">

                              <input  type="date" name="edate" value="<?php echo $edate;?>"  >

                              </label><p/>

                              <label id="main_lab">Search by:</label>

                              <input class="pos" type="submit" value="Date of arrival" name="post"  >
                         
                             <label style="padding-left:27%">

                              <input class="pos" type="submit" value="Range of arrival date" name="post">

                            </label>

          </form>
        </fieldset>
  <?php
   if ($V->rowCount()>0) {
   	 $nR=$V->fetchAll();
foreach ($nR as $key => $vR) {
	 

   	 $accountId=$vR["cust_id"];
     $VP=$con->getHotelVisitorsProfile($hnm,$accountId);
     if ($VP->rowCount()>0) {
      $np=$VP->fetch();
      
     ?>
  


       <fieldset id="new_visitors_reg_form">

      <table   width="100%">
  	 <tr class="tr2">
  	 	<td align="center"  colspan="4">
  	 	<label id="main_lab"><?php echo $ro["hname"]?>  SERVICES  RECEIPT</label>
  	 	</td>
  	 </tr>
     

  	 <tr>
  	 	<td align="right" width="20%">
  	 		 Customer name:
  	 	</td>

  	 	<td align="center"><?php echo $np["fname"]." ".$np["mname"]." ". $np["lname"];?> <hr>
  	 	</td>
        <td align="right" width="20%">
        Receipt No:	
        </td>

        <td align="center">
        	<?php echo $vR["recept_no"];?><hr>
        </td>
  	 </tr> 
 
     <tr>
  	 	<td align="right" width="20%">
  	 		Gender:
  	 	</td>

  	 	<td align="center"><?php echo  $np["gender"];?><hr>
  	 	</td>
        <td  align="right" width="20%">
        Phone No:	
        </td>

        <td align="center">
        	<?php echo  $np["phoneno"];?><hr>
        </td>
  	 </tr>
     <tr>
  	 	   <td align="right" width="20%">
  	 		  Age:
  	 	   </td>

  	 	    <td align="center">

  	 	       <?php 
                   $dob= strtotime($np["dob"]);
                   $today=strtotime(Date("Y-m-d"));

                   $age=(($today-$dob)/31536000);
  	 	       echo  floor($age);?><hr>
  	 	    </td>
            <td  align="right" width="20%">
              Number of night:	
            </td>
 
             <td align="center">
  	 	       <?php 
                   $arv= strtotime($vR["arrived_on"]);
                   $dp=strtotime($vR["departure_on"]);

                   $nn=(($dp-$arv)/86400);
  	 	       echo  $nn;?><hr>
             </td>
  	    </tr>


  	 <tr>
  	 	<td align="right" width="20%">
  	 		Occupation:
  	 	</td>

  	 	<td align="center"><?php echo  $np["occupation"];?><hr>
  	 	</td>
        <td  align="right" width="20%">
        Number of guest:	
        </td>

        <td align="center">
        	<?php echo $vR["nofguest"];?><hr>
        </td>
  	 </tr>

  	 <tr>
  	 	<td align="right" width="20%">
  	 		Country :
  	 	</td>

  	 	<td align="center"><?php echo  $np["country"];?><hr>
  	 	</td>
        <td  align="right" width="20%">
        Room No:	
        </td>

        <td align="center">
        	<?php echo $vR["room_id"];?><hr>
        </td>
  	 </tr>

  	 <tr>
  	 	<td align="right" width="20%">
  	 		Arrived from:
  	 	</td>

  	 	<td align="center"><?php echo $vR["arivedf"];?><hr>
  	 	</td>
        <td  align="right" width="20%">
        Date of arrival:	
        </td>

        <td align="center">
        	<?php echo $vR["arrived_on"];?><hr>
        </td>
  	 </tr>



  	 <tr>
  	 	<td align="right" width="20%">
  	 		Date of departure:
  	 	</td>

  	 	<td align="center"><?php echo $vR["departure_on"];?><hr>
  	 	</td>
        <td  align="right" width="20%">
        Depart to:	
        </td>

        <td align="center">
        	<?php echo $vR["departure_to"];?> <hr>
        </td>
  	 </tr>
     <tr>
  	 	<td align="right" width="20%">
  	 		Cash amount/Night:
  	 	</td>

  	 	<td align="center"><?php echo $vR["cash_amount"];?><hr>
  	 	</td>
        <td  align="right" width="20%">
        Total cash amount:	
        </td>

        <td align="center">
        	  <?php 
                   $arv= strtotime($vR["arrived_on"]);
                   $dp=strtotime($vR["departure_on"]);

                   $nn=(($dp-$arv)/86400);
  	 	       echo $TTC= ($nn*$vR["cash_amount"]);?><hr> 
        </td>
  	 </tr>
<tr class="trc"><td colspan="4"></td></tr>
   </table>
   </fieldset>
   <?php
    }
    }
   }
    else{
    	?>
    	<table><tr><td>No visitor receipt present!..</td></tr></table>
   <?php
    }
  ?>
   </center>
   <?php
require_once('footerIn.php');
?>
