 <?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")
    {
       if (isset($_POST['sdate'])) {
         
           $arrived_on=($_POST['sdate']); 
             
            $hIo=$con->getHotelExpenseByDate($hnm,$arrived_on); 
       }
    }

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

    if ($post=="Expense Report"){
        

        $hIo=$con->getHotelExpenses($hnm); 

    }
                 ////


    }
  }
?> 
  
    
      <ul><li> <label id="main_lab">   EXPENSE REPORT</label></li></ul>
     
    <!-- <table>
       <tr>
         <td>-->
           <ul >
         

                
                <li id="liL">
                            <form action="addExpenseFormStaff.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 record" name="post"  >

                          </form>
                </li>


       </ul> 

        <!-- </td>
       </tr>

     </table>-->
    
<!-- b/////////////////////////lll-->

 <center>
       <fieldset id="new_visitors_reg_form">
       <center>

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


                if ($post=="Date")
                {
                  if($arrived_on=="")
                  {
                  echo "Date required!";
                  }
               }
               ?>
            </sup>
        </center>
          <form action="expenseReportStaff.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" name="post"  >
                         
                             <label style="padding-left:27%">

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

                            </label>

          </form>
        </fieldset>
                    <!--////////////////////
                    ////////////////////////-->
 

                     <!--///////////////////////////
                            OTHER EXPENSES


                            /////////////////////
                            -->

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

    <tr><td colspan="4" align="center"><label id="min_lab">HOTEL EXPENSES</label></td></tr>
    <tr class="tr1">

       <td align="center">

       <label id="min_lab">EXPENSE ID </label>

       </td>

       <td align="center">

       <label id="min_lab">EXPENSE PURPOSE</label>

       </td>

       <td align="center"> 
         <label id="min_lab">DATE SPEND</label>

       </td>
        

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

       </td>
       

    </tr>

    <?php
    if($hIo->rowCount()>0)
    {
       $hNo=$hIo->fetchAll();
       $Tc=0;
       $tC=0;
       $Tn=0;
       foreach ($hNo as $key => $ico) 
       {
          
      
       ?>
        <tr class="tr">

             <td valign="bottom" height="45px" align="center">
                
               <?php echo $ico["expenses_id"];?>
              
             </td>
             <td align="center">

               <?php echo $ico["exp_purpose"];?> 
             </td>
 


            <td align="center">

            <?php echo $ico["exp_date"];?> 

            </td>

           <td align="center">

           <?php echo $ico["amount"];   
             
          $Tn=$Tn+ $ico["amount"]; 
             ?> 
          
        </td>

         </tr>
    <?php
       }
       ?>
       <tr><td colspan="3" align="right">

           <label id="main_lab"> TOTAL:</label>

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

       </tr>
       <?php
    }
    else{
      ?>
      <tr class="tr2" ><td colspan="4">No cash earned up to moment!..</td></tr>
   <?php
    }
    ?>
    </table>
     </fieldset> 
  