<?php
//echo $patientID= $_POST['patientID'];
//echo	$iname= $_POST['iname'];
  //echo  $sdate= $_POST['sdate'];
   //echo $recID= $_POST['recID'];
   echo $iQty= $_POST['iqty'];
   //echo $sdate= $_POST['sdate']; 
if($_POST["patientID"] && $_POST["recID"] && $_POST["iname"]  && $_POST["iqty"] && $_POST["sdate"])
{  
    $patientID= $_POST['patientID'];
	$iname= $_POST['iname'];
    $sdate= $_POST['sdate'];
    $recID= $_POST['recID'];
    $iQty= $_POST['iqty'];  
  //CHECKING ENDS HER
  require_once"labClass.php";
  $con=new labClass();
  $Q= $con->getThisDosEX($recID,$iname);
  if($Q->rowCount()>0)
    {
   $rQ= $con->getThisItem($iname);
  
   if($rQ->rowCount()>0)
      { 
        $dq=$rQ->fetch();
        if($dq['iqty']>=$iQty)
        {
        $Qr= $con->updateDosageQ($iname,$iQty,$recID,$patientID);
         //print_r($Qr->ErrorInfo());
        if($Qr->rowCount()>0)
         {
         ?>
          <h6 class="text-success">Save!..</h6>
          <?php
          }
  else{
       ?>
        <h6 class="text-danger">Error occurred!..</h6>
       <?php
       }
       }
  else{
       ?>
        <h6 class="text-danger">Low stock level!..</h6>
       <?php
       }
       }
    }
  else{
       ?>
        <h6 class="text-danger">Item does not exist!..</h6>
       <?php
       }
       }
  else{
       ?>
       <h6 class="text-danger">All field required!..</h6>
       <?php
       }
?>