<?php

	/*******************************************************************\
	|																	|
	|	房哨（多中介管理运营平台系统）									|
	|																	|
	|	© 2018-2023 http://www.kaidandashi.com/ All rights reserved.	|
	|																	|
	|	本系统由淮南市银泰软件科技有限公司提供技术支持					|
	|																	|
	|	QQ号：984784483													|
	|																	|
	\*******************************************************************/

	namespace Erpadmin\Controller;
	use Think\Controller;
	class ConfigController extends ErpadminbaseController {

		public function index() {
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				$this->site_info = k_get_option('site_info',1);
				$this->site_info = k_get_option('site_info',1);
				$this->fkyzt_config = k_get_option('fkyzt_config',1);
				$this->base_set = k_get_option('base_set',1);
				$this->within_wxapp_key = k_get_option('within_wxapp_key',1);
				if ($this->base_set['servicearea']) {
					$servicearea_str = $this->base_set['servicearea'];
					$servicecity_str = $this->base_set['servicecity'];
					$where['jjrxt_region.id'] = array('in',$servicecity_str);
					$where['jjrxt_xingzhengqu.id'] = array('in',$servicearea_str);
					$region = M('xingzhengqu')->join('jjrxt_region on jjrxt_xingzhengqu.pid=jjrxt_region.id')->where($where)->field('jjrxt_xingzhengqu.id,jjrxt_xingzhengqu.xzqming,jjrxt_region.name as regionname,jjrxt_xingzhengqu.pid')->select();
					$region_arr = array();
					foreach ($region as $key => $value) {
						$region_arr[] = $value['xzqming'] .'-'.$value['regionname'];
					}
					$this->region_str = implode(',',$region_arr);
				}
				$fkyzt = $this->fkyzt_config;
				$fkyzt['fygongpan_zhuangtai'] = $fkyzt['fygongpan_zhuangtai']?$fkyzt['fygongpan_zhuangtai']:0;
				$fkyzt['fysipan_zhuangtai'] = $fkyzt['fysipan_zhuangtai']?$fkyzt['fysipan_zhuangtai']:0;
				$fkyzt['kygongke_zhuangtai'] = $fkyzt['kygongke_zhuangtai']?$fkyzt['kygongke_zhuangtai']:0;
				$fkyzt['kysike_zhuangtai'] = $fkyzt['kysike_zhuangtai']?$fkyzt['kysike_zhuangtai']:0;
				$fyfpzt=$fkyzt['fyfengpan_zhuangtai'];
				$kyfpzt=$fkyzt['kyfengpan_zhuangtai'];
				$fyfpztids=explode(",",$fyfpzt);
				foreach ($fyfpztids as $key => $value) {
					$fyfpztid[$value]=$value;
				}
				$kyfpztids=explode(",",$kyfpzt);
				foreach ($kyfpztids as $key => $value) {
					$kyfpztid[$value]=$value;
				}
				$this->fyfpztid=$fyfpztid;
				$this->kyfpztid=$kyfpztid;
				$this->fyfpzt=M('peizhi')->where(" pzming = 'zhuangtai' and zhuangtai = 1 and lxid <> ".$fkyzt['fygongpan_zhuangtai']." and lxid <> ".$fkyzt['fysipan_zhuangtai'])->order('xsshunxu asc')->select();
				$this->kyfpzt=M('peizhi')->where(" pzming = 'khzhuangtai' and zhuangtai = 1 and lxid <> ".$fkyzt['kygongke_zhuangtai']." and lxid <> ".$fkyzt['kysike_zhuangtai'])->order('xsshunxu asc')->select();
				$this->display();
			}
		}

		public function setservicearea() {
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				$config_arr = k_get_option('base_set',1);
				$servicecity_str = $config_arr['servicecity'];
				if ($servicecity_str) {
					$this->region = M('region')->where(array('id'=>array('in',$servicecity_str)))->select();
				}
				$servicearea_str = $config_arr['servicearea'];
				if ($servicecity_str && $servicearea_str) {
					$where['jjrxt_region.id'] = array('in',$servicecity_str);
					$where['jjrxt_xingzhengqu.id'] = array('in',$servicearea_str);
					$this->area = M('xingzhengqu')->join('jjrxt_region on jjrxt_xingzhengqu.pid=jjrxt_region.id')->where($where)->field('jjrxt_xingzhengqu.id,jjrxt_xingzhengqu.xzqming,jjrxt_region.name as regionname,jjrxt_xingzhengqu.pid')->select();
				}
				$this->display();
			}
		}

		public function fkyzt_config() {
			if ((I('fychengjiao_zhuangtai') == I('fygongpan_zhuangtai')) || (I('fychengjiao_zhuangtai') == I('fysipan_zhuangtai')) || ((I('fygongpan_zhuangtai') == I('fysipan_zhuangtai')) && (I('fygongpan_zhuangtai') > 0) && (I('fysipan_zhuangtai') > 0))){
					$this->error('房源状态相同');
			}
			if ((I('kychengjiao_zhuangtai') == I('kygongke_zhuangtai')) || (I('kychengjiao_zhuangtai') == I('kysike_zhuangtai')) || ((I('kygongke_zhuangtai') == I('kysike_zhuangtai')) && (I('kygongke_zhuangtai') > 0) && (I('kysike_zhuangtai') > 0))){
				$this->error('客源状态相同');
			}
			$fyfpzt=I('fyfpzt');
			if ($fyfpzt) {
				foreach ($fyfpzt as $key => $value) {
					if (I('fygongpan_zhuangtai') == $value){
						$this->error('房源无效状态中有房源公盘状态');
					}
					if (I('fysipan_zhuangtai') == $value){
						$this->error('房源无效状态中有房源私盘状态');
					}
					$fyarr[]=$value;
				}
			}
			$fyids=implode(",",$fyarr);
			if (!in_array(I('fychengjiao_zhuangtai'), $fyarr)){
				$this->error('房源无效状态中没有房源成交状态');
			}
			$kyfpzt=I('kyfpzt');
			if ($kyfpzt) {
				foreach ($kyfpzt as $key => $value) {
					if (I('kygongke_zhuangtai') == $value){
						$this->error('客源无效状态中有客源公客状态');
					}
					if (I('kysike_zhuangtai') == $value){
						$this->error('客源无效状态中有客源私客状态');
					}
					$kyarr[]=$value;
				}
			}
			$kyids=implode(",",$kyarr);
			if (!in_array(I('kychengjiao_zhuangtai'), $kyarr)){
				$this->error('客源无效状态中没有客源成交状态');
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}

		public function within_wxapp_key() {
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}

	}