<?php
include 'ourphp_admin.php';
include 'ourphp_checkadmin.php';
include 'ourphp_page.class.php';

if(isset($_GET["type"]) == ""){

	echo '';

}elseif ($_GET["type"] == "del"){
	
	if (strstr($OP_Adminpower,"35")){

	$rs = $db -> select("OP_Usermoney,OP_Incomeuseremail","ourphp_usersaleinfo","where id = ".intval($_GET['id']));
	$db -> update("ourphp_user","OP_Usermoney = OP_Usermoney - ".$rs[0],"where OP_Useremail = '".$rs[1]."'");
	$db -> del("ourphp_usersaleinfo","where id = ".intval($_GET['id']));
	plugsclass::logs('删除用户分润记录('.$rs[1].' 减 '.$rs[0].')',$OP_Adminname);
	
	}else{
	
		$ourphp_font = 4;
		$ourphp_content = '权限不够，无法删除！';
		$ourphp_class = 'ourphp_article.php?id=ourphp&aid='.$aid;
		require 'ourphp_remind.php';
	
	}
	
}

function ourphp_usersaleinfo(){
  global $_page,$db,$smarty;
  $listpage = 55;
  if (intval(isset($_GET['page'])) == 0){
    $listpagesum = 1;
      }else{
    $listpagesum = intval($_GET['page']);
  }
  $start=($listpagesum-1)*$listpage;
  $ourphptotal = $db -> listgo("count(id) as tiaoshu","`ourphp_usersaleinfo`","");
  $ourphptotal = $db -> whilego($ourphptotal);

  $rs = array();
  $a = $db -> listgo("*","ourphp_usersaleinfo","ORDER BY id DESC LIMIT ".$start.",".$listpage);
  while($r = $db -> whilego($a)){
    $pr = $db -> select("*","ourphp_product","where id = ".$r['OP_Productid']);
    $rs[] = array(
      'id' => $r['id'],
      'buyuser' => $r['OP_Buyuseremail'],
      'incuser' => $r['OP_Incomeuseremail'],
      'prmoney' => $r['OP_Productmoney'],
      'usermoney' => $r['OP_Usermoney'],
      'promoney' => $r['OP_Proportion'],
      'pr' => $pr,
      'time' => $r['time'],
    );
  }
  $_page = new Page($ourphptotal['tiaoshu'],$listpage);
  $smarty->assign('ourphppage',$_page->showpage());
  return $rs;
}

$smarty->assign("saleinfo",ourphp_usersaleinfo());
$smarty->display('ourphp_distribution.html');
?>
