'开工大吉',2=>'拆改',3=>'水电',4=>'泥水',5=>'木工',6=>'油漆',7=>'验收']; public static $layout_arr = [1=>'一房',2=>'二房',3=>'三房',4=>'四房',5=>'五房',6=>'复式',7=>'楼中楼',8=>'别墅',9=>'办公室',10=>'店面',11=>'单身公寓',12=>'自建房',13=>'跃层式']; public static $style_arr = [1=>'北欧',2=>'欧式',3=>'现代简约',4=>'中式',5=>'新中式',6=>'美式乡村',7=>'田园',8=>'地中海',9=>'东南亚',10=>'时尚混搭',11=>'简欧',12=>'新古典',13=>'雅致主义',14=>'日韩式',15=>'工业风',16=>'港式']; public static $pattern_arr = [1=>'清包',2=>'半包',3=>'全包']; public static $type_arr = [1=>'工地',2=>'样板房']; public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => [], 'allow' => true, 'roles' => ['@'], ], ], ], ]; } //新建样板房 public function actionAddroom(){ $model_manager = Manager::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); $model_designer = Designer::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); if(Yii::$app->request->get()){ return companybuilding::add_building(); }else{ return $this->render('add_room', [ 'layout_arr'=>self::$layout_arr, 'style_arr'=>self::$style_arr, 'pattern_arr'=>self::$pattern_arr, 'model_manager'=>$model_manager, 'model_designer'=>$model_designer, ]); } } //新建工地 public function actionAddwork(){ $model_manager = Manager::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); $model_designer = Designer::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); if(Yii::$app->request->get()){ return companybuilding::add_building(); }else{ return $this->render('add_work', [ 'stage_arr'=>self::$stage_arr, 'layout_arr'=>self::$layout_arr, 'style_arr'=>self::$style_arr, 'pattern_arr'=>self::$pattern_arr, 'model_manager'=>$model_manager, 'model_designer'=>$model_designer, ]); } } /** * 编辑工地 */ public function actionEditwork() { $id = Yii::$app->request->get('id'); $model_manager = Manager::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); $model_designer = Designer::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); $model = Building::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->one(); if(empty($model)) { exit("找不到该工地"); } if(Yii::$app->request->get('typeModel')=='edit') { return companybuilding::update_building($id); } return $this->render('add_work', [ 'stage_arr'=>self::$stage_arr, 'layout_arr'=>self::$layout_arr, 'style_arr'=>self::$style_arr, 'pattern_arr'=>self::$pattern_arr, 'model_manager'=>$model_manager, 'model_designer'=>$model_designer, 'model' => $model, ]); } /** * 编辑样板房 */ public function actionEditroom() { $id = Yii::$app->request->get('id'); $model_manager = Manager::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); $model_designer = Designer::find()->where('company=:company and status=:status',[':company'=>Yii::$app->user->id,':status'=>Designer::STATUS_YES])->all(); $model = Building::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->one(); if(empty($model)) { exit("找不到该样板房"); } if(Yii::$app->request->get('typeModel')=='edit') { return companybuilding::update_building($id); } return $this->render('add_room', [ 'stage_arr'=>self::$stage_arr, 'layout_arr'=>self::$layout_arr, 'style_arr'=>self::$style_arr, 'pattern_arr'=>self::$pattern_arr, 'model_manager'=>$model_manager, 'model_designer'=>$model_designer, 'model' => $model, ]); } //验证名字 public function actionVerifyname(){ $name = Yii::$app->request->get('name'); $model = Building::find()->where('name=:name',[':name'=>$name])->one(); if(!empty($model)){ $result=['sign'=>4000,'msg'=>'名字已经被占用']; }else{ $result=['sign'=>1,'msg'=>'名字可用']; } return json_encode($result); } //样板房列表 public function actionIndex(){ $models = Building::find()->where('uid=:uid and posted!=:posted and type=:type',[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_DELETE,':type'=>Building::TYPE_HOUSE]); $pages = $models->count(); $pages = ceil($pages/self::PAGESIZE); $models = $models->orderBy('created_at desc')->limit(self::PAGESIZE)->all(); return $this->render('index', [ 'models'=>$models, 'pages'=>$pages, 'layout_arr'=>self::$layout_arr, 'style_arr'=>self::$style_arr, ]); } //样板房分页 public function actionIndexpage(){ $page = \Yii::$app->request->post('page'); $models = Building::find()->where('uid=:uid and posted!=:posted and type=:type',[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_DELETE,':type'=>Building::TYPE_HOUSE]); $models = $models->orderBy('created_at desc')->offset(self::PAGESIZE*$page)->limit(self::PAGESIZE)->all(); return $this->renderPartial('indexpage',['models'=>$models]); } //样板房详情 public function actionTemplatelist(){ $id = Yii::$app->request->get('id'); $model = Building::find()->where('id=:id and type=:type',[':id'=>$id,':type'=>Building::TYPE_HOUSE])->one(); $comment = Comment::find()->where('pid=:pid and type=:type',[':pid'=>$id,':type'=>Comment::TYPE_HOUSE])->all(); return $this->render('templatelist', [ 'model'=>$model, 'comment'=>$comment, ]); } //工地列表 public function actionWork(){ $models = Building::find()->where('uid=:uid and posted!=:posted and type=:type',[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_DELETE,':type'=>Building::TYPE_SITE]); $pages = $models->count(); $pages = ceil($pages/self::PAGESIZE); $models = $models->orderBy('created_at desc')->limit(self::PAGESIZE)->all(); return $this->render('work', [ 'models'=>$models, 'pages'=>$pages, 'layout_arr'=>self::$layout_arr, 'style_arr'=>self::$style_arr, ]); } //工地分页 public function actionWorkpage(){ $page = \Yii::$app->request->post('page'); $models = Building::find()->where('uid=:uid and posted!=:posted and type=:type',[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_DELETE,':type'=>Building::TYPE_SITE]); $models = $models->orderBy('created_at desc')->offset(self::PAGESIZE*$page)->limit(self::PAGESIZE)->all(); return $this->renderPartial('workpage',['models'=>$models]); } //工地详情 public function actionWorklist(){ $id = Yii::$app->request->get('id'); $model = Building::find()->where('id=:id and type=:type',[':id'=>$id,':type'=>Building::TYPE_SITE])->one(); $comment = Comment::find()->where('pid=:pid and type=:type',[':pid'=>$id,':type'=>Comment::TYPE_SITE])->all(); return $this->render('worklist', [ 'model'=>$model, 'comment'=>$comment, ]); } public function actionPosition(){ $id = Yii::$app->request->get('id'); $model = Building::find()->where('id=:id',[':id'=>$id])->one(); return $this->render('position',['model'=>$model]); } //样板详情的预约 public function actionPre(){ $id = Yii::$app->request->get('id'); $models = Appointment::find()->where('pid=:pid',[':pid'=>$id])->all(); return $this->render('pre',['models'=>$models]); } //发布和停止 public function actionHandle(){ $id = Yii::$app->request->get('id'); $posted = Yii::$app->request->get('posted'); if(!empty($id)){ if($posted==Building::POSTED_YES){ companybuilding::stop_posted($id); $result=['sign'=>1,'msg'=>'停止成功','posted'=>Building::POSTED_NO]; }else if($posted==Building::POSTED_NO){ companybuilding::delede_posted($id); $result=['sign'=>1,'msg'=>'发布成功','posted'=>Building::POSTED_YES]; } }else{ $result=['sign'=>0,'msg'=>'数据不存在']; } return json_encode($result); } //处理预约 public function actionDispose(){ $id = Yii::$app->request->get('id'); $model = Appointment::find()->where('id=:id',[':id'=>$id])->one(); $model->state = Appointment::STATE_YES; $model->updated_at = time(); if($model->validate()&&$model->save()){ $result=['sign'=>1,'msg'=>'已处理']; }else{ $result=['sign'=>4000,'msg'=>'处理失败']; } return json_encode($result); } //上传客厅 主卧 布局 平面 等图片 public function actionImgurl(){ $serverid = Yii::$app->request->get('serverid'); $result=['sign'=>4000,'msg'=>'参数有误']; $results = LMUploadFile::wechatUploaImage($serverid,'logo',false,200,200); if(!empty($results)){ $result=['sign'=>1,'msg'=>'保存成功','imgurl'=>$results['remote']]; } return json_encode($result); } }