public function actionTrain()
 {
     $levelId = Yii::$app->request->get('level_id');
     $imgNews = News::getImgRecommendNewsByCategory(3, 5);
     $teachersCount = Teachers::getTeachersCount();
     $trainCount = Train::getTrainCount();
     $trainTeachers = Teachers::getAllTeachersForNewsTrain();
     $trainWind = News::getTrainWindByLevelId($levelId, 8);
     $trainLand = TrainLand::getAllDataByCount(4);
     $data = ['imgNews' => $imgNews, 'teachersCount' => $teachersCount, 'trainTeachers' => $trainTeachers, 'levelId' => $levelId, 'trainWind' => $trainWind, 'trainCount' => $trainCount, 'trainLand' => $trainLand];
     return $this->render('train', ['data' => $data]);
     //        return $this->render('build', ['data' => $data]);
 }
 /**
  * Updates an existing TrainTeachers model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $train_id = $model->train_id;
     $trainName = Train::getOneTrainNameById($train_id);
     $model->trainName = $trainName;
     $model->trainId = $train_id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Train::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category' => $this->category, 'level_id' => $this->level_id, 'recruit_count' => $this->recruit_count, 'status' => $this->status, 'period_num' => $this->period_num, 'lesson' => $this->lesson, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     if (!empty($this->begin_date) && !empty($this->end_date)) {
         $query->andFilterWhere(['>', 'begin_time', $this->begin_date])->andFilterWhere(['<', 'begin_time', $this->end_date]);
     }
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]);
     $query->orderBy('id desc');
     return $dataProvider;
 }
 public function actionIndex()
 {
     $userCount = Users::getAllCount();
     $oneNewsPic = News::getOnePicIndexNewsByCategory(2);
     $newsA = News::getIndexNewsByCategory(2, 6);
     $newsB = News::getIndexNewsByCategory(5, 12);
     $newsC = News::getIndexNewsByCategory(7, 5);
     $newsF = News::getOnePicIndexNewsByCategory(2);
     $newsRegister = TrainUsers::getAllByCount(5);
     $newContent = Pages::findOne(9);
     if (!empty($newsRegister)) {
         foreach ($newsRegister as $key => $val) {
             $newsD[$key]['title'] = Users::getOneUserNameById($val['user_id']) . "报名" . Train::getOneTrainNameById($val['train_id']) . "已被录取";
             $newsD[$key]['create_time'] = $val['create_time'];
             $newsD[$key]['user_id'] = $val['user_id'];
         }
     }
     $newsE = News::getIndexNewsByCategory(6, 5);
     $data = ['userCount' => $userCount, 'oneNewsPic' => $oneNewsPic, 'newsA' => $newsA, 'newsB' => $newsB, 'newsC' => $newsC, 'newsD' => $newsD, 'newsE' => $newsE, 'newsF' => $newsF, 'newsRegister' => $newContent];
     return $this->render('index', ['data' => $data]);
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTrains()
 {
     return $this->hasMany(Train::className(), ['level_id' => 'id']);
 }
Example #6
0
?>

<div class="attendance-form">

    <?php 
$form = ActiveForm::begin();
?>


    <div class="form-group field-trainusers-trainname">
        <label class="control-label" for="trainusers-trainname">参与培训课程:</label>
        <a href="/Admin/train/index?TrainSearch[id]=<?php 
echo $model->train_id;
?>
" target="_blank" style="width:300px"><?php 
echo \app\models\Train::getOneTrainNameById($model->train_id);
?>
</a>
        <div class="help-block"></div>
    </div>
    <div class="form-group field-trainusers-username">
        <label class="control-label" for="trainusers-username">参与学员:</label>
        <a href="/Admin/users/index?UsersSearch[id]=<?php 
echo $model->user_id;
?>
" target="_blank" style="width:300px"><?php 
echo \app\models\Users::getOneUserNameById($model->user_id);
?>
</a>
        <div class="help-block"></div>
    </div>
Example #7
0
                        <td>招<b class="blue"><?php 
echo $data['trainModel']['recruit_count'];
?>
</b>人 | 录取<b class="blue"><?php 
echo \app\models\TrainUsers::getRecruitCount($data['trainModel']['id']);
?>
</b>人 | 结业<b class="blue"><?php 
echo \app\models\TrainUsers::getPassCount($data['trainModel']['id']);
?>
</b>人</td>
                        <td><?php 
echo date('Y-d-m', strtotime($data['trainModel']['sign_up_begin_time']));
?>
</td>
                        <td><?php 
echo \app\models\Train::getCategoryName($data['trainModel']['category']);
?>
</td>
                        <td><?php 
echo date('Y-d-m', strtotime($data['trainModel']['begin_time']));
?>
</td>
                        <td><b class="blue"><?php 
echo $data['trainModel']['address'];
?>
</b></td>
                        <td><b class="blue"><?php 
echo \app\models\Train::$statusList[$data['trainModel']['status']];
?>
</b></td>
                    </tr>
Example #8
0
" name="Train[name]" disabled class="form-control" id="train-name">
        <div class="help-block"></div>
    </div>
    <?php 
}
?>
    <?php 
echo $form->field($model, 'train_land_id')->dropDownList(\app\models\TrainLand::getAll(), ['style' => 'width:300px']);
?>

    <?php 
echo $form->field($model, 'level_id')->dropDownList(ArrayHelper::map(\app\models\Level::getAll(), 'id', 'name'), ['style' => 'width:100px']);
?>

    <?php 
echo $form->field($model, 'recruit_count')->dropDownList(\app\models\Train::getRecruitCount(), ['style' => 'width:100px']);
?>

    <?php 
if ($model->isNewRecord) {
    ?>
    <?php 
    echo $form->field($model, 'sign_up_begin_time')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['style' => '500px']]);
    ?>

    <?php 
    echo $form->field($model, 'sign_up_end_time')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['style' => '500px']]);
    ?>
    <?php 
} else {
    ?>
Example #9
0
 public static function getAllTrainByUserIdAndLevel($userId = '', $LevelId = '')
 {
     $result = Yii::$app->db->createCommand('SELECT tu.id as id,tu.train_id,t.name,t.category,t.create_time,t.address,t.recruit_count,tu.status,t.begin_time,tu.user_id as train_user_id,t.period_num,t.train_land_id FROM  ' . TrainUsers::tableName() . ' tu LEFT JOIN ' . Train::tableName() . ' t ON tu.train_id = t.id WHERE tu.user_id=:user_id AND tu.level_id=:level_id  ORDER BY id desc', [':user_id' => $userId, ':level_id' => $LevelId])->queryAll();
     return $result;
 }
Example #10
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model app\models\TrainUsersSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="train-users-search">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>

    <?php 
echo $form->field($model, 'train_id')->dropDownList(ArrayHelper::merge(['' => '选择课程'], ArrayHelper::map(\app\models\Train::getAll(), 'id', 'name')), ['style' => 'width:300px']);
?>

    <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::merge(['' => '选择用户'], ArrayHelper::map(\app\models\Users::getAll(), 'id', 'username')), ['style' => 'width:200px']);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(ArrayHelper::merge(['' => '选择状态'], \app\models\TrainUsers::$statusList), ['style' => 'width:100px']);
?>

    <?php 
// echo $form->field($model, 'theory_score')
?>

    <?php 
Example #11
0
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model app\models\UsersLevel */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => '用户晋升管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="users-level-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('删除', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'train_id', 'value' => \app\models\Train::getOneTrainNameById($model->train_id)], ['attribute' => 'user_id', 'value' => \app\models\Users::getOneUserNameById($model->user_id)], ['attribute' => 'status', 'value' => \app\models\UsersLevel::getStatusName($model->status)], 'certificate_number', ['attribute' => 'end_date', 'value' => date('Y-m-d', strtotime($model->end_date))], 'district', 'receive_address', 'postcode', ['attribute' => 'photo', 'format' => 'html', 'value' => "<img src='/upload/images/users_info/photo/" . \app\models\UsersInfo::getPhotoByUserId($model->user_id) . "' width=157 height='210'>"], ['attribute' => 'credentials_photo', 'format' => 'html', 'value' => "<img src='/upload/images/users_level/credentials_photo/" . $model->credentials_photo . "' width=500 height='210'>"], ['attribute' => 'level_id', 'value' => \app\models\Level::getOneLevelNameById($model->level_id + 1)], 'create_time', 'update_time', 'update_user']]);
?>

</div>
Example #12
0
                                            <td><?php 
        echo $key + 1;
        ?>
</td>
                                            <td><a href="<?php 
        echo \yii\helpers\Url::to(['/user-center/train-view', 'trainUsersId' => $val['id']]);
        ?>
"> <?php 
        echo $val['name'];
        ?>
 第<?php 
        echo $val['period_num'];
        ?>
期</a></td>
                                            <td><?php 
        echo \app\models\Train::getCategoryName($val['category']);
        ?>
</td>
                                            <td><?php 
        echo date('Y年m月d日', strtotime($val['begin_time']));
        ?>
</td>
                                            <td><?php 
        echo \app\models\TrainLand::getNameById($val['train_land_id']);
        ?>
</td>
                                            <td>
                                                <b class="<?php 
        if ($val['status'] == \app\models\TrainUsers::NO_APPROVED || $val['status'] == \app\models\TrainUsers::SIGN) {
            ?>
red<?php 
Example #13
0
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model app\models\TrainTeachers */
$this->title = '查看';
$this->params['breadcrumbs'][] = ['label' => '讲师管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="train-teachers-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('删除', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => '确认删除吗?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'train_id', 'format' => 'html', 'value' => '<a href="/Admin/train/index?TrainSearch[id]=' . $model->train_id . '" target="_blank" style="width:300px">' . \app\models\Train::getOneTrainNameById($model->train_id) . '</a>'], ['attribute' => 'teachers_id', 'format' => 'html', 'value' => '<a href="/Admin/teachers/index?TeachersSearch[id]=' . $model->teachers_id . '" target="_blank" style="width:300px">' . \app\models\Teachers::getOneTeacherNameById($model->teachers_id) . '</a>'], 'create_time', 'create_user', 'update_time', 'update_user']]);
?>

</div>
Example #14
0
 public static function getTeachersCountGroupByArea()
 {
     $result = Yii::$app->db->createCommand('SELECT count(t.id) as count,train.district FROM  ' . self::tableName() . ' t LEFT JOIN ' . TrainTeachers::tableName() . ' tt ON t.id = tt.teachers_id LEFT JOIN ' . Train::tableName() . ' train ON tt.train_id = train.id WHERE train.district is not null group by train.district')->queryAll();
     return $result;
 }
 public function actionView()
 {
     $trainId = Yii::$app->request->get('id');
     $trainModel = Train::findOne(['id' => $trainId]);
     $trainTeachersModel = TrainTeachers::getAllTeachersByTrainId($trainModel['id']);
     $trainUsers = [];
     if ($trainModel['recruit_count'] > 0) {
         for ($i = 1; $i <= $trainModel['recruit_count']; $i++) {
             $trainUsersInfo = TrainUsers::findOne(['train_id' => $trainModel['id'], 'orders' => $i]);
             if (empty($trainUsersInfo)) {
                 $trainUsers[$i]['status'] = '未报名';
                 $trainUsers[$i]['class'] = 'red';
                 $trainUsers[$i]['userId'] = '';
             } else {
                 $trainUsers[$i]['status'] = TrainUsers::$statusList[$trainUsersInfo['status']];
                 $trainUsers[$i]['userId'] = $trainUsersInfo['user_id'];
                 if ($trainUsersInfo['status'] == TrainUsers::NO_APPROVED) {
                     $trainUsers[$i]['class'] = 'blue';
                 } else {
                     $trainUsers[$i]['class'] = '';
                 }
             }
         }
     }
     $data = ['trainModel' => $trainModel, 'trainTeachersModel' => $trainTeachersModel, 'trainUsers' => $trainUsers];
     return $this->render('/train/view', ['data' => $data]);
 }
 /**
  * Finds the Train model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Train the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Train::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionApply()
 {
     $trainId = Yii::$app->request->get('train_id');
     $trainInfo = Train::findOne(['id' => $trainId]);
     if ($trainInfo['status'] != Train::BEGIN_SIGN_UP) {
         throw new ServerErrorHttpException('该课程的状态不是开始报名,谢谢。');
     }
     if (Yii::$app->user->isGuest) {
         return $this->redirect(['/user/register', 'train_id' => $trainId]);
     } else {
         $userId = Yii::$app->user->id;
         if (Yii::$app->user->identity->status != '1') {
             throw new ServerErrorHttpException('您目前的状态是未审核,不能报名课程,谢谢。');
         }
         $trainLevelInfo = Level::findOne($trainInfo['level_id']);
         if ($trainLevelInfo['order'] != Yii::$app->user->identity->level_order + 1) {
             throw new ServerErrorHttpException('您目前没有权限报名该级别下的课程,谢谢。');
         }
         //检查用户参与的课程,状态不是取消,注册未完成,审核未通过,未通过的都算是已经参与了报名
         $isExist = TrainUsers::getUserIsExistTrainStatus($userId, $trainInfo['level_id']);
         if (!empty($isExist)) {
             throw new ServerErrorHttpException('您已经参与了该级别下的培训课程,请耐心等待培训结果,谢谢。');
         }
         //报名成功,给出用户的序号
         $trainUsersOrder = TrainUsers::getTrainUsersOrder($trainId);
         if (empty($trainUsersOrder)) {
             $trainUsersOrder = 1;
         } else {
             $trainUsersOrder = $trainUsersOrder + 1;
         }
         $transaction = Yii::$app->db->beginTransaction();
         //如果用户未完成报名流程,更新状态为审核中
         $isSignExist = TrainUsers::getUserIsExistTrainStatusSign($userId, $trainInfo['level_id']);
         if (!empty($isSignExist)) {
             TrainUsers::updateAll(['status' => TrainUsers::APPROVED], ['id' => $isSignExist['id']]);
             $trainName = Train::getOneTrainNameById($isSignExist['train_id']);
             $data = ['orders' => $isSignExist['orders'], 'trainName' => $trainName];
             $transaction->commit();
             return $this->render('/user/apply-success', ['data' => $data]);
         } else {
             //如果没有记录,新增一条
             $data = ['train_id' => $trainId, 'user_id' => $userId, 'status' => TrainUsers::APPROVED, 'practice_score' => 0, 'theory_score' => 0, 'rule_score' => 0, 'level_id' => $trainInfo['level_id'], 'orders' => $trainUsersOrder];
             $model = new TrainUsers();
             $model->setAttributes($data);
             if ($model->save()) {
                 $trainName = Train::getOneTrainNameById($model->train_id);
                 $data = ['orders' => $model->orders, 'trainName' => $trainName];
                 $transaction->commit();
                 return $this->render('/user/apply-success', ['data' => $data]);
             } else {
                 throw new ServerErrorHttpException('系统错误,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE));
             }
         }
     }
 }
 /**
  * Updates an existing TrainUsers model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $trainInfo = Train::findOne(['id', $model->train_id]);
     $sourceStatus = $model->status;
     $userInfo = Users::findOne($model->user_id);
     $model->userName = $userInfo['username'];
     $model->trainName = $trainInfo->name;
     $statusList[TrainUsers::SIGN] = ['list' => [TrainUsers::APPROVED => TrainUsers::$statusList[TrainUsers::APPROVED]]];
     $statusList[TrainUsers::APPROVED] = ['list' => [TrainUsers::ENROLL => TrainUsers::$statusList[TrainUsers::ENROLL], TrainUsers::NO_APPROVED => TrainUsers::$statusList[TrainUsers::NO_APPROVED]]];
     $statusList[TrainUsers::ENROLL] = ['list' => [TrainUsers::DOING => TrainUsers::$statusList[TrainUsers::DOING]]];
     $statusList[TrainUsers::DOING] = ['list' => [TrainUsers::END => TrainUsers::$statusList[TrainUsers::END]]];
     $statusList[TrainUsers::END] = ['list' => [TrainUsers::END => TrainUsers::$statusList[TrainUsers::END]]];
     $statusList[TrainUsers::NO_APPROVED] = ['list' => [TrainUsers::APPROVED => TrainUsers::$statusList[TrainUsers::APPROVED]]];
     $statusList[TrainUsers::CANCEL] = ['list' => [TrainUsers::CANCEL => TrainUsers::$statusList[TrainUsers::CANCEL]]];
     $statusList[TrainUsers::PASS] = ['list' => [TrainUsers::PASS => TrainUsers::$statusList[TrainUsers::PASS]]];
     $statusList[TrainUsers::NO_PASS] = ['list' => [TrainUsers::NO_PASS => TrainUsers::$statusList[TrainUsers::NO_PASS]]];
     if (Yii::$app->request->isPost) {
         $updateParams = Yii::$app->request->post();
         $transaction = Yii::$app->db->beginTransaction();
         if ($model->load($updateParams) && $model->save()) {
             if ($updateParams['TrainUsers']['status'] == TrainUsers::END) {
                 //如果结束状态,必须评分
                 if ($sourceStatus == TrainUsers::END) {
                     $transaction->rollBack();
                     throw new ServerErrorHttpException('请提交不同的状态!');
                 }
                 if ($updateParams['TrainUsers']['practice_score'] <= 0 || $updateParams['TrainUsers']['theory_score'] <= 0 || $updateParams['TrainUsers']['rule_score'] <= 0) {
                     $transaction->rollBack();
                     throw new ServerErrorHttpException('每项评分都必须大于零!');
                 }
                 if ($updateParams['TrainUsers']['practice_score'] > 100 || $updateParams['TrainUsers']['theory_score'] > 100 || $updateParams['TrainUsers']['rule_score'] > 100) {
                     $transaction->rollBack();
                     throw new ServerErrorHttpException('每项评分都不能超过100分!');
                 }
                 //根据3个单项评分计算全部评价内容包括考勤
                 $result = $this->getSource($model->train_id, $model->user_id, $model->practice_score, $model->theory_score, $model->rule_score);
                 $model->score_appraise = $result['scoreAppraise'];
                 $model->appraise_result = $result['performance'];
                 $model->attendance_appraise = $result['attendanceComment'];
                 $model->practice_comment = $result['practiceComment'];
                 $model->theory_comment = $result['theoryComment'];
                 $model->rule_comment = $result['rulesComment'];
                 $model->total_comment = $result['commentAppraise'];
                 $model->result_comment = $result['scoreAppraise'];
                 $model->status = $result['status'];
                 if ($model->save()) {
                     //如果通过更新晋级信息
                     if ($model->status == TrainUsers::PASS) {
                         $trainCode = $trainInfo['code'];
                         $trainPeriodNum = $trainInfo['period_num'];
                         $levelInfo = Level::findOne($model->level_id);
                         $certificateNumber = $this->getCertificateNumber($trainCode, $trainPeriodNum, sprintf("%04d", $model->orders), $levelInfo['code']);
                         $res = UsersLevel::updateAll(['status' => 1, 'certificate_number' => $certificateNumber, 'update_time' => date('Y-m-d H:i:s', time()), 'update_user' => Yii::$app->admin->identity->username], ['user_id' => $model->user_id, 'train_id' => $model->train_id]);
                         if ($res) {
                             //通过发短信
                             $content = "您好,您的培训课程考试已经通过,请进入教练员管理系统-我的课程查看。【教练系统】";
                             $result = $this->sendMessage($content, Messages::TRAIN_PASS, $model->user_id, $userInfo['mobile_phone'], '1');
                             if ($result != '0') {
                                 $transaction->rollBack();
                                 throw new ServerErrorHttpException('' . $result . '!');
                             } else {
                                 $transaction->commit();
                                 return $this->redirect(['view', 'id' => $model->id]);
                             }
                         } else {
                             $transaction->rollBack();
                             throw new ServerErrorHttpException(json_encode($res, JSON_UNESCAPED_UNICODE) . '!');
                         }
                     } else {
                         UsersLevel::updateAll(['status' => UsersLevel::TRAIN_NO_PASS], ['user_id' => $userInfo['id'], 'train_id' => $model->train_id]);
                         //未通过发短信
                         $content = "尊敬的学员,您没有通过培训课程,谢谢!【教练系统】";
                         $result = $this->sendMessage($content, Messages::TRAIN_NO_PASS, $model->user_id, $userInfo['mobile_phone'], '1');
                         if ($result != '0') {
                             $transaction->rollBack();
                             throw new ServerErrorHttpException('' . $result . '!');
                         }
                         $transaction->commit();
                         return $this->redirect(['view', 'id' => $model->id]);
                     }
                 } else {
                     $transaction->rollBack();
                     throw new ServerErrorHttpException(json_encode($model->errors, JSON_UNESCAPED_UNICODE) . '!');
                 }
             } else {
                 if ($updateParams['TrainUsers']['status'] == TrainUsers::ENROLL) {
                     if ($sourceStatus == TrainUsers::ENROLL) {
                         $transaction->rollBack();
                         throw new ServerErrorHttpException('请提交不同的状态!');
                     }
                     //录取发短信
                     $content = "您好,很高兴的通知您,您报名的培训班已通过审核,请按指定日期前往培训地点缴费上课。【教练系统】";
                     $result = $this->sendMessage($content, Messages::TRAIN_SIGN_SUCCESS, $model->user_id, $userInfo['mobile_phone'], '1');
                     if ($result != '0') {
                         $transaction->rollBack();
                         throw new ServerErrorHttpException('' . $result . '!');
                     }
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 } elseif ($updateParams['TrainUsers']['status'] == TrainUsers::NO_APPROVED) {
                     if ($sourceStatus == TrainUsers::NO_APPROVED) {
                         $transaction->rollBack();
                         throw new ServerErrorHttpException('请提交不同的状态!');
                     }
                     //未通过审核发短信
                     $content = "尊敬的学员,您没有通过培训课程审核,谢谢!【教练系统】";
                     $result = $this->sendMessage($content, Messages::TRAIN_SIGN_ERROR, $model->user_id, $userInfo['mobile_phone'], '1');
                     if ($result != '0') {
                         $transaction->rollBack();
                         throw new ServerErrorHttpException('' . $result . '!');
                     }
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 } elseif ($updateParams['TrainUsers']['status'] == TrainUsers::DOING) {
                     if ($sourceStatus == TrainUsers::DOING) {
                         $transaction->rollBack();
                         throw new ServerErrorHttpException('请提交不同的状态!');
                     }
                     //培训开始发短信
                     $content = "尊敬的学员您好,您已缴费成功,请根据课培训班的课程安排按时上下课,谢谢!【教练系统】";
                     $result = $this->sendMessage($content, Messages::TRAIN_DOING, $model->user_id, $userInfo['mobile_phone'], '1');
                     if ($result != '0') {
                         $transaction->rollBack();
                         throw new ServerErrorHttpException('' . $result . '!');
                     }
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 } else {
                     if ($updateParams['TrainUsers']['practice_score'] != 0 || $updateParams['TrainUsers']['theory_score'] != 0 || $updateParams['TrainUsers']['rule_score'] != 0) {
                         throw new ServerErrorHttpException('只有更新结束状态需要评分!');
                     }
                     $transaction->commit();
                     Yii::$app->getSession()->setFlash('success', '更新成功!');
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             }
         } else {
             $transaction->rollBack();
             throw new ServerErrorHttpException('' . json_encode($model->errors, JSON_UNESCAPED_UNICODE) . '!');
         }
     } else {
         return $this->render('update', ['model' => $model, 'statusList' => $statusList]);
     }
 }
Example #19
0
    <?php 
echo $form->field($model, 'name')->textInput(['style' => 'width:200px']);
?>

    <?php 
echo $form->field($model, 'begin_date')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['style' => '500px']]);
?>
    <?php 
echo $form->field($model, 'end_date')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['style' => '500px']]);
?>

    <?php 
echo $form->field($model, 'level_id')->dropDownList(ArrayHelper::map(\app\models\Level::getAllByEnd(), 'id', 'name'), ['style' => 'width:100px']);
?>
    <?php 
echo $form->field($model, 'period_num')->dropDownList(\app\models\Train::getPeriodNum(), ['style' => 'width:100px']);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(ArrayHelper::merge(['' => '请选择状态'], \app\models\Train::$statusList), ['style' => 'width:200px']);
?>
    <?php 
// echo $form->field($model, 'sign_up_begin_time')
?>

    <?php 
// echo $form->field($model, 'sign_up_begin_time')
?>

    <?php 
// echo $form->field($model, 'sign_up_end_time')