/** * Displays a single TrainUsers model. * @param integer $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); $model->trainName = Train::getOneTrainNameById($model->train_id); $model->userName = Users::getOneUserNameById($model->user_id); return $this->render('view', ['model' => $model]); }
/** * 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]); } }
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]); }
?> <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>
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)); } } } }
public function actionApplySuccess() { $trainUserId = Yii::$app->request->get('id'); $trainUser = TrainUsers::findOne(['id' => $trainUserId]); $maxCount = TrainUsers::getMaxSignUpOrder($trainUser['train_id']); $trainName = Train::getOneTrainNameById($trainUser['train_id']); $data = ['maxCount' => $maxCount, 'trainName' => $trainName]; return $this->redirect(['/train/apply-success', 'data' => $data]); }
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>
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>