<?php

	/***************************************************************\
	|																|
	| 开单大师（专业的房产ERP管理系统）								|
	|																|
	| © 2018 http://www.kaidandashi.com All rights reserved.		|
	|																|
	| 本系统由淮南市银泰科技软件有限公司提供技术支持				|
	|																|
	| QQ号：1264399051												|
	|																|
	\***************************************************************/

	namespace Admin\Controller;
	use Think\Controller;
	class ZdxinxiController extends CommonController {
		//楼盘字典
		public function index(){
			$id=I('id');
			$this->xiaoquid=$id;
			$map .= " where gongsiid=".session('gongsiid');
			$x = _rbac_lists_where(503,0);
			if ($x && $x != "all" && $x != "me") {
				$map .= " and bumen in ({$x})";
			}elseif ($x == "me") {
				$map .= " and id=".session('uid');
			}elseif ($x == false) {
				$map .= " and id=0";
			}
			$list="select * from __ZDXINXI__ as a join (select id as e_id,ygmingcheng,bumen from __YONGHU__ {$map}) e on a.zerenrid=e.e_id where xqid=$id order by a.xsshunxu asc ";
			$zdxinxi=M('zdxinxi')->query($list);
			$this->assign('zdxinxi',$zdxinxi);
			$this->adduid=M('xiaoqu')->where(array('id'=>$id))->getField('adduid');
			$this->zdshu=M('zdxinxi')->where(array('gongsiid'=>session('gongsiid'),'xqid'=>$id))->count();
			$this->xianzhuang=M('peizhi')->where(array('pzming'=>'xianzhuang','zhuangtai'=>1))->order('xsshunxu asc')->select();
			$this->fjbackground=M('peizhi')->where(array('pzming'=>'fjbackground','zhuangtai'=>1))->order('xsshunxu asc')->select();
			$this->display();
		}
		//批量添加
		public function addpiliang(){
			$xqid=I('xqid');
			$zdid=I('zdid');
			$adduid=M('xiaoqu')->where(array('id'=>$xqid))->getField('adduid');
			$zerenrid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_node_show(505);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可添加楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->xqid=$xqid;
				$this->zdid=I('zdid');
				$this->dyid=I('dyid');
				$this->lcid=I('lcid');
				$this->xiaoqum=M('xiaoqu')->where(array('gongsiid'=>session('gongsiid'),'id'=>$xqid))->getField('xiaoqum');
				$this->zdming=M('zdxinxi')->where(array('gongsiid'=>session('gongsiid'),'id'=>I('zdid')))->getField('zdming');
				$this->dyming=M('dyxinxi')->where(array('gongsiid'=>session('gongsiid'),'id'=>I('dyid')))->getField('dyming');
				$this->lcming=M('lcxinxi')->where(array('gongsiid'=>session('gongsiid'),'id'=>I('lcid')))->getField('lcming');
				$this->zuodongdw=M('peizhi')->where(array('pzming'=>'zuodongdw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->loucengdw=M('peizhi')->where(array('pzming'=>'loucengdw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->fangjiandw=M('peizhi')->where(array('pzming'=>'fangjiandw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->fanghaopx=M('peizhi')->where(array('pzming'=>'fanghaopx','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//批量删除
		public function delpiliang(){
			$is_rbac = _rbac_node_show(586);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('学习版不可删除楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
		}
		//批量成交
		public function plchengjiao(){
			$is_rbac = _rbac_node_show(926);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('学习版不可添加楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
		}
		//批量改价
		public function plgaijia(){
			$is_rbac = _rbac_node_show(930);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$ids=I('ids');
			if (IS_POST) {
				$this->error('学习版不可更改房间价格！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->ids=$ids;
				$this->display();
			}
		}
		//批量设置户型
		public function hxpiliang(){
			$is_rbac = _rbac_node_show(878);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$ids=I('ids');
			$xqid=I('xqid');
			if (IS_POST) {
				$this->error('学习版不可更改房间户型！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->xqid=$xqid;
				$this->display();
			}
		}
		//添加座栋
		public function addzuodong(){
			$xqid=I('xqid');
			$adduid=M('xiaoqu')->where(array('id'=>$xqid))->getField('adduid');
			$is_rbac = _rbac_btn_show(506,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可添加楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->fwleixing=M('peizhi')->where(array('pzming'=>'fwleixing','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->jiegou=M('peizhi')->where(array('pzming'=>'jiegou','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->zhuangxiu=M('peizhi')->where(array('pzming'=>'zhuangxiu','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->zuodongdw=M('peizhi')->where(array('pzming'=>'zuodongdw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//更新座栋
		public function editzuodong(){
			$id=I('id');
			$adduid=M('zdxinxi')->where(array('id'=>$id))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(507,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可更新楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$zdxinxi=M("zdxinxi")->where(array('id'=>$id))->find();
				$this->zdxinxi=$zdxinxi;
				$select_categorys = bumen_option( $zdxinxi['zerenbmid'], 556);
				$this->assign("select_categorys", $select_categorys);
				$this->ygmingcheng=M('Yonghu')->where("gongsiid = ".session('gongsiid')." and lock1 = 0 and status = 1 and bumen=".$zdxinxi['zerenbmid'])->select();
				$this->fwleixing=M('peizhi')->where(array('pzming'=>'fwleixing','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->jiegou=M('peizhi')->where(array('pzming'=>'jiegou','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->zhuangxiu=M('peizhi')->where(array('pzming'=>'zhuangxiu','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->zuodongdw=M('peizhi')->where(array('pzming'=>'zuodongdw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//删除座栋
		public function delzuodong(){
			$id=I('id');
			$adduid=M('zdxinxi')->where(array('id'=>$id))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(508,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('学习版不可删除楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
		}
		//添加单元
		public function adddanyuan(){
			$zdid=I('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(509,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可添加楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->zdming=M('zdxinxi')->where(array('gongsiid'=>session('gongsiid'),'xqid'=>I('xqid'),'zdid'=>$zdid))->getField('zdming');
				$this->display();
			}
		}
		//更新单元
		public function editdanyuan(){
			$id=I('id');
			$zdid=M('dyxinxi')->where(array('id'=>$id))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(510,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可更新楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->dyxinxi=M("dyxinxi")->where(array('id'=>$id))->find();
				$this->display();
			}
		}
		//删除单元
		public function deldanyuan(){
			$id=I('id');
			$zdid=M('dyxinxi')->where(array('id'=>$id))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(511,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('学习版不可删除楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
		}
		//添加楼层
		public function addlouceng(){
			$zdid=I('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(512,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可添加楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->lcleixing=M('peizhi')->where(array('pzming'=>'lcleixing','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->loucengdw=M('peizhi')->where(array('pzming'=>'loucengdw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//更新楼层
		public function editlouceng(){
			$id=I('id');
			$zdid=M('lcxinxi')->where(array('id'=>$id))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(513,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可更新楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->lcxinxi=M("lcxinxi")->where(array('id'=>$id))->find();
				$this->lcleixing=M('peizhi')->where(array('pzming'=>'lcleixing','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->loucengdw=M('peizhi')->where(array('pzming'=>'loucengdw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//删除楼层
		public function dellouceng(){
			$id=I('id');
			$zdid=M("lcxinxi")->where(array('id'=>$id))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(514,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('学习版不可删除楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
		}
		//添加房间
		public function addfangjian(){
			$zdid=I('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(515,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可添加楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->fangjiandw=M('peizhi')->where(array('pzming'=>'fangjiandw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//更新房间
		public function editfangjian(){
			$id=I('id');
			$zdid=M("fjxinxi")->where(array('id'=>$id))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(516,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('学习版不可添加更新字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
			} else {
				$this->fjxinxi=M("fjxinxi")->where(array('id'=>$id))->find();
				$this->fangjiandw=M('peizhi')->where(array('pzming'=>'fangjiandw','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//删除房间
		public function delfangjian(){
			$id=I('id');
			$lcid=M("fjxinxi")->where(array('id'=>$id))->getField('lcid');
			$zdid=M("fjxinxi")->where(array('id'=>$id))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(517,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('学习版不可删除楼盘字典！请申请试用、采购正式版或联系销售经理：170-9573-9404！');
		}
		/**
		* webuploader 显示图片上传框
		*/
		public function photo() {
			$fjid=I('fjid');
			$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			if (I('fjtp')==1) {
				$is_rbac = _rbac_btn_show(526,0,$adduid);
				if (!$is_rbac) {
					$this->redirect('Index/error');
				}
				$list="select * from (select * from __FJPHOTO__ where fjid=$fjid ) as a left join (select id as yhid,ygmingcheng from __YONGHU__ ) as b on a.uid=b.yhid order by a.create_time DESC ";
				$photo=M('fjphoto')->query($list);
				if ($photo) {
					$pzming='zztplx';
				}
				foreach ($photo as &$value) {
					if ($value['leixing']) {
						$temp = get_peizhi($pzming,$value['leixing']);
					}
					$value['lxming'] = $temp?$temp:'未设置图片类型';
				}
				$this->assign('photo',$photo);
				$this->zerenrid=$adduid;
				$this->display();
			} elseif (I('sctp')==1) {
				$is_rbac = _rbac_btn_show(527,0,$adduid);
				if (!$is_rbac) {
					$this->redirect('Index/error');
				}
				$this->display();
			}
		}
		/**
		* webuploader 上传文件
		*/
		public function ajax_upload(){
			$fjid=I('fjid');
			$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(527,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			// 根据自己的业务调整上传路径、允许的格式、文件大小
			$path = "/Upload/".session('gongsiid')."/xiaoqu/fangjian/".$fjid;
			ajax_upload_fj($path);
		}
		/**
		* [fj_pic_setfengmian 异步房间图片为封面]
		* @return [json] [description]
		*/
		public function fj_pic_setfengmian(){
			$id=I('fj_pic_id');
			//根据图片id查找房间图片的房间id号fjid
			$fjid = M('fjphoto')->where(array('id'=>$id))->getField('fjid');
			$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(528,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			M('fjphoto')->where(array('fjid'=>$fjid,'fengmian'=>1))->setField(array('fengmian'=>0));
			$r = M('fjphoto')->where(array('id'=>$id))->setField(array('fengmian'=>1));
			if ($r) {
				$this->success('设置成功');
			}else{
				$this->error('设置失败');
			}
		}
		/**
		* [fj_pic_del 异步删除图片]
		* @return [json] [description]
		*/
		public function fj_pic_del(){
			$id=I('fj_pic_id');
			//根据图片id查看当前是否还有当前房间的图片
			$fjid = M('fjphoto')->where(array('id'=>$id))->getField('fjid');
			$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(529,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$piccount = M('fjphoto')->where(array('fjid'=>$fjid))->count();
			$dp=M('fjphoto');
			if($id){    //删除当前图片
				$plist = $dp->where(array('id'=>$id))->find();
				if ($plist){
					unlink('./Upload/'.$plist['gongsiid'].'/xiaoqu/fangjian/'.$plist['fjid'].'/'.$plist['image']);
					unlink('./Upload/'.$plist['gongsiid'].'/xiaoqu/fangjian/'.$plist['fjid'].'/t_'.$plist['image']);
					$dp->where(array('id'=>$id))->delete();
					$data=array('pics'=>$plist);
					//删除最后一个房间图片后给xiaoqu表的tupian字段置 0
					if ($piccount==1) {
						M('fjxinxi')->where(array('id'=>$fjid))->setField('tupian',0);
					}
				}else{
					$data=array('pics'=>$plist);
				}
			}
			//返回值
			header("Content-type: application/json");
			exit(json_encode($data));
		}
		//批量删除房间图片
		public function fj_pic_dels(){
			$is_rbac = _rbac_node_show(530);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$ids=I('fj_pic_ids');
			foreach ($ids as $key => $value) {
				$fjid = M('fjphoto')->where(array('id'=>$ids[$key]))->getField('fjid');
				$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
				$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
				$is_rbac = _rbac_btn_show(530,0,$adduid);
				if (!$is_rbac) {
					$this->error("您选择了权限范围之外的图片！");
				}
			}
			if(is_array($ids)){
				$where = 'id in('.implode(',',$ids).')';//p($where);die;
				//获取当前图片的房间id
				$fjid = M('fjphoto')->where(array('id'=>$ids[0]))->getField('fjid');
				$dp=M('fjphoto');
				foreach ($ids as $value) {//删除房间图片文件
					$plist = $dp->where(array('id'=>$value))->find();
					unlink('./Upload/'.$plist['gongsiid'].'/xiaoqu/fangjian/'.$plist['fjid'].'/'.$plist['image']);
					unlink('./Upload/'.$plist['gongsiid'].'/xiaoqu/fangjian/'.$plist['fjid'].'/t_'.$plist['image']);
				}
				$dp->where($where)->delete();
				//删除最后一个房间图片后给fjxinxi表的tupian字段置 0
				$nopic = M('fjphoto')->where(array('fjid'=>$fjid))->count();
				if ($nopic<=0) {
					M('fjxinxi')->where(array('id'=>$fjid))->setField('tupian',0);
				}
				$this->success('删除成功');
			}else{
				$this->error('删除失败'); 
			}
		}
		//批量下载房间图片
		public function fj_pic_downloads(){
			$is_rbac = _rbac_node_show(531);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$ids=I('fj_pic_ids');
			foreach ($ids as $key => $value) {
				$fjid = M('fjphoto')->where(array('id'=>$ids[$key]))->getField('fjid');
				$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
				$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
				$is_rbac = _rbac_btn_show(531,0,$adduid);
				if (!$is_rbac) {
					$this->error("您选择了权限范围之外的图片！");
				}
			}
			$where = 'id in('.implode(',',$ids).')';
			$dp=M('fjphoto');
			$plist = $dp->where($where)->field('id,gongsiid,fjid,image')->select();
			$zip = new \ZipArchive; 
			if ($plist) {
				//压缩文件名(临时文件)
				$filename = './Upload/'.$plist[0]['gongsiid'].'/xiaoqu/fangjian/'.$plist[0]['fjid'].'/'.md5($plist[0]['fjid']).'.zip';
				$downname = I("server.HTTP_HOST").'/Upload/'.$plist[0]['gongsiid'].'/xiaoqu/fangjian/'.$plist[0]['fjid'].'/'.md5($plist[0]['fjid']).'.zip';
				//p($downname);die;
			}
			//新建zip压缩包
			$zip->open($filename,\ZipArchive::OVERWRITE | \ZipArchive::CREATE);
			//把图片一张一张加进去压缩
			foreach ($plist as $value) {
				$zip->addFile('./Upload/'.$value['gongsiid'].'/xiaoqu/fangjian/'.$value['fjid'].'/'.$value['image']);
				$zip->renameName('./Upload/'.$value['gongsiid'].'/xiaoqu/fangjian/'.$value['fjid'].'/'.$value['image'],$value['image']);
			}
			//打包zip
			$zip->close();
			//可以直接重定向下载
			//header('Location:'.$downname);
			$this->success($downname);
		}
		//设置图片类型
		public function settupianleixing(){
			$is_rbac = _rbac_node_show(532);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			if (IS_POST) {
				$ids=explode(",",I('fj_pic_ids'));
				foreach ($ids as $key => $value) {
					$fjid = M('fjphoto')->where(array('id'=>$ids[$key]))->getField('fjid');
					$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
					$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
					$is_rbac = _rbac_btn_show(532,0,$adduid);
					if (!$is_rbac) {
						$this->error("您选择了权限范围之外的图片！");
					}
				}
				$ids1=I('fj_pic_ids');
				$tpleixing = I('tpleixing');
				if ($tpleixing=="") {
					$this->error("请选择图片类型");
				}
				$where = 'id in('.$ids1.')';
				$dp=M('fjphoto');
				$plist = $dp->where($where)->setField(array('leixing' => $tpleixing ));
				if ($plist) {
					$this->success("设置成功");
				}else{
					$this->error("设置失败");
				}
			} else {
				$this->tpleixing = M('Peizhi')->where(array('pzming'=>'zztplx','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();// 输出模板
			}
		}
		//设置全景地址
		public function quanjing(){
			$fjid=I('fjid');
			$zdid=M('fjxinxi')->where(array('id'=>$fjid))->getField('zdid');
			$adduid=M('zdxinxi')->where(array('id'=>$zdid))->getField('zerenrid');
			$is_rbac = _rbac_btn_show(850,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$isok=M('fjxinxi')->where(array('id'=>$fjid))->setField('url',I('url'));
				if ($isok) {
					$this->success('设置成功');
				}else{
					$this->error('设置失败');
				}
			} else {
				$this->fangjian=M('fjxinxi')->where(array('id'=>$fjid,'gongsiid'=>session('gongsiid')))->field('id,url')->find();
				$this->display();
			}
		}
		// 户型管理
		public function huxing(){
			$is_rbac = _rbac_node_show(841);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			$xqid=I('xqid');
			$condition="gongsiid=".session('gongsiid');
			$condition.=" and xqid=$xqid";
			$sousuo=I('sousuo');
			if ($sousuo) {
				$condition.=" and ((hxbiaoti like '%$sousuo%') or (hxbianhao like '%$sousuo%'))";
			}
			$count=M('huxing')->query("select count(*) from __HUXING__ where {$condition}");
			$Page=new \Think\Page($count['0']['count(*)'],30);
			$show=$Page->show();
			$list="select a.id,a.hxbiaoti,a.hxbianhao,a.shi,a.ting,a.wei,a.chu,a.yangtai,a.jzmianji,a.symianji,a.remark,a.adduid,a.addtime,b.cxming,c.zxming,e.tjren from (select * from __HUXING__ where {$condition} order by addtime desc limit ".$Page->firstRow.','.$Page->listRows.") a left join (select lxid as b_id,lxming as cxming from __PEIZHI__ where pzming = 'chaoxiang' ) b on a.chaoxiang=b.b_id left join (select lxid as c_id,lxming as zxming from __PEIZHI__ where pzming = 'zhuangxiu' ) c on a.zhuangxiu=c.c_id left join (select id as e_id,ygmingcheng as tjren from __YONGHU__) e on a.adduid=e.e_id ";
			$huxing=M('huxing')->query($list);
			$this->assign('firstRow',$Page->firstRow);
			$this->assign('xqid',$xqid);
			$this->assign('huxing',$huxing);
			$this->assign('count',$count);
			$this->assign('page',$show);
			$this->display();
		}
		// 添加户型
		public function addhuxing(){
			$is_rbac = _rbac_btn_show(842,0);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$bh=M('bianhao')->where(array('id'=>4))->setInc('bianhao');
				$bh1=M('bianhao')->where(array('id'=>4))->getField('bianhao');
				$xqid=I('xqid');
				$shi=I('shi');
				$ting=I('ting');
				$wei=I('wei');
				$chu=I('chu');
				$yangtai=I('yangtai');
				$jzmianji=I('jzmianji');
				$symianji=I('symianji');
				$fwzongjia=I('fwzongjia');
				$chaoxiang=I('chaoxiang');
				$zhuangxiu=I('zhuangxiu');
				if (!$shi) {
					$this->error('请输入户型室！');
				}
				if (!$ting) {
					$this->error('请输入户型厅！');
				}
				if (!$jzmianji) {
					$this->error('请输入建筑面积！');
				}
				if (!$fwzongjia) {
					$this->error('请输入房屋总价！');
				}
				if(!preg_match("/^([1-9]{1})$|^(1[0]{1})$/",$shi) || !preg_match("/^([1-9]{1})$|^(1[0]{1})$/",$ting) || !preg_match("/^$|^([1-9]{1})$|^(1[0]{1})$/",$wei) || !preg_match("/^$|^([1-9]{1})$|^(1[0]{1})$/",$chu) || !preg_match("/^$|^([1-9]{1})$|^(1[0]{1})$/",$yangtai)){
					$this->error('户型请输入＞0≤10的整数！');
				}
				if ($jzmianji || $symianji) {
					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})?$/",$jzmianji)) || (!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})?$/",$symianji))){
						$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})?$/",$fwzongjia)){
					$this->error('房屋总价请输入＞0且≤十亿的数字（限六位小数）！');
				}
				$condition['gongsiid']=session('gongsiid');
				$condition['xqid']=$xqid;
				$condition['shi']=$shi;
				$condition['ting']=$ting;
				$condition['wei']=$wei;
				$condition['chu']=$chu;
				$condition['yangtai']=$yangtai;
				$condition['jzmianji']=$jzmianji;
				$condition['symianji']=$symianji;
				$condition['fwzongjia']=$fwzongjia;
				$condition['chaoxiang']=$chaoxiang;
				$condition['zhuangxiu']=$zhuangxiu;
				$condition['fwdanjia']=$fwzongjia*10000/$jzmianji;
				$cfxzq=M('huxing')->where($condition)->find();
				if($cfxzq){
					$this->error('户型已存在');
				}
				$data['xqid']=$xqid;
				$data['shi']=$shi;
				$data['ting']=$ting;
				$data['wei']=$wei;
				$data['chu']=$chu;
				$data['yangtai']=$yangtai;
				$data['jzmianji']=$jzmianji;
				$data['symianji']=$symianji;
				$data['fwzongjia']=$fwzongjia;
				$data['chaoxiang']=$chaoxiang;
				$data['zhuangxiu']=$zhuangxiu;
				$data['fwdanjia']=$fwzongjia*10000/$jzmianji;
				$data['remark']=I('remark');
				$data['hxbianhao']="HX-".$bh1;
				$data['hxbiaoti']=I('hxbiaoti');
				$data['addtime']=time();
				$data['adduid']=session('uid');
				$data['gongsiid']=session('gongsiid');
				$isok=M('huxing')->add($data);
				if ($isok) {
					$this->success('添加成功');
				}else{
					$this->error('添加失败');
				}
			} else {
				$this->chaoxiang = M('Peizhi')->where(array('pzming'=>'chaoxiang','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->zhuangxiu = M('Peizhi')->where(array('pzming'=>'zhuangxiu','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		// 更新户型
		public function edithuxing(){
			$id=I('id');
			$adduid=M('huxing')->where(array('id'=>$id))->getField('adduid');
			$is_rbac = _rbac_btn_show(843,0,$adduid);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$hxjzmj=M('huxing')->where(array('id'=>$id))->getField('jzmianji');
				$ydfj=M('fjxinxi')->where(array('hxid'=>$id,'xianzhuang'=>2))->count();
				if ($ydfj > 0) {
					$ydfjts=$ydfj."个已预定房屋！";
				}
				$cjfj=M('fjxinxi')->where(array('hxid'=>$id,'xianzhuang'=>4))->count();
				if ($cjfj > 0) {
					$cjfjts=$cjfj."个已成交房屋！";
				}
				$cfyd=M('fjyd')->where(array('type'=>3))->field('fjid')->select();
				$cfyd1=implode(",",$cfyd);
				$ydshz=M('fjxinxi')->where(array('hxid'=>$id,'id'=>array('in',$cfyd1)))->count();
				$ydshzfj=M('fjxinxi')->where(array('hxid'=>$id,'id'=>array('in',$cfyd1)))->field('xianzhuang,bianhao')->select();
				foreach ($ydshzfj as $key => $value) {
					if ($value['xianzhuang'] != 1) {
						$ydfjxzyc.=$value['xianzhuang']."；";
					}
				}
				if ($ydshz > 0) {
					if ($ydfjxzyc) {
						$ydshzts=$ydshz."个预定待审核房屋（其中".$ydfjxzyc."现状异常）！";
					} else {
						$ydshzts=$ydshz."个预定待审核房屋！";
					}
				}
				$cfcj=M('chengjiao')->where(array('zhuangtai'=>3))->field('fybianhao')->select();
				$cfcj1=implode(",",$cfcj);
				$cjshz=M('fjxinxi')->where(array('hxid'=>$id,'bianhao'=>array('in',$cfcj1)))->count();
				$cjshzfj=M('fjxinxi')->where(array('hxid'=>$id,'bianhao'=>array('in',$cfcj1)))->field('xianzhuang,bianhao')->select();
				foreach ($cjshzfj as $key => $value) {
					if ($value['xianzhuang'] != 1) {
						$cjfjxzyc.=$value['xianzhuang']."；";
					}
				}
				if ($cjshz > 0) {
					if ($cjfjxzyc) {
						$cjshzts=$cjshz."个成交待审核房屋（其中".$cjfjxzyc."现状异常）！";
					} else {
						$cjshzts=$cjshz."个成交待审核房屋！";
					}
				}
				$yccwts="此户型下存在：".$ydshzts.$ydfjts.$cjfjxzyc.$cjfjts;
				if ($ydshzts || $ydfjts || $cjfjxzyc || $cjfjts) {
					$this->error($yccwts);
				}
				$xqid=I('xqid');
				$shi=I('shi');
				$ting=I('ting');
				$wei=I('wei');
				$chu=I('chu');
				$yangtai=I('yangtai');
				$jzmianji=I('jzmianji');
				$symianji=I('symianji');
				$fwzongjia=I('fwzongjia');
				$chaoxiang=I('chaoxiang');
				$zhuangxiu=I('zhuangxiu');
				if (!$shi) {
					$this->error('请输入户型室！');
				}
				if (!$ting) {
					$this->error('请输入户型厅！');
				}
				if (!$jzmianji) {
					$this->error('请输入建筑面积！');
				}
				if (!$fwzongjia) {
					$this->error('请输入房屋总价！');
				}
				if(!preg_match("/^([1-9]{1})$|^(1[0]{1})$/",$shi) || !preg_match("/^([1-9]{1})$|^(1[0]{1})$/",$ting) || !preg_match("/^$|^([1-9]{1})$|^(1[0]{1})$/",$wei) || !preg_match("/^$|^([1-9]{1})$|^(1[0]{1})$/",$chu) || !preg_match("/^$|^([1-9]{1})$|^(1[0]{1})$/",$yangtai)){
					$this->error('户型请输入＞0≤10的整数！');
				}
				if ($jzmianji || $symianji) {
					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})?$/",$jzmianji)) || (!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})?$/",$symianji))){
						$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})?$/",$fwzongjia)){
					$this->error('房屋总价请输入＞0且≤十亿的数字（限六位小数）！');
				}
				$condition['gongsiid']=session('gongsiid');
				$condition['id']=array('neq',$id);
				$condition['xqid']=$xqid;
				$condition['shi']=$shi;
				$condition['ting']=$ting;
				$condition['wei']=$wei;
				$condition['chu']=$chu;
				$condition['yangtai']=$yangtai;
				$condition['jzmianji']=$jzmianji;
				$condition['symianji']=$symianji;
				$condition['fwzongjia']=$fwzongjia;
				$condition['chaoxiang']=$chaoxiang;
				$condition['zhuangxiu']=$zhuangxiu;
				$condition['fwdanjia']=round($fwzongjia/$jzmianji*10000,2);
				$cfxzq=M('huxing')->where($condition)->find();
				if($cfxzq){
					$this->error('户型已存在');
				}
				$data['shi']=$shi;
				$data['ting']=$ting;
				$data['wei']=$wei;
				$data['chu']=$chu;
				$data['yangtai']=$yangtai;
				$data['jzmianji']=$jzmianji;
				$data['symianji']=$symianji;
				$data['fwzongjia']=$fwzongjia;
				$data['chaoxiang']=$chaoxiang;
				$data['zhuangxiu']=$zhuangxiu;
				$data['fwdanjia']=round($fwzongjia/$jzmianji*10000,2);
				$data['remark']=I('remark');
				$data['hxbiaoti']=I('hxbiaoti');
				$data['addtime']=time();
				$data['adduid']=session('uid');
				$data['gongsiid']=session('gongsiid');
				$isok=M("huxing")->where(array('id'=>$id))->save($data);
				if ($isok){
					if ($hxjzmj != $jzmianji) {
						$fjxxbd=M('fjxinxi')->where(array('hxid'=>$id))->field('id,zongjia')->select();
						foreach ($fjxxbd as $key => $value) {
							$fjdj=round($value['zongjia']/$jzmianji*10000,2);
							M('fjxinxi')->where(array('id'=>$value['id']))->setField('danjia',$fjdj);
						}
					}
					$this->success('更新成功');
				}else{
					$this->error('更新失败');
				}
			} else {
				$this->huxing=M('huxing')->where(array('id'=>$id))->find();
				$this->chaoxiang = M('Peizhi')->where(array('pzming'=>'chaoxiang','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->zhuangxiu = M('Peizhi')->where(array('pzming'=>'zhuangxiu','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		// 删除户型
		public function delhuxing(){
			$id=I('id');
			$fjs=M('fjxinxi')->where(array('hxid'=>$id))->count();
			if ($fjs > 0) {
				$this->error('此户型下存在'.$fjs.'个房屋！');
			}
			$adduid=M('huxing')->where(array('id'=>$id))->getField('adduid');
			$is_rbac = _rbac_btn_show(844,0,$adduid);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$isok=M('huxing')->where(array('id'=>$id))->delete();
			if ($isok){
				$this->success('删除成功');
			}else{
				$this->error('删除失败');
			}
		}
		//上传户型图片
		public function schxtp(){
			$hxid=I('hxid');
			$huxing=M('huxing')->where(array('id'=>$hxid))->field('hxbianhao,adduid')->find();
			$is_rbac = _rbac_btn_show(865,0,$huxing['adduid']);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$path = "./Upload/".session('gongsiid')."/xiaoqu/huxing/".$huxing['hxbianhao'];
				if (!file_exists($path)){
					mkdir($path);
				}
				$upload = new \Think\Upload();
				$upload->maxSize	=	5242880 ;
				$upload->exts		=	array('jpg','jpeg','png');
				$upload->rootPath	=	$path.'/';
				$upload->savePath	=	'';
				$upload->autoSub	=	false;
				$info = $upload->upload();
				if (!$info) {
					$this->error($upload->getError());
				} else {
					$data['gongsiid'] = session('gongsiid');
					$data['adduid'] = session('uid');
					$data['addtime'] = time();
					$data['data_id'] = $hxid;
					$data['data_table'] = "huxing";
					$data['img_path'] = '/Upload/'.session('gongsiid').'/xiaoqu/huxing/'.$huxing['hxbianhao'].'/'.$info['file']['savename'];
					$data['img_name'] = $info['file']['savename'];
					$isok=M('photos')->add($data);
					$xiugai.="上传了户型".$huxing['hxbianhao']."的图片";
					$data_rizhi['zy_type']=1;
					$data_rizhi['uid']=session("uid");
					$data_rizhi['addtime']=time();
					$data_rizhi['cz_type']=12;
					$data_rizhi['zy_id']=$hxid;
					$data_rizhi['neirong']=$xiugai;
					M('rizhi')->add($data_rizhi);
					$this->success('上传成功');
				}
			}else{
				$this->hxid=$hxid;
				$this->display();
			}
		}
		//查看户型图片
		public function ckhxtp(){
			$hxid=I('hxid');
			$map="gongsiid=".session('gongsiid');
			$x = _rbac_lists_where(866,0);
			if ($x && $x != "all" && $x != "me") {
				$map .= " and bumen in ({$x})";
			}elseif ($x == "me") {
				$map .= " and id=".session('uid');
			}elseif ($x == false) {
				$map .= " and id=0";
			}
			$condition="gongsiid=".session('gongsiid');
			$condition.=" and data_id=$hxid";
			$condition.=" and data_table='huxing'";
			$list="select * from (select * from __PHOTOS__ where {$condition}) a join (select id as yhid,ygmingcheng from __YONGHU__ where {$map}) b on a.adduid=b.yhid order by a.addtime DESC ";
			$photo=M('photos')->query($list);
			if ($photo) {
				$pzming='hxtplx';
			}
			foreach ($photo as &$value) {
				if ($value['data_type']) {
					$temp = get_peizhi($pzming,$value['data_type']);
				}
				$value['data_type'] = $temp?$temp:'未设置图片类型';
			}
			$this->assign('photo',$photo);
			$this->display();
		}
		//设置户型封面
		public function szhxfm(){
			$id=I('hx_pic_id');
			$hxid = M('photos')->where(array('id'=>$id))->getField('data_id');
			$huxing=M('huxing')->where(array('id'=>$hxid))->field('adduid,hxbianhao')->find();
			$is_rbac = _rbac_btn_show(867,0,$huxing['adduid']);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			M('photos')->where(array('data_id'=>$hxid,'data_fengmian'=>1))->setField(array('data_fengmian'=>0));
			$isok = M('photos')->where(array('id'=>$id))->setField(array('data_fengmian'=>1));
			if ($isok) {
				$xiugai.="设置了户型".$huxing['hxbianhao']."的封面";
				$data_rizhi['zy_type']=1;
				$data_rizhi['uid']=session("uid");
				$data_rizhi['addtime']=time();
				$data_rizhi['cz_type']=25;
				$data_rizhi['zy_id']=$hxid;
				$data_rizhi['neirong']=$xiugai;
				M('rizhi')->add($data_rizhi);
				$this->success('设置成功');
			}else{
				$this->error('设置失败');
			}
		}
		//删除户型图片
		public function hxtp_pic_del(){
			$id=I('hxtp_pic_id');
			$hxtp=M('photos')->where(array('id'=>$id))->field('adduid,img_path,data_id')->find();
			$hxbh = M('huxing')->where(array('id'=>$hxtp['data_id']))->getField('hxbianhao');
			$is_rbac = _rbac_btn_show(868,0,$hxtp['adduid']);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			if ($hxtp){
				unlink('.'.$hxtp['img_path']);
				M('photos')->where(array('id'=>$id))->delete();
				$xiugai.="删除了户型".$hxbh."的图片";
				$data_rizhi['zy_type']=1;
				$data_rizhi['uid']=session("uid");
				$data_rizhi['addtime']=time();
				$data_rizhi['cz_type']=13;
				$data_rizhi['zy_id']=$hxtp['data_id'];
				$data_rizhi['neirong']=$xiugai;
				M('rizhi')->add($data_rizhi);
				$this->success('删除成功');
			}else{
				$this->error('删除失败');
			}
		}
		//批量删除户型图片
		public function hxtp_pic_dels(){
			$ids=I('hxtp_pic_ids');
			foreach ($ids as $key => $value) {
				$hxtp = M('photos')->where(array('id'=>$ids[$key]))->field('adduid,data_id')->find();
				$is_rbac = _rbac_btn_show(869,0,$hxtp['adduid']);
				if (!$is_rbac) {
					$this->error("您选择了权限范围之外的图片！");
				}
				$hxid = $hxtp['data_id'];
				$hxbh = M('huxing')->where(array('id'=>$hxtp['data_id']))->getField('hxbianhao');
			}
			if(is_array($ids)){
				$where = 'id in('.implode(',',$ids).')';
				$dp=M('photos');
				foreach ($ids as $value) {
					$plist = $dp->where(array('id'=>$value))->find();
					unlink('.'.$plist['img_path']);
				}
				$dp->where($where)->delete();
				$xiugai.="删除了户型".$hxbh."的".count($ids)."张图片";
				$data_rizhi['zy_type']=1;
				$data_rizhi['uid']=session("uid");
				$data_rizhi['addtime']=time();
				$data_rizhi['cz_type']=13;
				$data_rizhi['zy_id']=$hxid;
				$data_rizhi['neirong']=$xiugai;
				M('rizhi')->add($data_rizhi);
				$this->success('删除成功');
			}else{
				$this->error('删除失败');
			}
		}
		//批量下载户型图片
		public function hxtp_pic_downloads(){
			$ids=I('hxtp_pic_ids');
			foreach ($ids as $key => $value) {
				$hxtp = M('photos')->where(array('id'=>$ids[$key]))->field('adduid,data_id')->find();
				$is_rbac = _rbac_btn_show(871,0,$hxtp['adduid']);
				if (!$is_rbac) {
					$this->error("您选择了权限范围之外的图片！");
				}
				$hxid = $hxtp['data_id'];
				$hxbh = M('huxing')->where(array('id'=>$hxtp['data_id']))->getField('hxbianhao');
			}
			$where = 'id in('.implode(',',$ids).')';
			$dp=M('photos');
			$plist = $dp->where($where)->field('img_path,img_name')->select();
			$zip = new \ZipArchive;
			if ($plist) {
				$filename = './Upload/'.session('gongsiid').'/xiaoqu/huxing/'.$hxbh.'/'.md5(time()).'.zip';
				$downname = I("server.HTTP_HOST").'/Upload/'.session('gongsiid').'/xiaoqu/huxing/'.$hxbh.'/'.md5(time()).'.zip';
			}
			$zip->open($filename,\ZipArchive::OVERWRITE | \ZipArchive::CREATE);
			if ($zip) {
				foreach ($plist as $value) {
					$zip->addFile('.'.$value['img_path']);
					$zip->renameName('.'.$value['img_path'],$value['img_name']);
				}
				$zip->close();
				$xiugai.="下载了户型".$hxbh."的".count($ids)."张图片";
				$data_rizhi['zy_type']=1;
				$data_rizhi['uid']=session("uid");
				$data_rizhi['addtime']=time();
				$data_rizhi['cz_type']=20;
				$data_rizhi['zy_id']=$hxid;
				$data_rizhi['neirong']=$xiugai;
				M('rizhi')->add($data_rizhi);
				$this->success($downname);
			} else {
				$this->error('压缩失败'); 
			}
		}
		//设置图片类型
		public function szhxtp(){
			$is_rbac = _rbac_node_show(870);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			if (IS_POST) {
				$ids=explode(",",I('hxtp_pic_ids'));
				foreach ($ids as $key => $value) {
					$hxtp = M('photos')->where(array('id'=>$ids[$key]))->field('adduid,data_id')->find();
					$is_rbac = _rbac_btn_show(870,0,$hxtp['adduid']);
					if (!$is_rbac) {
						$this->error("您选择了权限范围之外的图片！");
					}
					$hxid = $hxtp['data_id'];
					$hxbh = M('huxing')->where(array('id'=>$hxtp['data_id']))->getField('hxbianhao');
				}
				$ids1=I('hxtp_pic_ids');
				$tpleixing = I('tpleixing');
				if ($tpleixing=="") {
					$this->error("请选择图片类型");
				}
				$where = 'id in('.$ids1.')';
				$dp=M('photos');
				$plist = $dp->where($where)->setField(array('data_type' => $tpleixing ));
				if ($plist) {
					$xiugai.="设置了户型".$hxbh."的".count($ids1)."张图片类型";
					$data_rizhi['zy_type']=1;
					$data_rizhi['uid']=session("uid");
					$data_rizhi['addtime']=time();
					$data_rizhi['cz_type']=25;
					$data_rizhi['zy_id']=$hxid;
					$data_rizhi['neirong']=$xiugai;
					M('rizhi')->add($data_rizhi);
					$this->success("设置成功");
				}else{
					$this->error("设置失败");
				}
			} else {
				$this->tpleixing = M('Peizhi')->where(array('pzming'=>'hxtplx','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();// 输出模板
			}
		}
	}
?>