<?php
//获取对应分类下的正在审核的ID
function getCheckRowidByType($type)
{
	global $mc,$web_auth,$conf_cityflag;
	
	$memkey = $conf_cityflag."_".$type;
	$return = array();

	$cache = $mc->get($memkey);
	if($cache['isok'] == 1 && !empty($cache['data']))
	{
		foreach($cache['data'] as $key=>$val)
		{
			if($key != $_SESSION[$web_auth]["username"])
			{
				if(is_array($val) && !empty($val))
				{
					foreach($val as $v)
					{
						$return[$v] = $v;
					}
				}
			}
		}
	}
	
	return $return;
}

//设置正在审核记录
function resetCheckLog($type, $idarr = array())
{
	global $mc,$web_auth,$conf_cityflag;

	$memkey = $conf_cityflag."_".$type;
	$data = array($_SESSION[$web_auth]["username"] => $idarr);

	$cache = $mc->get($memkey);
	if($cache['isok'] == 1 && !empty($cache['data']))
	{
		$data = array_merge($cache['data'], array($_SESSION[$web_auth]["username"] => $idarr));
	}
	$mc->delete($memkey);
	$mc->add($memkey, array('isok'=>1, 'data'=>$data), false, 300);
}

//获取房源信息
function getHouseInfoByTblId($tbl, $id)
{
	global $dbback,$mc;
	
	$id = intval($id);
	$memkey = "check_pic_getHouseInfoByTblId_".$tbl.$id;
	$return = array();

	$cache = $mc->get($memkey);
	
	if($cache['isok'] == 1)
	{
		$return = $cache['data'];
	}
	else
	{
		$select = $tbl == 'sell' ? ",nofee" : "";
		$return = $dbback->GetRow("SELECT blockshowname,blockid,room, hall, toilet $select FROM ".$tbl." WHERE id = '".$id."' ");
		$mc->add($memkey, array('isok'=>1, 'data'=>$return), false, 120);
	}

	return $return;
}

//设置管理员审核房源数据操作数量记录
function setCheckOpernum($act = "remark", $numarr = array())
{
	global $db,$dbback,$web_auth;
	
	if($_SESSION[$web_auth]["username"] == "")
	{
		return false;
	}
	
	$field = "";
	switch($act)
	{
		case 'surface': $field = "surface_num";
						break;
		case 'sort0':	$field = "sort0_num";
						break;
		case 'sort1':	$field = "sort1_num";
						break;
		case 'sort2':	$field = "sort2_num";
						break;
		default:		$field = "remark_num";
						break;
	}
	
	$nowdate = date("Y-m-d");
	$operarr = $dbback->GetRow("SELECT id,surface_num,sort0_num,sort1_num,sort2_num,remark_num FROM admin_house_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['surface_num']	= intval($operarr['surface_num'])	+ intval($numarr['surface']);
	$data['sort0_num']		= intval($operarr['sort0_num'])		+ intval($numarr['sort0']);
	$data['sort1_num']		= intval($operarr['sort1_num'])		+ intval($numarr['sort1']);
	$data['sort2_num']		= intval($operarr['sort2_num'])		+ intval($numarr['sort2']);
	$data['remark_num']		= intval($operarr['remark_num'])	+ intval($numarr['remark']);
	
	$sql = "";
	$tbl = "admin_house_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);
}
?>