<?php
include_once("inc/conn.php");		
include_once("inc/function.php");
login_check();
business_check();

$query=$db->query("Select * FROM {$web_dbtop}payset Order by id desc");
if($rs=$db->fetch_array($query)){
	$reg_userid=$rs["paysetid"];
	$reg_key=$rs["paysetpassword"];
	$receive_url=$web_url."/".$rs["pysetreceiver"];
}
$servicename="商户进货";
$cardid=implode(",",$_POST["cardid"]);
$num=implode(",",$_POST["num"]);
$discount=showcontent("business","discount",showbusinessid(intval($_COOKIE["usersid"])));
$query=$db->query("Select * FROM {$web_dbtop}cardtype where id in ($cardid) Order by id desc");
$i=0;
while($rs=$db->fetch_array($query)){
	$amount=$amount+($rs["cardprice"]*$discount/10*$_POST["num"][$i]);
	$i++;
}
$amount=$amount*100;

$ymd=date('Ymd',time());//不可为空值，长度为8位，格式为yyyymmdd
$billno=date('YmdHis',time());//30个字符以内，必填
$custom1name="businesscontent";
$custom1=$cardid."$|$".$num;
$custom2name="businessid";
$custom2=showbusinessid(intval($_COOKIE["usersid"]));
$payvia=$_GET["payvia"];
//运行模式，不启用测试模式可不设置此变量，将paymode值设为testmode即可进入支付平台测试模式。
$paymode="";
$post_key=$reg_userid.$amount.$ymd.$receive_url.$billno.$custom1.$custom2.$payvia.$reg_key.$paymode;
$post_md5info=strtoupper(md5($post_key));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>商户中心-<?=$web_name;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<?=$web_keywords;?>" />
<meta name="description" content="<?=$web_description;?>" />
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<link href="style/default.css" rel="stylesheet" type="text/css" />
</head>
<?php include_once("top.php");?>
<DIV class="wrapper">
	<DIV class="page_content">
  		<!--主体右边 Start-->
    	<div class="area260 fl">
			<DIV class="news-title">
				 <H3>商户中心</H3>
			</DIV>
			<ul class="area260-info business-list">
				<LI><A href="businessnotice.php">商户公告</A></LI>
                <LI><A href="businessusers.php">商户汇豆</A></LI>
                <LI><A href="businesscardlog.php">汇豆记录</A></LI>
                <LI><A href="businesscardback.php">查看库存</A></LI>
                <LI class="my_nav_on"><A href="businesspay.php">我要进货</A></LI>
                <LI><A href="businesslog.php">进货记录</A></LI>
			</ul>
			 <DIV class="area260-b h5px"></DIV>
			 <DIV class=blank10></DIV>
		</div>
		<!--主体左边 Start-->
		<div class="area690 fr">
			<DIV class="users-title">
				 <H3>我要进货</H3>
			</DIV>
        	<div class="users-content">
				<ul class="bgk">
				<?
				$query=$db->query("Select * FROM {$web_dbtop}cardtype where id in ($cardid) Order by id desc");
				$i=0;
				while($rs=$db->fetch_array($query)){
				?>
					<li class="b22" style="MARGIN-LEFT: 0px;"><span style="padding-left:10px"><?=$rs["cardname"]?> / 每张 <?=number_format($rs["cardprice"]*$discount/10,2);?> 元</span></li>
					<li class="b21a"><span style="padding-left:5px"> <?=$_POST["num"][$i];?>张</span></li>
				<?
					$i++;
				}
				?>
				<li class="bb21" style="padding-left:5px">合计：<?=$amount/100;?> 元</li>
				<form action="http://pay.168reg.cn/pay.do" name="form" method="post">
				<input type=hidden name="reg_userid" value="<?php echo $reg_userid;?>">
				<input type=hidden name="servicename" value="<?php echo $servicename;?>">
				<input type=hidden name="amount" value="<?php echo $amount;?>">
				<input type=hidden name="ymd" value="<?php echo $ymd;?>">
				<input type=hidden name="receive_url" value="<?php echo $receive_url;?>">
				<input type=hidden name="billno" value="<?php echo $billno;?>">
				<input type=hidden name="custom1name" value="<?php echo $custom1name;?>">
				<input type=hidden name="custom1" value="<?php echo $custom1;?>">
				<input type=hidden name="custom2name" value="<?php echo $custom2name;?>">
				<input type=hidden name="custom2" value="<?php echo $custom2;?>">
				<input type=hidden name="paymode" value="<?php echo $paymode;?>">
				<input type=hidden name="payvia" value="<?php echo $payvia;?>">
				<input type=hidden name="post_md5info" value="<?php echo $post_md5info;?>">
				<li class="tj"><input id="btnSubmit" type="image" src="images/an_ljtj_03.gif"  border="0"/></li>
				</form>
				</ul>
			</div>
			<div class="area690-b h5px"></div>
        	<div class="blank10"></div>
		</div>
		<!--主体左边 End-->
	</DIV>
	<!--Flink End-->
	<div class="blank10"></div>
	<!--Footer Start-->
<?php include_once("footer.php");?>
</DIV>