<?php

	/*******************************************************************\
	|																	|
	|	房开源（综合房产ERP管理系统）									|
	|																	|
	|	© 2019-2023 http://www.kaidandashi.com/ All rights reserved.	|
	|																	|
	|	本系统由淮南市银泰软件科技有限公司提供技术支持					|
	|																	|
	|	QQ号：984784483													|
	|																	|
	\*******************************************************************/

	namespace Admin\Controller;
	use Think\Controller;
	class FyshangpuController extends CommonController {

		//商铺
		public function shangpu(){
			if (I('is_ajax')) {
				$sousuo = I('sousuo');
				$mmzl = I('mmzl');
				$yetai = I('yetai');
				$hangye = I('hangye');
				$leixing = I('leixing');
				$zhuangtai = I('zhuangtai');
				$zhuangxiu = I('zhuangxiu');
				$myfy = I('myfy');
				$mysc = I('mysc');
				$dshenhe = I('dshenhe');
				$bohui = I('bohui');
				$isdel = I('isdel');
				$jrll = I('jrll');
				$tupian = I('tupian');
				$shipin = I('shipin');
				$xinshang = I('xinshang');
				$heyan = I('heyan');
				$jishou = I('jishou');
				$waiwangtb = I('waiwangtb');
				$yaoshi = I('yaoshi');
				$wuxiao = I('wuxiao');
				$jiage1 = I('jiage1');
				$jiage2 = I('jiage2');
				$mianji1 = I('mianji1');
				$mianji2 = I('mianji2');
				$shijian1 = I('shijian1');
				$shijian2 = I('shijian2');
				$louceng1 = I('louceng1');
				$louceng2 = I('louceng2');
				/*权限控制开始*/
				$condition = "e.gongsiid=".session('gongsiid');
				$x = _rbac_lists_where(41,0);
				if ($x && $x != "all" && $x != "me") {
					$condition .= " and e.bumen in ({$x})";
				} elseif ($x == "me") {
					$condition .= " and e.id=".session('uid');
				} elseif ($x == false) {
					$condition .= " and e.id=0";
				}
				/*权限控制结束*/
				$is_rbacfck = _rbac_node_show(863);
				if (!$is_rbacfck) {
					$condition .= " and a.fpck=2";
				}
				if ($isdel) {
					$condition .= " and a.isdel=1";
				} else {
					$condition .= " and a.isdel=2";
				}
				if ($mmzl) {
					$condition .= " and a.mmzl=".$mmzl;
				}
				$fywxzt = get_options('chengjiao_options','fyfengpan_zhuangtai');
				if ($wuxiao) {
					$condition .= " and a.zhuangtai in (".$fywxzt.")";
				} else {
					$condition .= " and a.zhuangtai not in (".$fywxzt.")";
				}
				if ($zhuangtai) {
					$condition .= " and a.zhuangtai=".$zhuangtai;
				}
				if ($dshenhe) {
					$condition .= " and a.shtype=3";
				}
				if ($bohui) {
					$condition .= " and a.shtype=2";
				}
				if (!$dshenhe && !$bohui) {
					$condition .= " and a.shtype=1";
				}
				if ($myfy) {
					$condition .= " and a.weihurenid=".session('uid');
				}
				if ($mysc) {
					$sc = M('shoucang')->where(array('user_id'=>session('uid')))->select();
					if ($sc) {
						foreach ($sc as $key => $value) {
							$cs_arr[] = $value['fyid'];
						}
						$in_sc = implode(',', $cs_arr);
					} else {
						$in_sc = 0;
					}
					$condition .= " and a.id in ($in_sc)";
				}
				if ($jrll) {
					$today = "fysp".date("m-d");
					if (!cookie($today)) {
						$history = 0;
					} else {
						$history = cookie($today);
					}
					$condition .= " and a.id in (".$history.")";
				}
				if ($yetai) {
					$condition .= " and a.yetai=".$yetai;
				}
				if ($hangye) {
					$condition .= " and a.hangye=".$hangye;
				}
				if ($leixing) {
					$condition .= " and a.leixing=".$leixing;
				}
				if ($zhuangxiu) {
					$condition .= " and a.zhuangxiu=".$zhuangxiu;
				}
				if ($tupian) {
					$condition .= " and a.tupian=1";
				}
				if ($shipin) {
					$condition .= " and a.shipin_url <> ''";
				}
				if ($xinshang) {
					$xshang = time()-(86400*3);
					$condition .= " and a.lurusj>".$xshang;
				}
				if ($heyan) {
					$condition .= " and a.heyan=1";
				}
				if ($jishou) {
					$condition .= " and a.jishou=1";
				}
				if ($waiwangtb) {
					$condition .= " and s.waiwangtb=1";
				}
				if ($yaoshi) {
					$condition .= " and (s.shouyaobm<>'' or a.shouyaoren<>'')";
				}
				if ($mmzl == 1) {
					if ($jiage1 && $jiage2) {
						$condition .= " and a.shoujia>=".$jiage1." and a.shoujia<=".$jiage2;
					} elseif ($jiage1) {
						$condition .= " and a.shoujia>=".$jiage1;
					} elseif ($jiage2) {
						$condition .= " and a.shoujia<=".$jiage2;
					}
				} elseif ($mmzl == 2) {
					if ($jiage1 && $jiage2) {
						$condition .= " and a.zujia>=".$jiage1." and a.zujia<=".$jiage2;
					} elseif ($jiage1) {
						$condition .= " and a.zujia>=".$jiage1;
					} elseif ($jiage2) {
						$condition .= " and a.zujia<=".$jiage2;
					}
				}
				if ($mianji1 && $mianji2) {
					$condition .= " and a.jzmianji>=".$mianji1." and a.jzmianji<=".$mianji2;
				} elseif ($mianji1) {
					$condition .= " and a.jzmianji>=".$mianji1;
				} elseif ($mianji2) {
					$condition .= " and a.jzmianji<=".$mianji2;
				}
				if ($shijian1) {
					$shijian3 = strtotime($shijian1);
				}
				if ($shijian2) {
					$shijian4 = strtotime($shijian2)+86400;
				}
				if ($shijian3 and $shijian4) {
					if ($shijian3 > $shijian4) {
						$shijian3 = strtotime($shijian2);
						$shijian4 = strtotime($shijian1)+86400;
					}
					$condition .= " and a.lurusj>=".$shijian3." and a.lurusj<".$shijian4;
				} elseif ($shijian3) {
					$condition .= " and a.lurusj>=".$shijian3;
				} elseif ($shijian4) {
					$condition .= " and a.lurusj<".$shijian4;
				}
				if ($louceng1 && $louceng2) {
					$condition .= " and a.louceng>=".$louceng1." and a.louceng<=".$louceng2;
				} elseif ($louceng1) {
					$condition .= " and a.louceng>=".$louceng1;
				} elseif ($louceng2) {
					$condition .= " and a.louceng<=".$louceng2;
				}
				if ($sousuo) {
					$condition .= " and (a.fybiaoti like '%$sousuo%' or a.yezhu like '%$sousuo%' or a.weihuren like '%$sousuo%' or a.yezhudianhua like '%$sousuo%' or a.yezhudianhua2 like '%$sousuo%' or a.yezhudianhua3 like '%$sousuo%' or a.bianhao like '%$sousuo%' or a.xiaoqum like '%$sousuo%')";
				}
				$field = I('field'); //排序字段名
				$order = I('order'); //排序方式
				$limit = I('limit',30,'int'); //每页条数
				$limit = $limit > 150 ? 150 : $limit;
				if ($field && $order) {
					$fypx .= "order by a.".$field." ".$order;
				} else {
					$fypx .= "order by a.id DESC";
				}
				$Model = new \Think\Model();
				$count = $Model->query("select count(*) from __FYSHANGPU__ a join __YONGHU__ e on a.weihurenid=e.id where {$condition}");
				$Page = new \Think\Page($count['0']['count(*)'],$limit);
				$list = "select a.*,e.ygmingcheng from __FYSHANGPU__ a join __YONGHU__ e on a.weihurenid=e.id where {$condition} ".$fypx." limit ".$Page->firstRow.','.$Page->listRows;
				$data = $Model->query($list);
				foreach ($data as $key => $value) {
					$isshikan[$key] = M('shikan')->where(array('fybh'=>$es['bianhao'],'fylx'=>14))->find();
					$dqshu[$key] = M('xianzhi')->where(array('fyid'=>$value['id'],'fylx'=>14))->count();
					if ($isshikan[$key]) {
						$data[$key]['isshikan'] = 1;
					}
					if ($value['shoujia'] > 0) {
						$fyjg = floatval($value['shoujia'])."万";
					} else if ($value['zujia']) {
						$fyjg = floatval($value['zujia']).get_peizhi('zujialx',$value['zujialx'],3);
					}
					$data[$key]['dqshu'] = $dqshu[$key];
					$data[$key]['img'] = get_s_img($value['bianhao']);
					$data[$key]['xqm'] = zym($value['xiaoqu'],3);
					$data[$key]['jzmianji'] = floatval($value['jzmianji'])."m²";
					$data[$key]['fyjg'] = $fyjg;
					$data[$key]['danjia'] = $value['danjia'] ? floatval($value['danjia'])."元/m²" : "——";
					$data[$key]['fylc'] = $value['louceng']."/".$value['zlouceng'];
					$data[$key]['splx'] = get_peizhi('spleixing',$value['leixing'],3);
					$data[$key]['spyt'] = get_peizhi('spyetai',$value['yetai'],3);
					$data[$key]['sphy'] = get_peizhi('sphangye',$value['hangye'],3);
					$data[$key]['syl'] = get_peizhi('sptese',$value['shiyonglv'],3);
					$data[$key]['fyzt'] = get_peizhi('zhuangtai',$value['zhuangtai'],3);
					$data[$key]['fyzx'] = get_peizhi('zhuangxiu',$value['zhuangxiu'],3);
					$data[$key]['fydj'] = $value['fydengji'] ? get_peizhi('fydengji',$value['fydengji'],3) : "——";
					$data[$key]['lurusj'] = $value['lurusj'] ? date('Y-m-d H:i:s',$value['lurusj']) : "——";
					$is_rbacxq = _rbac_btn_show(46,$value['zhuangtai'],$value['weihurenid']);
					if ($value['isdel'] == 1) {
						$is_rbachy = _rbac_btn_show(766,$value['zhuangtai'],$value['weihurenid']);
						$is_rbacsc = _rbac_btn_show(767,$value['zhuangtai'],$value['weihurenid']);
						$data[$key]['rbachy'] = $is_rbachy ? 1 : 0;
						$data[$key]['rbacsc'] = $is_rbacsc ? 1 : 0;
					} else if ($value['isdel'] == 2) {
						$is_rbacdy = _rbac_btn_show(214,$value['zhuangtai'],$value['weihurenid']);
						$data[$key]['rbacdy'] = $is_rbacdy ? 1 : 0;
					}
					if ($value['shtype'] == 3) {
						$is_rbacsh = _rbac_btn_show(766,$value['zhuangtai'],$value['weihurenid']);
						$data[$key]['rbacsh'] = $is_rbacsh ? 1 : 0;
					}
					$data[$key]['rbacxq'] = $is_rbacxq ? 1 : 0;
					$photo[$key] = M('photo')->where(array('fybh'=>$value['bianhao'],'image'=>array('neq',$data[$key]['img'])))->field('image')->select();
					$data[$key]['photo'] = $photo[$key];
				}
				$return_data = array(
					'code'=>0,
					'count'=>$count['0']['count(*)'],
					'data'=>$data
				);
				$this->ajaxReturn($return_data);
			} else {
				$this->zhuangtai = get_peizhi('zhuangtai',0,1);
				$this->zhuangxiu = get_peizhi('zhuangxiu',0,1);
				$this->leixing = get_peizhi('spleixing',0,1);
				$this->hangye = get_peizhi('sphangye',0,1);
				$this->yetai = get_peizhi('spyetai',0,1);
				$this->display();// 输出模板
			}
		}

		//添加房源
		public function addesfy(){
			$is_rbac = _rbac_node_show(42);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$khxqid = I('khxqid');
				if ($khxqid) {
					$xiaoqu = I('xiaoqu');
				} else {
					$fjid = I('fjid');
					if ($fjid) {
						if (I('ishb') == 1) {
							$fjxxb = M('fjhbxx');
						} else {
							$fjxxb = M('fjxinxi');
						}
						$fangjian = $fjxxb->where(array('id'=>$fjid))->find();
						$xiaoqum = zym($fangjian['xqid'],3);
					} else {
						$this->error('异常错误!');
					}
					if ($fangjian['xqid']) {
						$xiaoqu = $fangjian['xqid'];
					} else {
						$this->error('请选择楼盘');
					}
				}
				$xingzhengqu = M('xiaoqu')->where(array('id'=>$xiaoqu))->getField('ssxzq');
				$pianqu = M('xiaoqu')->where(array('id'=>$xiaoqu))->getField('sspianqu');
				$dizhi = M('xiaoqu')->where(array('id'=>$xiaoqu))->getField('xiaoqudz');
				$zuodong = I('zuodong');
				$danyuan = I('danyuan');
				$louceng = I('louceng');
				$zlouceng = I('zlouceng');
				$fanghao = I('fanghao');
				$mmzl = I('mmzl');
				$condition['gongsiid'] = session('gongsiid');
				$condition['zhuangtai'] = array('neq',get_options('chengjiao_options','fychengjiao_zhuangtai'));
				$condition['isdel'] = 2;
				$condition['xiaoqu'] = $xiaoqu;
				$condition['zuodong'] = $zuodong;
				$condition['danyuan'] = $danyuan;
				$condition['fanghao'] = $fanghao;
				$condition['mmzl'] = $mmzl;
				$cffy = M('fyshangpu')->where($condition)->find();
				if ($cffy) {
					$this->error('房源已存在');
				}
				if ($fangjian['jzmianji']) {
					$jzmianji = $fangjian['jzmianji'];
				} elseif (I('jzmianji')) {
					$jzmianji = I('jzmianji');
				} else {
					$this->error('请输入建筑面积');
				}
				if ($fangjian['yezhu']) {
					$yezhu = $fangjian['yezhuxm'];
				} elseif (I('yezhu')) {
					$yezhu = I('yezhu');
				} else {
					$this->error('请输入业主姓名');
				}
				if ($fangjian['yezhuxb']) {
					$yezhulx = $fangjian['yezhuxb'];
				} elseif (I('yezhulx')) {
					$yezhulx = I('yezhulx');
				} else {
					$this->error('请选择业主类型');
				}
				if ($fangjian['yezhudianhua']) {
					$yezhudianhua = $fangjian['yezhusj'];
				} elseif (I('yezhudianhua')) {
					$yezhudianhua = I('yezhudianhua');
				} else {
					$this->error('请输入业主电话');
				}
				if ($dizhi) {
					$dizhi = $dizhi;
				} elseif (I('dizhi')) {
					$dizhi = I('dizhi');
				}
				$cenggao = I('cenggao');
				$jinshen = I('jinshen');
				$wuyefei = I('wuyefei');
				$miankuan = I('miankuan');
				$cqnianxian=I('cqnianxian');
				if ($louceng > $zlouceng) {
					$this->error('所在楼层大于总楼层！');
				}
				if (!preg_match("/^([1-9]{1})$|^([1-9][0-9]{1})$|^(1[0-9]{2})$|^(2[0]{2})$/",$louceng)) {
					$this->error('所在楼层请输入＞0且≤200的整数！');
				}
				if (!preg_match("/^([1-9]{1})$|^([1-9][0-9]{1})$|^(1[0-9]{2})$|^(2[0]{2})$/",$zlouceng)) {
					$this->error('总楼层请输入＞0且≤200的整数！');
				}
				if (!preg_match("/^([1-9][0-9]{0,4})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{5})(\.[0][0]{0,1})?$/",$jzmianji)) {
					$this->error('建筑面积请输入＞0且≤十万的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,1})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{2})(\.[0][0]{0,1})?$/",$miankuan)) {
					$this->error('面宽请输入＞0且≤100的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,1})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{2})(\.[0][0]{0,1})?$/",$jinshen)) {
					$this->error('进深请输入＞0且≤100的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9]{1})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{1})(\.[0][0]{0,1})?$/",$cenggao)) {
					$this->error('层高请输入＞0且≤10的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,3})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{4})(\.[0][0]{0,1})?$/",$wuyefei)) {
					$this->error('物业费请输入＞0且≤一万的数字（限两位小数）！');
				}
				if (!preg_match("/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[8-9])\d{8}$|^0\d{2,3}-?\d{7,8}$/",$yezhudianhua)) {
					$this->error('业主电话请输入正确的手机号码或电话号码！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,2})$|^(1[0]{3})$/",$cqnianxian)) {
					$this->error('产权年限请输入＞0≤1000的整数！');
				}
				if ($mmzl == 1) {
					$chushoudj = I('chushoudj');
					$shoujia = I('shoujia');
					if (!preg_match("/^([1-9][0-9]{0,4})(\.[0-9]{1,6})?$|^([0]\.[1-9][0-9]{0,5})$|^([0]\.[0][0-9]{0,4}[1-9]{1})$|^([0]\.[0]{2}[0-9]{0,3}[1-9]{1})$|^([0]\.[0]{3}[0-9]{0,2}[1-9]{1})$|^([0]\.[0]{4}[0-9]{0,1}[1-9]{1})$|^([0]\.[0]{5}[1-9]{1})$|^(1[0]{5})(\.[0][0]{0,5})?$/",$chushoudj)) {
						$this->error('出售底价请输入＞0且≤十亿的数字（限六位小数）！');
					}
					if (!preg_match("/^([1-9][0-9]{0,4})(\.[0-9]{1,6})?$|^([0]\.[1-9][0-9]{0,5})$|^([0]\.[0][0-9]{0,4}[1-9]{1})$|^([0]\.[0]{2}[0-9]{0,3}[1-9]{1})$|^([0]\.[0]{3}[0-9]{0,2}[1-9]{1})$|^([0]\.[0]{4}[0-9]{0,1}[1-9]{1})$|^([0]\.[0]{5}[1-9]{1})$|^(1[0]{5})(\.[0][0]{0,5})?$/",$shoujia)) {
						$this->error('售价请输入＞0且≤十亿的数字（限六位小数）！');
					}
				} elseif ($mmzl == 2) {
					$chuzudj = I('chuzudj');
					$zujia = I('zujia');
					if (!preg_match("/^([1-9][0-9]{0,5})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{6})(\.[0][0]{0,1})?$/",$chuzudj)) {
						$this->error('出租底价请输入＞0且≤一百万的数字（限两位小数）！');
					}
					if (!preg_match("/^([1-9][0-9]{0,5})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{6})(\.[0][0]{0,1})?$/",$zujia)) {
						$this->error('租价请输入＞0且≤一百万的数字（限两位小数）！');
					}
				}
				$jianjie = preg_replace ( "/\s(?=\s)/","\\1", I('jianjie') );
				$beizhu = preg_replace ( "/\s(?=\s)/","\\1", I('beizhu') );
				if (!preg_match("/^$|^[\s\S]{0,300}$/",$jianjie)) {
					$this->error('简介只能输入300个字符！');
				}
				if (!preg_match("/^$|^[\s\S]{0,300}$/",$beizhu)) {
					$this->error('备注只能输入300个字符！');
				}
				$bh = M('bianhao')->where(array('id'=>1))->setInc('bianhao');
				$bh1 = M('bianhao')->where(array('id'=>1))->getField('bianhao');
				if ($mmzl == 1) {
					$data['bianhao'] = "MS-".$bh1;
					$data['shoujia'] = $shoujia;
					$data['chushoudj'] = $chushoudj;
					if ($jzmianji and $shoujia) {
						$num1 = $shoujia*10000;
						$num2 = $jzmianji;
						$num = $num1/$num2;
						$danjia = number_format($num,2,".", "");
						$data['danjia'] = $danjia;
					}
					$zyzs = "商铺（出售）";
				} elseif ($mmzl == 2) {
					$data['bianhao'] = "ZS-".$bh1;
					$data['zujia'] = $zujia;
					$data['chuzudj'] = $chuzudj;
					$data['zujialx'] = I('zujialx');
					$zyzs = "商铺（出租）";
				}
				$zhan_bumen = M('xingzhengqu')->where(array('id'=>$xingzhengqu))->getField('bumen');
				$pt1 = array_keys(I('peitao'));
				$pt2 = implode(',',$pt1);
				$ts1 = array_keys(I('tese'));
				$ts2 = implode(',',$ts1);
				$is_rbactb = _rbac_node_show(1052);
				if ($is_rbactb) {
					if (I('waiwangtb')) {
						$waiwangtb = 1;
					} else {
						$waiwangtb = 0;
					}
				} else {
					$waiwangtb = 0;
				}
				if (I('fenge')) {
					$fenge = 1;
				} else {
					$fenge = 2;
				}
				if (I('zuyue')) {
					$zuyue = 1;
				} else {
					$zuyue = 2;
				}
				if (I('jishou')) {
					$jishou = 1;
				} else {
					$jishou = 0;
				}
				if (I('heyan')) {
					$heyan = 1;
				} else {
					$heyan = 0;
				}
				$data['gongsiid'] = session('gongsiid');
				$data['zhan_bumen'] = $zhan_bumen;
				$data['leixing'] = I('leixing');
				$data['yetai'] = I('yetai');
				$data['hangye'] = I('hangye');
				if ($khxqid) {
					$zhuangtai = get_options('chengjiao_options','fygongpan_zhuangtai');
				} else {
					$zhuangtai = get_options('chengjiao_options','fysipan_zhuangtai');
				}
				$data['zhuangtai'] = $zhuangtai;
				$data['xingzhengqu'] = $xingzhengqu;
				$data['pianqu'] = $pianqu;
				$data['xiaoqu'] = $xiaoqu;
				$data['xiaoqum'] = $xiaoqum;
				$data['zuodong'] = $zuodong;
				$data['danyuan'] = $danyuan;
				$data['louceng'] = $louceng;
				$data['zlouceng'] = $zlouceng;
				$data['fanghao'] = $fanghao;
				$data['dizhi'] = $dizhi;
				$data['fybiaoti'] = I('fybiaoti');
				$data['jzmianji'] = $jzmianji;
				$data['miankuan'] = $miankuan;
				$data['jinshen'] = $jinshen;
				$data['cenggao'] = $cenggao;
				$data['wuyefei'] = $wuyefei;
				$data['wyflx'] = I('wyflx');
				$data['fydengji'] = I('fydengji');
				$data['zhuangxiu'] = I('zhuangxiu');
				$data['shiyonglv'] = I('shiyonglv');
				$data['peitao'] = $pt2;
				$data['tese'] = $ts2;
				$data['shihejy'] = I('shihejy');
				$data['jianjie'] = $jianjie;
				$data['beizhu'] = $beizhu;
				$data['cqnianxian'] = $cqnianxian;
				$data['laiyuan'] = I('laiyuan');
				$data['kanfangfs'] = I('kanfangfs');
				$data['fukuanfs'] = I('fukuanfs');
				$data['yezhu'] = $yezhu;
				$data['yezhulx'] = $yezhulx;
				$data['yezhugx'] = I('yezhugx');
				$data['yezhudianhua'] = $yezhudianhua;
				$data['waiwangtb'] = $waiwangtb;
				$data['fenge'] = $fenge;
				$data['zuyue'] = $zuyue;
				$data['jishou'] = $jishou;
				$data['heyan'] = $heyan;
				$data['chanquanzheng'] = I('chanquanzheng');
				$data['tudizheng'] = I('tudizheng');
				$data['budongchanzheng'] = I('budongchanzheng');
				$data['czriqi'] = strtotime(I('czriqi'));
				$data['weihuren'] = session('ygmingcheng');
				$data['weihurenid'] = session('uid');
				$data['bumen'] = yhbm(session("uid"),1);
				$data['lurusj'] = time();
				$data['lururenid'] = session('uid');
				$data['xiugaisj'] = time();
				$data['zhgjsj'] = time();
				$data['whrzhgenjin'] = time();
				$data['qyzhgenjin'] = time();
				$data['mmzl'] = $mmzl;
				$isok = M('fyshangpu')->add($data);
				if ($isok) {
					if ($khxqid) {
						$xiugai = "客户需求转入商机中心（商铺）。";
						$data_khxq['zybh'] = $data['bianhao'];
						$data_khxq['zylj'] = U('fyshangpu/neirong',array('id'=>$isok));
						$data_khxq['zrsjzx'] = "已被".zym(session('uid'),5)."转入商机中心（商铺）。";
						$data_khxq['wangzhipc'] = U('Home/shangpu/content',array('fybh'=>$data['bianhao']));
						$data_khxq['wangzhiyd'] = U('Wap/fyshangpu/content',array('fybh'=>$data['bianhao']));
						M('fabufy')->where(array("id"=>$khxqid))->save($data_khxq);
						data_rizhi(5,1,$isok,$data['bianhao'],$xiugai,U('fyshangpu/neirong',array('id'=>$isok)),"外网客户");
					} else {
						$xiugai = "添加了一条房源数据。";
						data_fkywhr(14,$isok,session('uid'));
					}
					data_rizhi(14,1,$isok,$data['bianhao'],$xiugai,U('fyshangpu/neirong',array('id'=>$isok)),$zyzs);
					$this->success('已添加，请等待审核！');
				} else {
					$this->error('添加失败！');
				}
			} else {
				if (I('mmzl') == 1) {
					$fuk = "fukuan";
				} elseif (I('mmzl') == 2) {
					$fuk = "zlfukuan";
					$this->zujialx = get_peizhi('zujialx',0,1);
				}
				$this->leixing = get_peizhi('spleixing',0,1);
				$this->yetai = get_peizhi('spyetai',0,1);
				$this->hangye = get_peizhi('sphangye',0,1);
				$this->wyflx = get_peizhi('wyfdwlx',0,1);
				$this->fydengji = get_peizhi('fydengji',0,1);
				$this->zhuangxiu = get_peizhi('zhuangxiu',0,1);
				$this->shiyonglv = get_peizhi('spshiyonglv',0,1);
				$this->peitao = get_peizhi('sppeitao',0,1);
				$this->tese = get_peizhi('sptese',0,1);
				$this->laiyuan = get_peizhi('laiyuan',0,1);
				$this->kanfangfs = get_peizhi('kanfangfs',0,1);
				$this->fukuanfs = get_peizhi($fuk,0,1);
				$this->yezhulx = get_peizhi('yezhulx',0,1);
				$this->yezhugx = get_peizhi('yezhugx',0,1);
				$this->iszheng = get_peizhi('iszheng',0,1);
				if (I('fjid')) {
					if (I('ishb') == 1) {
						$fjxxb = M('fjhbxx');
					} else {
						$fjxxb = M('fjxinxi');
					}
					$fangjian = $fjxxb->where(array('id'=>I('fjid')))->find();
					$this->fangjian = $fangjian;
					$this->xiaoqum = zym($fangjian['xqid'],3);
					$this->zdmwdw = M('zdxinxi')->where(array('id'=>$fangjian['zdid']))->getField('zdmwdw');
					$this->dymwdw = M('dyxinxi')->where(array('id'=>$fangjian['dyid']))->getField('dymwdw');
					$this->lcmwdw = M('lcxinxi')->where(array('id'=>$fangjian['lcid']))->getField('lcmwdw');
					$this->lcshu = M('lcxinxi')->where(array('dyid'=>$fangjian['dyid']))->count();
					$this->dizhi = M('xiaoqu')->where(array('id'=>$xiaoqu))->getField('xiaoqudz');
				}
				$this->display();
			}
		}

		//房源内容页
		public function neirong(){
			$id = I('id');
			$fybh = I('bianhao');
			if ($id) {
				$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			} elseif ($fybh) {
				$fangyuan = M('fyshangpu')->where(array('bianhao'=>$fybh))->find();
			}
			if (!$fangyuan) {
				$this->error('未找到房源！');
			}
			$is_rbacfck = _rbac_node_show(863);
			if (!$is_rbacfck && ($fangyuan['fpck'] != 2)) {
				$this->redirect('Index/error');
			}
			$is_rbac = _rbac_btn_show(46,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			$is_rbacfdh = _rbac_node_show(859);
			if ($is_rbacfdh || ($fangyuan['fpdh'] == 2)) {
				$this->is_rbacfdh=1;
			}
			$is_rbacfdz = _rbac_node_show(860);
			if ($is_rbacfdz || ($fangyuan['fpdz'] == 2)) {
				$this->is_rbacfdz=1;
			}
			$is_rbacfdj = _rbac_node_show(861);
			if ($is_rbacfdj || ($fangyuan['fpdj'] == 2)) {
				$this->is_rbacfdj=1;
			}
			$is_rbacfdq = _rbac_node_show(862);
			if ($is_rbacfdq || ($fangyuan['fpdq'] == 2)) {
				$this->is_rbacfdq=1;
			}
			$iskzq = 1;
			$fywxzt = get_options('chengjiao_options','fyfengpan_zhuangtai');
			if (!in_array($fangyuan['zhuangtai'],$fywxzt)) {
				$fywhrs = M('fkywhr')->where(array('zylx'=>14,'id'=>$fangyuan['id']))->select();
				foreach ($fywhrs as $key => $value) {
					if ($value['whrid'] == session('uid')) {
						$iskzq = 2;
					}
				}
			}
			$this->iskzq = $iskzq;
			$this->fangyuan = $fangyuan;
			if ($fangyuan['mmzl'] == 1) {
				$fuk = "fukuan";
			} elseif ($fangyuan['mmzl'] == 2) {
				$fuk = "zlfukuan";
				$this->zujialx = get_peizhi('zujialx',$fangyuan['zujialx'],3);
			}
			$this->leixing = get_peizhi('spleixing',$fangyuan['leixing'],3);
			$this->yetai = get_peizhi('spyetai',$fangyuan['yetai'],3);
			$this->hangye = get_peizhi('sphangye',$fangyuan['hangye'],3);
			$this->wyflx = get_peizhi('wyfdwlx',$fangyuan['wyflx'],3);
			$this->fydengji = get_peizhi('fydengji',$fangyuan['fydengji'],3);
			$this->zhuangtai = get_peizhi('zhuangtai',$fangyuan['zhuangtai'],3);
			$this->zhuangxiu = get_peizhi('zhuangxiu',$fangyuan['zhuangxiu'],3);
			$this->shiyonglv = get_peizhi('spshiyonglv',$fangyuan['shiyonglv'],3);
			$this->laiyuan = get_peizhi('laiyuan',$fangyuan['laiyuan'],3);
			$this->kanfangfs = get_peizhi('kanfangfs',$fangyuan['kanfangfs'],3);
			$this->fukuanfs = get_peizhi($fuk,$fangyuan['fukuanfs'],3);
			$this->chanquanzheng = get_peizhi('iszheng',$fangyuan['chanquanzheng'],3);
			$this->budongchanzheng = get_peizhi('iszheng',$fangyuan['budongchanzheng'],3);
			$this->tudizheng = get_peizhi('iszheng',$fangyuan['tudizheng'],3);
			$options_arr = get_options('chengjiao_options',0);
			$this->options_arr = $options_arr;
			$this->isshoucang = M('shoucang')->where(array('user_id'=>session('uid'),'fyid'=>$fangyuan['id'],'fylx'=>1))->find();
			$Model = new \Think\Model();
			if ($fangyuan['peitao']) {
				$condition1 = "pzming = 'sppeitao' and lxid in (".$fangyuan['peitao'].")";
				$peitao1 = $Model->query("select * from __PEIZHI__ where {$condition1} order by xsshunxu asc");
				$peitao2 = array();
				foreach ($peitao1 as $key => $value) {
					$peitao2[$key] = $value['lxming'];
				}
				$this->peitao = implode('；',$peitao2);
			}
			if ($fangyuan['tese']) {
				$condition2 = "pzming = 'sptese' and lxid in (".$fangyuan['tese'].")";
				$tese1 = $Model->query("select * from __PEIZHI__ where {$condition2} order by xsshunxu asc");
				$tese2 = array();
				foreach ($tese1 as $key => $value) {
					$tese2[$key] = $value['lxming'];
				}
				$this->tese = implode('；',$tese2);
			}
			$uid = M('photo')->where(array('gongsiid'=>session('gongsiid'),'fybh'=>$fangyuan['bianhao']))->group('fybh')->getField('uid');
			if ($uid) {
				$this->shangturen = M('yonghu')->where(array('id'=>$uid))->field('ygmingcheng,bumen,dianhua')->find();
			}
			if ($fangyuan['shouyaobm']) {
				$this->bmdianhua = M('bumen')->where(array('id'=>$fangyuan['shouyaobm']))->getField('bmdianhua');
			}
			if ($fangyuan['shouyaoren']) {
				$this->shouyaoren = M('yonghu')->where(array('id'=>$fangyuan['shouyaoren']))->field('ygmingcheng,bumen,dianhua')->find();
			}
			if ($fangyuan['lururenid']) {
				$this->lururen = M('yonghu')->where(array('id'=>$fangyuan['lururenid']))->field('ygmingcheng,bumen,dianhua')->find();
			}
			if ($fangyuan['weihurenid']) {
				$this->weihuren = M('yonghu')->where(array('id'=>$fangyuan['weihurenid']))->field('ygmingcheng,bumen,dianhua')->find();
			}
			if ($fangyuan['fengpanrenid']) {
				$this->fengpanren = M('yonghu')->where(array('id'=>$fangyuan['fengpanrenid']))->field('ygmingcheng,bumen,dianhua')->find();
			}
			$weibanuid = M('weiban')->where(array('fybianhao'=>$fangyuan['bianhao'],'fylx'=>14))->getField('uid');
			$shikanuid = M('shikan')->where(array('fybh'=>$fangyuan['bianhao'],'fylx'=>14))->getField('uid');
			if ($weibanuid) {
				$this->weibanren = M('yonghu')->where(array('id'=>$weibanuid))->field('ygmingcheng,bumen,dianhua')->find();
			}
			if ($shikanuid) {
				$this->shikanren = M('yonghu')->where(array('id'=>$shikanuid))->field('ygmingcheng,bumen,dianhua')->find();
			}
			$this->fygenjin = M('fygenjin')->where(array('fyid'=>$fangyuan['id'],'fylx'=>14))->order('shijian desc')->select();
			$this->diaoqujl = M('xianzhi')->where(array('fyid'=>$fangyuan['id'],'fylx'=>14))->order('shijian desc')->select();
			$this->volist = M('rizhi')->where(array('zy_bianhao'=>$fangyuan['bianhao'],'zy_type'=>14))->order('addtime desc')->select();
			$this->xiaoqu = M('xiaoqu')->where(array('id'=>$fangyuan['xiaoqu']))->find();
			$qitiannei = time()-604800;
			$this->daikanshu = M('kydaikan')->where(array('kylx'=>16,'fybh'=>$fangyuan['bianhao'],'dkshijian'=>array('gt',$qitiannei)))->count();
			$today = "fysp".date("m-d");
			   if (!cookie($today)) {
				cookie($today,$fangyuan['id'],3600*24);
			} else {
				$value = cookie($today);
				$val = $value.','.$fangyuan['id'];
				cookie($today,$val,3600*24);
			}
			$this->yaoshi = M('yaoshi')->where(array('fybianhao'=>$fangyuan['bianhao'],'fylx'=>14))->order('addtime desc')->select();
			$this->weiban = M('weiban')->where(array('fybianhao'=>$fangyuan['bianhao'],'fylx'=>14))->order('addtime desc')->select();
			$this->display();
		}

		// 房源审核
		public function fyshenhe(){
			$id = I('id');
			$fy1 = M('fyshangpu')->where(array('id'=>$id))->field('weihurenid,isdel,shtype,mmzl')->find();
			$is_rbac = _rbac_btn_show(954,0,$fy1['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fy1['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if (IS_POST) {
				$shtype = I('shtype');
				if ($fy1['shtype'] == 1 || $fy1['shtype'] == 2) {
					$this->error('已审核');
				}
				if ($shtype == "") {
					$this->error('请选择审核意见');
				}
				$isok = M('fyshangpu')->where(array('id'=>$id))->setField('shtype',$shtype);
				if ($isok){
					if ($shtype == 1) {
						$xiugai = "通过了";
					}
					if ($shtype == 2) {
						$xiugai = "驳回了";
					}
					$fybh = M('fyshangpu')->where(array('id'=>$id))->getField('bianhao');
					$xiugai .= $fybh."的添加。";
					if ($fy1['mmzl'] == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($fy1['mmzl'] == 2) {
						$zyzs = "商铺（出租）";
					}
					data_rizhi(14,18,$id,$fybh,$xiugai,U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
					$this->success('审核成功！');
				} else {
					$this->error('审核失败！');
				}
			} else {
				$this->display();
			}
		}

		//更新房源
		public function editesfy(){
			$id=I('id');
			$fy1=M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(56,$fy1['zhuangtai'],$fy1['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fy1['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fy1['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			$is_rbacfdj = _rbac_node_show(861);
			if ($is_rbacfdj || ($fy1['fpdj'] == 2)) {
				$is_rbacfdj=1;
				$this->is_rbacfdj=1;
			}
			if (IS_POST) {
				$mmzl = $fy1['mmzl'];
				$cenggao = I('cenggao');
				$jinshen = I('jinshen');
				$wuyefei = I('wuyefei');
				$jzmianji = I('jzmianji');
				$miankuan = I('miankuan');
				$cqnianxian=I('cqnianxian');
				if (!preg_match("/^([1-9][0-9]{0,4})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{5})(\.[0][0]{0,1})?$/",$jzmianji)) {
					$this->error('建筑面积请输入＞0且≤十万的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,1})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{2})(\.[0][0]{0,1})?$/",$miankuan)) {
					$this->error('面宽请输入＞0且≤100的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,1})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{2})(\.[0][0]{0,1})?$/",$jinshen)) {
					$this->error('进深请输入＞0且≤100的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9]{1})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{1})(\.[0][0]{0,1})?$/",$cenggao)) {
					$this->error('层高请输入＞0且≤10的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,3})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{4})(\.[0][0]{0,1})?$/",$wuyefei)) {
					$this->error('物业费请输入＞0且≤一万的数字（限两位小数）！');
				}
				if (!preg_match("/^$|^([1-9][0-9]{0,2})$|^(1[0]{3})$/",$cqnianxian)) {
					$this->error('产权年限请输入＞0≤1000的整数！');
				}
				if ($mmzl == 1) {
					if ($is_rbacfdj == 1) {
						$chushoudj = I('chushoudj');
						if (!preg_match("/^([1-9][0-9]{0,4})(\.[0-9]{1,6})?$|^([0]\.[1-9][0-9]{0,5})$|^([0]\.[0][0-9]{0,4}[1-9]{1})$|^([0]\.[0]{2}[0-9]{0,3}[1-9]{1})$|^([0]\.[0]{3}[0-9]{0,2}[1-9]{1})$|^([0]\.[0]{4}[0-9]{0,1}[1-9]{1})$|^([0]\.[0]{5}[1-9]{1})$|^(1[0]{5})(\.[0][0]{0,5})?$/",$chushoudj)) {
							$this->error('出售底价请输入＞0且≤十亿的数字（限六位小数）！');
						}
					}
					$shoujia = I('shoujia');
					if (!preg_match("/^([1-9][0-9]{0,4})(\.[0-9]{1,6})?$|^([0]\.[1-9][0-9]{0,5})$|^([0]\.[0][0-9]{0,4}[1-9]{1})$|^([0]\.[0]{2}[0-9]{0,3}[1-9]{1})$|^([0]\.[0]{3}[0-9]{0,2}[1-9]{1})$|^([0]\.[0]{4}[0-9]{0,1}[1-9]{1})$|^([0]\.[0]{5}[1-9]{1})$|^(1[0]{5})(\.[0][0]{0,5})?$/",$shoujia)) {
						$this->error('售价请输入＞0且≤十亿的数字（限六位小数）！');
					}
				} elseif ($mmzl == 2) {
					if ($is_rbacfdj == 1) {
						$chuzudj = I('chuzudj');
						if (!preg_match("/^([1-9][0-9]{0,5})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{6})(\.[0][0]{0,1})?$/",$chuzudj)) {
							$this->error('出租底价请输入＞0且≤一百万的数字（限两位小数）！');
						}
					}
					$zujia = I('zujia');
					if (!preg_match("/^([1-9][0-9]{0,5})(\.[0-9]{1,2})?$|^([0]\.[1-9][0-9]{0,1})$|^([0]\.[0][1-9]{1})$|^(1[0]{6})(\.[0][0]{0,1})?$/",$zujia)) {
						$this->error('租价请输入＞0且≤一百万的数字（限两位小数）！');
					}
				}
				$jianjie = preg_replace ( "/\s(?=\s)/","\\1", I('jianjie') );
				$beizhu = preg_replace ( "/\s(?=\s)/","\\1", I('beizhu') );
				if (!preg_match("/^$|^[\s\S]{0,300}$/",$jianjie)) {
					$this->error('简介只能输入300个字符！');
				}
				if (!preg_match("/^$|^[\s\S]{0,300}$/",$beizhu)) {
					$this->error('备注只能输入300个字符！');
				}
				if ($mmzl == 1) {
					$data['shoujia'] = $shoujia;
					if ($is_rbacfdj == 1) {
						$data['chushoudj'] = $chushoudj;
					}
					if ($jzmianji and $shoujia) {
						$num1 = $shoujia*10000;
						$num2 = $jzmianji;
						$num = $num1/$num2;
						$danjia = number_format($num,2,".", "");
						$data['danjia'] = $danjia;
					}
				} elseif ($mmzl == 2) {
					$data['zujia'] = $zujia;
					if ($is_rbacfdj == 1) {
						$data['chuzudj'] = $chuzudj;
					}
					$data['zujialx'] = I('zujialx');
				}
				$pt1 = array_keys(I('peitao'));
				$pt2 = implode(',',$pt1);
				$ts1 = array_keys(I('tese'));
				$ts2 = implode(',',$ts1);
				$is_rbactb = _rbac_node_show(1052);
				if ($is_rbactb) {
					if (I('waiwangtb')) {
						$waiwangtb = 1;
					} else {
						$waiwangtb = 0;
					}
				}
				if (I('fenge')) {
					$fenge = 1;
				} else {
					$fenge = 2;
				}
				if (I('zuyue')) {
					$zuyue = 1;
				} else {
					$zuyue = 2;
				}
				if (I('jishou')) {
					$jishou = 1;
				} else {
					$jishou = 0;
				}
				if (I('heyan')) {
					$heyan = 1;
				} else {
					$heyan = 0;
				}
				$data['leixing'] = I('leixing');
				$data['yetai'] = I('yetai');
				$data['hangye'] = I('hangye');
				$data['fybiaoti'] = I('fybiaoti');
				$data['jzmianji'] = $jzmianji;
				$data['miankuan'] = $miankuan;
				$data['jinshen'] = $jinshen;
				$data['cenggao'] = $cenggao;
				$data['wuyefei'] = $wuyefei;
				$data['wyflx'] = I('wyflx');
				$data['fydengji'] = I('fydengji');
				$data['zhuangxiu'] = I('zhuangxiu');
				$data['shiyonglv'] = I('shiyonglv');
				$data['peitao'] = $pt2;
				$data['tese'] = $ts2;
				$data['shihejy'] = I('shihejy');
				$data['jianjie'] = $jianjie;
				$data['beizhu'] = $beizhu;
				$data['cqnianxian'] = $cqnianxian;
				$data['laiyuan'] = I('laiyuan');
				$data['kanfangfs'] = I('kanfangfs');
				$data['fukuanfs'] = I('fukuanfs');
				$data['waiwangtb'] = $waiwangtb;
				$data['fenge'] = $fenge;
				$data['zuyue'] = $zuyue;
				$data['jishou'] = $jishou;
				$data['heyan'] = $heyan;
				$data['chanquanzheng'] = I('chanquanzheng');
				$data['tudizheng'] = I('tudizheng');
				$data['budongchanzheng'] = I('budongchanzheng');
				$data['czriqi'] = strtotime(I('czriqi'));
				$data['xiugaisj'] = time();
				$xiugai = "";
				if ($mmzl == 1) {
					if ($fy1['shoujia'] != $shoujia && ($fy1['shoujia'] || $shoujia)) {
						$xiugai .= "售价：[".$fy1['shoujia']."万]=>[".$shoujia."万]；";
					}
					if ($is_rbacfdj == 1) {
						if ($fy1['chushoudj'] != $chushoudj && ($fy1['chushoudj'] || $chushoudj)) {
							$xiugai .= "出售底价：[".$fy1['chushoudj']."万]=>[".$chushoudj."万]；";
						}
					}
					if ($fy1['danjia'] != $danjia && ($fy1['danjia'] || $danjia)) {
						$xiugai .= "单价：[".$fy1['danjia']."元/m²]=>[".$danjia."元/m²]；";
					}
				} elseif ($mmzl == 2) {
					if (($fy1['zujia'] != $zujia && ($fy1['zujia'] || $zujia)) || ($fy1['zujialx'] != I('zujialx') && ($fy1['zujialx'] || I('zujialx')))) {
						$xiugai .= "租价：[".$fy1['zujia'].get_peizhi('zujialx',$fy1['zujialx'],3)."]=>[".$zujia.get_peizhi('zujialx',I('zujialx'),3)."]；";
					}
					if ($is_rbacfdj == 1) {
						if (($fy1['chuzudj'] != $chuzudj && ($fy1['chuzudj'] || $chuzudj)) || ($fy1['zujialx'] != I('zujialx') && ($fy1['zujialx'] || I('zujialx')))) {
							$xiugai .= "出租底价：[".$fy1['chuzudj'].get_peizhi('zujialx',$fy1['zujialx'],3)."]=>[".$chuzudj.get_peizhi('zujialx',I('zujialx'),3)."]；";
						}
					}
				}
				if ($fy1['leixing'] != I('leixing') && ($fy1['leixing'] || I('leixing'))) {
					$xiugai .= get_xiugai($fy1['leixing'],I('leixing'),'spleixing');
				}
				if ($fy1['yetai'] != I('yetai') && ($fy1['yetai'] || I('yetai'))) {
					$xiugai .= get_xiugai($fy1['yetai'],I('yetai'),'spyetai');
				}
				if ($fy1['hangye'] != I('hangye') && ($fy1['hangye'] || I('hangye'))) {
					$xiugai .= get_xiugai($fy1['hangye'],I('hangye'),'sphangye');
				}
				if ($fy1['fybiaoti'] != I('fybiaoti') && ($fy1['fybiaoti'] || I('fybiaoti'))) {
					$xiugai .= "房源标题：[".$fy1['fybiaoti']."]=>[".I('fybiaoti')."]；";
				}
				if ($fy1['jzmianji'] != $jzmianji && ($fy1['jzmianji'] || $jzmianji)) {
					$xiugai .= "建筑面积：[".$fy1['jzmianji']."m²]=>[".$jzmianji."m²]；";
				}
				if ($fy1['miankuan'] != $miankuan && ($fy1['miankuan'] || $miankuan)) {
					$xiugai .= "面宽：[".$fy1['miankuan']."m²]=>[".$miankuan."m²]；";
				}
				if ($fy1['jinshen'] != $jinshen && ($fy1['jinshen'] || $jinshen)) {
					$xiugai .= "进深：[".$fy1['jinshen']."m²]=>[".$jinshen."m²]；";
				}
				if ($fy1['cenggao'] != $cenggao && ($fy1['cenggao'] || $cenggao)) {
					$xiugai .= "层高：[".$fy1['cenggao']."m²]=>[".$cenggao."m²]；";
				}
				if (($fy1['wuyefei'] != $wuyefei && ($fy1['wuyefei'] || $wuyefei)) || ($fy1['wyflx'] != I('wyflx') && ($fy1['wyflx'] || I('wyflx')))) {
					$xiugai .= "物业费：[".$fy1['wuyefei'].get_peizhi('wyfdwlx',$fy1['wyflx'],3)."]=>[".$wuyefei.get_peizhi('wyfdwlx',I('wyflx'),3)."]；";
				}
				if ($fy1['fydengji'] != I('fydengji') && ($fy1['fydengji'] || I('fydengji'))) {
					$xiugai .= get_xiugai($fy1['fydengji'],I('fydengji'),'fydengji');
				}
				if ($fy1['zhuangxiu'] != I('zhuangxiu') && ($fy1['zhuangxiu'] || I('zhuangxiu'))) {
					$xiugai .= get_xiugai($fy1['zhuangxiu'],I('zhuangxiu'),'zhuangxiu');
				}
				if ($fy1['shiyonglv'] != I('shiyonglv') && ($fy1['shiyonglv'] || I('shiyonglv'))) {
					$xiugai .= get_xiugai($fy1['shiyonglv'],I('shiyonglv'),'spshiyonglv');
				}
				$Model = new \Think\Model();
				if ($fy1['peitao'] != $pt2) {
					if ($fy1['peitao']) {
						$condition1 = "pzming = 'sppeitao' and lxid in (".$fy1['peitao'].")";
						$peitao1 = $Model->query("select * from __PEIZHI__ where {$condition1} order by xsshunxu asc");
						$spptsz1 = array();
						foreach ($peitao1 AS $key => $val) {
							$spptsz1[] =  $val['lxming'];
						}
						$sppts1 = implode("；",$spptsz1);
					}
					if ($pt2) {
						$condition2 = "pzming = 'sppeitao' and lxid in (".$pt2.")";
						$peitao2 = $Model->query("select * from __PEIZHI__ where {$condition2} order by xsshunxu asc");
						$spptsz2 = array();
						foreach ($peitao2 AS $key => $val) {
							$spptsz2[] =  $val['lxming'];
						}
						$sppts2 = implode("；",$spptsz2);
					}
					$xiugai .= "配套：[".$sppts1."]=>[".$sppts2."]；";
				}
				if ($fy1['tese'] != $ts2) {
					if ($fy1['tese']) {
						$condition3 = "pzming = 'sptese' and lxid in (".$fy1['tese'].")";
						$tese1 = $Model->query("select * from __PEIZHI__ where {$condition3} order by xsshunxu asc");
						$sptssz1 = array();
						foreach ($tese1 AS $key => $val) {
							$sptssz1[] =  $val['lxming'];
						}
						$sptss1 = implode("；",$sptssz1);
					}
					if ($ts2) {
						$condition4 = "pzming = 'sptese' and lxid in (".$ts2.")";
						$tese2 = $Model->query("select * from __PEIZHI__ where {$condition4} order by xsshunxu asc");
						$sptssz2 = array();
						foreach ($tese2 AS $key => $val) {
							$sptssz2[] =  $val['lxming'];
						}
						$sptss2 = implode("；",$sptssz2);
					}
					$xiugai .= "特色：[".$sptss1."]=>[".$sptss2."]；";
				}
				if ($fy1['shihejy'] != I('shihejy') && ($fy1['shihejy'] || I('shihejy'))) {
					$xiugai .= "适合经营：[".$fy1['shihejy']."]=>[".I('shihejy')."]；";
				}
				if ($fy1['jianjie'] != $jianjie && ($fy1['jianjie'] || $jianjie)) {
					$xiugai .= "简介：[".$fy1['jianjie']."]=>[".$jianjie."]；";
				}
				if ($fy1['beizhu'] != $beizhu && ($fy1['beizhu'] || $beizhu)) {
					$xiugai .= "备注：[".$fy1['beizhu']."]=>[".$beizhu."]；";
				}
				if ($fy1['cqnianxian'] != $cqnianxian && ($fy1['cqnianxian'] || $cqnianxian)) {
					$xiugai .= "产权年限：[".$fy1['cqnianxian']."]=>[".$cqnianxian."]；";
				}
				if ($fy1['laiyuan'] != I('laiyuan') && ($fy1['laiyuan'] || I('laiyuan'))) {
					$xiugai .= get_xiugai($fy1['laiyuan'],I('laiyuan'),'spshiyonglv');
				}
				if ($fy1['kanfangfs'] != I('kanfangfs') && ($fy1['kanfangfs'] || I('kanfangfs'))) {
					$xiugai .= get_xiugai($fy1['kanfangfs'],I('kanfangfs'),'spshiyonglv');
				}
				if ($fy1['fukuanfs'] != I('fukuanfs') && ($fy1['fukuanfs'] || I('fukuanfs'))) {
					if ($mmzl == 1) {
						$fuk = "fukuan";
					} elseif ($mmzl == 2) {
						$fuk = "zlfukuan";
					}
					$xiugai .= get_xiugai($fy1['fukuanfs'],I('fukuanfs'),$fuk);
				}
				if ($fy1['waiwangtb'] != $waiwangtb && ($fy1['waiwangtb'] || $waiwangtb)) {
					$wai1 = $fy1['waiwangtb'] ? "是" : "否";
					$wai2 = $waiwangtb ? "是" : "否";
					$xiugai .= "外网同步：[".$wai1."]=>[".$wai2."]；";
				}
				if ($fy1['fenge'] != $fenge && ($fy1['fenge'] || $fenge)) {
					$fge1 = $fy1['fenge']==1 ? "是" : "否";
					$fge2 = $fenge==1 ? "是" : "否";
					$xiugai .= "是否分割：[".$fge1."]=>[".$fge2."]；";
				}
				if ($fy1['zuyue'] != $zuyue && ($fy1['zuyue'] || $zuyue)) {
					$zuy1 = $fy1['zuyue']==1 ? "有" : "无";
					$zuy2 = $zuyue==1 ? "有" : "无";
					$xiugai .= "有无租约及租约到期日：[".$zuy1."]=>[".$zuy2."]；";
				}
				if ($fy1['jishou'] != $jishou && ($fy1['jishou'] || $jishou)) {
					$jis1 = $fy1['jishou'] ? "是" : "否";
					$jis2 = $jishou ? "是" : "否";
					$xiugai .= "急售：[".$jis1."]=>[".$jis2."]；";
				}
				if ($fy1['heyan'] != $heyan && ($fy1['heyan'] || $heyan)) {
					$hey1 = $fy1['heyan'] ? "是" : "否";
					$hey2 = $heyan ? "是" : "否";
					$xiugai .= "核验：[".$hey1."]=>[".$hey2."]；";
				}
				if ($fy1['chanquanzheng'] != I('chanquanzheng') && ($fy1['chanquanzheng'] || I('chanquanzheng'))) {
					$xiugai .= get_xiugai1("产权证",$fy1['chanquanzheng'],I('chanquanzheng'),'iszheng');
				}
				if ($fy1['tudizheng'] != I('tudizheng') && ($fy1['tudizheng'] || I('tudizheng'))) {
					$xiugai .= get_xiugai1("土地证",$fy1['tudizheng'],I('tudizheng'),'iszheng');
				}
				if ($fy1['budongchanzheng'] != I('budongchanzheng') && ($fy1['budongchanzheng'] || I('budongchanzheng'))) {
					$xiugai .= get_xiugai1("不动产证",$fy1['budongchanzheng'],I('budongchanzheng'),'iszheng');
				}
				if ($fy1['czriqi'] != strtotime(I('czriqi')) && ($fy1['czriqi'] || I('czriqi'))) {
					$xiugai .= "产证日期：[".date('Y-m-d',$fy1['czriqi'])."]=>[".I('czriqi')."]；";
				}
				$isok = M('fyshangpu')->where(array('id'=>$id))->save($data);
				if ($isok) {
					if ($fy1['mmzl'] == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($fy1['mmzl'] == 2) {
						$zyzs = "商铺（出租）";
					}
					data_rizhi(14,2,$id,$fy1['bianhao'],$xiugai,U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
					if ($fy1['shtype'] == 2) {
						M('fyshangpu')->where(array('id'=>$id))->setField('shtype',3);
						$this->success('已更新，请等待审核！');
					} else {
						$this->success('更新成功');
					}
				} else {
					$this->error('更新失败！');
				}
			} else {
				if ($fy1['mmzl'] == 1) {
					$fuk = "fukuan";
				} elseif ($fy1['mmzl'] == 2) {
					$fuk = "zlfukuan";
					$this->zujialx = get_peizhi('zujialx',0,1);
				}
				$this->leixing = get_peizhi('spleixing',0,1);
				$this->yetai = get_peizhi('spyetai',0,1);
				$this->hangye = get_peizhi('sphangye',0,1);
				$this->wyflx = get_peizhi('wyfdwlx',0,1);
				$this->fydengji = get_peizhi('fydengji',0,1);
				$this->zhuangxiu = get_peizhi('zhuangxiu',0,1);
				$this->shiyonglv = get_peizhi('spshiyonglv',0,1);
				$this->peitao = get_peizhi('sppeitao',0,1);
				$this->tese = get_peizhi('sptese',0,1);
				$this->laiyuan = get_peizhi('laiyuan',0,1);
				$this->kanfangfs = get_peizhi('kanfangfs',0,1);
				$this->fukuanfs = get_peizhi($fuk,0,1);
				$this->yezhulx = get_peizhi('yezhulx',0,1);
				$this->yezhugx = get_peizhi('yezhugx',0,1);
				$this->iszheng = get_peizhi('iszheng',0,1);
				$this->peitao2 = explode(",",$fy1['peitao']);
				$this->tese2 = explode(",",$fy1['tese']);
				$this->fangyuan = $fy1;
				$this->display();
			}
		}

		//变更状态
		public function bgfyzt(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(695,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				if ($fangyuan['zhuangtai'] == get_options('chengjiao_options','fychengjiao_zhuangtai')){
					$this->error('房源已成交');
				}
				$data['zhuangtai'] = I('zhuangtai');
				$data['xiugaisj'] = time();
				$isok = M("fyshangpu")->where(array('id'=>$id))->save($data);
				if ($isok){
					$xiugai = "变更".get_xiugai($fangyuan['zhuangtai'],I('zhuangtai'),'zhuangtai');
					if ($fangyuan['mmzl'] == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($fangyuan['mmzl'] == 2) {
						$zyzs = "商铺（出租）";
					}
					data_rizhi(14,24,$id,$fangyuan['bianhao'],$xiugai,U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
					$this->success('变更成功！');
				} else {
					$this->error('变更失败！');
				}
			} else {
				$this->fyzt = $fangyuan['zhuangtai'];
				$this->zhuangtai = get_peizhi('zhuangtai',0,1);
				$this->display();
			}
		}

		//变更维护人
		public function bgwhr(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(381,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				$data['weihurenid'] = I('weihurenid');
				$xweihu = M('yonghu')->where(array('id'=>I('weihurenid')))->getField('ygmingcheng');
				$data['weihuren'] = $xweihu;
				$data['xiugaisj'] = time();
				$isok = M("fyshangpu")->where(array('id'=>$id))->save($data);
				if ($isok){
					M('fyshangpu')->where(array('id'=>$id))->setField('xiugaisj',time());
					data_fkywhr(14,$id,session('uid'));
					$xiugai = "变更维护人：[".$fangyuan['weihuren']."]=>[".$xweihu."]";
					if ($fangyuan['mmzl'] == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($fangyuan['mmzl'] == 2) {
						$zyzs = "商铺（出租）";
					}
					data_rizhi(14,9,$id,$fangyuan['bianhao'],$xiugai,U('fangyuan/neirong',array('id'=>$id)),$zyzs);
					$this->success('修改成功');
				} else {
					$this->error('修改失败');
				}
			} else {
				$this->weihuren = M('fyshangpu')->where(array('id'=>$id,'gongsiid'=>session('gongsiid')))->getField('weihuren');
				$this->display();
			}
		}

		//调取
		public function diaoqu() {
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(58,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error('您没有权限!');
			}
			$is_rbacfdq = _rbac_node_show(862);
			if (!$is_rbacfdq && ($fangyuan['fpdq'] != 2)) {
				$this->error('您没有权限!');
			}
			$is_rbacfdh = _rbac_node_show(859);
			$is_rbacfdz = _rbac_node_show(860);
			if (!$is_rbacfdh && !$is_rbacfdz && ($fangyuan['fpdh'] == 1) && ($fangyuan['fpdz'] == 1)) {
				$this->error('您没有权限!');
			}
			$Model = new \Think\Model;
			$diaoqu_arr = get_options('diaoqu_options',0);
			$username = zym(session('uid'),14);
			if ($diaoqu_arr['sz_ytpe'] == 1 && $username != C('RBAC_SUPERADMIN')) {
				switch ($diaoqu_arr['sz_ytpe1']['type']) {
					case '1':
						$startUnix = strtotime(date('Y-m-d',time()));
						break;
					case '2':
						$startUnix = strtotime(date('Y-m-d', strtotime('this week')));
						break;
					case '3':
						$startUnix = strtotime(date('Y-m', time()) . '-01 00:00:00');
						break;
					case '4':
						$season = ceil((date('n'))/3);
						$startUnix = mktime(0, 0, 0,$season*3-3+1,1,date('Y'));
						break;
					case '5':
						$startUnix = strtotime(date('Y', time()) . '-01-01 00:00:00');
						break;
					default:
						$startUnix = strtotime(date('Y-m-d',time()));
						break;
				}
				$find = M('xianzhi')->where(array('fyid'=>$id,'fylx'=>14,'uid'=>session('uid'),'shijian'=>array('gt',$startUnix)))->find();
				$map = ' fylx=14 and uid='.session('uid')." and shijian>=".$startUnix;
				$sql = "select count(*) from (select * from __XIANZHI__ where $map group by fyid) as a";
				$count=$Model->query($sql);
				if ($count[0]['count(*)'] >= $diaoqu_arr['sz_ytpe1']['count']) {
					$this->error('调取次数已用完!');
				}
				$sycishu = $diaoqu_arr['sz_ytpe1']['count'] - $count[0]['count(*)'] - 1;
			} elseif ($diaoqu_arr['sz_ytpe'] == 2 && $username != C('RBAC_SUPERADMIN')) {
				$role_id=M('role_user')->where(array('user_id'=>session('uid')))->getField('role_id');
				switch ($diaoqu_arr['sz_ytpe2'][$role_id]['type']) {
					case '1':
						$startUnix = strtotime(date('Y-m-d',time()));
						break;
					case '2':
						$startUnix = strtotime(date('Y-m-d', strtotime('this week')));
						break;
					case '3':
						$startUnix = strtotime(date('Y-m', time()) . '-01 00:00:00');
						break;
					case '4':
						$season = ceil((date('n'))/3);
						$startUnix = mktime(0, 0, 0,$season*3-3+1,1,date('Y'));
						break;
					case '5':
						$startUnix = $startUnix = strtotime(date('Y', time()) . '-01-01 00:00:00');
						break;
					default:
						$startUnix = strtotime(date('Y-m-d',time()));
						break;
				}
				$find = M('xianzhi')->where(array('fyid'=>$id,'fylx'=>14,'uid'=>session('uid'),'shijian'=>array('gt',$startUnix)))->find();
				$map = ' fylx=14 and uid='.session('uid')." and shijian>=".$startUnix;
				$sql = "select count(*) from (select * from __XIANZHI__ where $map group by fyid) as a";
				$count=$Model->query($sql);
				if ($count[0]['count(*)'] >= $diaoqu_arr['sz_ytpe2'][$role_id]['count']) {
					$this->error('调取次数已用完!');
				}
				$sycishu = $diaoqu_arr['sz_ytpe2'][$role_id]['count'] - $count[0]['count(*)'] - 1;
			}
			$data['fylx']=14;
			$data['fyid']=$id;
			$data['fybh']=$fangyuan['bianhao'];
			$data['uid']=session('uid');
			$data['time']=date("Y-m");
			$data['shijian']=time();
			M('xianzhi')->add($data);
			if ($is_rbacfdh || ($fangyuan['fpdh'] == 2)) {
				$yezhulx=get_peizhi('yezhulx',$fangyuan['yezhulx'],3);
				$yezhugx=get_peizhi('yezhugx',$fangyuan['yezhugx'],3);
				$yezhugx2=get_peizhi('yezhugx',$fangyuan['yezhugx2'],3);
				$yezhugx3=get_peizhi('yezhugx',$fangyuan['yezhugx3'],3);
				if ($yezhugx) {
					$yzguanxi = "（".$yezhugx."）";
				} else {
					$yzguanxi = "";
				}
				if ($yezhugx2) {
					$yzguanxi2 = "（".$yezhugx2."）";
				} else {
					$yzguanxi2 = "";
				}
				if ($yezhugx3) {
					$yzguanxi3 = "（".$yezhugx3."）";
				} else {
					$yzguanxi3 = "";
				}
				$diaoqu['yezhu']=$fangyuan['yezhu'].$yezhulx;
				$diaoqu['yezhudianhua']=$fangyuan['yezhudianhua'].$yzguanxi;
				$diaoqu['yezhudianhua2']=$fangyuan['yezhudianhua2'].$yzguanxi2;
				$diaoqu['yezhudianhua3']=$fangyuan['yezhudianhua3'].$yzguanxi3;
			}
			if ($is_rbacfdz || ($fangyuan['fpdz'] == 2)) {
				$diaoqu['zuodong']=$fangyuan['zuodong'];
				$diaoqu['danyuan']=$fangyuan['danyuan'];
				$diaoqu['fanghao']=$fangyuan['fanghao'];
			}
			if ($sycishu) {
				$info="剩余调取数为".$sycishu."次";
			}
			$data1=array('status'=>1,'diaoqu1'=>$diaoqu,'info'=>$info);
			header("Content-type: application/json");
			exit(json_encode($data1));
		}

		//修改门牌号
		public function xgzuodong(){
			$id=I('id');
			$fangyuan=M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(150,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			$is_rbacfdh = _rbac_node_show(859);
			$is_rbacfdz = _rbac_node_show(860);
			if (!$is_rbacfdh && !$is_rbacfdz && ($fangyuan['fpdh'] == 1) && ($fangyuan['fpdz'] == 1)) {
				$this->redirect('Index/error');
			}
			if ($is_rbacfdh || ($fangyuan['fpdh'] == 2)) {
				$this->is_rbacfdh=1;
			}
			if ($is_rbacfdz || ($fangyuan['fpdz'] == 2)) {
				$this->is_rbacfdz=1;
			}
			if (IS_POST) {
				if ($is_rbacfdh || ($fangyuan['fpdh'] == 2)) {
					$dianhua1=I('dianhua1');
					$dianhua2=I('dianhua2');
					$dianhua3=I('dianhua3');
					if(!preg_match("/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[8-9])\d{8}$/",$dianhua1) && !preg_match("/^0\d{2,3}-?\d{7,8}$/",$dianhua1)){
						$this->error('请输出正确的手机号码或电话号码！');
					}
					if ($dianhua2) {
						if(!preg_match("/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[8-9])\d{8}$/",$dianhua2) && !preg_match("/^0\d{2,3}-?\d{7,8}$/",$dianhua2)){
							$this->error('请输出正确的手机号码或电话号码！');
						}
					}
					if ($dianhua3) {
						if(!preg_match("/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[8-9])\d{8}$/",$dianhua3) && !preg_match("/^0\d{2,3}-?\d{7,8}$/",$dianhua3)){
							$this->error('请输出正确的手机号码或电话号码！');
						}
					}
					if (($dianhua1 && $dianhua2 && $dianhua1 == $dianhua2) || ($dianhua1 && $dianhua3 && $dianhua1 == $dianhua3) || ($dianhua1 && $dianhua2 && $dianhua2 == $dianhua3)) {
						$this->error('手机号码或电话号码重复！');
					}
					$yezhulxq=get_peizhi('yezhulx',$fangyuan['yezhulx'],3);
					$yezhulxh=get_peizhi('yezhulx',I('yezhulx'),3);
					$yezhugxq=get_peizhi('yezhugx',$fangyuan['yezhugx'],3);
					$yezhugxh=get_peizhi('yezhugx',I('yezhugx1'),3);
					$yezhugx2q=get_peizhi('yezhugx',$fangyuan['yezhugx2'],3);
					$yezhugx2h=get_peizhi('yezhugx',I('yezhugx2'),3);
					$yezhugx3q=get_peizhi('yezhugx',$fangyuan['yezhugx3'],3);
					$yezhugx3h=get_peizhi('yezhugx',I('yezhugx3'),3);
				}
				if ($is_rbacfdz || ($fangyuan['fpdz'] == 2)) {
					$zuodong=I('zuodong');
					$danyuan=I('danyuan');
					$fanghao=I('fanghao');
					if(!preg_match("/^[a-zA-Z1-9][0-9]{0,6}$/",$zuodong)){
						$this->error('座栋首字符可以是非零整数或字母，除首字符外必须为非负整数（限六位整数）！');
					}
					if(!preg_match("/^[a-zA-Z1-9][0-9]{0,6}$/",$danyuan)){
						$this->error('单元首字符可以是非零整数或字母，除首字符外必须为非负整数（限六位整数）！');
					}
					if(!preg_match("/^[a-zA-Z1-9][0-9]{0,6}$/",$fanghao)){
						$this->error('房号首字符可以是非零整数或字母，除首字符外必须为非负整数（限六位整数）！');
					}
					$condition['gongsiid']=session('gongsiid');
					$condition['zhuangtai']=array('neq',get_options('chengjiao_options','fychengjiao_zhuangtai'));
					$condition['id']=array('neq',$id);
					$condition['isdel']=2;
					$condition['xiaoqu']=$fangyuan['xiaoqu'];
					$condition['zuodong']=$zuodong;
					$condition['danyuan']=$danyuan;
					$condition['fanghao']=$fanghao;
					$condition['mmzl']=$fangyuan['mmzl'];
					$cffy = M('fyshangpu')->where($condition)->find();
					if ($cffy) {
						$this->error('房源已存在！');
					}
				}
				$xiugai = "";
				if ($is_rbacfdh || ($fangyuan['fpdh'] == 2)) {
					if (($fangyuan['yezhu'] != I('yezhu') && ($fangyuan['yezhu'] || I('yezhu'))) || ($yezhulxq != $yezhulxh && ($yezhulxq || $yezhulxh))) {
						$xiugai .= "业主：[".$fangyuan['yezhu'].$yezhulxq."]=>[".I('yezhu').$yezhulxh."]；";
					}
					if (($fangyuan['yezhudianhua'] != $dianhua1 && ($fangyuan['yezhudianhua'] || $dianhua1)) || ($yezhugxq != $yezhugxh && ($yezhugxq || $yezhugxh))) {
						$xiugai .= "电话1：[".$fangyuan['yezhudianhua']."（".$yezhugxq."）]=>[".$dianhua1."（".$yezhugxh."）]；";
					}
					if (($fangyuan['yezhudianhua2'] != $dianhua1 && ($fangyuan['yezhudianhua2'] || $dianhua1)) || ($yezhugx2q != $yezhugx2h && ($yezhugx2q || $yezhugx2h))) {
						$xiugai .= "电话2：[".$fangyuan['yezhudianhua2']."（".$yezhugx2q."）]=>[".$dianhua1."（".$yezhugx2h."）]；";
					}
					if (($fangyuan['yezhudianhua3'] != $dianhua1 && ($fangyuan['yezhudianhua3'] || $dianhua1)) || ($yezhugx3q != $yezhugx3h && ($yezhugx3q || $yezhugx3h))) {
						$xiugai .= "电话3：[".$fangyuan['yezhudianhua3']."（".$yezhugx3q."）]=>[".$dianhua1."（".$yezhugx3h."）]；";
					}
				}
				if ($is_rbacfdz || ($fangyuan['fpdz'] == 2)) {
					if ($fangyuan['zuodong'] != $zuodong && ($fangyuan['zuodong'] || $zuodong)) {
						$xiugai .= "座栋：[".$fangyuan['zuodong']."]=>[".$zuodong."]；";
					}
					if ($fangyuan['danyuan'] != $danyuan && ($fangyuan['danyuan'] || $danyuan)) {
						$xiugai .= "单元：[".$fangyuan['danyuan']."]=>[".$danyuan."]；";
					}
					if ($fangyuan['fanghao'] != $fanghao && ($fangyuan['fanghao'] || $fanghao)) {
						$xiugai .= "房号：[".$fangyuan['fanghao']."]=>[".$fanghao."]；";
					}
				}
				if ($is_rbacfdh || ($fangyuan['fpdh'] == 2)) {
					$data['yezhu']=I('yezhu');
					$data['yezhulx']=I('yezhulx');
					$data['yezhugx']=I('yezhugx1');
					$data['yezhugx2']=I('yezhugx2');
					$data['yezhugx3']=I('yezhugx3');
					$data['yezhudianhua']=$dianhua1;
					$data['yezhudianhua2']=$dianhua2;
					$data['yezhudianhua3']=$dianhua3;
				}
				if ($is_rbacfdz || ($fangyuan['fpdz'] == 2)) {
					$data['zuodong']=$zuodong;
					$data['danyuan']=$danyuan;
					$data['fanghao']=$fanghao;
				}
				$data['xiugaisj']=time();
				$isok=M('fyshangpu')->where(array('id'=>$id))->save($data);
				if ($isok) {
					if ($fangyuan['mmzl'] == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($fangyuan['mmzl'] == 2) {
						$zyzs = "商铺（出租）";
					}
					data_rizhi(14,7,$id,$fangyuan['bianhao'],$xiugai,U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
					$this->success('修改成功');
				} else {
					$this->error('修改失败');
				}
			} else {
				$this->fangyuan=$fangyuan;
				if ($is_rbacfdh || ($fangyuan['fpdh'] == 2)) {
					$this->yezhulx=get_peizhi('yezhulx',0,1);
					$this->yezhugx=get_peizhi('yezhugx',0,1);
				}
				$this->display();
			}
		}

		//收藏房源
		public function shoucang(){
			$is_rbac = _rbac_btn_show(388,0);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			$id = I('id');
			$fybh = M('fyshangpu')->where(array('id'=>$id))->getField('bianhao');
			$data['user_id'] = session("uid");
			$data['fyid'] = $fybh;
			$data['fyid'] = $id;
			$data['fylx'] = 14;
			$data['addtime'] = time();
			$isok = M('shoucang')->add($data);
			if ($isok) {
				$mmzl = M('fyshangpu')->where(array('id'=>$id))->getField('mmzl');
				if ($mmzl == 1) {
					$zyzs = "商铺（出售）";
				} elseif ($mmzl == 2) {
					$zyzs = "商铺（出租）";
				}
				data_rizhi(14,4,$id,$fybh,"收藏房源",U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
				$this->success('添加成功');
			} else {
				$this->error('添加失败');
			}
		}

		//取消收藏
		public function noshoucang(){
			$is_rbac = _rbac_btn_show(389,0);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			$id = I('id');
			$fybh = M('fyshangpu')->where(array('id'=>$id))->getField('bianhao');
			$isok = M('shoucang')->where(array('fyid'=>$id,'user_id'=>session("uid"),'fylx'=>14))->delete();
			if ($isok) {
				$mmzl = M('fyshangpu')->where(array('id'=>$id))->getField('mmzl');
				if ($mmzl == 1) {
					$zyzs = "商铺（出售）";
				} elseif ($mmzl == 2) {
					$zyzs = "商铺（出租）";
				}
				data_rizhi(14,4,$id,$fybh,"取消收藏房源",U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
				$this->success('取消成功');
			} else {
				$this->error('取消失败');
			}
		}

		//设置全景地址处理
		public function quanjing(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(76,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			$data['vr_url'] = I('text');
			$data['xiugaisj'] = time();
			$isok = M('fyshangpu')->where(array('id'=>$id))->save($data);
			if ($isok) {
				$xiugai = "全景设置：[".$fangyuan['vr_url']."]=>[".$data['vr_url']."]；";
				if ($fangyuan['mmzl'] == 1) {
					$zyzs = "商铺（出售）";
				} elseif ($fangyuan['mmzl'] == 2) {
					$zyzs = "商铺（出租）";
				}
				data_rizhi(14,6,$id,$fangyuan['bianhao'],$xiugai,U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
				$this->success('添加成功');
			} else {
				$this->error('添加失败');
			}
		}

		//编辑视频
		public function editshipin(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->field('zhuangtai,weihurenid,bianhao,isdel,shtype,mmzl')->find();
			$is_rbac = _rbac_btn_show(498,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				if (preg_match_all('/src=&quot;(.*?)&quot;/', I('shipin_url'), $matches)) {
					$s1 = $matches[1][0];
					$shipin_url = '<iframe src="'.$s1.'" frameborder="0" allowfullscreen="true" width="100%" height="100%"></iframe>';
				} elseif (preg_match_all('/src=\'(.*?)\'/', I('shipin_url'), $matches)) {
					$s1 = $matches[1][0];
					$shipin_url = '<iframe src="'.$s1.'" frameborder="0" allowfullscreen="true" width="100%" height="100%"></iframe>';
				} else {
					$this->error('修改失败!');
				}
				$isok = M('fyshangpu')->where(array('id'=>$id))->setField('shipin_url',$shipin_url);
				if ($isok) {
					M('fyshangpu')->where(array('id'=>$id))->setField('xiugaisj',time());
					if ($fangyuan['mmzl'] == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($fangyuan['mmzl'] == 2) {
						$zyzs = "商铺（出租）";
					}
					data_rizhi(14,31,$id,$fangyuan['bianhao'],"设置视频地址：".$shipin_url,U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
					$this->success('修改成功!');
				} else {
					$this->error('修改失败!');
				}
			} else {
				$this->shipin_url=M('fyshangpu')->where(array('id'=>$id))->getField('shipin_url');
				$this->display();
			}
		}

		/**
			* webuploader 显示图片上传框
		*/

		//上传图片
		function add() {
			$fybh = I('fybh');
			$fangyuan = M('fyshangpu')->field('zhuangtai,weihurenid,isdel,shtype')->where(array('bianhao'=>$fybh))->find();
			$is_rbac = _rbac_btn_show(70,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				// 根据自己的业务调整上传路径、允许的格式、文件大小
				$path = "/Upload/".session('gongsiid')."/".$fybh;
				ajax_upload($path,14);
			} else {
				$this->display();
			}
		}

		//设置图片类型
		public function settupianleixing(){
			$is_rbac = _rbac_node_show(484,0);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$ids = explode(",",I('fy_pic_ids'));
				$fybh = M('Photo')->where(array('id'=>$ids[0]))->getField('fybh');
				$fyzhuangtai = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('zhuangtai');
				foreach ($ids as $key => $value) {
					$uid = M('photo')->where(array('id'=>$value))->getField('uid');
					$is_rbac = _rbac_btn_show(484,$fyzhuangtai,$uid);
					if (!$is_rbac) {
						$this->error("您选择了权限范围之外的图片！");
					}
				}
				$ids1 = I('fy_pic_ids');
				$tpleixing = I('tpleixing');
				if ($tpleixing == "") {
					$this->error("请选择图片类型");
				}
				$where = 'id in('.$ids1.')';
				$dp = M('Photo');
				$plist = $dp->where($where)->setField(array('leixing'=>$tpleixing ));
				if ($plist) {
					M('fyshangpu')->where(array('bianhao'=>$fybh))->setField('xiugaisj',time());
					$fyid = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('id');
					$mmzl = M('fyshangpu')->where(array('id'=>$fyid))->getField('mmzl');
					if ($mmzl == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($mmzl == 2) {
						$zyzs = "商铺（出租）";
					}
					$xiugai = "设置了".count($ids)."张商铺图片的类型为".get_peizhi("sptplx",$tpleixing,3);
					data_rizhi(14,25,$fyid,$fybh,$xiugai,U('fyshangpu/neirong',array('id'=>$fyid)),$zyzs);
					$this->success("设置成功");
				} else {
					$this->error("设置失败");
				}
			} else {
				$this->tpleixing = get_peizhi("sptplx",0,1);
				$this->display();// 输出模板
			}
		}

		/**
			* [fy_pic_setfengmian 异步房源图片为封面]
			* @return [json] [description]
		*/

		//设置图片封面
		public function fy_pic_setfengmian(){
			$id = I('fy_pic_id');
			//根据图片id查找房源图片的房源编号fybh
			$fybh = M('Photo')->where(array('id'=>$id))->getField('fybh');
			$fyzhuangtai = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('zhuangtai');
			$uid = M('photo')->where(array('id'=>$id))->getField('uid');
			$is_rbac = _rbac_btn_show(481,$fyzhuangtai,$uid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			M('Photo')->where(array('fybh'=>$fybh,'fengmian'=>1))->setField(array('fengmian'=>0));
			$r = M('Photo')->where(array('id'=>$id))->setField(array('fengmian'=>1));
			if ($r) {
				M('fyshangpu')->where(array('bianhao'=>$fybh))->setField('xiugaisj',time());
				$fyid = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('id');
				$mmzl = M('fyshangpu')->where(array('id'=>$fyid))->getField('mmzl');
				if ($mmzl == 1) {
					$zyzs = "商铺（出售）";
				} elseif ($mmzl == 2) {
					$zyzs = "商铺（出租）";
				}
				data_rizhi(14,30,$id,$fybh,"设置图片封面",U('fyshangpu/neirong',array('id'=>$fyid)),$zyzs);
				$this->success('设置成功');
			} else {
				$this->error('设置失败');
			}
		}

		//批量下载房源图片
		public function fy_pic_downloads(){
			$is_rbac = _rbac_node_show(483,0);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$ids = I('fy_pic_ids');
			$fybh = M('Photo')->where(array('id'=>$ids[0]))->getField('fybh');
			$fyzhuangtai = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('zhuangtai');
			foreach ($ids as $key => $value) {
				$uid = M('photo')->where(array('id'=>$value))->getField('uid');
				$is_rbac = _rbac_btn_show(483,$fyzhuangtai,$uid);
				if (!$is_rbac) {
					$this->error("您选择了权限范围之外的图片！");
				}
			}
			$where = 'id in('.implode(',',$ids).')';
			$dp = M('Photo');
			$plist = $dp->where($where)->field('id,gongsiid,fybh,image')->select();
			$zip = new \ZipArchive;
			if ($plist) {
				//压缩文件名(临时文件)
				$filename = './Upload/'.$plist[0]['gongsiid'].'/'.$plist[0]['fybh'].'/'.md5($plist[0]['fybh']).'.zip';
				$downname = I("server.HTTP_HOST").'/Upload/'.$plist[0]['gongsiid'].'/'.$plist[0]['fybh'].'/'.md5($plist[0]['fybh']).'.zip';
			}
			//新建zip压缩包
			$zip->open($filename,\ZipArchive::OVERWRITE | \ZipArchive::CREATE);
			//把图片一张一张加进去压缩
			foreach ($plist as $value) {
				$zip->addFile('./Upload/'.$value['gongsiid'].'/'.$value['fybh'].'/'.$value['image']);
				$zip->renameName('./Upload/'.$value['gongsiid'].'/'.$value['fybh'].'/'.$value['image'],$value['image']);
			}
			//打包zip
			$zip->close();
			$fyid = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('id');
			$mmzl = M('fyshangpu')->where(array('id'=>$fyid))->getField('mmzl');
			if ($mmzl == 1) {
				$zyzs = "商铺（出售）";
			} elseif ($mmzl == 2) {
				$zyzs = "商铺（出租）";
			}
			data_rizhi(14,20,$fyid,$fybh,"下载了".count($ids)."张图片",U('fyshangpu/neirong',array('id'=>$fyid)),$zyzs);
			//可以直接重定向下载
			//header('Location:'.$downname);
			$this->success($downname);
		}

		/**
			* [fy_pic_del 异步删除图片]
			* @return [json] [description]
		*/

		//删除房源图片
		public function fy_pic_del(){
			$id = I('fy_pic_id');
			//根据图片id查看当前是否还有当前房源的图片
			$fybh = M('Photo')->where(array('id'=>$id))->getField('fybh');
			$fyzhuangtai = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('zhuangtai');
			$uid = M('photo')->where(array('id'=>$id))->getField('uid');
			$is_rbac = _rbac_btn_show(50,$fyzhuangtai,$uid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$piccount = M('Photo')->where(array('fybh'=>$fybh))->count();
			$dp = M('Photo');
			//删除当前图片
			if ($id) {
				$plist = $dp->where(array('id'=>$id))->find();
				if ($plist) {
					unlink('./Upload/'.$plist['gongsiid'].'/'.$plist['fybh'].'/'.$plist['image']);
					unlink('./Upload/'.$plist['gongsiid'].'/'.$plist['fybh'].'/t_'.$plist['image']);
					$dp->where(array('id'=>$id))->delete();
					$fyid = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('id');
					$mmzl = M('fyshangpu')->where(array('id'=>$fyid))->getField('mmzl');
					if ($mmzl == 1) {
						$zyzs = "商铺（出售）";
					} elseif ($mmzl == 2) {
						$zyzs = "商铺（出租）";
					}
					data_rizhi(14,13,$id,$fybh,"删除图片",U('fyshangpu/neirong',array('id'=>$fyid)),$zyzs);
					$data = array('pics'=>$plist);
					//删除最后一个房源图片后给fangyun表的tupian字段置 0
					if ($piccount == 1) {
						M('fyshangpu')->where(array('bianhao'=>$fybh))->setField('tupian',0);
					}
					M('fyshangpu')->where(array('bianhao'=>$fybh))->setField('xiugaisj',time());
					$this->success('删除成功');
				} else {
					$this->error('删除失败');
				}
			}
		}

		//批量删除房源图片
		public function fy_pic_dels(){
			$is_rbac = _rbac_node_show(482,0);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$ids = I('fy_pic_ids');
			$fybh = M('Photo')->where(array('id'=>$ids[0]))->getField('fybh');
			$fyzhuangtai = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('zhuangtai');
			foreach ($ids as $key => $value) {
				$uid = M('photo')->where(array('id'=>$value))->getField('uid');
				$is_rbac = _rbac_btn_show(482,$fyzhuangtai,$uid);
				if (!$is_rbac) {
					$this->error("您选择了权限范围之外的图片！");
				}
			}
			if (is_array($ids)) {
				$where = 'id in('.implode(',',$ids).')';
				$dp = M('Photo');
				//删除房源图片文件
				foreach ($ids as $value) {
					$plist = $dp->where(array('id'=>$value))->find();
					unlink('./Upload/'.$plist['gongsiid'].'/'.$plist['fybh'].'/'.$plist['image']);
					unlink('./Upload/'.$plist['gongsiid'].'/'.$plist['fybh'].'/t_'.$plist['image']);
				}
				//删除图片记录
				$dp->where($where)->delete();
				//写入删除日志
				$fyid = M('fyshangpu')->where(array('bianhao'=>$fybh))->getField('id');
				$mmzl = M('fyshangpu')->where(array('id'=>$fyid))->getField('mmzl');
				if ($mmzl == 1) {
					$zyzs = "商铺（出售）";
				} elseif ($mmzl == 2) {
					$zyzs = "商铺（出租）";
				}
				data_rizhi(14,13,$fyid,$fybh,"删除了".count($ids)."张图片",U('fyshangpu/neirong',array('id'=>$fyid)),$zyzs);
				//删除最后一个房源图片后给fangyun表的tupian字段置 0
				$nopic = M('Photo')->where(array('fybh'=>$fybh))->count();
				if ($nopic <= 0) {
					M('fyshangpu')->where(array('bianhao'=>$fybh))->setField('tupian',0);
				}
				M('fyshangpu')->where(array('bianhao'=>$fybh))->setField('xiugaisj',time());
				$this->success('删除成功');
			} else {
				$this->error('删除失败'); 
			}
		}

		//写跟进
		public function genjin(){
			$fangyuan = M('fyshangpu')->where(array('id'=>I('fyid')))->find();
			$is_rbac = _rbac_btn_show(61,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			$gjid = I('gjid');
			$gongsiid = session('gongsiid');
			if ($fangyuan['mmzl'] == 1) {
				$zyzs = "商铺（出售）";
			} elseif ($fangyuan['mmzl'] == 2) {
				$zyzs = "商铺（出租）";
			}
			//音频操作ajax（上传，删除）
			switch (I('gt')) {
				case '1':
					//语音上传
					$upload = new \Think\Upload();
					$upload->maxSize = 2097152;
					$upload->exts = ''; //array('mp3','ogg');
					$upload->rootPath = './Upload/';
					$upload->savePath = './Genjin/'.$gongsiid.'/fangyuan/'.$fangyuan['bianhao'].'/';
					$upload->autoSub = false;
					$uplaod->replace = true;	//存在同名文件是否是覆盖，默认为false
					$upload->saveName = 'gj'.$gjid;
					//开始上传音频文件
					$info = $upload->upload();
					p($info);die;
					if (!$info) {
						$this->error($upload->getError());
					} else {
						M('fygenjin')->where(array('id'=>$gjid))->setField(array('gjvoice'=>1));
						data_rizhi(14,5,$gjid,$fangyuan['bianhao'],"上传跟进语音",U('fyshangpu/neirong',array('id'=>$fangyuan['id'])),$zyzs);
						$this->success($info);
					}
					break;
				case '2':
					$isok = unlink('./Upload/Genjin/'.$gongsiid.'/fangyuan/'.$fangyuan['bianhao'].'/gj'.$gjid.'.mp3');
					if ($isok) {
						M('fygenjin')->where(array('id'=>$gjid))->setField(array('gjvoice'=>null)); 
					}
					data_rizhi(14,5,$gjid,$fangyuan['bianhao'],"删除跟进语音",U('fyshangpu/neirong',array('id'=>$fangyuan['id'])),$zyzs);
					$this->success('删除语音成功！');
					break;
				default:
					break;
			}
			if (IS_POST) {
				$data['gongsiid'] = session("gongsiid");
				$data['fylx'] = 14;
				$data['fybh'] = I('fybh');
				$data['fyid'] = I('fyid');
				$data['uid'] = session("uid");
				$data['genjinfs'] = I('genjinfs');
				$data['neirong'] = I('neirong');
				$data['shijian'] = strtotime(I('gjshijian'));
				$data['time'] = time();
				$isok = M('fygenjin')->add($data);
				if ($isok) {
					$data_genjin['zhgjsj'] = time();
					$data_genjin['xiugaisj'] = time();
					if ($fangyuan['weihurenid'] == session("uid")) {
						$data_genjin['whrzhgenjin'] = time();
					}
					$data_genjin['qyzhgenjin'] = time();
					M('fyshangpu')->where(array('id'=>I('fyid')))->save($data_genjin);
					$xiugai = "添加房源跟进：".$data['neirong'];
					data_rizhi(14,5,$isok,$data['fybh'],$xiugai,U('fyshangpu/neirong',array('id'=>$data['fyid'])),$zyzs);
					$this->success('添加成功');
				} else {
					$this->error('添加失败');
				}
			} else {
				$this->genjinfs = get_peizhi('genjinfs',0,1);
				$this->display();
			}
		}

		//抓取房源
		public function sipan(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(379,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			$options_arr = get_options('chengjiao_options',0);
			if ($fangyuan['zhuangtai'] == $options_arr['fychengjiao_zhuangtai']){
				$this->error('房源已成交');
			}
			$fywhrs = M('fkywhr')->where(array('zylx'=>14,'id'=>$id))->select();
			foreach ($fywhrs as $key => $value) {
				if ($value['whrid'] == session('uid')) {
					$this->error('您不能抓取此房源');
				}
			}
			$data['zhuangtai']=$options_arr['fysipan_zhuangtai'];
			$data['weihurenid']=session('uid');
			$data['weihuren']=session('ygmingcheng');
			$data['xiugaisj']=time();
			$isok=M('fyshangpu')->where(array('id'=>$id))->save($data);
			if ($isok) {
				data_fkywhr(14,$id,session('uid'));
				$xiugai = session("ygmingcheng")."抓取房源".$fangyuan['bianhao']."为私盘";
				if ($fangyuan['mmzl'] == 1) {
					$zyzs = "商铺（出售）";
				} elseif ($fangyuan['mmzl'] == 2) {
					$zyzs = "商铺（出租）";
				}
				data_rizhi(14,3,$id,$fangyuan['bianhao'],$xiugai,U('fyshangpu/neirong',array('id'=>$id)),$zyzs);
				$this->success('修改成功');
			} else {
				$this->error('修改失败');
			}
		}

		//委办
		public function weiban(){
			$fybh = I('fybianhao');
			$fangyuan = M('fyshangpu')->where(array('bianhao'=>$fybh))->field('zhuangtai,weihurenid,isdel,shtype,mmzl')->find();
			$is_rbac = _rbac_btn_show(564,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				$this->display();
			}
		}

		//添加钥匙
		public function yaoshi(){
			$fybh = I('fybianhao');
			$fangyuan = M('fyshangpu')->where(array('bianhao'=>$fybh))->field('zhuangtai,weihurenid,isdel,shtype,mmzl')->find();
			$is_rbac = _rbac_btn_show(750, $fangyuan['zhuangtai'], $fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				$parentid = I("get.parentid",0,'intval');
				$select_categorys = bumen_option( $parentid, 739);
				$this->assign("select_categorys", $select_categorys);
				$this->display();
			}
		}

		//上传附件
		public function fujianimg(){
			$data = array(
				'info' => '请联系客服（19965783436）获取正式版功能！',
				'data' => '',
				'status' => 0
			);
			$this->ajaxReturn($data);
		}

		//移动钥匙
		public function ydyaoshi(){
			$fybianhao = I('fybianhao');
			$fangyuan = M('fyshangpu')->where(array('bianhao'=>$fybianhao))->field('zhuangtai,weihurenid,mmzl')->find();
			$is_rbac = _rbac_btn_show(753, $fangyuan['zhuangtai'], $fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				$this->yaoshi = M('yaoshi')->where(array('fybianhao'=>$fybianhao,'fylx'=>14,'status'=>1))->select();
				$parentid = I("get.parentid",0,'intval');
				$select_categorys = bumen_option( $parentid, 739);
				$this->assign("select_categorys", $select_categorys);
				$this->display();
			}
		}

		//认证房源
		public function renzheng(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->field('zhuangtai,weihurenid,bianhao,isdel,shtype,mmzl')->find();
			$is_rbac = _rbac_btn_show(618,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}

		//实勘
		public function shikan(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->field('zhuangtai,weihurenid,bianhao,isdel,shtype,mmzl')->find();
			$is_rbac = _rbac_btn_show(565,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			$isshikan = M('shikan')->where(array('fybh'=>$fangyuan['bianhao'],'fylx'=>14,'status'=>1))->find();
			if ($isshikan) {
				$this->error('已有人实勘!');
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}

		//封盘
		public function fengpan(){
			$fangyuan = M('fyshangpu')->where(array('id'=>I('fyid')))->find();
			$is_rbac = _rbac_btn_show(830,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				if ($fangyuan['fpdh'] == 2) {
					$this->fdh = 1;
				}
				if ($fangyuan['fpdz'] == 2) {
					$this->fdz = 1;
				}
				if ($fangyuan['fpdj'] == 2) {
					$this->fdj = 1;
				}
				if ($fangyuan['fpdq'] == 2) {
					$this->fdq = 1;
				}
				if ($fangyuan['fpck'] == 2) {
					$this->fck = 1;
				}
				$this->fyid = I('fyid');
				$this->display();
			}
		}

		//开盘
		public function kaipan(){
			$fangyuan = M('fyshangpu')->where(array('id'=>I('fyid')))->find();
			$is_rbac = _rbac_btn_show(831,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if ($fangyuan['isdel'] == 1) {
				$this->error('房源已删除！');
			}
			if ($fangyuan['shtype'] == 3) {
				$this->error('请等待审核！');
			}
			if ($fangyuan['shtype'] == 2) {
				$this->error('房源已驳回！');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				if ($fangyuan['fpdh'] == 1) {
					$this->kdh = 1;
				}
				if ($fangyuan['fpdz'] == 1) {
					$this->kdz = 1;
				}
				if ($fangyuan['fpdj'] == 1) {
					$this->kdj = 1;
				}
				if ($fangyuan['fpdq'] == 1) {
					$this->kdq = 1;
				}
				if ($fangyuan['fpck'] == 1) {
					$this->kck = 1;
				}
				$this->fyid = I('fyid');
				$this->display();
			}
		}

		//删除房源
		public function delEsfy(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(416,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}

		//还原房源
		public function huifufy(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(766,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			$condition['gongsiid'] = session('gongsiid');
			$condition['zhuangtai'] = array('neq',get_options('chengjiao_options','fychengjiao_zhuangtai'));
			$condition['id'] = array('neq',$id);
			$condition['isdel'] = 2;
			$condition['mmzl'] = $fangyuan['mmzl'];
			$condition['dizhi'] = $fangyuan['dizhi'];
			$condition['xiaoqu'] = $fangyuan['xiaoqu'];
			$condition['louceng'] = $fangyuan['louceng'];
			$condition['zlouceng'] = $fangyuan['zlouceng'];
			$cffy = M('fyshangpu')->where($condition)->find();
			if($cffy){
				$this->error('房源已存在，无法还原！');
			}
			if($fangyuan['isdel'] == 2){
				$this->error('房源已还原！');
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}

		//永久删除房源
		public function yjdelfy(){
			$id = I('id');
			$fangyuan = M('fyshangpu')->where(array('id'=>$id))->find();
			$is_rbac = _rbac_btn_show(767,$fangyuan['zhuangtai'],$fangyuan['weihurenid']);
			if (!$is_rbac) {
				$this->error("异常错误！");
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}

	}