123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646 |
- <?php
- /*
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/12
- * Time: 下午6:23
- **/
- namespace backend\controllers;
- //特色主题,价格区间,物业类型,建筑类别,楼盘标签,4=>装修品鉴
- use backend\base\CommonController;
- use backend\base\Help;
- use backend\server\UploadFile;
- use common\models\HousesPrice;
- use common\models\Characteristic;
- use common\models\CategoryLabel;
- use Yii;
- class DictionaryaController extends CommonController
- {
- //===============================价格区间================================
- /*
- * 区间价格显示页面
- * **/
- public function actionPrice()
- {
- return $this->render('price');
- }
- /*
- * 获取价格区间数据
- * **/
- public function actionPriceform()
- {
- $model = new HousesPrice();
- $rows = $model->getList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
- $val['state'] = Yii::$app->params['state'][$val['state']];
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- }
- /*
- * 添加价格区间页面
- * **/
- public function actionPriceadd()
- {
- return $this->render('priceadd');
- }
- /*
- * 添加价格区间数据
- * **/
- public function actionPriceaddform()
- {
- $model = new HousesPrice();
- $model->load(Yii::$app->request->post('data'),'');
- if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
- return Help::JsonCode(Help::ERROR,'添加失败');
- }
- /*
- * 价格区间修改页面
- * **/
- public function actionPriceedit()
- {
- $model = new HousesPrice();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if($row != null)
- {
- return $this->render('priceedit',['model'=>$row]);
- }
- }
- /*
- * 价格区间修改数据
- * **/
- public function actionPriceeditform()
- {
- $model = new HousesPrice();
- $model->load(Yii::$app->request->post('data'),'');
- if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
- $row = $model->FindById(Yii::$app->request->post('data')['id']);
- if($row != null)
- {
- $row->price = $model->price;
- $row->price_short = $model->price_short;
- $row->state = $model->state;
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
- }
- return Help::JsonCode(Help::ERROR,'修改失败');
- }
- /*
- * 价格区间删除
- * **/
- public function actionPricedel()
- {
- $model = new HousesPrice();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if($row != null)
- {
- $row->del = 2;
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
- }
- return Help::JsonCode(Help::ERROR,'删除失败');
- }
- /*
- * 价格区间 排序
- * **/
- public function actionPricesort()
- {
- $model = new HousesPrice();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if($row != null)
- {
- $row->sort = Yii::$app->request->post('sort');
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
- }
- return Help::JsonCode(Help::ERROR,'删除失败');
- }
- //===============================特色主题================================
- /*
- * 特色主题显示页面
- * **/
- public function actionTheme()
- {
- return $this->render('theme');
- }
- /*
- * 获取特色主题数据
- * **/
- public function actionThemeform()
- {
- $model = new Characteristic();
- $rows = $model->getAllList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- }
- /*
- * 特色主题添加页面
- * **/
- public function actionThemeadd()
- {
- return $this->render('themeadd');
- }
- /*
- * 特色主题添加数据
- * **/
- public function actionThemeaddform()
- {
- $model = new Characteristic();
- $model->scenario = 'add';
- $model->load(Yii::$app->request->post('data'),'');
- if($model->validate() && $model->save())
- {
- return Help::JsonCode(Help::SUCCESS,'添加成功');
- }
- return Help::JsonCode(Help::ERROR,'添加失败');
- }
- /*
- * 特色主题修改页面
- * **/
- public function actionThemeedit()
- {
- $model = new Characteristic();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if($row != null)
- {
- return $this->render('themeedit',['model'=>$row]);
- }
- }
- public function actionThemeshow()
- {
- $input = Yii::$app->request->post();
- $model = new Characteristic();
- $row = $model->FindById($input['id']);
- if(!empty($row)){
- $row->is_show = $input['state'];
- if($row->save(false)){
- return Help::JsonCode(Help::SUCCESS, '修改成功');
- }
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- /*
- * 特色主题修改数据
- * **/
- public function actionThemeeditform()
- {
- $model = new Characteristic();
- $model->load(Yii::$app->request->post('data'),'');
- if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
- $row = $model->FindById(Yii::$app->request->post('data')['id']);
- if($row != null)
- {
- $row->name = $model->name;
- if($row->update() == true)
- {
- return Help::JsonCode(Help::SUCCESS,'修改成功');
- }
- }
- return Help::JsonCode(Help::ERROR,'修改失败');
- }
- /*
- * 删除特色主题
- * **/
- public function actionThemedel()
- {
- $model = new Characteristic();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if($row != null)
- {
- $row->del = 2;
- if($row->update() == true){
- return Help::JsonCode(Help::SUCCESS,'删除成功');
- }
- }
- return Help::JsonCode(Help::ERROR,'删除失败');
- }
- //===============================物业类型================================
- /*
- * 物业类型显示页面
- * **/
- public function actionLabel()
- {
- return $this->render('label');
- }
- /*
- * 获取物业类型数据页面
- * **/
- public function actionLabelform()
- {
- $model = new CategoryLabel();
- $model->type = 1;
- $rows = $model->getList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- }
- /*
- * 添加物业类型页面
- * **/
- public function actionLabeladd()
- {
- return $this->render('labeladd',['type'=>1]);
- }
- /*
- * 添加物业类型数据
- * **/
- public function actionLabeladdform()
- {
- $model = $model = new CategoryLabel();
- $model->load(Yii::$app->request->post('data'),'');
- if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
- return Help::JsonCode(Help::ERROR,'添加失败');
- }
- /*
- * 物业类型修改页面
- * **/
- public function actionLabeledit()
- {
- $model = $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if($row != null)
- {
- return $this->render('labeledit',['model'=>$row]);
- }
- }
- /*
- * 修改物业类型数据
- * **/
- public function actionLabeleditform()
- {
- $model = $model = new CategoryLabel();
- $model->load(Yii::$app->request->post('data'),'');
- if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败',$model->errors);
- $row = $model->FindById(Yii::$app->request->post('data')['id']);
- if($row != null)
- {
- $row->name = $model->name;
- if($row->update(false) == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
- }
- return Help::JsonCode(Help::ERROR,'修改失败');
- }
- /*
- * 删除物业类型
- * **/
- public function actionLabeldel()
- {
- $model = $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if($row != null)
- {
- $row->del = 2;
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
- }
- return Help::JsonCode(Help::ERROR,'删除失败');
- }
- //===============================建筑类别================================
- /*
- * 建筑类别显示页面
- * **/
- public function actionArchitecturetype()
- {
- return $this->render('architecturetype');
- }
- /*
- * 获取物业类型数据页面
- * **/
- public function actionArchitectureform()
- {
- $model = new CategoryLabel();
- $model->type = 2;
- $rows = $model->getList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- $val['update_at'] = date('Y-m-d H:i',$val['update_at']);
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- }
- /*
- * 添加物业类型页面
- * **/
- public function actionArchitectureadd()
- {
- return $this->render('labeladd',['type'=>2]);
- }
- /*
- * 添加物业类型数据
- * **/
- public function actionArchitectureaddform()
- {
- $model = $model = new CategoryLabel();
- $model->load(Yii::$app->request->post('data'),'');
- if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
- return Help::JsonCode(Help::ERROR,'添加失败');
- }
- /*
- * 物业类型修改页面
- * **/
- public function actionArchitectureedit()
- {
- $model = $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if($row != null)
- {
- return $this->render('labeledit',['model'=>$row]);
- }
- }
- /*
- * 修改物业类型数据
- * **/
- public function actionArchitectureeditform()
- {
- $model = $model = new CategoryLabel();
- $model->load(Yii::$app->request->post('data'),'');
- if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
- $row = $model->FindById(Yii::$app->request->post('data')['id']);
- if($row != null)
- {
- $row->name = $model->name;
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
- }
- return Help::JsonCode(Help::ERROR,'修改失败');
- }
- /*
- * 删除物业类型
- * **/
- public function actionArchitecturedel()
- {
- $model = $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if($row != null)
- {
- $row->del = 2;
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
- }
- return Help::JsonCode(Help::ERROR,'删除失败');
- }
- //===============================楼盘标签================================
- /*
- * 建筑类别显示页面
- * **/
- public function actionHouselabel()
- {
- return $this->render('houselabel');
- }
- /*
- * 获取物业类型数据页面
- * **/
- public function actionHouselabelform()
- {
- $model = new CategoryLabel();
- $model->type = 3;
- $rows = $model->getList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d',$val['create_at']);
- $val['update_at'] = date('Y-m-d',$val['update_at']);
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- }
- /*
- * 添加物业类型页面
- * **/
- public function actionHouselabeladd()
- {
- return $this->render('labeladd',['type'=>3]);
- }
- /*
- * 添加物业类型数据
- * **/
- public function actionHouselabeladdform()
- {
- $model = $model = new CategoryLabel();
- $model->load(Yii::$app->request->post('data'),'');
- if($model->validate() && $model->save()) return Help::JsonCode(Help::SUCCESS,'添加成功');
- return Help::JsonCode(Help::ERROR,'添加失败');
- }
- /*
- * 物业类型修改页面
- * **/
- public function actionHouselabeledit()
- {
- $model = $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if($row != null)
- {
- return $this->render('labeledit',['model'=>$row]);
- }
- }
- /*
- * 修改物业类型数据
- * **/
- public function actionHouselabeleditform()
- {
- $model = $model = new CategoryLabel();
- $model->load(Yii::$app->request->post('data'),'');
- if(!$model->validate()) return Help::JsonCode(Help::ERROR,'修改失败');
- $row = $model->FindById(Yii::$app->request->post('data')['id']);
- if($row != null)
- {
- $row->name = $model->name;
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
- }
- return Help::JsonCode(Help::ERROR,'修改失败');
- }
- /*
- * 删除物业类型
- * **/
- public function actionHouselabeldel()
- {
- $model = $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if($row != null)
- {
- $row->del = 2;
- if($row->update() == true) return Help::JsonCode(Help::SUCCESS,'删除成功');
- }
- return Help::JsonCode(Help::ERROR,'删除失败');
- }
- /*
- *装修品鉴 - 页面
- **/
- public function actionRenovation()
- {
- return $this->render('renovation');
- }
- /*
- *装修品鉴 - 数据
- **/
- public function actionRenovationform()
- {
- $model = new CategoryLabel();
- $model->type = 4;
- $rows = $model->getList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d',$val['create_at']);
- $val['update_at'] = date('Y-m-d',$val['update_at']);
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- }
- /*
- *装修品鉴-添加页面
- **/
- public function actionRenovationadd()
- {
- return $this->render('renovationadd');
- }
- /*
- *
- **/
- public function actionRenovationedit()
- {
- $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if(!empty($row))
- {
- return $this->render('renovationedit',['model'=>$row]);
- }
- }
- /*
- *
- **/
- public function actionRenovationeditform()
- {
- $model = new CategoryLabel();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if(!empty($row))
- {
- if(!empty($_FILES['img']))
- {
- $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['pj']);
- if(is_string($img))
- {
- UploadFile::delImg(Yii::$app->params['img_url']['pj'],$row->img);
- $row->img = $img;
- }
- }
- if(!empty($_FILES['img1']))
- {
- $img = UploadFile::InstanceImgName('img1',Yii::$app->params['img_url']['pj']);
- if(is_string($img))
- {
- UploadFile::delImg(Yii::$app->params['img_url']['pj'],$row->img1);
- $row->img1 = $img;
- }
- }
- $row->name = Yii::$app->request->post('name');
- $row->sort = Yii::$app->request->post('sort');
- if($row->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
- }
- /*
- *装修品鉴 - 添加数据
- ***/
- public function actionRenovationaddform()
- {
- $model = $model = new CategoryLabel();
- $model->load(Yii::$app->request->post(),'');
- if($model->validate()){
- $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['pj']);
- if(is_string($img))
- {
- $model->img = $img;
- }
- $img1 = UploadFile::InstanceImgName('img1',Yii::$app->params['img_url']['pj']);
- if(is_string($img1))
- {
- $model->img1 = $img1;
- }
- if($model->save(false)){
- return Help::JsonCode(Help::SUCCESS,'添加成功');
- }
- }
- return Help::JsonCode(Help::ERROR,'添加失败');
- }
- }
|