'开工大吉',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 actionIndex(){
$models = Building::find()->where('uid=:uid and posted!=:posted',[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_DELETE]);
$pages=new Pagination(["totalCount"=>$models->count(),"pageSize"=>self::PAGESIZE]);
$models=$models->offset($pages->offset)->limit($pages->limit)->orderBy('created_at desc')->all();
$conduct = Yii::$app->request->get('conduct');
$id = Yii::$app->request->get('id');
switch($conduct){
case "add":
return companybuilding::add_building();
break;
case "update":
return companybuilding::update_building($id);
break;
case "delete":
return companybuilding::delede_building($id);
case "posted":
return companybuilding::delede_posted($id);
case "stop":
return companybuilding::stop_posted($id);
default:
return $this->render('index',
[
'models'=>$models,
'pages'=>$pages,
'stage_arr'=>self::$stage_arr,
'layout_arr'=>self::$layout_arr,
'style_arr'=>self::$style_arr,
'pattern_arr'=>self::$pattern_arr,
]);
break;
}
}
//新加板样房、 工地1
public function actionAddbuilding(){
$picture_form = new LMUploadFile();
$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();
return $this->render('add_building',['model_manager'=>$model_manager,'model_designer'=>$model_designer,'picture_form'=>$picture_form]);
}
//更新板样房、 工地2
public function actionUpdatebuilding(){
$id = Yii::$app->request->get('id');
$model = Building::find()->where('id=:id',[':id'=>$id])->one();
$picture_form = new LMUploadFile();
$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();
return $this->render('add_building',['model'=>$model,'model_manager'=>$model_manager,'model_designer'=>$model_designer,'picture_form'=>$picture_form]);
}
//上传客厅 主卧 布局 平面 等图片
public function actionImgurl()
{
if (Yii::$app->request->isPost) {
$type = Yii::$app->request->post('type_image');
$picture_form = new LMUploadFile();
$picture_form->imageFile = UploadedFile::getInstance($picture_form, 'imageFile');
if ($picture_form->upload('product_picture',true,160,160)) {
return "";
} else {
if(isset($picture_form->getErrors()['imageFile'][0])){
$error = $picture_form->getErrors()['imageFile'][0];
}else{
$error = '图片上传失败';
}
return "";
}
}
}
//预约管理
public function actionSubscribe(){
$models = Appointment::find()
->joinWith('building')->where('{{%building}}.uid=:userid',[':userid'=>Yii::$app->user->id]);
$pages=new Pagination(["totalCount"=>$models->count(),"pageSize"=>self::PAGESIZE]);
$models=$models->offset($pages->offset)->limit($pages->limit)->orderBy('{{%appointment}}.created_at desc')->all();
$member = UserCompany::find()->where(['uid'=>Yii::$app->user->id])->select('member')->one();
return $this->render('subscribe',['models'=>$models,'pages'=>$pages,'member'=>$member->member]);
}
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);
}
}