<?php
  ini_set('display_errors', 1);
     ini_set('display_startup_errors', 1);
     error_reporting(E_ALL);
   
if($_POST["etype"] && $_POST["itemID"] && $_POST["iname"] && $_POST["user"] && $_POST["ipprice"] && $_POST["isprice"]&& $_POST["tQty"] && $_POST["nQty"] && $_POST["sdate"])
{   $etype= $_POST['etype'];
    $isprice= $_POST['isprice'];
    if($etype=="Sells return"){
        
    $ipprice= $_POST['isprice'];
    }else{
      
    $ipprice= $_POST['ipprice'];  
    }
     
    //$ipprice= $_POST['ipprice'];
    $user= $_POST['user']."(".$etype.")";
    $iname= $_POST['iname'];
    $nQty= $_POST['nQty'];
    $itemID= $_POST['itemID'];
    $tQty= $_POST['tQty'];
    $sdate= $_POST['sdate']; 
  //CHECKING ENDS HER
  require_once"labClass.php";
  $con=new labClass();
  $Q= $con->getThisItemBID($itemID,$iname);
  if($Q->rowCount()>0)
    {
         //echo "Pass";
   $rQ= $con->itemPurchaseEntry($itemID,$iname,$ipprice,$isprice,$nQty,$sdate,$user);
   //print_r($rQ->ErrorInfo());
   if($rQ->rowCount()>0)
      {
          echo "Pass";
       //itemID:itemID,iqty:iqty,nQty:nQty,isprice:isprice,ipprice:ipprice,iname:iname,tQty:tQty
        $Qr= $con->updateItemQ($iname,$tQty,$itemID);
        if($Qr->rowCount()>0)
      {
      ?>
      <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
       }
?>