public static function getProcessWindowHierarchy($winIdCluster, $fromTime, $toTime = null) { $query = Record::find(); StatsHelper::whereFromTo($query, $fromTime, $toTime); $query->joinWith(['window', 'window.process']); $query->groupBy('window_id'); $query->select(['SUM(duration) as duration', 'process_id', 'window_id', 'window.title']); $data = $query->createCommand()->queryAll(); /** @var Process[] $processMap */ // $processMap = self::processMap(); $groups = ['children' => [], 'name' => 'root']; // build tree of processes foreach ($data as $window) { if ((int) $window['duration'] == 0) { continue; } $clusterId = isset($winIdCluster[$window['window_id']]) ? $winIdCluster[$window['window_id']] : '-1'; if (!isset($groups['children'][$clusterId])) { $groups['children'][$clusterId] = ['name' => 'Cluster #' . $clusterId, 'sector_id' => $clusterId, 'process_id' => $window['process_id'], 'children' => [], 'size' => 0]; } $groups['children'][$clusterId]['children'][] = ['name' => $window['title'], 'window_id' => $window['window_id'], 'size' => (int) $window['duration'] / 1000]; $groups['children'][$clusterId]['size'] += (int) $window['duration'] / 1000; } $groups['children'] = array_values($groups['children']); foreach ($groups['children'] as $key => $process) { usort($groups['children'][$key]['children'], function ($a, $b) { return $b['size'] - $a['size']; }); } usort($groups['children'], function ($a, $b) { return $b['size'] - $a['size']; }); return $groups; }
public function behaviors() { return ['verbs' => ['class' => VerbFilter::class, 'actions' => ['delete' => ['post']]], 'access' => ['class' => Access::class, 'plain' => ['index', 'view']], 'cache' => ['class' => 'yii\\filters\\HttpCache', 'cacheControlHeader' => 'must-revalidate, private', 'only' => ['index'], 'enabled' => true, 'lastModified' => function ($action, $params) { $query = Record::find(); if (isset($params['user'])) { $query->where(['user_name' => $params['user']]); } return strtotime($query->max('time')); }]]; }
public function actionIndex() { $today = strtotime(date('Y-m-d', time()) . ' 00:00:00'); $startDate = $today - 86400; $count = Record::find()->where('created_at>:startDate and created_at<:endDate', [':startDate' => $startDate, ':endDate' => $today - 1])->count(); $validCount = Record::find()->where('created_at>:startDate and created_at<:endDate and is_valid=1', [':startDate' => $startDate, ':endDate' => $today - 1])->count(); $reservedCount = Record::find()->where('created_at>:startDate and created_at<:endDate and is_reserve=1', [':startDate' => $startDate, ':endDate' => $today - 1])->count(); $arrivedCount = Record::find()->where('arrived_at>:startDate and arrived_at<:endDate and is_arrive=1', [':startDate' => $startDate, ':endDate' => $today - 1])->count(); return $this->render('index', ['count' => [$count, $validCount, $reservedCount, $arrivedCount]]); }
/** * get current department status * @return array */ public function departmentInfo() { $record = Record::find()->all(); $data = $this->departmentAttribute(); foreach ($record as $item) { $data[$item->department]['total_count']++; if ($item->sex == 1) { $data[$item->department]['boys_count']++; } } return $data; }
public function getRoleClass($teID, $te_id, $academy) { if ($te_id == "辅导员") { $classArray = teClass::find()->where(['teID' => $teID])->asArray()->all(); } else { if ($te_id == "副书记") { $classArray = Record::find()->where(["academy" => $academy, "status" => "等待副书记审核"])->asArray()->all(); } else { if ($te_id == "书记") { $classArray = Record::find()->where(["academy" => $academy, "status" => "等待书记审核"])->asArray()->all(); } } } return $classArray; }
public function actionDel($id) { $result = array(); $model = Doctor::findOne($id); if (Record::find()->where('doctor_id=' . $id . '')->exists()) { $model->enabled = 0; $model->update(); $result['status'] = 1; $result['message'] = '该医生已关联数据,不能删除,已经禁用!'; } else { $model->delete(); $result['status'] = 1; $result['message'] = '删除成功'; } return $this->renderJson($result); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = RecordModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith(['caseStatus']); $dataProvider->setSort(['attributes' => ['id', 'infraction_date', 'state_id', 'license', 'status_id' => ['asc' => ['CaseStatus.name' => SORT_ASC], 'desc' => ['CaseStatus.name' => SORT_DESC], 'label' => 'Status'], 'created_at']]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['Record.id' => $this->id, 'infraction_date' => $this->infraction_date, 'state_id' => $this->state_id, 'license' => $this->license, 'status_id' => $this->status_id]); // filter by country name $query->joinWith(['caseStatus' => function ($q) { $q->where('CaseStatus.name LIKE "%' . $this->statusName . '%"'); }]); return $dataProvider; }
public function search($params) { // $query = Record::find(); $b = Yii::$app->user->getId(); // var_dump(Yii::$app->user); // die; $admin = Users::findOne($b); $academy = $admin->te_aca; $id = $admin->id; $te_id = self::searchte_id(); $teClass = array(); $te = teClass::find()->where(['teID' => $id])->asArray()->all(); // var_dump($te);die; for ($i = 0; $i < sizeof($te); $i++) { $teClass[] = $te[$i]['st_class']; } // var_dump($teClass);die; if ($academy == "学生处") { $query = Record::find()->where(['status' => ['审核不通过', '审核通过']]); } else { if ($te_id == "辅导员") { $query = Record::find()->where(["academy" => $academy])->andwhere(['st_class' => $teClass])->andwhere(['status' => ['待审核', '审核通过', '审核不通过']]); } else { if ($te_id == "副书记") { $query = Record::find()->where(["academy" => $academy])->andwhere(['status' => ['等待副书记审核']]); } else { if ($te_id == "书记") { $query = Record::find()->where(["academy" => $academy])->andwhere(['status' => ['等待书记审核']]); } } } } // // $sql = 'SELECT * FROM record where academy=".$aa"'; // $sql = "SELECT * FROM record where academy=(select te_aca from admin where id='".$b."' )"; // $query = Record::findBySql($sql); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['today' => SORT_DESC]]]); $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(['totalday' => $this->totalday]); $query->andFilterWhere(['like', 'todaydetail', $this->todaydetail])->andFilterWhere(['like', 'st_classmark', $this->st_classmark])->andFilterWhere(['like', 'startday', $this->startday])->andFilterWhere(['like', 'endday', $this->endday])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'countryEN', $this->countryEN])->andFilterWhere(['like', 'st_name', $this->st_name])->andFilterWhere(['like', 'st_nameEN', $this->st_nameEN])->andFilterWhere(['like', 'gaokaohao', $this->gaokaohao])->andFilterWhere(['like', 'idcard', $this->idcard])->andFilterWhere(['like', 'sex', $this->sex])->andFilterWhere(['like', 'st_year', $this->st_year])->andFilterWhere(['like', 'st_class', $this->st_class])->andFilterWhere(['like', 'academy', $this->academy])->andFilterWhere(['like', 'major', $this->major])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'today', $this->today]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = RecordModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['time' => SORT_DESC]]]); $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, 'object_id' => $this->object_id, 'time' => $this->time, 'ip' => $this->ip]); if (isset($params['user'])) { $user = User::findOne(['name' => $params['user']]); $query->andWhere(['or', ['user_name' => $user->name], ['object_id' => $user->id]]); } $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'event', $this->event])->andFilterWhere(['like', 'data', $this->data])->andFilterWhere(['like', 'user_name', $this->user_name]); return $dataProvider; }
public function update(Request $request) { $id = $request->input('data.id'); $record = Record::find($id); $record->name = $request->input('data.name'); $record->type = $request->input('data.type'); $record->content = $request->input('data.content'); $record->prio = $request->input('data.priority'); $record->ttl = $request->input('data.ttl'); $record->auth = "1"; $record->save(); $domain_id = $record->domain_id; $type = $record->type; if ($type == 'SOA') { $zone = Domain::find($domain_id); $zone->name = $request->input('data.name'); $zone->save(); } return response()->json(['success' => 'record_updated'], 200); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Record::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created' => SORT_DESC]]]); $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, 'window_id' => $this->window_id, 'duration' => $this->duration, 'motions' => $this->motions, 'clicks' => $this->clicks, 'keys' => $this->keys, 'created' => $this->created]); $timezone = new \DateTimeZone(Yii::$app->timeZone); if ($this->timestampFrom) { $from = (new \DateTime('@' . strtotime('today', $this->timestampFrom)))->setTimezone($timezone); $query->andWhere('{{record}}.start >= :today', [':today' => $from->format('Y-m-d H:i:s')]); } if ($this->timestampTo) { $to = (new \DateTime('@' . strtotime('tomorrow', $this->timestampTo)))->setTimezone($timezone); $query->andWhere('{{record}}.start < :todayNight', [':todayNight' => $to->format('Y-m-d H:i:s')]); } return $dataProvider; }
/** * 获取上线进度 * @param $taskId */ public function actionGetProcess($taskId) { $record = Record::find()->select(['action', 'status', 'memo'])->where(['task_id' => $taskId])->orderBy('id desc')->asArray()->one(); $record['percent'] = isset(Record::$ACTION_PERCENT[$record['action']]) ? Record::$ACTION_PERCENT[$record['action']] : 0; static::renderJson($record); }
public function actionAssign() { $taskId = Yii::$app->request->getBodyParam('task'); $windowId = Yii::$app->request->getBodyParam('window'); $processId = Yii::$app->request->getBodyParam('process'); $transaction = Yii::$app->db->beginTransaction(); $timezone = new \DateTimeZone(Yii::$app->timeZone); $from = new \DateTime('today', $timezone); $to = new \DateTime('tomorrow', $timezone); try { $ids = Record::find()->with('window')->select(['id'])->andFilterWhere(['window_id' => $windowId, 'window.process_id' => $processId])->andWhere(['>=', 'start', $from->format('Y-m-d H:i:s')])->andWhere(['<', 'end', $to->format('Y-m-d H:i:s')])->createCommand()->queryColumn(); RecordTask::deleteAll(['record_id' => $ids]); $values = array_map(function ($id) use($taskId) { return [$id, $taskId]; }, $ids); Yii::$app->db->createCommand()->batchInsert('{{record_task}}', ['record_id', 'task_id'], $values)->execute(); $transaction->commit(); } catch (Exception $e) { $transaction->rollBack(); } }
/** * 获取上线进度 * * @param $taskId */ public function actionGetProcess($taskId) { $record = Record::find()->select(['percent' => 'action', 'status', 'memo', 'command'])->where(['task_id' => $taskId])->orderBy('id desc')->asArray()->one(); $record['memo'] = stripslashes($record['memo']); $record['command'] = stripslashes($record['command']); $this->renderJson($record); }
public function actionList() { $data = Record::find()->all(); return $this->render('list', ['data' => $data]); }
public function actionLogin() { $model = new Login(); if ($model->load(Yii::$app->request->post())) { $user = $model->getUser(); if ($user) { if (empty($user->hash)) { Yii::$app->session->setFlash('error', Yii::t('app', Yii::t('app', 'Your account is not activated. Check your email'))); } else { $can = $user->canLogin(); if ($can && $user->validatePassword($model->password)) { if ($user->status > 0) { if (empty($user->auth)) { $user->generateAuthKey(); $user->save(); } if (Yii::$app->user->login($user, $model->remember ? $user->duration * 60 : 0)) { $bundle = $user->getBundle(); if ($bundle && isset($bundle['node_id'])) { $node_id = (int) $bundle['node_id']; $user->setBundle(null); $user->save(); if (Node::find()->where(['id' => $node_id])->count() > 0) { Yii::$app->session->addFlash('success', Yii::t('app', 'Congratulation! You receive a gift')); return $this->redirect(['/pyramid/node/index', 'id' => $node_id]); } } return $this->redirect(['view']); // return $this->actionView($user->name); } else { Yii::$app->session->addFlash('error', Yii::t('app', 'Something wrong happened')); } } else { Yii::$app->session->setFlash('error', Yii::t('app', Yii::t('app', 'Your account is blocked'))); } } else { Journal::write('user', 'login_fail', $user->id); if ($can) { Yii::$app->session->setFlash('error', Yii::t('app', 'Invalid username or password')); } else { $record = Record::find()->where(['object_id' => $user->id, 'event' => 'login_fail'])->orderBy(['time' => SORT_DESC])->one(); Yii::$app->session->setFlash('error', Yii::t('app', 'You have exceeded the maximum number of login attempts, you will be able to enter after {time}', ['time' => $record->time])); } } } } else { Yii::$app->session->setFlash('error', Yii::t('app', 'Invalid username or password')); } } return $this->render('login', ['model' => $model]); }
public function canLogin() { return Record::find()->andWhere(['object_id' => $this->id, 'event' => 'login_fail'])->andWhere('time > DATE_SUB(NOW(), INTERVAL 5 MINUTE)')->count() < 10; }
public function canLogin() { return Record::find()->andWhere(['object_id' => $this->id, 'event' => 'login_fail'])->andWhere('(NOW() - "time") < interval \'5 minutes\'')->count() < 30; }
public static function windows($fromTime, $toTime) { $query = Record::find()->joinWith(['window'])->distinct()->select(['window_id as id', 'window.title']); self::whereFromTo($query, $fromTime, $toTime); return $query->createCommand()->queryAll(); }
public function actionAssignTask($id) { $records = Record::find()->where(['window_id' => $id])->select(['id'])->column(); $transaction = Yii::$app->db->beginTransaction(); foreach ($records as $record_id) { $link = new RecordTask(); $link->record_id = $record_id; $link->task_id = Yii::$app->request->getBodyParam('task_id'); $link->save(); } $transaction->commit(); $this->redirect(['view', 'id' => $id]); }
public function actionLogin() { $model = new Login(); if ($model->load(Yii::$app->request->post())) { $user = $model->getUser(); if ($user) { $can = $user->canLogin(); if ($can && $user->validatePassword($model->password)) { if ($user->status > 0) { Yii::$app->user->login($user); return $this->redirect(['view', 'name' => $user->name]); } else { Yii::$app->session->setFlash('error', Yii::t('app', 'Ваш аккаунт заблокирован')); } } else { Journal::write('user', 'login_fail', $user->id); if ($can) { Yii::$app->session->setFlash('error', Yii::t('app', 'Invalid username or password')); } else { $record = Record::find()->where(['object_id' => $user->id, 'event' => 'login_fail'])->orderBy(['time' => SORT_DESC])->one(); Yii::$app->session->setFlash('error', "Вы превысили максимальное количество попыток входа, вы сможете войти после {$record->time}"); } } } else { Yii::$app->session->setFlash('error', Yii::t('app', 'Invalid username or password')); } } return $this->render('login', ['model' => $model]); }
public function actionAutocomplete($col = 'name', $key) { if (isset($key)) { $result = Record::find()->select(['name', 'phone'])->where($col . ' like "%' . $key . '%"')->limit(10)->all(); if ($result) { $result = ArrayHelper::getColumn($result, $col); return $this->renderJson($result); } } }
public function actionUserreport() { $ids = ArrayHelper::getColumn(Record::find()->select('user_id')->where('is_reserve=1')->distinct()->all(), 'user_id'); $model = User::find()->select(['id', 'username'])->andWhere(['in', 'id', $ids])->asArray()->all(); $startDate = strtotime(Yii::$app->request->get('startdate') . ' 00:00:00'); $endDate = strtotime(Yii::$app->request->get('enddate') . ' 23:59:59'); for ($i = 0; $i < count($model); $i++) { $baseQuery = Record::find()->andWhere(['user_id' => $model[$i]['id']]); $tempQuery = clone $baseQuery; $model[$i]['reservecount'] = $tempQuery->andWhere(['>', 'created_at', $startDate])->andWhere(['<', 'created_at', $endDate])->andWhere(['is_reserve' => 1])->count(); $tempQuery = clone $baseQuery; $model[$i]['arrivedcount'] = $tempQuery->andWhere(['>', 'arrived_at', $startDate])->andWhere(['<', 'arrived_at', $endDate])->andWhere(['is_arrive' => 1])->count(); } return $this->renderPartial('userreport', ['model' => $model]); }
use yii\helpers\Html; use yii\grid\GridView; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $searchModel app\models\RecordSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = '申请记录(搜索框内可模糊查询)'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="record-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php header("Content-type:text/html;charset=utf-8"); // var_dump($classArray);die; $academy = Record::find()->where(['academy' => $academy, 'st_class' => $major])->asArray()->all(); // $academy=Record::find()->where(['academy'=>$academy,'major'=>['财务管理']])->all(); // var_dump(Yii::$app->user->identity); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'today', 'st_classmark', 'st_name', ['attribute' => 'major', 'filter' => Html::activeDropDownList($searchModel, 'major', ArrayHelper::map($academy, 'major', 'major'), ['class' => 'form-control', 'prompt' => '显示全部'])], ['attribute' => 'status', 'filter' => Html::activeDropDownList($searchModel, 'status', ArrayHelper::map($array, 'name', 'name'), ['class' => 'form-control', 'prompt' => '显示全部'])], ['attribute' => 'st_class', 'filter' => Html::activeDropDownList($searchModel, 'st_class', ArrayHelper::map($classArray, 'st_class', 'st_class'), ['class' => 'form-control', 'prompt' => '显示全部'])], ['attribute' => 'model', 'filter' => Html::activeDropDownList($searchModel, 'model', ArrayHelper::map(Record::find()->asArray()->all(), 'model', 'model'), ['class' => 'form-control', 'prompt' => '显示全部'])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}{update}']]]); ?> </div>
/** * @return array */ public function getTitleRecord() { $titles = Record::find()->joinWith('window')->select(['title', '{{record}}.id'])->orderBy('{{record}}.id')->createCommand()->queryAll(); return $titles; }