<?php

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

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

    public function chengjiao(){
        if (IS_POST) {
            $this->error('请联系客服（19965783436）获取正式版功能！');
        }else{
            $chengjiao_options=M('options')->where(array('option_name'=>'chengjiao_options'))->find();
            $options_arr = json_decode($chengjiao_options['option_value'],true);
            $this->arr = $options_arr;
            $fyfpzt=$options_arr['fyfengpan_zhuangtai'];
            $kyfpzt=$options_arr['kyfengpan_zhuangtai'];
            $this->fyfpzt=M('peizhi')->where("pzming = 'zhuangtai' and zhuangtai = 1 and lxid <> ".$options_arr['fygongpan_zhuangtai']." and lxid <> ".$options_arr['fysipan_zhuangtai'])->order('xsshunxu asc')->select();
            $this->kyfpzt=M('peizhi')->where("pzming = 'khzhuangtai' and zhuangtai = 1 and lxid <> ".$options_arr['kygongke_zhuangtai']." and lxid <> ".$options_arr['kysike_zhuangtai'])->order('xsshunxu asc')->select();
            $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->display();
        }
    }

    public function diaoqu(){
        if (IS_POST) {
            $data = I('data');
            $diaoqu_json = json_encode($data);
            $isok=M('options')->where(array('option_name'=>'diaoqu_options'))->setField('option_value',$diaoqu_json);
            if ($isok) {
                $this->success('保存成功!');
            } else {
                $this->error('保存失败!');
            }
        }else{
            $guohu_options=M('options')->where(array('option_name'=>'diaoqu_options'))->find();
            $this->arr = json_decode($guohu_options['option_value'],true);
            $this->role = M('role')->select();
            $this->display();
        }
    }
}