public function show($id, $num = 3) { if (Auth::user()->can('read-escalation-profiles')) { $data['title'] = "Escalation Profile"; $data['menu_actions'] = [Form::editItem(route('escalation_profiles.edit', $id), "Edit This Profile", Auth::user()->can('update-escalation-profiles'))]; $escalation_profile_events = DB::table('escalation_profile_event')->where('profile_id', $id)->get(); if (count($escalation_profile_events) > 0) { foreach ($escalation_profile_events as $key => $escalation_profile_event) { $data['escalation_profile_events']['delay_time'][$key] = $escalation_profile_event->delay_time; $data['escalation_profile_events']['event_id'][$key] = explode(",", $escalation_profile_event->event_id); $data['escalation_profile_events']['level_id'][$key] = $escalation_profile_event->level_id; $data['escalation_profile_events']['priority_id'][$key] = $escalation_profile_event->priority_id; $data['escalation_profile_events']['email_text'][$key] = $escalation_profile_event->email_text; } } else { $data['escalation_profile_events'] = null; } $data['escalation_profile'] = EscalationProfile::find($id); $data['escalation_events'] = EscalationEvent::all(); $data['levels'] = Level::all(); $data['priorities'] = Priority::all(); $data['delays'] = self::parseDelays(); $count = count($escalation_profile_events); $num = $num > 0 ? $num : 3; $data['rows'] = $count > 0 ? $count > $num ? $count : $num : $num; return view('escalation_profiles/show', $data); } else { return redirect()->back()->withErrors(['Access denied to esclation profiles show page']); } }
public function actionIndex() { $levelList = Level::getAll(); $districtList = Train::$districtList; $data = ['levelList' => $levelList, 'districtList' => $districtList]; return $this->render('index', ['data' => $data]); }
public function actionApply() { $trainId = Yii::$app->request->get('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('您已经参与了该级别下的培训课程,请耐心等待培训结果,谢谢。'); } // if (strtotime($trainInfo['sign_up_begin_time']) < time()) { // throw new ServerErrorHttpException('此课程已过期。'); // } $noPassInfo = TrainUsers::findOne(['user_id' => Yii::$app->user->id, 'level_id' => Yii::$app->user->identity->level_id + 1, 'status' => TrainUsers::NO_PASS]); if (!empty($noPassInfo)) { $noPassTrainInfo = Train::findOne($noPassInfo['train_id']); if (!empty($noPassTrainInfo)) { if ($noPassTrainInfo['end_time'] > $trainInfo['begin_time']) { throw new ServerErrorHttpException('训课课程的开课时间一定要大于未通过考试培训课程结束时间。'); } } } //报名成功,给出用户的序号 $trainUsersOrder = TrainUsers::getMaxSignUpOrder($trainId); if (empty($trainUsersOrder)) { $trainUsersOrder = 1; } else { $trainUsersOrder = $trainUsersOrder + 1; } $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()) { $trainUserId = $model->id; $trainUser = TrainUsers::findOne(['id' => $trainUserId]); $trainName = Train::getOneTrainNameById($trainUser['train_id']); $data = ['orders' => $trainUser['orders'], 'trainName' => $trainName]; //更新级别信息的信息 UsersLevel::updateAll(['train_id' => $trainId], ['user_id' => $userId, 'level_id' => Yii::$app->user->identity->level_id]); return $this->render('/train/apply-success', ['data' => $data]); } else { throw new ServerErrorHttpException('' . json_encode($model->errors, JSON_UNESCAPED_UNICODE)); } } }
public function actionApply() { $activityId = Yii::$app->request->get('id'); $activityInfo = Activity::findOne(['id' => $activityId]); if ($activityInfo['status'] != Activity::BEGIN_SIGN_UP) { throw new ServerErrorHttpException('该活动的状态不是开始报名,谢谢。'); } if (Yii::$app->user->isGuest) { return $this->redirect(['/user/register', 'activity_id' => $activityId]); } else { $userId = Yii::$app->user->id; $CredentialsNumber = UsersInfo::getCredentialsNumberByUserId($userId); if (Yii::$app->user->identity->status != '1') { throw new ServerErrorHttpException('系统错误,原因:您目前的状态是未审核,不能报名课程,谢谢。'); } $activityLevelInfo = Level::findOne(['id' => $activityInfo['level_id']]); if ($activityLevelInfo['order'] != Yii::$app->user->identity->level_order + 1) { throw new ServerErrorHttpException('系统错误,原因:您目前没有权限报名该级别下的课程,谢谢。'); } //检查用户参与的课程,状态不是取消的都算是已经参与了报名 $isExist = ActivityUsers::getUserIsExistActivityStatus($userId, $activityInfo['level_id']); if (!empty($isExist)) { throw new ServerErrorHttpException('系统错误,原因:您已经参与了该级别下的培训课程,请耐心等待培训结果,谢谢。'); } //报名成功,给出用户的序号 $activityUsersOrder = ActivityUsers::getActivityUsersOrder($userId, $activityId); if (empty($activityUsersOrder)) { $activityUsersOrder = 1; } $transaction = Yii::$app->db->beginTransaction(); $data = ['activity_id' => $activityId, 'user_id' => $userId, 'status' => ActivityUsers::APPROVED, 'practice_score' => 0, 'theory_score' => 0, 'rule_score' => 0, 'level_id' => $activityInfo['level_id'], 'orders' => $activityUsersOrder]; $model = new ActivityUsers(); $model->setAttributes($data); if ($model->save()) { $activityUserId = $model->id; $activityUser = ActivityUsers::findOne(['id' => $activityUserId]); $activityName = Activity::getOneActivityNameById($activityUser['activity_id']); $data = ['orders' => $activityUser['orders'], 'activityName' => $activityName]; //新增一条用户和级别对应的信息 $userLevelModel = new UsersLevel(); $userLevelModel->user_id = $userId; $userLevelModel->activity_id = $activityId; $userLevelModel->level_id = $activityInfo['level_id']; $userLevelModel->credentials_number = $CredentialsNumber; if (!$userLevelModel->save()) { $transaction->rollBack(); throw new ServerErrorHttpException('更新状态错误,原因:' . json_encode($userLevelModel->errors, JSON_UNESCAPED_UNICODE) . '!'); } else { $transaction->commit(); } return $this->render('/activity/apply-success', ['data' => $data]); } else { throw new ServerErrorHttpException('系统错误,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE)); } } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Level::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, 'lesson' => $this->lesson, 'credit' => $this->credit, 'score' => $this->score, 'login_duration' => $this->login_duration, 'register_fee' => $this->register_fee, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'update_user', $this->update_user]); return $dataProvider; }
/** * Creates a new MessagesUsers model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new MessagesUsers(); $type = Yii::$app->request->get('type'); if (Yii::$app->request->isPost) { $param = Yii::$app->request->post(); if ($param['user_type'] == 'user_name') { $userId = Users::getIdByName($param['MessagesUsers']['users_id']); if (empty($userId)) { throw new ServerErrorHttpException('不存在的用户姓名!'); } $model->messages_id = $param['MessagesUsers']['messages_id']; $model->type = $param['MessagesUsers']['type']; $model->users_id = $userId; $model->content = $param['MessagesUsers']['content']; if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } elseif ($param['user_type'] == 'user_level') { $levelId = Level::getIdByName($param['MessagesUsers']['users_id']); if (empty($levelId)) { throw new ServerErrorHttpException('不存在的级别名称!'); } $usersList = Users::findAll(['level_id' => $levelId, 'status' => 1]); if (!empty($usersList)) { foreach ($usersList as $key => $val) { $messagesUsersInfo['messages_id'] = $param['MessagesUsers']['messages_id']; $messagesUsersInfo['type'] = $param['MessagesUsers']['type']; $messagesUsersInfo['users_id'] = $val['id']; $messagesUsersInfo['content'] = $param['MessagesUsers']['content']; $messagesUsersInfo['create_time'] = date('Y-m-d H:i:s', time()); $messagesUsersInfo['create_user'] = '******'; $messagesUsersInfo['update_time'] = date('Y-m-d H:i:s', time()); $messagesUsersInfo['update_user'] = '******'; MessagesUsers::addInfo($messagesUsersInfo); } return $this->redirect('index'); } } elseif ($param['user_type'] == 'all_user') { $usersList = Users::getAll(); if (!empty($usersList)) { foreach ($usersList as $key => $val) { $messagesUsersInfo['messages_id'] = $param['MessagesUsers']['messages_id']; $messagesUsersInfo['type'] = $param['MessagesUsers']['type']; $messagesUsersInfo['users_id'] = $val['id']; $messagesUsersInfo['content'] = $param['MessagesUsers']['content']; $messagesUsersInfo['create_time'] = date('Y-m-d H:i:s', time()); $messagesUsersInfo['create_user'] = admin; $messagesUsersInfo['update_time'] = date('Y-m-d H:i:s', time()); $messagesUsersInfo['update_user'] = '******'; MessagesUsers::addInfo($messagesUsersInfo); return $this->redirect('index'); } } } else { throw new ServerErrorHttpException('参数错误!'); } } else { return $this->render('create', ['model' => $model, 'type' => empty($type) ? '1' : $type]); } }
/** * Updates an existing UsersLevel 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); if (Yii::$app->request->isPost) { $infoParams = Yii::$app->request->post(); if ($infoParams['UsersLevel']['status'] == UsersLevel::SEND_CARD) { $infoParams['UsersLevel']['end_date'] = date('Y-m-d', time() + 3600 * 24 * 365); } $userLevelInfo = $infoParams; if ($model->load($userLevelInfo) && $model->save()) { //如果状态更新为已经注册 if ($model->status == UsersLevel::SEND_CARD) { if ($model->level_id == 1) { //如果是注册学员升级市级教练 UsersLevel::updateAll(['status' => UsersLevel::LEVEL_UP], ['user_id' => $model->user_id, 'level_id' => $model->level_id]); $userInfo = UsersInfo::findOne(['user_id' => $model->user_id]); //新增一条用户和级别对应的信息 $userLevelModel = new UsersLevel(); $userLevelModel->user_id = $model->user_id; $userLevelModel->level_id = $model->level_id + 1; $userLevelModel->credentials_number = $userInfo['credentials_number']; $userLevelModel->district = $userInfo['account_location']; $userLevelModel->receive_address = $userInfo['contact_address']; $userLevelModel->postcode = $userInfo['contact_postcode']; $userLevelModel->status = UsersLevel::NO_TRAIN; if (!$userLevelModel->save()) { throw new ServerErrorHttpException(json_encode($userLevelModel->errors, JSON_UNESCAPED_UNICODE) . '!'); } else { Users::updateAll(['level_id' => $model->level_id + 1, 'level_order' => $model->level_id + 1], ['id' => $model->user_id]); } } $usersTrainInfo = UsersLevel::getUserTrainInfo($model->id); $teacherInfo = Teachers::findOne($usersTrainInfo['teachers_id']); $usersTrainModel = new UsersTrain(); $usersTrain['UsersTrain']['user_id'] = $usersTrainInfo['user_id']; $usersTrain['UsersTrain']['credentials_number'] = $usersTrainInfo['certificate_number']; $usersTrain['UsersTrain']['begin_time'] = $usersTrainInfo['begin_time']; $usersTrain['UsersTrain']['end_time'] = $usersTrainInfo['end_time']; $usersTrain['UsersTrain']['level'] = Level::getOneLevelNameById($usersTrainInfo['level_id']); $usersTrain['UsersTrain']['address'] = $usersTrainInfo['address']; $usersTrain['UsersTrain']['witness'] = $teacherInfo['name']; $usersTrain['UsersTrain']['witness_phone'] = $teacherInfo['phone']; $usersTrain['UsersTrain']['description'] = '通过培训课程' . $usersTrainInfo['content']; if ($usersTrainModel->load($usersTrain) && $usersTrainModel->save()) { $content = "很高兴的通知您,您已完成" . Level::getOneLevelNameById($model->level_id) . "级教练员的注册,注册时效为1年,您现在可以正式开展教练员工作。【教练系统】"; $userInfo = Users::findOne($model->user_id); $result = $this->sendMessage($content, Messages::REGISTER_SUCCESS, $model->user_id, $userInfo['mobile_phone'], '1'); if ($result != '0') { throw new ServerErrorHttpException($result); } else { return $this->redirect(['view', 'id' => $model->id]); } } else { throw new ServerErrorHttpException(json_encode($usersTrainModel->errors, JSON_UNESCAPED_UNICODE)); } } } } else { $photo = UsersInfo::getPhotoByUserId($model->user_id); return $this->render('update', ['model' => $model, 'photo' => $photo]); } }
public static function workingTimeData($days, $type) { $result = null; if ($type == "division") { $grouping = Division::whereIn('id', [LGV_DIVISION_ID, PLC_DIVISION_ID, PC_DIVISION_ID, BEMA_DIVISION_ID, FIELD_DIVISION_ID, SPARE_PARTS_DIVISION_ID, RELIABILITY_DIVISION_ID, OTHERS_DIVISION_ID])->orderBy("name")->get(); } elseif ($type == "priority") { $grouping = Priority::orderBy("name")->get(); } elseif ($type == "level") { $grouping = Level::orderBy("name")->get(); } elseif ($type == "company") { $grouping = Company::orderBy("name")->get(); } elseif ($type == "assignee") { $grouping = CompanyPerson::select("company_person.*", "people.first_name", "people.last_name")->leftJoin('people', 'company_person.person_id', '=', 'people.id')->where('company_person.company_id', '=', ELETTRIC80_COMPANY_ID)->orderBy("last_name")->get(); foreach ($grouping as $group) { $group->name = $group->last_name . " " . $group->first_name; } } if (isset($grouping)) { foreach ($grouping as $index => $group) { for ($i = 0; $i < 50; $i++) { $query = "SELECT SUM(resolution_time) as sum, COUNT(*) as ticket_count, AVG(resolution_time) as average, DATE_SUB(NOW(), INTERVAL " . $days * ($i + 1) . " day) as date\n FROM (\n SELECT before.ticket_id, SUM(\n TIMESTAMPDIFF(SECOND, \n GREATEST(DATE_SUB(NOW(), INTERVAL " . $days * ($i + 1) . " day), before.created_at), \n LEAST(DATE_SUB(NOW(), INTERVAL " . $days * $i . " day), IFNULL(after.created_at,NOW()))\n )\n )/3600 as resolution_time\n FROM tickets_history as `before`\n LEFT JOIN tickets_history as `after` ON before.id = after.previous_id\n INNER JOIN tickets ON tickets.id = before.ticket_id \n WHERE (\n after.status_id IN (" . TICKET_NEW_STATUS_ID . "," . TICKET_IN_PROGRESS_STATUS_ID . ",\n " . TICKET_REQUESTING_STATUS_ID . "," . TICKET_SOLVED_STATUS_ID . "," . TICKET_CLOSED_STATUS_ID . ")\n OR \n (before.status_id IN (" . TICKET_NEW_STATUS_ID . "," . TICKET_IN_PROGRESS_STATUS_ID . ",\n " . TICKET_REQUESTING_STATUS_ID . ") AND after.id IS NULL)\n )\n AND tickets.deleted_at IS NULL\n AND tickets." . $type . "_id = {$group->id}\n AND TIMESTAMPDIFF(SECOND, \n GREATEST(before.created_at,DATE_SUB(NOW(), INTERVAL " . $days * ($i + 1) . " day)), \n LEAST(DATE_SUB(NOW(), INTERVAL " . $days * $i . " day), IFNULL(after.created_at,NOW()))) > 0\n GROUP BY before.ticket_id\n ) as " . $type[0] . "_{$index} "; $temp = DB::select(DB::raw($query)); foreach ($temp[0] as $key => $value) { if ($key != "date") { $div_key = str_replace(" ", "_", $group->name); if ($i == 0) { $result[$div_key][$key]['current'] = round($temp[0]->{$key}, 2); } if ($i == 1) { $result[$div_key][$key]['previous'] = round($temp[0]->{$key}, 2); } $result[$div_key][$key]['historical'][$temp[0]->date] = $temp[0]->{$key}; } } } } } return $result; }
/** * Finds the Level model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Level the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Level::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="zs_img"> <div class="zsBox"> <p class="pimg80"><img src="/upload/images/users_info/photo/<?php echo \app\models\UsersInfo::getPhotoByUserId($data['user_id']); ?> " /></p> <p class="puName">北京<?php echo \app\models\Level::getOneLevelNameById($data['level_id'] + 1); ?> 足球教练证书</p> <p class="pName"><?php echo \app\models\Users::getOneUserNameById($data['user_id']); ?> </p> <p class="psucessBox">成功完成"北京市<?php echo \app\models\Level::getOneLevelNameById($data['level_id'] + 1); ?> 足球教练员"全部培训课程<span>日期:<?php echo date('Y年m月d日', strtotime($data['end_date']) - 3600 * 24 * 365); ?> ~ <?php echo date('Y年m月d日', strtotime($data['end_date'])); ?> </span></p> <p class="bhBset">编号:<?php echo $data['certificate_number']; ?> </p> </div> </div> <div class="bobj"></div>
/** * 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]); } }
<td><?php echo empty(\app\models\UsersInfo::$sexList[$data['sex']]) ? '' : \app\models\UsersInfo::$sexList[$data['sex']]; ?> </td> </tr> <tr> <td>年 龄</td> <td><?php echo date('Y', time()) - date('Y', strtotime($data['birthday'])); ?> </td> </tr> <tr> <td>级 别</td> <td><?php echo \app\models\Level::getOneLevelNameById($userModel['level_id']); ?> </td> </tr> <tr> <td>注册地区</td> <td><?php echo $data['account_location']; ?> </td> </tr> <tr> <td>证书编号</td> <td><?php echo \app\models\UsersLevel::getLevelCertificateNumberByUserIdAndLevelId($userModel['id'], $userModel['level_id']); ?>
<td>收证地址:</td> <td> <span><?php echo $data['model']['contact_address']; ?> </span><span>邮编:<?php echo $data['model']['contact_postcode']; ?> </span> </td> </tr> <tr> <td>注册费:</td> <td><span><input type="text" readonly class="w70" value="<?php echo \app\models\Level::getRegisterFeeById($data['model']['level_id'] + 1); ?> "/> 元 (注册费用包含:教练员证书、教练员装备、教练员年费)</span><span class="pay"><b class="fl"> </td> </tr> <tr> <td></td> <td><b>注:</b>您可以选择线下缴纳注册费,线下缴费需要在7个工作日内到指定地点完成缴费</td> </tr> <tr> <td>状态:</td> <td><span><?php echo \app\models\UsersLevel::$statusList[$data['model']['status']]; ?>
public function actionLevelUp() { $levelInfo = Level::findOne(['id' => Yii::$app->user->identity->level_id + 1]); $usersLevel = UsersLevel::findOne(['user_id' => Yii::$app->user->id, 'level_id' => Yii::$app->user->identity->level_id]); $usersLevelStatusCurrent = $usersLevel['status']; if ($usersLevelStatusCurrent != UsersLevel::SEND_CARD) { throw new ServerErrorHttpException('当前注册状态不符合!'); } $loginDuration = Users::getLoginDuration(Yii::$app->user->id); $loginDurationDiff = $levelInfo['login_duration'] - $loginDuration; if ($loginDurationDiff > 0) { throw new ServerErrorHttpException('当前注册时长不符合!'); } $scoreDiff = $levelInfo['score'] - Yii::$app->user->identity->score; if ($scoreDiff > 0) { throw new ServerErrorHttpException('当前一般活动积分不符合!'); } $creditDiff = $levelInfo['credit'] - Yii::$app->user->identity->credit; if ($creditDiff > 0) { throw new ServerErrorHttpException('当前公益活动积分不符合!'); } $transaction = Yii::$app->db->beginTransaction(); UsersLevel::updateAll(['status' => UsersLevel::LEVEL_UP], ['user_id' => Yii::$app->user->id, 'level_id' => Yii::$app->user->identity->level_id]); $userInfo = UsersInfo::findOne(['user_id' => Yii::$app->user->id]); //新增一条用户和级别对应的信息 $userLevelModel = new UsersLevel(); $userLevelModel->user_id = Yii::$app->user->id; $userLevelModel->level_id = Yii::$app->user->identity->level_id + 1; $userLevelModel->credentials_number = $userInfo['credentials_number']; $userLevelModel->district = $userInfo['account_location']; $userLevelModel->receive_address = $userInfo['contact_address']; $userLevelModel->postcode = $userInfo['contact_postcode']; $userLevelModel->status = UsersLevel::NO_TRAIN; if (!$userLevelModel->save()) { $transaction->rollBack(); throw new ServerErrorHttpException('更新状态错误,原因:' . json_encode($userLevelModel->errors, JSON_UNESCAPED_UNICODE) . '!'); } else { Users::updateAll(['level_id' => Yii::$app->user->identity->level_id + 1, 'level_order' => Yii::$app->user->identity->level_order + 1], ['id' => Yii::$app->user->id]); $transaction->commit(); } return $this->redirect('/user-center/index'); }
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>
public static function getLevelUpInfoByUserIdOrder($userId, $levelOrder) { $sql = "SELECT u.score,u.lesson,u.credit,u.create_time,l.credit as level_credit,l.score as level_score,l.name,l.login_duration,l.content FROM " . self::tableName() . " ul LEFT JOIN " . Users::tableName() . " u ON ul.user_id = u.id LEFT JOIN " . Level::tableName() . " l ON ul.level_id = l.id WHERE ul.user_id=:user_id AND l.order=:level_order"; $result = Yii::$app->db->createCommand($sql, [':user_id' => $userId, ':level_order' => $levelOrder])->queryOne(); return $result; }
public function edit($id) { if (Auth::user()->can('update-ticket')) { $data['ticket'] = self::API()->find(['id' => $id]); $temp = DB::table("ticket_links")->where("ticket_id", "=", $id)->get(); foreach ($temp as $elem) { $links[] = $elem->linked_ticket_id; } $data['ticket']['linked_tickets_id'] = isset($links) ? implode(",", $links) : ''; $data['companies'] = Company::where('id', '!=', ELETTRIC80_COMPANY_ID)->orderBy('name')->get(); $data['priorities'] = Priority::orderBy('id', 'desc')->get(); $data['divisions'] = Division::orderBy('name')->get(); $data['job_types'] = JobType::orderBy('name')->get(); $data['levels'] = Level::orderBy('name')->get(); $data['assignees'] = CompanyPersonController::API()->all(["where" => ["companies.id|=|" . ELETTRIC80_COMPANY_ID], "order" => ["people.last_name|ASC", "people.first_name|ASC"], "paginate" => "false"]); $data['companies'] = CompaniesController::API()->all(['where' => ['companies.id|!=|' . ELETTRIC80_COMPANY_ID], 'order' => ['companies.name|ASC'], 'paginate' => 'false']); $data['tags'] = ""; foreach ($data['ticket']->tags as $tag) { $data['tags'] .= $tag->name . ","; } $is_draft = $data['ticket']->status_id == TICKET_DRAFT_STATUS_ID ? true : false; $data['title'] = "Edit Ticket #" . $id; return view('tickets/edit', $data); } else { return redirect()->back()->withErrors(['Access denied to tickets edit page']); } }
public function actionIndex() { $keyword = Yii::$app->request->get('keyword', ''); $levelId = Yii::$app->request->get('level_id', ''); $district = Yii::$app->request->get('district', ''); $sex = Yii::$app->request->get('sex', ''); if (empty($keyword) && empty($levelId) && empty($district) && empty($sex)) { throw new ServerErrorHttpException('шп╖ш╛УхЕехЕ│щФохнЧя╝Б'); } $levelList = Level::getAll(); $districtList = Train::$districtList; $userName = ''; $certificateNumber = ''; $credentialsNumber = ''; if (preg_match("/^[- ]+\$/", $keyword)) { $userName = $keyword; } else { if (strlen($keyword) > 10) { $credentialsNumber = $keyword; } else { $certificateNumber = $keyword; } } $order = Yii::$app->request->get('order'); $query = Users::find()->from(Users::tableName() . ' u')->select("u.*,ui.account_location,ui.sex")->leftJoin(UsersLevel::tableName() . ' ul', ' u.id = ul.user_id')->leftJoin(UsersInfo::tableName() . ' ui', ' u.id = ui.user_id'); if (!empty($order)) { $query->orderBy($order); } $query->andFilterWhere(['!=', 'u.level_id', '1']); if (!empty($levelId)) { $query->andFilterWhere(['u.level_id' => $levelId]); } if (!empty($district)) { $query->andFilterWhere(['account_location' => $district]); } if (!empty($sex)) { $query->andFilterWhere(['sex' => $sex]); } if (!empty($userName)) { $query->andFilterWhere(['like', 'name', $userName]); } if (!empty($certificateNumber)) { $query->andFilterWhere(['like', 'certificate_number', $certificateNumber]); } if (!empty($credentialsNumber)) { $query->andFilterWhere(['like', 'credentials_number', $credentialsNumber]); } $pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 15]); $models = $query->offset($pages->offset)->limit($pages->limit)->all(); $result = []; if (!empty($models)) { foreach ($models as $key => $val) { $result[$key]['name'] = $val['username']; $result[$key]['photo'] = UsersInfo::getPhotoByUserId($val['id']); $result[$key]['birthday'] = UsersInfo::getBirthdayByUserId($val['id']); $result[$key]['level_id'] = $val['level_id']; $result[$key]['user_id'] = $val['id']; } } $data = ['models' => $result, 'pages' => $pages, 'count' => $query->count(), 'levelList' => $levelList, 'districtList' => $districtList, 'keyword' => empty($keyword) ? '' : $keyword, 'levelId' => empty($levelId) ? '' : $levelId, 'district' => empty($district) ? '' : $district, 'sex' => empty($sex) ? '' : $sex]; return $this->render('index', ['data' => $data]); }
if ($levelId == 7) { ?> class="hover" <?php } ?> >职业级班</a> <span class="pxke_Set">培训课程</span></h3> <!--北京市市级教练员培训--> <div class="tab_son" style="display: block;"> <div class="h132"> <p class="fl"><img src="/images/l<?php echo $levelId - 1; ?> .jpg" /></p> <div class="fl con_h"><span>录取条件!</span><?php echo \app\models\Level::getContentById($levelId); ?> </div> <p class="fr"><img src="/images/pic3.jpg" /></p> </div> <div class="table_box"> <table cellpadding="0" cellspacing="0" class="h31"> <tr> <td width="50" class="pxset">排序</td> <td colspan="4"> </td> <?php if ($orderBy == '`begin_time` desc') { ?> <td width="100">时间 <a href="<?php echo \yii\helpers\Url::to(['/train/index', 'order_by' => '`begin_time` asc']); ?>
/** * @return \yii\db\ActiveQuery */ public function getLevel() { return $this->hasOne(Level::className(), ['id' => 'level_id']); }
/* @var $model app\models\UsersSearch */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="users-search"> <?php $form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']); ?> <?php echo $form->field($model, 'username')->textInput(['style' => 'width:200px']); ?> <?php echo $form->field($model, 'level_id')->dropDownList(ArrayHelper::map(\app\models\Level::getAllByEnd(), 'id', 'name'), ['style' => 'width:100px']); ?> <?php // echo $form->field($model, 'email_auth') ?> <?php // echo $form->field($model, 'phone_auth') ?> <?php echo $form->field($model, 'status')->dropDownList(ArrayHelper::merge(['' => '选择状态'], \app\models\Users::$statusList), ['style' => 'width:100px']); ?> <?php
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)); } } } }
<div class="col-sm-6 col-md-6 col-md-6"> <?php echo $form->field($model, 'program_text')->textInput(['maxlength' => true]); ?> </div> <div class="col-sm-6 col-md-6"> <?php echo $form->field($model, 'risk_simple')->widget(Select2::classname(), ['data' => ArrayHelper::map(Simple::find()->all(), 'SIMPLE_ID', 'SIMPLE_NAME'), 'options' => ['placeholder' => 'เลือกหัวข้อตาม simple ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-6 col-md-6"> <?php echo $form->field($model, 'risk_level')->widget(Select2::classname(), ['data' => ArrayHelper::map(Level::find()->all(), 'level', 'name'), 'options' => ['placeholder' => 'เลือกระดับความรุนแรง ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-6 col-md-6 col-md-6"> <?php echo $form->field($model, 'input_complain')->widget(Select2::classname(), ['data' => ArrayHelper::map(\app\models\Complain::find()->all(), 'COMPLAIN_ID', 'COMPLAIN_NAME'), 'options' => ['placeholder' => 'เลือกช่องทางรับเรื่องร้องเรียน ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <?php
public function getLevels() { return @$this->hasOne(Level::className(), ['level' => 'risk_level']); }