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

  {

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

        $hnm=$_POST['hiD'];
        $ownID=$_POST['owniD'];  
       
      
    }

    /////
    $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=="New visitor" || $post=="Visitors report"){
       
      $V=$con->getHotelVisitorsReceipt($hnm);

    }
                 ////
         //$V=$con->getHotelVisitorsReceipt($hnm);


     }
     ?>
  

  <ul><li> <label id="main_lab">   VISITORS DETAILS</label></li></ul>

    <ul>
       	
    <li id="liL">
                          
               <form action="addHotelVistorsFormStaff.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="hotelVisitorsStaff.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="View receipt" name="post"  >

                        </form>
                        </li>


       </ul> 


<!-- b/////////////////////////lll-->
<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="visitorsReportStaff.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>
                    <!--////////////////////
                    ////////////////////////-->


       <fieldset id="new_reports_reg_form">
     
      <table   width="100%">
     

     <tr class="tr1" >
      <td align="center">
        <label id="min_lab"> NAME</label> 
      </td>
     
      <td align="center">
        <label id="min_lab">  RECEIPT NO </label> 
        </td>

      <td align="center" >
        <label id="min_lab">   GENDER</label> 
      </td>



      <td  align="center">
        <label id="min_lab"> PHONE NO</label>  
      </td>

      <td  align="center">
        <label id="min_lab"> OCCUPATION  </label>  
      </td>

      <td align="center">
        <label id="min_lab"> NO OF GUEST</label> 
      </td>


     <td align="center">
        <label id="min_lab"> COUNTRY</label> 
      </td>


     <td  align="center">
        <label id="min_lab"> ROOM NO</label>   
        </td>

     <td align="center">
        <label id="min_lab"> ARRIVED FROM</label> 
     </td>

     <td  align="center">
        <label id="min_lab"> DATE OF ARRIVAL</label>   
      </td>
    
    <td align="center">
        <label id="min_lab"> DATE OF DEPART</label> 
      </td>

    <td align="center">
        <label id="min_lab"> DEPART TO</label> 
      </td>

    <td align="center">
        <label id="min_lab"> CASH AMOUNT </label> 
        </td>
</tr>








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

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


<tr class="tr2">
  	<td align="center">

         <?php echo $np["fname"]." ".$np["mname"]." ". $np["lname"];?>  
  	 	
    </td>
       

    <td align="center">

        	<?php echo $vR["recept_no"];?> 
    </td>
  	  

  	<td align="center">

          <?php echo  $np["gender"];?> 
  	 	</td>
        
    <td align="center">

        	<?php echo  $np["phoneno"];?> 
        
      </td>
  	 
  	 	 

  	 	<td align="center">

          <?php echo  $np["occupation"];?>

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

      </td>
  	  
  	 	
  	  <td align="center">

          <?php echo  $np["country"];?> 

  	 	</td>
       
      <td align="center">

        <?php echo $vR["room_id"];?> 

      </td>
  	  
  	 	<td align="center">

        <?php echo $vR["arivedf"];?> 
  	 	
      </td>
       

      <td align="center">

        	<?php echo $vR["arrived_on"];?> 

      </td>
  	  

  	 	<td align="center">

          <?php echo $vR["departure_on"];?> 

  	 	</td>

      <td align="center">

        	<?php echo $vR["departure_to"];?> 

      </td>
  	 
  	 	

  	  <td align="center">

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

                   $nn=(($dp-$arv)/86400);
               $TTC= ($nn*$vR["cash_amount"]); 
           $Tc=$Tc+$TTC;
           echo $vR["cash_amount"];
           ?> 
  	  </td>
         

        
  	 </tr>
   
   <?php
    }

    }

  ?>
     <tr class="tr1">

  <td align="right" colspan="5">  

        <label id="min_lab"> TOTAL NUMBER OF GUESTS: </label>

   </td>

   <td align="center">
      <label id="main_lab">
       <?php  
           echo $Ng;
      ?> <hr></label>

   </td>
    <td align="right" colspan="6">

      <label id="min_lab"> TOTAL CASH AMOUNT: </label>

    </td>
    <td align="center">
      <label id="main_lab">
       <?php  
           echo $Tc;
      ?> <hr></label>

    </td>
   </tr>
   
   <?php


   }
    else{
    	?>
    	 <tr><td colspan="13">No visitor receipt present!..</td></tr></table>
   <?php
    }
  ?>
  

   </table>
   </fieldset></center>