<?
	include("config/connect.php");
	include("functions.php");
	$uid  = $_SESSION["userid"];
	$aucid = $_REQUEST["aucid"];
  //echo $aucid;
	$qrysel = "select * from products p left join auction a on p.productID=a.productID  left join auc_due_table adt on a.auctionID=adt.auction_id left join registration r on a.buy_user=r.id left join shipping s on a.shipping_id=s.id  left join auction_management am on am.auc_manage=a.time_duration where a.auctionID='$aucid'";
	$ressel = mysql_query($qrysel);
	$total = mysql_num_rows($ressel);
	$obj = mysql_fetch_object($ressel);

	if($uid!="" && $aucid!="")
	{
			$qrybid2 = "select *,sum(bid_count) as bidcount from bid_account where bid_flag='d' and auction_id='$aucid' and user_id='$uid' group by auction_id";
			$resbid2 = mysql_query($qrybid2);
			$total2 = mysql_num_rows($resbid2);
			$objbid2 = mysql_fetch_object($resbid2);
			$totbid2 = $objbid2->bidcount; 
			$totbidprice2 = $totbid2 ;
			$price2 = $obj->price;
			if($obj->fixedpriceauction=="1") { $fprice2 = $obj->auc_fixed_price;}
			elseif($obj->offauction=="1")  { $fprice2 = "0.00"; }
			else { $fprice2 = $obj->auc_final_price;}
			$saving_price2 = $price2-$totbidprice2-$fprice2;
			$saving_percent2 = ($saving_price2*100)/$price2;
	}								
	$actual_price = $price2-$totbidprice2;
	//$need_price=$actual_price+$obj->shippingcharge ;
	//echo $actual_price;
	//$OrdersId = 'S-P'.time().'RN'.mt_rand(100,999);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>购物车 - 下单购买</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="generator" content="DedeCMS V5.3" />
<meta name="author" content="desdev.cn" />
<link href="css/dedecms.css" rel="stylesheet" media="screen" type="text/css" />
<link href="css/table.css" rel="stylesheet" media="screen" type="text/css" />
<link href="css/page.css" rel="stylesheet" media="screen" type="text/css" />
</head>
<body class="buycarpage" onload="Dodelivery(2);">

<div class="header">
	<div class="top w960 center">
		<div class="title">
			<h1> <a href="/">我的网站</a> </h1>
		</div><!-- /title -->
		<!--div class="welcome">
            wisheo 您好,欢迎来到本网站, <a href="../member/">会员中心</a> | <a href="../member/index_do.php?fmdo=login&dopost=exit">退出</a>
            		</div-->
	</div><!-- /top -->
</div><!-- /header -->

<div class="w960 clear center mt1 cmt-box">
	<div class="sp-title"><h2>商品购买</h2></div>
	<div class="buycar">
		<form id="fixupformid" name="fixupform" action="carbuyaction.php" method="post">
        <input name="do" type="hidden" value="clickout">
        <input name="pc" type="hidden" value="<?=$actual_price;?>">
        <input name="dprice" type="hidden" value="<?=$obj->shippingcharge;?>">
        <input name="oid" type="hidden" value="<?=$OrdersId;?>">
        <input name="aucid" type="hidden" value="<?=$aucid;?>">
        <table cellpadding="0" cellspacing="0" class="flow">
			<tr>
				<td class="thisclass">下单购买</td>
				<td>买家付款</td>
				<td>交易结束 </td>
			</tr>
		</table>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="dede_table">
			<thead>
				<tr>
					<td colspan="6">确认订单信息</td>
				</tr>
			</thead>
			<tbody>
				<!--tr>
					<td width="180" class="td1">订单编号</td>
					<td><strong><?=$OrdersId;?></strong></td>
				</tr-->
				<tr>
					<td width="180" class="td1">订单价格</td>
					<td><strong class="fc-f60" id="priceCount"><?=$need_price;?></strong> 元(该价格已包含快递费用)<BR> (特别说明：您已在竞拍中付出<?=$totbidprice2;?>元。商品原价<?=$price2;?>，现在您要付出<?=$actual_price;?>元。快递费用另计。)</td>
				</tr>
				<tr>
					<td width="180" class="td1">商品总数</td>
					<td>1件</td>
				</tr>
				<tr>
					<td width="180" class="td1">支付方式</td>
					<td>
             <input name="paytype" type="radio" value="alipay"  checked="true"/>支付宝(www.alipay.com)
             <input name="paytype" type="radio" value="chinabank" />网银在线(www.chinabank.com.cn)
             <input name="paytype" type="radio" value="tenpay" />财付通(www.tenpay.com)
					</td>
				</tr>
				<tr>
					<td width="180" class="td1">配送方式</td>
			  <td>                                                
           <p><input type="radio" name="pid" checked value="2" /><strong>快递</strong> <span class="fc-f90">手续费：<em id="delivery_price_2"><?=$obj->shippingcharge;?></em>元</span> </p>                        
					</td>
				</tr>
				<tr>
					<td width="180" class="td1">状态</td>
					<td>下单</td>
				</tr>
			</tbody>
		</table>
        
        
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="dede_table">
			<thead>
				<tr>
					<td colspan="6">确认订单信息</td>
				</tr>
			</thead>            
			<tbody>
				<tr>
					<td width="180" class="td1">收货地址</td>
					<td><input name="address" id="address" type="text" class="ipt-txt" size="50" /> <small>请填写详细的收货地址，不能为空!</small></td>
				</tr>
				<tr>
					<td width="180" class="td1">收货人</td>
					<td><input name="postname" id="postname" type="text" class="ipt-txt" size="20" /> <small>请填写收货人姓名</small></td>
				</tr>
				<tr>
					<td width="180" class="td1">E-Mail</td>
					<td><input name="email" id="email" type="text" class="ipt-txt" size="30" /> <small>可选，联系您的电子邮箱</small></td>
				</tr>
				<tr>
					<td width="180" class="td1">手机/电话</td>
					<td><input name="tel" id="tel" type="text" class="ipt-txt" size="30" /> <small>请填写可以联系到您的电话</small></td>
				</tr>
				<tr>
					<td width="180" class="td1">邮编</td>
					<td><input name="zip" id="zip" type="text" class="ipt-txt" size="30" /> <small>请填写格式如：300030</small></td>
				</tr>
			</tbody>
		</table>
        
        			
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="dede_table">
			<thead>
				<tr>
					<td colspan="6">确认订单信息</td>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td width="180" class="td1">购买留言</td>
					<td>
						<textarea name="des" id="des" cols="50" rows="5" class="ipt-txt"></textarea>
						<p><small>请在购买留言中填写您对商品的特殊要求，如“我要红色的iPod”(100个字以内)</small></p>
					</td>
				</tr>
				
			</tbody>
			<tfoot>
				<tr>
					<td colspan="2">
					<button type="submit" class="btn-2">确认下单</button>
					</td>
				</tr>
			</tfoot>
		</table>		
		</form>
	</div>
	
</div>

<script language="JavaScript" type="text/javascript">
function Dodelivery(_id){
	var _price = document.getElementById("delivery_price_"+_id).innerHTML;
	var _priceCount = parseFloat(<?=$actual_price;?>)+parseFloat(_price);
	document.getElementById("priceCount").innerHTML = number_format(_priceCount,2);
	document.getElementById("pc").innerHTML = number_format(_priceCount,2);
	_priceCount = null;
}
function number_format(number)   {
	if(number<0){
		return '-'+outputDollars(Math.floor(Math.abs(number)-0)+'')+outputCents(Math.abs(number)-0);
	}else{
		return outputDollars(Math.floor(number-0)+'')   +   outputCents(number-0);
	}
}
function outputDollars(number)   {
	if(number.length <= 3){
		return (number == '' ? '0' : number);
	}else{
		var mod = number.length%3;
		var output = (mod == 0 ? '' : (number.substring(0,mod)));
		for(i=0   ;   i<   Math.floor(number.length/3)   ;   i++)   {
			if((mod == 0) && (i == 0))
			output+= number.substring(mod+3*i,mod+3*i+3);
			else
			output+= ',' + number.substring(mod+3*i,mod+3*i+3);
		}
		return (output);
	}
}
function outputCents(amount){
	amount = Math.round(((amount)-Math.floor(amount))*100);
	return (amount<10 ? '.0' + amount : '.' + amount);
}
</script>


</body>
</html>