<?php 
 $cc=0;
 require_once "labClass.php";
 $con = new labClass();
 $chkp= $con->getDrugListStore();     
 if ($chkp->rowCount()>0) {
  $chp=$chkp->fetchAll();
  ?>
  <table class="table table-bordered"> 
      <th>
        <small><h6>S/N</h6></small>
      </th>
      <th width="">
        <small><h6>ITEM NAME</h6></small>
      </th>
      <th>
        <small><h6>STOCK</h6></small>
      </th>
      <th align="right">
        <small><h6>P. PRICE (RATE)</h6></small>
      </th>
      <th align="right">
        <small><h6>W. PRICE (RATE)</h6></small>
      </th>
      <th align="right">
        <small><h6>R. PRICE (RATE)</h6></small>
      </th>
      <th align="right">
        <small><h6>P. PRICE (TOTAL)</h6></small>
      </th align="right">
      <th align="right">
        <small><h6>W. PRICE (TOTAL)</h6></small>
      </th>
      <th align="right">
        <small><h6>R. PRICE (TOTAL)</h6></small>
      </th>
      
      <th>
        <small><h6>PROFIT</h6></small>
      </th>
      <th>
        <small><h6>EXPIRED DATE</h6></small>
       
      </th>
       
<?php
 $tpprice=0;
 $twsprice=0;
 $tsprice=0;
 $tprofit=0;
 foreach ($chp as $key => $p) {
    $itemID=$p['itemID'];
      $cc++; 
     
        ?>
 
  <tr>
   <td width="5%">
      
      <?php
          echo $cc;
       ?>  
      </td>
       <td width="30%">
          <?php echo $p['iname'];?> 
  </td>
  <td align="right">
   <?php echo $p['iqty'];?>
  </td> 
  <td align="right"> 
      <?php  
      echo number_format($p['ipprice'],2);
      ?> 
  </td>
  <td align="right"> 
    <?php 
     echo number_format($p['wsprice'],2);?> 
  </td> 
  <td align="right"> 
    <?php 
     echo number_format($p['isprice'],2);?> 
  </td>
  <td align="right"> 
      <?php 
     $tpprice=$tpprice+$p['ipprice']*$p['iqty'];
      echo number_format($p['ipprice']*$p['iqty'],2);
      ?> 
  </td>
  <td align="right"> 
    <?php 
     echo number_format($p['wsprice']*$p['iqty'],2);?> 
  </td> 
  <td align="right"> 
    <?php
    $twsprice=$twsprice+$p['wsprice']*$p['iqty'];
    
     $tsprice=$tsprice+$p['isprice']*$p['iqty'];
     echo number_format($p['isprice']*$p['iqty'],2);?> 
  </td>
  <td align="right">
      <?php
     $tprofit=$tprofit+($p['isprice']*$p['iqty'])-($p['ipprice']*$p['iqty']);
     echo number_format(($p['isprice']*$p['iqty'])-($p['ipprice']*$p['iqty']),2);?> 
  </td>
  <td> 
    <?php echo $p['expd'];?> 
  </td>
  
</tr> 
 
  <?php
}
$cc=0;
 ?>
 <tr>
  <td colspan="6" align="right">Total:</td>
    <td align="right">
     <?php echo number_format($tpprice,2);?>
  </td>
  <td align="right">
      <?php echo number_format($twsprice,2);?>
  </td>
  <td align="right">
      <?php echo number_format($tsprice,2);?>
  </td>
  <td align="right">
      <?php echo number_format($tprofit,2);?>
  </td>
  <td></td>
 </tr> 
 <?php
}
?>