<?php
 
if(  isset($_POST["n"]) && isset($_POST["orderID"]) && isset($_POST["itemID"]) && isset($_POST["iname"]) && isset($_POST["user"]) && isset($_POST["rate"]) && isset($_POST["tsprice"]) && isset($_POST["tprice"])  && isset($_POST["cus"]) && isset($_POST["eQty"]) &&   isset($_POST["sdate"]))
{ 
    $nr=0;
    $tsprice= $_POST['tsprice']; 
    $sn= $_POST['n'];
    $bal=0;
    $ptd=0;
    $pst="NOT APPLICABLE";
    $user= $_POST['user']; 
    $isprice= $_POST['rate'];
    $tprice= $_POST['tprice'];
    $user= $_POST['user'];
    $cus= $_POST['cus'];
    $iname= $_POST['iname'];
    $nQty= $_POST['eQty'];
    $itemID= $_POST['itemID'];
    $orderID= $_POST['orderID']; 
    $sdate= $_POST['sdate']; 
  
    require_once"labClass.php";
    $con=new labClass();

  $Q= $con->getThisItemBID($itemID,$iname);
  if($Q->rowCount()>0)
    {

   $n=$Q->fetch();
   //$tQty=$n["iqty"]-$nQty;

   $tQty=$nQty;
   $ipprice=$n["ipprice"];
   //$rQ= $con->itemSellEntry($itemID,$iname,$ipprice,$isprice,$nQty,$sdate,$user,$pOpt);
   //$Qr= $con->updateItemQ($iname,$tQty,$itemID);
   $rQ= $con->storeQItem($orderID,$itemID,$iname,$tprice,$isprice,$nQty,$sdate,$user);
  
   if($rQ->rowCount()>0)
      {
       //echo "PASS";
      

      $ql= $con->getThisStrRq($orderID);
      //print_r($Qc->ErrorInfo());
      
      $nr=$ql->rowCount();
       if($sn==1)
        {
          $rQc= $con->regStorerQord($orderID,$cus,$bal,$ptd,$tsprice,$pst,$sdate);
             //if(($ptd>0) && ($ptd<$tsprice)) 
             //{ 
              //$rc= $con->debitPRec($orderID,$cus,$ptd,$sdate,$user);
             //}
       $rQ= $con->clearStoreqTemp();
       require_once "storeRequest.php";
         }
        }
        }
   }
   //echo "2.finish";
?>