/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MessagesUsers::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; } if ($this->type == 2) { $query->andWhere('type > 1'); } else { $query->andWhere('type = 1'); } $query->andFilterWhere(['id' => $this->id, 'messages_id' => $this->messages_id, 'users_id' => $this->users_id, 'status' => $this->status]); $query->orderBy('id desc'); return $dataProvider; }
public function sendMessage($content, $type, $userId, $phone) { $messagesUsersInfo['messages_id'] = 1; $messagesUsersInfo['type'] = $type; $messagesUsersInfo['title'] = Messages::$typeList[$type]; $messagesUsersInfo['users_id'] = $userId; $messagesUsersInfo['content'] = $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); $smsModel = Sms::getInstance(Yii::$app->params['smsUserName'], Yii::$app->params['smsPassword']); $result = $smsModel->pushMt($phone, time(), $content, 0); return $result; }
public function actionMyActivityView() { $activityUsersId = \Yii::$app->request->get('activityUserId'); if (empty($activityUsersId)) { throw new ServerErrorHttpException('查看活动信息失败,原因:参数错误!'); } $levelName = Level::getOneLevelNameById(\Yii::$app->user->identity->level_id); $photo = UsersInfo::getPhotoByUserId(\Yii::$app->user->id); $messageCount = MessagesUsers::getCountByUserIdAndType(\Yii::$app->user->id); $currentTrain = TrainUsers::getTrainByUserId(\Yii::$app->user->id); //培训信息 $activityModel = ActivityUsers::getActivityInfoById($activityUsersId); if (empty($activityModel)) { throw new ServerErrorHttpException('查看课程信息失败,原因:不存在的培训课程!'); } //考勤信息 $activityProcessModel = ActivityProcess::getAllByActivityIdAndUserId($activityModel['activity_id'], $activityModel['user_id']); //迟到数量 $finishCount = ActivityProcess::getCount($activityModel['activity_id'], $activityModel['user_id'], ActivityProcess::FINISH); $noFinishCount = ActivityProcess::getCount($activityModel['activity_id'], $activityModel['user_id'], ActivityProcess::NO_FINISH); $data = ['levelName' => $levelName, 'currentTrain' => $currentTrain, 'activityModel' => $activityModel, 'activityProcessModel' => $activityProcessModel, 'finishCount' => $finishCount, 'noFinishCount' => $noFinishCount, 'attendanceAppraise' => $activityModel['attendance_appraise'], 'photo' => $photo, 'messageCount' => $messageCount]; return $this->render('my-activity-view', ['data' => $data]); }
/** * Finds the MessagesUsers model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MessagesUsers the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MessagesUsers::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
style="display:block;"<?php } ?> > <a href="<?php echo \yii\helpers\Url::to('/user-center/messages-comment'); ?> "><span>最新公告(<b><?php echo \app\models\MessagesUsers::getCountByUserIdAndType(\Yii::$app->user->id, 1); ?> </b>)</span></a> <a href="<?php echo \yii\helpers\Url::to('/user-center/system-comment'); ?> "><span>系统通知(<b><?php echo \app\models\MessagesUsers::getCountByUserIdAndType(\Yii::$app->user->id, 2); ?> </b>)</span></a> </div> </li> <li> <h1 <?php if (Yii::$app->controller->action->id == 'orders') { ?> class="hover"<?php } ?> ><a href="javascript:;">缴费管理</a></h1> <div class="second_div"