<?php
$cc=0; 
  require_once"labClass.php";
  $con=new labClass();
  $rQ= $con->getThisPTemOrder();
  if ($rQ->rowCount()>0) {
  $chp=$rQ->fetchAll();
 ?>
  <table class="table table-bordered table-striped" border="1">
  <thead class="bg-secondary" >
        <th>  
        <small><h6>S/N</h6></small>
      </th>
      <th>  
        <small><h6>ITEM NAME</h6></small>
      </th>
      <th>  
        <small><h6>QUANTITY</h6></small>
      </th>
       
      <th>  
        <small><h6>RATE</h6></small>
      </th>
     <th>  
        <small><h6>TOTAL</h6></small>
      </th>
    </thead>
  <tbody>
   
  <?php
 $tpprice=0;
 $tsprice=0;
 $tprofit=0;
///////////////////////////////

foreach ($chp as $key => $p) {
    $itemID=$p['itemID'];
    $iname=$p['iname'];
      $cc++; 
    $r= $con->getThisStoreItem($iname)->fetch(); 
        ?>
 
 <tr>
 <td height="30px" width="10%" >
 <input value="<?php echo $cc;?>" style="color:blue; border:none; outline:none; caret-color:white; background:transparent; cursor:pointer;width:100%;"
  onclick="var iname =$('#iname<?php echo $cc;?>').val();  if(iname!='' ) { $.post('pharmpDelTempLPO.php',{iname:iname},function(data){$('#ss<?php echo $cc;?>').html(data).show();});} else{document.getElementById('ss<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />  </td> <td colspan="4" > 

 <input type="hidden" name="item<?php echo $cc;?>" id="item<?php echo $cc;?>" value="<?php echo $p['itemID'];?>"/>
<input type="hidden" name="iname<?php echo $cc;?>" id="iname<?php echo $cc;?>" value="<?php echo $p['iname'];?>"/>
<input  style="color:blue; border:none; outline:none; caret-color:white; background:transparent; cursor:pointer; width:100%;" 
  value="<?php echo $p['iname'];?>" 
  onclick="var sdate =$('#sdate').val();var iname =$('#iname<?php echo $cc;?>').val();
         var itemID =$('#item<?php echo $cc;?>').val();
         var user =$('#user').val();
         var orderID =$('#orderID').val();  
         if(iname!=''&& orderID!='' && itemID!='' && user!='' ) { 
            $.post('createPorder.php',{sdate:sdate,iname:iname,itemID:itemID,orderID:orderID,user:user},function(data){
                $('#ss<?php echo $cc;?>').html(data).show();
            }); 
         } else {
            document.getElementById('ss<?php echo $cc;?>').innerHTML='Valide item detail required!..';
         }" 
>
<sup id="ss<?php echo $cc;?>"></sup>
  </td>
</tr>
<tr>
  <td height="30px"></td>
  <td>
      
  <?php echo "Store:". $r['iqty'];?>
  
  <input type="number" style="background-color:white;border-radius:12px; width:100%;" disabled="true" name="eQty<?php echo $cc;?>" id="eQty<?php echo $cc;?>"  value="<?php echo $p['eQty'];?>" onclick="document.getElementById('eQty<?php echo $cc;?>').disabled=false;" onchange="shareData()"  />
  </td> 
  
  <td> 
   <input type="number" style="background-color:white;border-radius:12px; border-color: white; width:100%;"  name="rate<?php echo $cc;?>" id="rate<?php echo $cc;?>" disabled="true" value="<?php echo $p['ipprice'];?>" onclick="document.getElementById('rate<?php echo $cc;?>').disabled=false;" onchange="shareData()"  />  
  </td>
  <td> 
     <?php
     $tsprice=$tsprice+$p['ipprice']*$p['eQty'];
      ?>
    <input type="number" style="background-color:white;border-radius:12px; width:100%;"  name="tprice<?php echo $cc;?>" id="tprice<?php echo $cc;?>" disabled="true" value="<?php echo $p['ipprice']*$p['eQty'];?>"  />
  </td>
 
   
</tr>
 
<?php
} 

?>

 <tr>
  <td colspan="3" align="right">Total:
  </td>
 
  <td>
      
      <input type="number" style="background-color:white;border-radius:12px; width:100%;"  name="tprice" id="tprice" disabled="true" value="<?php echo $tsprice;?>"  />
  </td>
   
   
 </tr>
  <tr><td><input type="radio" name="pst" id="pst" onclick="cashS()" value="PAID">Paid </td><td><input type="radio" name="npst" id="npst" onclick="ncashS()" value="NOT PAID">Not paid</td><td colspan="2"><sup id="cs" style="display: none;">Cash (if any):<input type="number" name="cash" id="cash" value="0" style="background-color:white;border-radius:12px; width:50%;"></sup></td>
 </tr>
</tbody>
</table>
<input type="hidden" name="cc" id="cc" value="<?php echo $cc;?>">
<?php
}
$cc=0;
 ?> 

 