<?php
require("../head2Alts.php");
  if(isset($_POST['post']))
    {
   $post=$_POST['post'];
   
   $code=""; 
     
   $quantity=$_POST['quantity'];
  

  //require_once("buda_connect.php");
  //$con = new connect_class();
 
  
  if(isset($_POST['shopid']) && isset($_POST['owniD']) && isset($_POST['quantity']) && isset($_POST['itemid']) && $scon->vQuantity($quantity))
     {

       $customerid=$ownID=$_POST['owniD'];
       $itemid=$_POST['itemid'];
       $shopid=$_POST['shopid'];
       $ownerD=$_POST['ownerD'];
       $pD=$scon->getShopItemPricesOtherView($shopid,$ownerD);
      $pi=$pD->fetch();
       $SI=$scon->getThisItem($itemid);
    
      if($SI->rowCount()>0)
        {
          $ro=$SI->fetch();

        }

      $Sp=$scon->getThisShop($shopid);
    
      if($Sp->rowCount()>0)
        {
          $shop=$Sp->fetch();

        }
        
        
      
    
     if($post=="CheckOut Now")
    
    {  
   $code=$_POST['code']; 
     
   $quantity=$_POST['quantity'];
  

   if($scon->vCode($code)  && $scon->vQuantity($quantity))
      {
      	$CD=$scon->getConfirmCode($code);
      	if ($CD->rowCount()>0)
      	{
        //echo "string";
         print_r($scon->addOrder($shopid,$itemid,$code,$customerid,$quantity));
      	}
      	else
      	{
           ?>
  
     <center>
     <div>
       <sup>
          <?php
       echo "Invalid payment code!";
           ?>   
       </sup>
      </div>
   </center> 
         <?php
      	}

      }
   else
      {
      ?>
   <center>
     <div>
       <sup>
          <?php
            echo $con->eCode($code)."<p/>"; 
            echo $scon->eQuantity($quantity)."<p/>";   

     ?>
  </sup>
</div>
</center> 
<?php
            require("ordeNowPage.php");
   
}
 }	
 
    	require("ordeNowPage.php");
     
}else
{
  echo "Error!..";
}
}
else{
  echo "ITEM QUANTITYERROR!.i.e.".$scon->eQuantity($quantity);
}
 
 require_once('../footerIns.php');
?>

