<?php 
 $cc=0;
     
 
  require_once "labClass.php";
  
  $con = new labClass();
  
 $chkp= $con->getExpensesR(); 
    
     
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?> 

  <div class="container-fluid" id="co">
    EXPENSES REPORT
   <table width="73%" border="0"><tr>
  <td style="width:25%;" align="right">Sort by date range:</td><td style="width:10%;" ><input type="date" style="width:200px;" class="form-control" id="dat1" name="dat1"  value="<?php echo Date("Y-m-d");?>" >
  </td>
  <td>and:</td><td style="width:10%;">
          <input type="date" style="width:200px;" class="form-control" id="dat2" name="dat2" value="<?php echo Date("Y-m-d");?>">
  </td><td style="width:10%;">  
  <button type="submit" class="btn btn-primary" style="width:100%; height:40px;" onclick="var sdate=$('#sdate').val(); var dat1=$('#dat1').val(); var dat2=$('#dat2').val();  $.post('delexpensRBdt.php',{sdate:sdate,dat1:dat1,dat2:dat2},function(data){$('#dpl').html(data).show();});">Generate</button>
 </td>      
 </tr>
 </table> 

 <div class="container-fluid " id="dpl">
  <table class="table table-bordered" style="width:74%;">
    <thead> 
     <th class="">
         
        <small><h6>S/N- PURPOSE</h6></small>
     </th>
      <th class=""> 
        <small><h6>AMOUNT</h6></small>
      </th>
     <th class=""> 
        <small><h6>DATE</h6></small>
     </th>
      <th class=""> 
        <small><h6>ACTION</h6></small>
     </th>
    </thead> 
   <tbody>
   
  <?php
$tex=0;
 foreach ($chp as $key => $p) {

    $expID=$p['expID'];
    
      $cc++; 
     
        ?>

 
  <tr>
  <td>
      
    <sup id="rdn<?php echo $cc;?>" class="text-danger" ></sup>
   <input type="hidden" name="exD<?php echo $cc;?>" id="exD<?php echo $cc;?>" value="<?php echo $p['expID'];?>"/>
       <?php echo $p['expID'];?>
      
        . <?php echo $p['exReason'];?>
         
  
  </td>
  <td> 
    <?php $tex=$tex+$p['exAmount']; echo $p['exAmount'];?>
  </td> 

  <td>
        <?php echo $p['exDate'];?>
  </td> 
    
         <td> 
        <input type="submit" name="add<?php echo $cc;?>" id="add<?php echo $cc;?>" value="Delete" id="submit" onclick="var exD =$('#exD<?php echo $cc;?>').val();  if(exD!='' ) { $.post('delexpensRpro.php',{exD:exD},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />
  </td> 
</tr>
 
 
 
  <?php
 
}
  $cc=0;

 ?>
   <tr>
  <td>
   Total:
  
  </td>
  <td> 
    <?php echo $tex;?>
  </td> 

  <td> 
  </td> 
     
</tr> 
 </tbody>
</table> 
 </div>
 </div>
 <?php
}
   

  ?>