public function actionView($id)
 {
     // var_dump($_POST);exit();
     if ($_POST['type'] == 'recommend') {
         $teacher = Teacher::find()->where('id=:id', [':id' => $_POST['teacher_id']])->with('details')->one();
         if (!empty($teacher)) {
             $recommend = new BusinessRecommend();
             $recommend->business_id = $id;
             $recommend->teacher_id = $teacher->id;
             $recommend->contact = $teacher->details->phone;
             $recommend->recommend_time = time();
             $recommend->recommend_people = \Yii::$app->session['userid'];
             $recommend->recommend_remarks = $_POST['recommend_remarks'];
             $recommend->result = '已推荐';
             if ($recommend->save()) {
                 \Yii::$app->getSession()->setFlash('success', '推荐成功!^_^');
             }
         }
     }
     if ($_POST['type'] == 'charge') {
         $charge = new BusinessCharges();
         $charge->business_id = $id;
         $charge->charges_item = $_POST['charges_item'];
         $charge->receipt = $_POST['receipt'];
         $charge->money = $_POST['money'];
         $charge->charges_time = time();
         $charge->charges_people = $_POST['charges_people'];
         $charge->charges_remarks = $_POST['charges_remarks'];
         if ($charge->save()) {
             \Yii::$app->getSession()->setFlash('success', '提交成功!^_^');
         }
     }
     $business_info = Business::find()->where('id=:id', [':id' => $id])->with(['charges', 'applicants', 'admin'])->one();
     return $this->render('view', ['business' => $business_info]);
 }
 public function actionView($id)
 {
     $teacher_info = Teacher::find()->where('id=:id', [':id' => $id])->with('details')->one();
     $sex = $teacher_info->sex == 1 ? '男' : '女';
     $pimg = empty($teacher_info->details->head_image) ? '20130830135948.jpg' : $teacher_info->details->head_image;
     $free_time = explode(",", $teacher_info->free_time);
     $exam_score = explode(',', $teacher_info->details->exam_score);
     $ky_score_arr = explode(',', $teacher_info->details->ky_score);
     $ky_score = $teacher_info->details->ky_score == ',,,' ? '无' : '数学:' . $ky_score_arr[0] . '  英语:' . $ky_score_arr[1] . '  综合:' . $ky_score_arr[2] . '  其他:' . $ky_score_arr[3];
     $map_arr = [1 => '是', 0 => '否'];
     $map_stay = [0 => '不留校', 1 => '暑假留校', 2 => '寒假留校', 3 => '放假都在学校'];
     $map_type = [0 => '未认证', 1 => '认证教员', 2 => '明星教员', 3 => '黑名单'];
     // var_dump($teacher_info);exit();
     return $this->render('view', ['teacher' => $teacher_info, 'sex' => $sex, 'pimg' => $pimg, 'exam_score' => $exam_score, 'ky_score_arr' => $ky_score_arr, 'ky_score' => $ky_score, 'map_arr' => $map_arr, 'map_stay' => $map_stay, 'map_type' => $map_type, 'free_time' => $free_time]);
 }
Пример #3
0
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         //设置session
         $teacher = Teacher::find()->where(['username' => $_POST['LoginForm']['username']])->with('details')->one();
         $session = Yii::$app->session;
         $session['tid'] = $teacher->id;
         $session['username'] = $teacher->username;
         $session['head_image'] = $teacher->details->head_image;
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
Пример #4
0
 public function actionDb()
 {
     $teacher = Teacher::find()->where(['id' => 80])->with('details')->one();
     var_dump($teacher->details);
 }