<?php
require("../../class/connect.php");
include("../../class/config.php");
include("../../class/q_functions.php");
include("../../class/db_sql.php");
include("../../class/class.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//------------------显示购物车
function ShowBuycar(){
	global $empire,$class_r,$dbtbpre;
	$buycar=getcvar('mybuycar');
	$record="!";
	$field="|";
	$r=explode($record,$buycar);
	$alltotal=0;
	$return[0]=0;
	$return[1]=0;
	echo"<form name=form1 method=post action=../../enews/index.php>
  <table width=100%% border=0 align=center cellpadding=3 cellspacing=1>
  <input type=hidden name=enews value=EditBuycar>
    <tr bgcolor=#698CC3> 
      <td width=17% height=20> <div align=center><font color=#FFFFFF>图片</font></div></td>
      <td width=28%> <div align=center><font color=#FFFFFF>商品名称</font></div></td>
      <td width=13%> <div align=center><font color=#FFFFFF>市场价格</font></div></td>
      <td width=13%> <div align=center><font color=#FFFFFF>优惠价格</font></div></td>
      <td width=8%> <div align=center><font color=#FFFFFF>数量</font></div></td>
      <td width=16%> <div align=center><font color=#FFFFFF>小计</font></div></td>
      <td width=5%> <div align=center><font color=#FFFFFF>删除</font></div></td>
    </tr>";
	for($i=0;$i<count($r)-1;$i++)
	{
		$pr=explode($field,$r[$i]);
		$productid=$pr[1];
		$fr=explode(",",$pr[1]);
		//ID
		$classid=$fr[0];
		$id=$fr[1];
		//数量
		$num=$pr[2];
		if(empty($num))
		{$num=1;}
		//取得产品信息
		$productr=$empire->fetch1("select title,tprice,price,titleurl,groupid,classid,newspath,filename,id,titlepic,buyfen from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid='$classid' and id='$id' limit 1");
		//是否全部积分
		if(!$productr[buyfen])
		{
			$return[0]=1;
		}
		$return[1]+=$productr[buyfen]*$num;
		//产品图片
		if(empty($productr[titlepic]))
		{$productr[titlepic]="../../data/images/notimg.gif";}
		//返回链接
		$titleurl=sys_ReturnBqTitleLink($productr);
		$thistotal=$productr[price]*$num;
		$alltotal+=$thistotal;
		echo"<tr>
	<td align=center><a href='".$titleurl."' target=_blank><img src='".$productr[titlepic]."' border=0 width=80 height=80></a></td>
	<td align=center><a href='".$titleurl."' target=_blank>".$productr[title]."</a></td>
	<td align=center>$".$productr[tprice]."</td>
	<td align=center><b>$".$productr[price]."</b></td>
	<td align=center><input type=text name=num[] value='".$num."' size=6></td>
	<td align=center>".$thistotal."</td>
	<td align=center><input type=checkbox name=del[] value='".$productid."'></td>
	<input type=hidden name=productid[] value='".$productid."'></tr>";
    }
	//支付积分付费
	if(!$return[0])
	{
		$a="<tr> 
      <td colspan=6><div align=right>合计积分:<strong>".$return[1]."</strong></div></td>
      <td>&nbsp;</td>
    </tr>";
	}
	echo"<tr> 
      <td colspan=6><div align=right>合计:<strong>$".$alltotal."</strong></div></td>
      <td>&nbsp;</td>
    </tr>".$a."
    <tr> 
      <td colspan=7><div align=right><a href=../../enews?enews=ClearBuycar><img src=../../data/images/shop/clearbuycar.gif width=92 height=23 border=0></a>&nbsp;&nbsp;
          <input name=imageField type=image src=../../data/images/shop/editbuycar.gif width=135 height=23 border=0>
          &nbsp;&nbsp;<a href=javascript:window.close();><img src=../../data/images/shop/buynext.gif width=87 height=23 border=0></a>&nbsp;&nbsp;<a href=../order><img src=../../data/images/shop/buycarnext.gif width=87 height=19 border=0></a></div></td>
    </tr>
  </table>
</form>";
	return $return;
}
?>
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<meta http-equiv=Content-Type content=text/html; charset=gb2312>
<title>我的购物车</title>
<link href=../../data/images/qcss.css rel=stylesheet type=text/css>
</head>

<body>
<?
ShowBuycar();
?>
</body>
</html>
<?
db_close();
$empire=null;
?>