<table width="980" border="0" cellpadding="0" cellspacing="0" align="center" class="ft2">
  <tr>
    <td valign="top">
	<? 
	$tilte="The Best Marketplace";
	require 'templates/'.$tfold.'/header.php';?>
	</td>
  </tr>
   
   <?
   
   $flag=$_POST[flag];
if($flag==1)
{  

   $userid=$_SESSION[userid];   
   $cat_id=$_SESSION[categoryid];
//   $category_id=$_SESSION[categoryid];
   
   
   $producttitle=$_SESSION[item_name];
   $qty=$_SESSION[qty];
   $itemdes=$_SESSION[des];
   $currency=$_SESSION[currency];
   $postmethod=$_SESSION[postmethod];
   $min_amt=$_SESSION[min_amt];  
   $bid_inc=$_SESSION[bid_inc];
   $dur=$_SESSION[dur];
   $rev_price=$_SESSION[rev_price];
   // $bid_starting_date=$_SESSION[bid_start];
   $quick=$_SESSION[quick_price];	  
   $size_of_qty=$_SESSION[size_of_qty];
   $start_delay=$_SESSION[start_delay];
   $img1=$_SESSION[image1];
   $img2=$_SESSION[image2];
   $img3=$_SESSION[image3];
   $img4=$_SESSION[image4];
   $img5=$_SESSION[image5];
   $shipping_route=$_SESSION[shipping_route];
   $shipping_amt=$_SESSION[shipping_amt];
   $tax=$_SESSION[tax];
   //payment
   
   $payment=$_SESSION[payment];
   $payname=$_SESSION[payname];
   $payid=$_SESSION[payid];
   $repost=$_SESSION[repost];
   if($_SESSION[mode]!="repost" or $_SESSION[mode]="relist")
   {
   //$bidding_start_date=date("Y-m-d G:i:s");
   $bidding_start_date=date("Y-m-d");
   $bidding_start_date = AddDays($bidding_start_date,$start_delay); 
   $interval =$dur +$start_delay;
   $expire_date = AddDays($bidding_start_date,$interval); 
   $sql="insert into auction_details(user_id,category_id,producttitle,quantity,detailed_descrip, currency ,selling_method,min_bid_amount,bidincrement,duration,reserve_price,quick_buy_price,bid_starting_date,picture1,picture2,picture3,picture4,picture5,size_of_quantity,start_delay,expire_date,shipping_route,shipping_cost,status,tax,payment_gateway,payment_name,payment_id,no_of_repost)";
   $sql.="values('$userid','$cat_id','$producttitle',$qty,'$itemdes','$currency','$postmethod','$min_amt','$bid_inc','$dur','$rev_price','$quick','$bidding_start_date','$img1','$img2','$img3','$img4','$img5','$size_of_qty',$start_delay,'$expire_date','$shipping_route','$shipping_amt','Active','$tax','$payment','$payname','$payid','$repost')"; 
   $res=mysql_query($sql);  
   if($res)
{
$productid=mysql_insert_id();
// featured items 
$user="select * from member_details where user_id=$_SESSION[userid]";
$user_res=mysql_query($user);
$user_row=mysql_fetch_array($user_res);
//if($user_row[member_account]==3)
{
  $Gallery=$_SESSION[Gallery];
  $Border=$_SESSION[Border];
    $Highlight=$_SESSION[Highlight];
    $Privateauc=$_SESSION[Privateauc];

   $Bold=$_SESSION[Bold];
    $Home=$_SESSION[Home];
   $repost=$_SESSION[repost];
   
   $gallery_fee=$_SESSION[gallery_fee];
   $home_fee=$_SESSION[home_fee];
    $bold_fee=$_SESSION[bold_fee];
	$highlight_fee=$_SESSION[highligt_fee];
	$private_fee=$_SESSION[private_fee];

   
    //add item fee report
   $user_query="select * from member_details where user_id='$_SESSION[userid]'";
   $user_tab=mysql_query($user_query);
   if($user_row=mysql_fetch_array($user_tab))
   {
   $seller=$user_row['user_name'];
   }
   if($Gallery=='yes')
   {
   $item_query="insert into item_fee_report(item_name , seller , amount ,ad_type  ,date )values";
   $item_query.="('$producttitle','$seller','$gallery_fee','gallery',now())";
   mysql_query($item_query);
   }
   if($Home=='yes')
   {
   $item_query="insert into item_fee_report(item_name , seller , amount ,ad_type  ,date )values";
   $item_query.="('$producttitle','$seller','$home_fee','home',now())";
   mysql_query($item_query);
   }
   if($Bold=='yes')
   {
   $item_query="insert into item_fee_report(item_name , seller , amount ,ad_type  ,date )values";
   $item_query.="('$producttitle','$seller','$bold_fee','bold',now())";
   mysql_query($item_query);
   }
   if($Highlight=='yes')
   {
   $item_query="insert into item_fee_report(item_name , seller , amount ,ad_type  ,date )values";
   $item_query.="('$producttitle','$seller','$highlight_fee','highlight',now())";
   mysql_query($item_query);
   }
      if($Privateauc=='yes')
   {
   $item_query="insert into item_fee_report(item_name , seller , amount ,ad_type  ,date )values";
   $item_query.="('$producttitle','$seller','$private_fee','Private Auction',now())";
   mysql_query($item_query);
   }

   
   
   
   
   
 //if(!empty($Highlight) || !empty($Border) || !empty($Bold) || !empty($Gallery) || !empty($Subtitle) || !empty($Home))
 { 
    $feature_sql="insert into featuredproducts(productid,gallery_feature,home_feature,bold,border,highlight,subtitle_feature,subtitle,privateauc)";
    $feature_sql.="values($productid,'$Gallery','$Home','$Bold','$Border','$Highlight','$Subtitle','$Subtitle_name','$Privateauc')";
    $feature_res=mysql_query($feature_sql);
} 

}

 $cat_sql="select * from downcats where category_id=$cat_id";
$res=mysql_query($cat_sql);
$row=mysql_fetch_array($res);
$tablename=$row[tablename];
$file_path=$row[file_path];
  if($tablename)
   { 
     	$tab_sql="select * from $tablename";
        $tab_res=mysql_query($tab_sql);
        $i =2; 
		$j=3;
		$in_sql="insert into $tablename(productid,";
		$in_sql_value="values(' $productid ', ";
 while ($i < mysql_num_fields($tab_res))
{

    $tab_col = mysql_fetch_field($tab_res, $i);
	$dummy=$tab_col->name;
	$in_sql.="$dummy ,";
	//if($i<$j)
   	$in_sql_value.="'$_SESSION[$dummy]',";
   // echo "sesssion"."<br>". $_SESSION[third]."<br>";
	$i++;
	// $j++;
}
$in_sql=rtrim($in_sql,", "); 
$in_sql_value=rtrim($in_sql_value,", "); 
$in_sql.=")".$in_sql_value.")";
 $in_res=mysql_query($in_sql);

}
$sucess=1;

} //if($res)
} //
else if($mode="repost")
{

  $up="update auction_details set status='new',no_of_repost=no_of_repost+1,category_id='$category_id',producttitle='$producttitle',quantity='$qty',detailed_descrip='itemdes', currency='$currency',selling_method='$postmethod'";
  $up.=",min_bid_amount='$min_amt',bidincrement='$bid_inc',duration='$dur',reserve_price='$rev_price',quick_buy_price='$quick',bid_starting_date='$bid_starting_date',picture1='$img1',picture2='$img2',picture3='$img3',picture4='$img4',picture5='$img5'";
  $up.=",size_of_quantity='$size_of_qty',start_delay='$start_delay',no_of_repost='$repost' where productid=$productid";
  $res=mysql_query($up); 
  
  if($tablename)
  {
  $tab_sql="select * from $tablename";
  $tab_res=mysql_query($tab_sql);
  $i =2;
  $up_cat="update $tablename set ";
  $in_sql="insert into $tablename(productid,";
  $in_sql_value="values(' $productid ', ";
while ($i < mysql_num_fields($tab_res))
{
      $tab_col = mysql_fetch_field($tab_res, $i);
   	  $dummy=$tab_col->name;
	  
      $table_sql="select * from $tablename where productid=$productid";
	  $table_res=mysql_query($table_sql);
      $var_value=$table_row[$tab_col->name];
	  if(mysql_num_rows($table_res)==0)
	  {
	    $in_sql.="$tab_col->name ,";
     	$in_sql_value.="'$_SESSION[$dummy]',";
	    // $table_row=mysql_fetch_array($table_res);
	  }
	  else
	  {	   
	  $up_cat.=$tab_col->name.'='."'".$_SESSION[$tab_col->name] ."'".", ";
	  }
	 // $_SESSION[$tab_col->name]=$table_row[$tab_col->name];
	  $i++;
} // while
if(mysql_num_rows($table_res) > 0)
{
$up_cat=rtrim($up_cat,", ");
$up_cat.=" where productid=".$productid;
$up_res=mysql_query($up_cat);
}
else
{
$in_sql=rtrim($in_sql,", "); 
$in_sql_value=rtrim($in_sql_value,", "); 
 $in_sql.=")".$in_sql_value.")";
 $in_res=mysql_query($in_sql);
}
 $up_cat;
} // if($tablename)
  /* $no_of_sql="select * from auction_details where productid=$productid";
  $no_of_res=mysql_query($no_of_sql);
  $no_of_row=mysql_fetch_array($no_of_res);
  $repost="update auction_details set no_of_repost='$no_of_row[no_of_repost]+1' where productid=$productid";
  $ repost_res=mysql_query($repost); */
 } // mode="repost"
 if($res)
 $sucess=1;
 else
 $fail=1;
 } 

if($sucess==1)
{

$_SESSION[des]="";
$_SESSION[postmethod]="";
$_SESSION[currency]="";
$_SESSION[min_amt]="";
 $_SESSION[quick_price] ="";
$_SESSION[rev_price]="";
$_SESSION[bid_inc]="";
$_SESSION[size_of_qty]="";
$_SESSION[qty]="";
$_SESSION[start_delay]="";
$_SESSION[image1]="";
$_SESSION[image2]="";
$_SESSION[image3]="";
$_SESSION[shipping_route]="";
$_SESSION[shipping_amt]="";
$_SESSION[tax]="";
$_SESSION[mode]="";
$_SESSION[Gallery]="";
$_SESSION[Border]="";
$_SESSION[Highlight]="";
$_SESSION[Privateauc]="";
$_SESSION[Bold]="";
$_SESSION[Home]="";
$_SESSION[repost]="";
$_SESSION[dur] ="";
$_SESSION[categoryid]="";
$_SESSION[gallery_fee]="";
$_SESSION[home_fee]="";
$_SESSION[bold_fee]="";
$_SESSION[highligt_fee]="";	
if($tablename)
  {
  $tab_sql="select * from $tablename";
  $tab_res=mysql_query($tab_sql);
  $i =2;
while ($i < mysql_num_fields($tab_res))
{
    $tab_col = mysql_fetch_field($tab_res, $i);
    if (!$tab_col) 
	{
        echo "";
    }
	else
	{
	  $dummy="$".$tab_col->name;
      $dummy=$_POST[$tab_col->name];
	  $_SESSION[$tab_col->name]="";		
    }
	$i++;
} // while
} // if($tablename)




} // if($sucess==1)


   
   
   ?>
 <tr><td>
<table width="100%" cellpadding="5" cellspacing="0" align="center" border="0">
<?

if($sucess==1)
{
?>
<tr height=40>
<td class="tr_border"><font size="2"><b>
Sell Your Item: Congratulations</b></font></td></tr>
<tr><td valign="top">
<table cellpadding="5" cellspacing="2" align="center" class="ft2" width="95%">
<tr><td><font size="2" color=green><b>You have successfully listed your item.</b></font></td></tr>
<!-- <tr><td><b>View your listing:</b>&nbsp;<a href="review.php?productid=<?= $productid ?> "><?= $item_row[producttitle]; ?></a></td></tr> -->
<tr><td><b>View your listing:</b>&nbsp;<a href="itechd.php?productid=<?= $productid ?> "><?= $_SESSION[item_name]; ?></a></td></tr>
<tr><td><form name="relist" action="modifyitem_cate.php" method="get">
<input type="hidden" name="productid" value="<?= $productid ?>" >
<input type="hidden" name="mode" value="relist" >
<input class="submit_button" type="submit" name="relist" value="Sell Similar Item">
 &nbsp;&nbsp;&nbsp; or <a href="selectpostformat.php">Sell a Different Item </a>
 </form></td></tr>
 
</table>
</td></tr>
<tr><td><? require 'templates/'.$tfold.'/footer.php'; ?></td></tr>
</table>
<?
$_SESSION[item_name]="";
exit();
}
else
{
?>
<tr height=40>
<td class="tr_border"><font size="2"><b>
Sell Your Item:Shipping Details &amp; Sales Tax</b></font></td></tr>

<tr class="sub_tr_border">
<td height="30" colspan="2" >
  1.Category&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.&nbsp;Tittle & Description  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.&nbsp;Shipping Details & Sales Tax
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.<b>&nbsp;Preview & Submit</b></td>
</tr>
<?
}
?>

<tr><td>&nbsp;</td></tr>
<? 
 /* if($sucess==1)
{
?>
<tr><td ><br>
<br>
<br>
<table align="center" class="ft2" cellpadding="15" width=50% >
<tr class="mylist" height="30">
<td align="center" class="tdhead"><font size="+1"><b>Congratulations!</b></font> </td></tr>
<tr><td><font size="2"><b>You have successfully listed your item.The item can be viewed in the User Panel after the admin's approval!</b></font>
 </td></tr>
<!-- <tr><td><b>View your listing:</b>&nbsp;<a href="review.php?productid=<?= $productid ?> "><?= $item_row[producttitle]; ?></a></td></tr> -->
</table><br>
<br>
<br></td></tr>
<!-- <tr align="center"><td align="center"><a href="pay.php">Pay Now</a></td></tr> -->
</table>
</td></tr>
<tr><td><? require 'templates/'.$tfold.'/footer.php'; ?></td></tr>
</table>
<?  
exit();
} */
?> 



<!-- <tr >
<td class="tr_top_border"><font size=2><b>Step 1: Review Your Listing</b></font>
</td></tr>
<tr><td><a href="review.php">review</a><br><hr color="#999999" noshade></td></tr> -->
<tr >
<td class="tr_top_border"><font size=2><b>Step 1: Edit Your Listing</b></font>
</td></tr>
<tr><td>Click on 'Edit' link to make changes. When you do, you'll be directed to a page where you can make your desired changes. </td></tr>

<!-- <tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="0" width=100% class="table_border_with_bg1">
	<tr  valign="top">
	<td bgcolor="#CCCCCC" height="30" valign="top">
	<div align="left">
    <b>Categories</b></div></td><td bgcolor="#CCCCCC">
	<div align="right"><a href="catselect.php?mode=change">Edit Category</a></div>
	</td></tr>
	<tr><td colspan="2">
	<?
	 $cat="select category_name from site_categories where category_id=".$_SESSION[categoryid];
     $cat_res=mysql_query($cat);
     $cat_row=mysql_fetch_array($cat_res); 
	 echo $cat_row[category_name];
	?></td></tr>
	</table>
	
</td></tr> -->





<tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="0" width=100% class="table_border_with_bg1">
	<tr  valign="top">
	<td bgcolor="#CCCCCC" height="30" valign="top">
	<div align="left">
    <b>Title & Description </b></div></td>
	<td bgcolor="#CCCCCC"><div align="right"><a href="postdetails.php?mode=change">Edit 
                  Title &amp; Description</a></div>
	</td></tr>
	<tr><td><b>Item Title</b></td><td> <?= $_SESSION[item_name]; ?> </td></tr>
	<tr><td><b>Item Description</b></td><td> <?= $_SESSION[des]; ?> </td></tr>
        <tr><td><b>Currency</b></td><td align="left"><?=$_SESSION[currency]?></td></tr>
    <tr><td><b>Minimum Bid Amount</b></td><td align="left"><?= $_SESSION[min_amt]?></td></tr>
    <tr><td><b>Bid Increment</b></td><td><?= $_SESSION[bid_inc]?></td></tr>
	<? if($_SESSION[rev_price])
	{
	?>
    <tr><td><b>Reserve Price</b></td><td><?= $_SESSION[rev_price] ?></td></tr>
	<?
	}
	?>
	<? if($_SESSION[start_delay])
	{
	?>
    <tr><td><b>Start Delay</b></td><td><?= $_SESSION[start_delay]." Days" ?></td></tr>
	<?
	}
	?>
	<? if($_SESSION[quick_price])
	{
	?>
    <tr><td><b>Fixed Price Auction</b></td><td><?= $_SESSION[quick_price] ?></td></tr>
	<?
	}
	?>
	<tr><td><b>Duration</b></td><td><?= $_SESSION[dur] ?></td></tr>
    <tr><td><b>Size of Quantity</b></td><td><?= $_SESSION[size_of_qty]?></td></tr>
    <tr><td><b></b></td><td><?= ?></td></tr>
	<tr><td><b></b></td><td><?= ?></td></tr>
	<tr><td><b></b></td><td><?= ?></td></tr>
	<tr><td><b>Quantity </b></td><td> <?= $_SESSION[qty]; ?> </td></tr>
	<tr><td></td><td></td></tr>
	</table>
	

	
</td></tr>
<tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="0" width=100% class="table_border_with_bg1">
	<tr  valign="top">
	<td bgcolor="#CCCCCC" height="30" valign="top">
	<div align="left">
    <b>Images</b></div></td><td bgcolor="#CCCCCC" colspan="2">
	<div align="right"><a href="postdetails.php?mode=change">Edit Images</a></div>
	</td></tr>
	<? 	if($_SESSION[image1])
	{
	?>
	<tr align="center"><td ><img src="uploads/<?= $_SESSION[image1] ?>"></td>
	<?
	}
	?>
        <? 	if($_SESSION[image2])
	{
	?>
	<td><img src="uploads/<?= $_SESSION[image2] ?>"></td>
	<?
	}
	?>
    <? 	if($_SESSION[image3])
	{
	?>
    <td><img src="uploads/<?= $_SESSION[image3] ?>"></td>
	<?
	}
	?>
    </tr>
	  
	
	</table>
	
</td></tr>

<tr><td>
<table border="0" align="center" cellpadding="5" cellspacing="0" width=100% class="table_border_with_bg1">
	<tr  valign="top">
	<td bgcolor="#CCCCCC" height="30" valign="top">
	<div align="left">
    <b>Shipping Details & Sales Tax </b></div></td>
	<td bgcolor="#CCCCCC"><div align="right"><a href="ship_itechd.php?mode=change">Edit 
                  Shipping Details & Sales Tax</a></div>
	</td></tr>
	 	<tr><td><b>Shipping Route</b></td><td>
		 <? 
		if($_SESSION[shipping_route]=="Australia Asia Americanada Europe Africa")
    	{
		 echo "WorldWide";
		}
		else
		  echo $_SESSION[shipping_route];
		 
		?> </td></tr>
	<tr><td><b>Shipping Amount</b></td><td> <?= $_SESSION[shipping_amt]; ?> </td></tr>
        <tr><td><b>Tax</b></td><td align="left"><?=$_SESSION[tax]?></td></tr>
    	</table>
	</td></tr>




<tr><td><hr noshade color="gray"></td></tr>
<tr><td>
<form name=preview action="postpreview.php" method=post>
<table align="center">
<tr><td>
<input type="hidden" name="flag" value=1>
<input type="button" value="Cancel" onClick="cancel()">
</td>
<td><input class="submit_button" type="submit" value="Submit"></td>
</tr></table>
</form>
</td></tr>
<tr><td> <? require 'templates/'.$tfold.'/footer.php'; ?></td></tr>
</table>
