<?php
//die('先别审了，数据库吃不消了~');
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
checkAuth('10');	//判断登录和权限

//一秒内只能一个人来审核，过滤重复，下面还会做重复过滤，实在想不到其他办法了，先这么试试，FISHER 2013-9-3
//pass=1下一次必过，防止1秒内反复跳转
$memkey = $conf_cityflag."_pic_check_".$act."_page";
$cache = $mc->get($memkey);
if($cache['isok'] == 1 && $pass != 1)
{
	echo "<script>window.location.href='./pic_manage.php?act=".$act."&fitment=".$fitment."&pass=1'</script>";
	exit;
}
else
{
	$mc->add($memkey, array('isok'=>1), false, 1);
}
//一秒内只能一个人来审核，过滤重复，下面还会做重复过滤，实在想不到其他办法了，先这么试试，FISHER 2013-9-3


$js = "<script type='text/javascript' src='http://esfadmin.house365.com/script/js/showpic.js'></script>";

$allow_act = array("sort0", "sort1", "sort2");

//查询条件
$wherecond = "";

$act = in_array($act, $allow_act) ? $act : "sort0";

$fitment = intval($fitment);
$fitmentsql = $fitment > 0 ? " AND fitment = $fitment " : "";

//由于封面图需要一个小时才能查看到
$dateline = strtotime(date("Y-m-d H:00:00"));

switch($act)
{
	case "surface":		$wherecond = " AND surface = 1 $fitmentsql ";
						$type = "封面图";
						break;
	case "sort0":		$wherecond = " AND sort = 0 $fitmentsql ";
						$type = "户型图";
						break;
	case "sort1":		$wherecond = " AND sort = 1 $fitmentsql ";
						$type = "外景图";
						break;
	case "sort2":		$wherecond = " AND sort = 2 $fitmentsql ";
						$type = "室内图";
						break;
}

$title = "经纪人房源".$type."审核";

$infotypearr = array(1=>"住宅",2=>"别墅",3=>"商铺",4=>"写字楼",5=>"厂房");
$fitmentarr = array(0=>"全部",1=>"精装",2=>"简装",3=>"毛坯");
$fitmentcond = tonyForm("select","fitment",$fitmentarr,$fitment);

//分页参数
$pagesize = 10;

//过滤正在审核的
$idarr = getCheckRowidByType("pic_check_".$act);
if(is_array($idarr) && !empty($idarr))
{
	$notidsql = "";
	foreach($idarr as $val)
	{
		$id = intval($val);
		$notidsql .= $notidsql != "" ? " AND id != ".$id." " : " id != ".$id." ";
	}

	$wherecond .= " AND (".$notidsql.") ";
}

//获得数据当前页面数据
$sql = "SELECT * FROM admin_pic_check WHERE dateline < $dateline ".$wherecond." ORDER BY surface DESC, id ASC LIMIT ".$pagesize." ";
$data_info = $dbback->GetAll($sql);

//设置正在审核记录
if($data_info)
{
	$idarr = array();
	foreach($data_info as $data)
	{
		$idarr[] = $data['id'];
	}
	resetCheckLog("pic_check_".$act, $idarr);
}

//获得数据总条数
$sql = "SELECT COUNT(*) FROM admin_pic_check WHERE dateline < $dateline ".$wherecond;
$numrows = $dbback->GetOne($sql);

//获取房源信息
if($data_info)
{
	foreach($data_info as $data)
	{
		$houseinfo[$data['houseid']] = getHouseInfoByTblId($data['housetbl'], $data['houseid']);
	}
}

$housearr = array();
if($act == "sort2")
{
	if($data_info)
	{
		foreach($data_info as $data)
		{
			$arr = array();
			$arr['infotype'] = $infotypearr[$data['infotype']];
			$housearr[$data['id']]['infotype'] = "&nbsp;&nbsp;".$arr['infotype'];
		}
	}
}
else if($act == "sort1")
{
	if($data_info)
	{
		foreach($data_info as $data)
		{
			$arr = array();
			$arr['blockname'] = $dbback->GetOne("SELECT blockshowname FROM ".$data['housetbl']." WHERE id = '".$data['houseid']."' ");
			$housearr[$data['id']]['blockname'] = "<br />".$arr['blockname'];

			$arr['infotype'] = $infotypearr[$data['infotype']];
			$housearr[$data['id']]['infotype'] = "&nbsp;&nbsp;".$arr['infotype'];
		}
	}
}
else if($act == "sort0")
{
	if($data_info)
	{
		foreach($data_info as $data)
		{
			$housearr[$data['id']]['partment'] = $houseinfo[$data['houseid']]['room']."室".$houseinfo[$data['houseid']]['hall']."厅".$houseinfo[$data['houseid']]['toilet']."卫";
		}
	}
}


//引用模版文件
include_once(Template("header"));
include_once(Template("broker_house/pic_manage"));
include_once(Template("footer"));
?>