<?php 
 $cc=0;
     
 
  require_once "labClass.php";
  
  $con = new labClass();
  
 $chkp= $con->getMedicalTestList(); 
    
     
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?> 
 <table class="table">
  <thead>
      <th>
        <small><h6>S/N</h6></small>
      </th>
      <th>
        <small><h6>MEDICAL TEST</h6></small>
      </th>
      <th>
        <small><h6>CATEGORY</h6></small>
      </th>
       <th>
        <small><h6>TEST PRICE</h6></small>
      </th>
       <th>
        <small><h6>EDIT</h6></small>
      </th>
</thead>

   
  <?php

 foreach ($chp as $key => $p) {

    $testID=$p['testID'];
    
      $cc++; 
     
        ?>


 <tr>
  <td colspan="5">
       <sup id="rdn<?php echo $cc;?>" class="text-danger" ></sup>
  </td>
  </tr> 
  <tr>
  
 
  
   <td width="3%">

       <input type="hidden" name="testID<?php echo $cc;?>" id="testID<?php echo $cc;?>" value="<?php echo $p['testID'];?>"/>
      <?php
          echo $cc;
       ?>  
    </td>
    <td width="50%">
      <textarea style="height:30px; width:90%;" disabled="true" name="tname<?php echo $cc;?>" id="tname<?php echo $cc;?>"><?php echo $p['mName'];?></textarea><br/>
         
  
  </td>
    <td>
      <select  class="form-control" style="background-color:white;border-radius:12px; width:100%;" id="cat<?php echo $cc;?>" name="cat<?php echo $cc;?>" required>
        <option value="<?php echo $p['cat'];?>"><?php echo $p['cat'];?></option>
        <option value="Laboratory">Laboratory</option>
        <option value="Radiology">Radiology</option>
        <option value="Procedure">Procedure</option>
      </select>
      
  </td>

  <td>
        <input type="number" style="width:100%;" disabled="true" name="tPrice<?php echo $cc;?>" id="tPrice<?php echo $cc;?>"  value="<?php echo $p['tPrice'];?>" />
  </td> 
    
 <td>
     <input type="submit"  name="postEdit<?php echo $cc;?>" id="postEdit<?php echo $cc;?>" value="Edit" id="submit" onclick="document.getElementById('tname<?php echo $cc;?>').disabled=false;document.getElementById('cat<?php echo $cc;?>').disabled=false;document.getElementById('tPrice<?php echo $cc;?>').disabled=false;$('#postEdit<?php echo $cc;?>').hide();$('#postUpdate<?php echo $cc;?>').show();" />


        <input type="submit" style="display:none;" name="postUpdate<?php echo $cc;?>" id="postUpdate<?php echo $cc;?>"value="Update" id="submit" onclick="  var tname=$('#tname<?php echo $cc;?>').val();var cat=$('#cat<?php echo $cc;?>').val();var tPrice=$('#tPrice<?php echo $cc;?>').val(); var testID =$('#testID<?php echo $cc;?>').val();if(cat!='' && testID!='' && tPrice!='' && tname!='') {$.post('updateMtestPro.php',{testID:testID,tPrice:tPrice,cat:cat,tname:tname},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});document.getElementById('tname<?php echo $cc;?>').disabled=true;document.getElementById('cat<?php echo $cc;?>').disabled=true;document.getElementById('tPrice<?php echo $cc;?>').disabled=true;$('#postUpdate<?php echo $cc;?>').hide();$('#postEdit<?php echo $cc;?>').show();} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />
 </td>
</tr> 
  <?php
}
  $cc=0;
 ?> 
</table>
 <?php
}
?>