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

{

  $patientID= $_POST['patientID'];
  $tDate= $_POST['tDate'];   
  require_once"labClass.php";

  $con=new labClass();

  $rQ= $con->getPatientCheckUpForupdateD($patientID,$tDate);

              // print_r($rQ->ErrorInfo());
  if ($rQ->rowCount()>0) {

    $chp=$rQ->fetchAll();
    $pn= $con->getThisPatientD($patientID)->fetch();
      ?> 
  <small>PATIENT NAME:<h6 class="text-primary"><?php echo $pn['fname']." ". $pn['mname']." ".$pn['lname'];?></h6></small>
  <div class="container-fluid">
  <small><h6>MEDICAL CHECKUP LIST:</h6></small> 
  <table class="table table-bordered table-striped">
  <thead class="bg-secondary">
   <th>  
        <small><h6>S/N-MEDICAL TEST</h6></small>
      </th>
      
       <th>
        <small><h6>R. DESCRIPTION</h6></small>
      </th>
       <th>
        <small><h6>CHECKED BY / R. STATUS</h6></small>
      </th>
        <th>
        <small><h6>P. STATUS</h6></small>
      </th>

        <th>
        <small><h6>SAVE R.</h6></small>
      </th>
    </thead>
  <tbody>
   
  <?php
 $ttPrice=0;
  
 foreach ($chp as $key => $p) {

       $recordID=$p['recordID'];
    
       $cc++; 
      
       $ttPrice=$ttPrice+$p['billAmount'];
        ?>


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

       <input type="hidden" name="recordID<?php echo $cc;?>" id="recordID<?php echo $cc;?>" value="<?php echo $p['recordID'];?>"/>
     

      <?php
          echo $cc;
       ?>  
         .<textarea style="height:30px; width:95%;" disabled="true" name="tname<?php echo $cc;?>" id="tname<?php echo $cc;?>"><?php echo $p['mTest'];?></textarea><br/>
         
  
  </td>
  
   <td style="width:40%;">

       
         <textarea style="height:200px; width:100%;" name="rDescrip<?php echo $cc;?>" id="rDescrip<?php echo $cc;?>"></textarea><br/>
         
  
  </td>

     <td>
      <small>Checked by:</small>
       <div class="form-floating mb-3 mt-3"> 
           <select class="form-select" id="Checkedby<?php echo $cc;?>" name="Checkedby<?php echo $cc;?>">

             <option value=""></option>
  <?php
   
   $Q= $con->getLabTech();
 
  if ($Q->rowCount()>0) {

    $lb=$Q->fetchAll();
    foreach ($lb as $key => $l) {
      ?>
             <option value="<?php echo  $l["lname"].", ".$l["fname"];?>"><?php echo  $l["lname"].", ".$l["fname"];?></option> 
             <?php
           }
         }
           ?>
           </select>  
        </div>
         <small>Result status:</small>
       <div class="form-floating mb-3 mt-3"> 
           <select class="form-select" id="rStatus<?php echo $cc;?>" name="rStatus<?php echo $cc;?>">
             <option value="+ve">+ve</option>
             <option value="-ve">-ve</option> 
           </select>  
        </div>
  </td> 

  <td align="center">
     <?php echo $p['pStatus'];?>
  </td> 
    
  <td>
    

        <input type="submit" name="postUpdate<?php echo $cc;?>" id="postUpdate<?php echo $cc;?>"value="SAVE" id="submit" onclick="  var tname=$('#tname<?php echo $cc;?>').val();var rDescrip=$('#rDescrip<?php echo $cc;?>').val();var rStatus=$('#rStatus<?php echo $cc;?>').val(); var Checkedby=$('#Checkedby<?php echo $cc;?>').val();var user=$('#user').val();var recordID=$('#recordID<?php echo $cc;?>').val(); var patientID =$('#pID').val();if(rDescrip!='' && rStatus!='' && Checkedby!='' && patientID!='' && recordID!='' && tname!='') {alert(recordID+tname+patientID); $.post('saveCheckupResultsPro.php',{rDescrip:rDescrip,rStatus:rStatus,Checkedby:Checkedby, patientID:patientID,recordID:recordID,tname:tname,user:user},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='The problem occured, make sure you entered patient ID!..';}" />
  </td>
    
  </tr>

 
  <?php
 
}
  $cc=0;
?>
 
</tbody>
</table>
</div>
<?php
}
else{
  echo "Invalid input values submission!.";
}
         
}
//echo "out";

?>