<?php
  //ini_set('display_errors', 1);
   // ini_set('display_startup_errors', 1);
 //error_reporting(E_ALL);
if($_POST["pOpt"] && $_POST["itemID"] && $_POST["iname"] && $_POST["user"] && $_POST["ipprice"] && $_POST["isprice"]&& $_POST["nQty"] && $_POST["sdate"])
{ 
     //$_POST["tQty"] &&
    $etype="Transfer";
    $pOpt= $_POST['pOpt'];
    $isprice= $_POST['isprice'];
    $ipprice= $_POST['ipprice'];
    $user= $_POST['user'];
    
    $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();
  $Qk= $con->getThisStoreItem($iname);
  if($Qk->rowCount()>0)
    {
   $user= $_POST['user']."(".$etype.")";
   $rQ= $con->transferStore($itemID,$iname,$ipprice,$isprice,$nQty,$sdate,$user,$pOpt);
   print_r($rQ->ErrorInfo());
   if($rQ->rowCount()>0)
      {
           
       ///itemID:itemID,iqty:iqty,nQty:nQty,isprice:isprice,ipprice:ipprice,iname:iname,tQty:tQty
  $Qr= $con->updateItemQStore($iname,$tQty,$itemID);
 if($Qr->rowCount()>0)
      {
           
        //////////////////////  
    $Qb= $con->getThisItem($iname);
  if($Qb->rowCount()>0)
    {
   $user= $_POST['user']."(".$etype.")";
   $rQd= $con->itemPurchaseEntry($itemID,$iname,$ipprice,$isprice,$nQty,$sdate,$user);
   //print_r($rQ);
   if($rQd->rowCount()>0)
      { 
       //itemID:itemID,iqty:iqty,nQty:nQty,isprice:isprice,ipprice:ipprice,iname:iname,tQty:tQty
        $qr=$Qb->fetch();
        $tQty=$qr['iqty']+$nQty;
        $Qrr= $con->updateItemQTrans($iname,$tQty);
        //print_r($Qrr->ErrorInfo());
        if($Qrr->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 in shop!..</h6>
       <?php
       }
         ///////////////////// 
          
       
        }
  else{
       ?>
        <h6 class="text-danger">Item error occurred!..</h6>
       <?php
       }
       }
    }
  else{
       ?>
        <h6 class="text-danger">Item does not exist in store!..</h6>
       <?php
       }
       }
  else{
       ?>
       <h6 class="text-danger">All field required!..</h6>
       <?php
       }
?>