<?php 
 
 $cc=0;
 $sdate=$_POST['sdate'];
  require_once "labClass.php";
  $con = new labClass();
  $sourceID=1;
  $chkp= $con->getWithdrawR($sourceID,$sdate);  
     
  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('pharmExpenseRByDate.php',{sdate:sdate,dat1:dat1,dat2:dat2},function(data){$('#dpl').html(data).show();});">Generate</button>
 </td>      
 </tr>
 </table> -->

 <div class="container-fluid " id="dpl">
     SHOP CASH IN HAND WITHDRAW:
  <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>TIME</h6></small>
     </th>
    </thead> 
   <tbody>
   
  <?php
$tex=0;
 foreach ($chp as $key => $p) {
    $recID=$p['recID'];
      $cc++;   
        ?>
  <tr>
  <td>
  <?php echo $p['recID'];?>
  . <?php echo $p['wreason'];?>
  </td>
  <td> 
    <?php $tex=$tex+$p['amount']; echo $p['amount'];?>
  </td> 
  <td>
     <?php echo $p['dateW'];?>
  </td> 
  <td>
    <?php echo $p['timeAt'];?>
  </td>  
</tr>
<?php
}
$cc=0;
?>
 <tr>
 <td>
   Total:
 </td>
 <td> 
    <?php echo $tex;?>
 </td> 
<td> 
</td> 
</tr> 
 </tbody>
</table> 
<?php
}
  ////////////////OTHER SOURCE OF INCOME
  $tex=0;
  
  $sourceID=2;
  
  $chkp= $con->getWithdrawR($sourceID,$sdate); 
     
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?> 
 OTHER SOURCE WITHDRAW:
  <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>TIME</h6></small>
     </th>
    </thead> 
   <tbody>
   
  <?php
$tex=0;
 foreach ($chp as $key => $p) {
    $recID=$p['recID'];
      $cc++;   
        ?>
  <tr>
  <td>
  <?php echo $p['recID'];?>
 . <?php echo $p['wreason'];?>
 </td>
  <td> 
    <?php $tex=$tex+$p['amount']; echo $p['amount'];?>
  </td> 
  <td>
    <?php echo $p['dateW'];?>
  </td> 
  <td>
    <?php echo $p['timeAt'];?>
  </td>  
</tr>
<?php
}
$cc=0;
?>
<tr>
 <td>
  Total:
  </td>
  <td> 
    <?php echo $tex;?>
  </td> 
  <td> 
  </td> 
</tr> 
 </tbody>
</table> 
 <?php
}


  ////////////////OTHER SOURCE OF INCOME
  
  
  $tex=0;
  
  $sourceID=12;
  
  $chkp= $con->getWithdrawR($sourceID,$sdate); 
     
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?> 
 BOTH SOURCE:
  <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>TIME</h6></small>
     </th>
    </thead> 
   <tbody>
   
  <?php
$tex=0;
 foreach ($chp as $key => $p) {
    $recID=$p['recID'];
      $cc++;   
        ?>
  <tr>
  <td>
  <?php echo $p['recID'];?>
 . <?php
  
$text = $p['wreason'];
 
$firstString = explode(":", $text)[0]; 
$firstString = trim($firstString);

echo $firstString; ?>
 </td>
  <td> 
    <?php $tex=$tex+$p['amount']; echo $p['amount'];?>
  </td> 
  <td>
    <?php echo $p['dateW'];?>
  </td> 
  <td>
    <?php echo $p['timeAt'];?>
  </td>  
</tr>
<?php
}
$cc=0;
?>
<tr>
 <td>
  Total:
  </td>
  <td> 
    <?php echo $tex;?>
  </td> 
  <td> 
  </td> 
</tr> 
 </tbody>
</table> 
 <?php
}
?>
 </div>
 </div>