<?php
if($_POST["pOpt"] && $_POST["tim"] && $_POST["itemID"] && $_POST["iname"] && $_POST["user"] && $_POST["ipprice"] && $_POST["isprice"] && $_POST["sdate"])
{ 
//&& $_POST["tQty"]>0 && $_POST["nQty"]>0
    $tim= $_POST['tim'];
    $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();
  $Q= $con->getThisItemBID($itemID,$iname);//getThisStoreItem($iname)
  if($Q->rowCount()>0)
    {
   $rQ= $con->itemShTostEntry($itemID,$tim,$iname,$ipprice,$isprice,$nQty,$sdate,$user); 
   if($rQ->rowCount()>0)
      {
      
        $Qr= $con->updateItemQ($iname,$tQty,$itemID);
        if($Qr->rowCount()>0)
      {
          
       $Qk= $con->getThisStoreItem($iname);//getThisItemStoreBID($itemID,$iname);
        if($Qk->rowCount()>0)
        {
       $etype="Shop to store trans";
        $user= $_POST['user']."(".$etype.")";
        $k=$Qk->fetch();
        $rQ= $con->itemPurchaseEntryStore($itemID,$iname,$ipprice,$isprice,$nQty,$sdate,$user); 
        
        if($rQ->rowCount()>0)
        {
           
     
         $tQty=$k['iqty']+$nQty;
         $Qr= $con->updateItemQStoreNoID($iname,$tQty);//updateItemQStore($iname,$tQty,$itemID);
         if($Qr->rowCount()>0)
          {
         ?>
          <h6 class="text-success">Save!..</h6>
           <?php
      
          }
        else{
          ?>
           <h6 class="text-danger">Failed to update store!..</h6>
           <?php
            }
           }
         else{
            ?>
             <h6 class="text-danger">Transfer not recorded!..</h6>
             <?php
             }
      
           }
         else{
       ?>
        <h6 class="text-danger">The item not found in store!..</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
       }
?>