<?php
if($_POST["itemID"] && $_POST["iname"] && $_POST["user"] && $_POST["recID"] && $_POST["pOpt"]&& $_POST["npOpt"]&& $_POST["tim"]  && $_POST["ds"])
{ 
   // user:user,itemID:itemID,recID:recID,pOpt:pOpt,ds:ds,tim:tim,iname:iname
     $npOpt= $_POST['npOpt'];
     $pOpt= $_POST['pOpt'];
     $recID= $_POST['recID'];
     $user= $_POST['user'];
     $iname= $_POST['iname'];
     $ds= $_POST['ds'];
     $itemID= $_POST['itemID'];
     $tim= $_POST['tim']; 
     $us=$tim."(Edt:".$user.")";
  //CHECKING ENDS HER
  require_once"labClass.php";
  $con=new labClass();
  $Q= $con->getThisSellBID($tim,$recID,$itemID,$iname);
  if($Q->rowCount()>0)
    {
   //$rQ= $con->itemPurchaseEntry($itemID,$iname,$ipprice,$isprice,$nQty,$sdate,$user);
   //print_r($rQ);
  // if($rQ->rowCount()>0)
     // {
       //itemID:itemID,iqty:iqty,nQty:nQty,isprice:isprice,ipprice:ipprice,iname:iname,tQty:tQty
        $Qr= $con->updateSellD($ds,$npOpt,$us,$iname,$itemID,$recID);
        if($Qr->rowCount()>0)
      {
          ////////////////
         if( $pOpt=="Unspecified"){
             
              $Qq= $con->getThisItmInvLstBID($tim,$itemID,$iname);
              if($Qq->rowCount()>0)
               {
                $gr=$Qq->fetch();
                $orderID=$gr['orderID'];
                $cr= $con->updateInvItmListD($ds,$us,$iname,$itemID,$orderID);
                if($cr->rowCount()>0)
                  {
                       $crc= $con->updateOrderD($ds,$orderID);
                 ?>
                 <h6 class="text-success">Save!..</h6>
               <?php
                  }
               }
          }else{
           ?>
           <h6 class="text-success">Save!..</h6>
          <?php
             }
          /////////////////
        }
  else{
       ?>
        <h6 class="text-danger">Item error occurred!..</h6>
       <?php
       }
       //}
    }
   else{
       ?>
        <h6 class="text-danger">Item does not exist!..</h6>
       <?php
       }
       }
  else{
       ?>
       <h6 class="text-danger">All field required!..</h6>
       <?php
       }
?>