Example #1
0
 public function actionStaffhome($gh_id, $openid)
 {
     $this->layout = 'wapx';
     $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     $model = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     if ($model === null) {
         U::W(['Invalid openid.', __METHOD__, $gh_id, $openid]);
         return $this->redirect(['staffsearch', 'gh_id' => $gh_id, 'openid' => $openid]);
     }
     if (empty($model->office_id)) {
         U::W(['Invalid office_id.', __METHOD__, $gh_id, $openid]);
         return $this->redirect(['staffbind', 'gh_id' => $gh_id, 'openid' => $openid, 'mobile' => $model->mobile]);
     }
     $office = MOffice::findOne($model->office_id);
     if ($office === null) {
         U::W(['Invalid office.', __METHOD__, $gh_id, $openid]);
     }
     if (Yii::$app->request->post('Unbind') !== null) {
         //$n = MStaff::updateAll(['openid' => ''], 'gh_id = :gh_id AND openid = :openid', [':gh_id'=>$gh_id, ':openid'=>$openid]);
         $n = MStaff::deleteAll('gh_id = :gh_id AND openid = :openid', [':gh_id' => $gh_id, ':openid' => $openid]);
         U::W("Unbind {$n}");
         return $this->redirect(['staffsearch', 'gh_id' => $gh_id, 'openid' => $openid]);
     }
     return $this->render('staffhome', ['model' => $model, 'office' => $office, 'user' => $user]);
 }