<?php 
 $cc=0;
      
if(isset($_POST["patientID"]) && isset($_POST["sdate"]))

{
 require_once "labClass.php";
 $con = new labClass();
 $patientID= $_POST['patientID'];
 $sdate= $_POST['sdate'];
  $pn= $con->getThisPatientD($patientID);
if($pn->rowCount()>0){
   $n=$pn->fetch();
      ?> 
   <small>PATIENT NAME:<h6 class="text-primary"><?php echo $n['fname']." ". $n['mname']." ".$n['lname'];?></h6></small>
<?php

 $chkp= $con->getPatientDos($patientID,$sdate); 
   
if ($chkp->rowCount()>0) {
  $chp=$chkp->fetchAll();
  ?>
  <table class="table"> 
  <th>
        <small><h6>S/N</h6></small>
      </th>

      <th>
        <small><h6>DRUG NAME</h6></small>
      </th>
       <th>
        <small><h6>DOSAGE </h6></small>
      </th>
      <th>
        <small><h6>PRICE</h6></small>
      </th>

       <th>
        <small><h6>DISPENSABLE QTY</h6></small>
      </th>
        <th>
        <small><h6>SAVE</h6></small>
       
      </th>
       
<?php
 foreach ($chp as $key => $p) {

      $cc++; 
     
        ?>
 <tr>
     <td colspan="6">
       <sup id="rdn<?php echo $cc;?>" class="text-danger" ></sup>
     </td>
   </tr> 
  <tr>
   <td width="5%">
       <input type="hidden" name="recID<?php echo $cc;?>" id="recID<?php echo $cc;?>" value="<?php echo $p['recID'];?>"/>
     

      <?php
          echo $cc;
       ?>  
      </td>
       <td width="30%">
          <textarea style="background-color:white; height:30px; width:95%;" disabled="true" name="inam<?php echo $cc;?>" id="inam<?php echo $cc;?>"><?php echo $p['drugname'];?></textarea> 
  </td>
  <td>
  <?php echo $p['dosage'];?>
  </td> 
  
  <td>
    <?php echo $p['dprice'];?> 
  </td>
  <td width="10%">
    <input type="number" style="background-color:white;border-radius:12px; width:100%;"  name="iQty<?php echo $cc;?>" id="iQty<?php echo $cc;?>" />
  </td>
  <td> 
   <input type="submit" name="add<?php echo $cc;?>" id="add<?php echo $cc;?>" value="Add" id="submit" onclick="var patientID=$('#pID').val(); var sdate=$('#sdate').val(); var iname=$('#inam<?php echo $cc;?>').val(); var iqty=$('#iQty<?php echo $cc;?>').val();var recID =$('#recID<?php echo $cc;?>').val();if(recID!='' && iname!='' && patientID!=''&& sdate!=''&&  user!=''   && iqty!='' && parseInt(iqty) > 0 ) { $.post('pharmDispensableQPro.php',{iname:iname,recID:recID,patientID:patientID,iqty:iqty,sdate:sdate},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;
}
else{
       ?>
        <h6 class="text-danger">No drugs exist!..</h6>
       <?php
       }
       }
else{
       ?>
        <h6 class="text-danger">Invalid patient ID!..</h6>
       <?php
       }
}
   

  ?>