<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[44]!=1)
  jump("jump.php?id=25&jump=main.php");
if(isset($_GET['action']) and $_GET['action'] == "yes" and isset($_GET['id']))
{
  $phpcolor->table="shop_cards";
  $phpcolor->field="status='0'";
  $phpcolor->where="id = '".$_GET['id']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=shop_card.php");
}
elseif(isset($_GET['action']) and $_GET['action'] == "no" and isset($_GET['id']))
{
  $phpcolor->table="shop_cards";
  $phpcolor->field="status='3'";
  $phpcolor->where="id = '".$_GET['id']."' and status='0'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=shop_card.php");
}
else
{
  $phpcolor->table="shop_cards";
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="*";
  if(isset($_GET['id']))
    $phpcolor->where="id = '".$_GET['id']."'";
  else
  {
    $phpcolor->where="1 = 1";
    $count = $phpcolor->exist(2);
    $phpcolor->where="1 = 1 order by cardtime desc limit ".($_GET['page']*20).",20";
    $page=pages($count,20,$_GET['page'],'shop_card','','','0');
  }
  $card=$phpcolor->assignment();
  for($count=0;$count<count($card);$count++)
  {
    $phpcolor->table="shop_card";
	$phpcolor->field="*";
	$phpcolor->where="id = '".$card[$count]['cardid']."'";
	$rs=$phpcolor->exist(1);
	$card[$count]['cardname']=$rs['cardname'];
	$phpcolor->table="user";
	$phpcolor->field="*";
	$phpcolor->where="id = '".$card[$count]['uid']."'";
	$rs=$phpcolor->exist(1);
	$card[$count]['username']=$rs['username'];
	if($card[$count]['status']=="0")
	  $card[$count]['status']="未使用";
	elseif($card[$count]['status']=="1")
	  $card[$count]['status']="已使用";
	elseif($card[$count]['status']=="2")
	  $card[$count]['status']="标价：".$card[$count]['prices']." 转让中";
	elseif($card[$count]['status']=="3")
	  $card[$count]['status']="冻结";
  }
  $tpl -> assign("card", $card);
  $tpl -> assign("page", $page);
  $tpl -> display("shop_card.htm");
}
?>