<?php

	/***************************************************************\
	|																|
	|	开单大师（专业的房产ERP管理系统）							|
	|																|
	|	© 2017-2022 淮南市银泰软件科技有限公司 All rights reserved	|
	|																|
	|	http://www.kaidandashi.com									|
	|																|
	|	QQ号：984784483												|
	|																|
	\***************************************************************/

	namespace Admin\Controller;
	use Think\Controller;
	class PeizhiController extends CommonController {
		//配置列表
		public function Peizhi(){
			$is_rbac = _rbac_node_show(92);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			$condition = "zhuangtai = 1";
			$pzfl=I('pzfl');
			$sousuo=I('sousuo');
			if ($pzfl) {
				$condition.=" and pzfl=$pzfl";
			}
			if ($sousuo) {
				$condition.=" and ((pzming like '%$sousuo%') or (zhushi like '%$sousuo%'))";
			}
			$count=M('peizhi')->query("select count(*) from (select count(*) from jjrxt_peizhi where {$condition} group by pzming) a");
			$Page = new \Think\Page($count['0']['count(*)'],20);
			$show = $Page->show();
			$list="select a.*,b.pzflm from (select max(id) as id,pzming,zhushi,pzfl from __PEIZHI__ where {$condition} group by pzming) a left join (select lxid as b_id,lxming as pzflm from __PEIZHI__ where pzming = 'pzfl') b on a.pzfl=b.b_id order by a.id DESC limit ".$Page->firstRow.','.$Page->listRows;
			$Peizhi=M('peizhi')->query($list);
			$this->assign('firstRow',$Page->firstRow);
			$this->assign('peizhi',$Peizhi);
			$this->assign('count',$count);
			$this->assign('page',$show);
			$this->pzfl=M('Peizhi')->where(array('pzming'=>'pzfl','zhuangtai'=>1))->order('xsshunxu asc')->select();
			$this->display();
		}
		//添加配置
		public function addPeizhi(){
			$is_rbac = _rbac_node_show(93);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			}else{
				$this->pzfl=M('Peizhi')->where(array('pzming'=>'pzfl','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//更新配置
		public function editPeizhi(){
			$is_rbac = _rbac_node_show(95);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			}else{
				$this->peizhi=M('Peizhi')->where(array('id'=>I('id')))->field('id,pzming,zhushi,pzfl')->find();
				$this->pzfl=M('Peizhi')->where(array('pzming'=>'pzfl','zhuangtai'=>1))->order('xsshunxu asc')->select();
				$this->display();
			}
		}
		//删除配置
		public function delPeizhi(){
			$is_rbac = _rbac_node_show(97);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}
		//配置设置列表
		public function Pzshezhi(){
			$is_rbac = _rbac_node_show(421);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			$condition = "zhuangtai = 1";
			$pzfl=I('pzfl');
			$sousuo=I('sousuo');
			if ($pzfl) {
				$condition.=" and pzfl=$pzfl";
			}
			if ($sousuo) {//搜索
				$condition.=" and ((pzming like '%$sousuo%') or (zhushi like '%$sousuo%'))";
			}
			$count=M('peizhi')->query("select count(*) from (select count(*) from jjrxt_peizhi where {$condition} group by pzming) a");
			$Page=new \Think\Page($count['0']['count(*)'],15);
			$show=$Page->show();
			$list="select max(id),pzming,zhushi from jjrxt_peizhi where {$condition} group by pzming order by id DESC limit ".$Page->firstRow.','.$Page->listRows;
			$Peizhi=M('peizhi')->query($list);
			$this->assign('peizhi',$Peizhi);
			$this->assign('count',$count);
			$this->assign('page',$show);
			$this->pzfl=M('Peizhi')->where(array('pzming'=>'pzfl','zhuangtai'=>1))->order('xsshunxu asc')->select();
			$this->display();
		}
		//添加配置类型
		public function addPzshezhi(){
			$is_rbac = _rbac_node_show(423);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				$this->peizhi=M('peizhi')->where(array('id'=>I('id')))->find();
				$this->display();
			}
		}
		//更新配置类型
		public function editPzshezhi(){
			$is_rbac = _rbac_node_show(425);
			if (!$is_rbac) {
				$this->redirect('Index/error');
			}
			if (IS_POST) {
				$this->error('请联系客服（19965783436）获取正式版功能！');
			} else {
				$this->peizhi=M('peizhi')->where(array('id'=>I('id')))->find();
				$this->display();
			}
		}
		//删除配置类型
		public function delPzshezhi(){
			$is_rbac = _rbac_node_show(427);
			if (!$is_rbac) {
				$this->error('异常错误！');
			}
			$this->error('请联系客服（19965783436）获取正式版功能！');
		}
	}