<?php 
 $cc=0;
 require_once "labClass.php";
 $con = new labClass();
 $chkp= $con->getDrugList();     
 if ($chkp->rowCount()>0) {
  $chp=$chkp->fetchAll();
  ?>
  <table class="table"> 
      <th>
        <small><h6>S/N</h6></small>
      </th>
      <th>
        <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>S. PRICE (RATE)</h6></small>
      </th>
      <th align="right">
        <small><h6>P. PRICE (TOTAL)</h6></small>
      </th align="right">
      <th align="right">
        <small><h6>S. PRICE (TOTAL)</h6></small>
      </th>
      <th>
        <small><h6>PROFIT</h6></small>
      </th>
      <th>
        <small><h6>EXPIRED DATE</h6></small>
       
      </th>
       
<?php
 $tpprice=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 $p['ipprice'];
      ?> 
  </td> 
  <td align="right"> 
    <?php 
     echo $p['isprice'];?> 
  </td>
  <td align="right"> 
      <?php 
     $tpprice=$tpprice+$p['ipprice']*$p['iqty'];
      echo $p['ipprice']*$p['iqty'];
      ?> 
  </td> 
  <td align="right"> 
    <?php
     $tsprice=$tsprice+$p['isprice']*$p['iqty'];
     echo $p['isprice']*$p['iqty'];?> 
  </td>
  <td align="right">
      <?php
     $tprofit=$tprofit+($p['isprice']*$p['iqty'])-($p['ipprice']*$p['iqty']);
     echo ($p['isprice']*$p['iqty'])-($p['ipprice']*$p['iqty']);?> 
  </td>
  <td> 
    <?php echo $p['expd'];?> 
  </td>
  
</tr> 
 
  <?php
}
$cc=0;
 ?>
 <tr>
  <td colspan="5" align="right">Total:</td>
    <td align="right">
     <?php echo $tpprice;?>
  </td>
  <td align="right">
      <?php echo $tsprice;?>
  </td>
  <td align="right">
      <?php echo $tprofit;?>
  </td>
  <td></td>
 </tr> 
 <?php
}
?>