<?php
function doaction($type,$id)
{
  GLOBAL $db,$tbl,$q_ext, $changeAgentCode;
  $id2=explode(",,",$id);
  $aa=explode(",",$id2[0]);


	switch ($type)
	{
		case 'del':
			user_del($id,$q_ext);
			break;
		case 'multdel':
			foreach ($aa as $v)
			{
				user_del($v,$q_ext);
              //echo "$v<BR>";
			}
			break;
		case 'ext':
			foreach($aa as $v){
				funcdate_ext($v);
		    }
			break;
		case 'changeCode':

				$intNum = $db->GetOne("SELECT COUNT(*) AS num FROM `agency` WHERE  agentcode = '{$changeAgentCode}'");
				if ($intNum == 0) {echo "<script type='text/javascript'>alert('门店编号有误，请重新输入！');</script>"; return false;}
				foreach ($aa as $v)
				{
					$strSql = "UPDATE broker SET agentcode = '$changeAgentCode' WHERE uid = {$v}";
					//$db->Execute($strSql);
				}
			
			break;
		default:
			return "";
	}
}

//删除
function user_del($uid) {
  GLOBAL $web_auth,$db;

//数据删除
	$q="delete from broker where uid=".intval($uid);
	//$db->Execute($q);
}

//账号延期
function funcdate_ext($uid){
	 GLOBAL $web_auth,$db;
	$q= "update broker set expiredate='".$_REQUEST[funcdate]."',valid_flag='1' where uid=$uid";
	//$db->Execute($q);
}

//设置管理员审核经纪人数据操作数量记录
function setCheckBrokerOpernum($act,$numarr = array())
{
	global $db,$dbback,$web_auth;
	
	if($_SESSION[$web_auth]["username"] == ""){
		return false;
	}
	
	$field = "";
	switch($act){
		case 'real': 
			$field = "real_num";
			break;
		case 'head':
			$field = "head_num";
			break;
		case 'certificate':	
			$field = "cert_num";
			break;
		case 'account':	
			$field = "account_num";
			break;
		default:
			return '';
			break;
	}
	
	$nowdate = date("Y-m-d");
	$operarr = $dbback->GetRow("SELECT id,head_num,cert_num,real_num,account_num FROM admin_broker_check_opernum_log WHERE dateline = '".$nowdate."' AND admin = '".$_SESSION[$web_auth]["username"]."'");

	$operarr['id'] = intval($operarr['id']);

	$data['dateline']	= $nowdate;
	$data['admin']		= $_SESSION[$web_auth]["username"];
	$data['head_num']	= intval($operarr['head_num'])	+ intval($numarr['head']);
	$data['cert_num']	= intval($operarr['cert_num'])		+ intval($numarr['certificate']);
	$data['real_num']	= intval($operarr['real_num'])		+ intval($numarr['real']);
	$data['account_num']	= intval($operarr['account_num'])	+ intval($numarr['account']);
 
	
	$sql = "";
	$tbl = "admin_broker_check_opernum_log";
	if($operarr['id'] > 0)
	{
		$sql = update_sql($tbl, $data, " WHERE id = '".$operarr['id']."'");
	}
	else
	{
		$sql = insert_sql($tbl, $data);
	}

	$db->Execute($sql);
}

?>