/** * Create Record model or update an existing Record model. Create Files and attach to Record model. * If update is successful, the browser will be redirected to the 'upload' page. * @return array|string|Response * @throws \yii\web\NotFoundHttpException */ public function run() { $recordId = Yii::$app->request->get('id'); if ($recordId) { $model = $this->controller()->findModel(Record::className(), $recordId); } else { $model = new Record(); $model->scenario = Record::SCENARIO_UPLOAD; } $model->user_id = Yii::$app->user->id; if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } $post = Yii::$app->request->post(); if ($model->load($post) && $model->validate()) { if ($this->saveRecord($model, $post)) { Yii::$app->trigger(EventNames::UPLOAD_SUCCESS, new UploadEvent(['record' => $model, 'user_id' => Yii::$app->user->id])); } return $this->controller()->redirect(['upload', 'id' => $model->id]); } $media = self::media(); $uploadUrl = $media->uploadRoute; $handleUrl = $media->handleRoute; $dropZone = $media->dropZone; $maxFileSize = $media->maxFileSize; $maxChunkSize = $media->maxChunkSize; $acceptMimeTypes = $media->acceptMimeTypes; $view = $recordId ? 'edit' : 'upload'; return $this->controller()->render($view, ['model' => $model, 'handleUrl' => $handleUrl, 'uploadUrl' => $uploadUrl, 'dropZone' => $dropZone, 'maxFileSize' => $maxFileSize, 'maxChunkSize' => $maxChunkSize, 'acceptMimeTypes' => $acceptMimeTypes]); }
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 beforeSave($insert) { if ($this->extCorrelation === null) { $this->extCorrelation = '0'; } return parent::beforeSave($insert); }
/** * Finds the Journal model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Record the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Record::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function delete() { foreach ($this->transactions as $transaction) { $transaction->intCorrelation = 0; $transaction->intType = 0; $transaction->save(); } return parent::delete(); }
/** * @return string the associated database table name */ public function delete() { if ($this->id >= 16) { //protect all sys docs return parent::delete(); } else { return false; } }
public function run($id = 0) { if (!$id) { $this->controller()->redirect(['search']); } $record = $this->controller()->findModel(Record::className(), $id); Yii::$app->view->params['aside'] = Timeline::widget(['stages' => self::collectCaseStages($record), 'remaining' => self::calculateRemainingDays($record)]); return $this->controller()->render('review', ['model' => $record, 'form' => $this->getForm($record)]); }
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]]); }
public function actionInsert() { $session = Yii::$app->session; $record = new Record(); $record->todaydetail = date('md') . date('Hi') . date('s'); $record->today = $session['today']; $record->st_classmark = $session['stu']->st_classmark; $record->startday = $session['startday']; $record->endday = $session['endday']; $record->totalday = $session['totalday']; $record->country = $session['country']; $record->countryEN = $session['countryEN']; $record->st_name = $session['stu']->st_name; $record->st_nameEN = $session['st_nameEN']; $record->gaokaohao = $session['stu']->st_gaokaohao; $record->idcard = $session['idcard']; $record->sex = $session['sex']; $record->st_year = $session['stu']->st_year; $record->st_class = $session['stu']->st_class; $record->major = $session['major']->mj_name_zh; $record->academy = $session['academy']->ac_name_zh; $record->status = '审核中'; switch ($session['model_id']) { case 'baodao': $record->model = "报道证明"; break; case 'putongzaidu': $record->model = "普通在读证明"; break; case 'chuguoliuxue': $record->model = "出国留学在读证明"; break; case 'chuguolvyou': $record->model = "出国旅游在读证明"; break; case 'churujing': $record->model = "出入境在读证明"; break; } $record->save(); echo "<script>\n alert ('申请成功,现在返回首页');\n window.location.href='../web/index.php';\n \n </script>"; }
public function delete() { foreach ($this->Transactions as $transaction) { $transaction->extCorrelation = 0; $transaction->save(); } foreach ($this->Bankbooks as $bankbook) { $bankbook->extCorrelation = 0; $bankbook->save(); } return parent::delete(); }
public function destroy($id) { $domain = Domain::find($id); if ($domain = null) { return response()->json(['error' => 'domain_does_not_existe'], 400); } $domain_id = $id; $zones = Zone::where('domain_id', '=', $domain_id)->delete(); $records = Record::where('domain_id', '=', $domain_id)->delete(); $domain = Domain::where('id', '=', $id)->delete(); return response()->json(['success'], 200); }
/** * 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 delete() { $users = User::find()->All(); foreach ($users as $user) { $IncomeMap = UserIncomeMap::findOne(array('user_id' => $user->id, 'itemVatCat_id' => $this->id)); if ($IncomeMap) { //'user_id', 'itemVatCat_id' $IncomeMap->delete(); } } parent::delete(); }
public function store(Request $request) { $name = $request->input('data.name'); if ($name != null) { $dominio = Domain::where('name', '=', $name)->first(); if ($dominio != null) { return response()->json(['error' => 'zone_exists'], 409); } $master = new Domain(); $master->name = $request->input('data.name'); $master->type = $request->input('data.type'); $master->save(); $id = $master->id; //Get the las insert //Insert into Records $records = new Record(); $records->domain_id = $id; $records->name = $request->input('data.name'); $records->type = 'SOA'; $records->content = 'ns1.' . $request->input('data.name') . ' hostmasters.' . $request->input('data.name') . ' ' . date("Ymd") . "00 28800 7200 604800 86400"; $records->ttl = '86400'; $records->prio = '0'; $records->change_date = time(); $records->auth = '1'; $records->save(); //Insert into Zones $zones = new Zone(); $zones->domain_id = $id; $zones->owner = '1'; $zones->comment = ''; $zones->zone_templ_id = '0'; $zones->save(); return response()->json(['success' => 'zone_created'], 200); } else { return response()->json(['error' => 'zone_error'], 400); } }
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); }
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]); $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; }
/** * 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; }
/** * 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; }
public function addRecord(Request $request) { $rsa = new RSA(); $rsa->loadKey(Config::get('keys.private')); // private key $encryptedData = $request->input('data'); //Выставляем нужный режим декодировния $rsa->setEncryptionMode(RSA::ENCRYPTION_PKCS1); //Декодируем куски текста $decryptedData = ''; foreach ($encryptedData as $encryptedDataSubstring) { $decryptedData .= $rsa->decrypt(base64_decode($encryptedDataSubstring)); } //Преобразуем декодированный текст из json массива $data = json_decode($decryptedData, true); if ($data) { //Пишем в базу только если есть данные if (array_get($data, 'data')) { Record::create($data); } } //Возвращать ничего не нужно return ''; }
private function ini() { if ($this->valuedate == null) { $this->valuedate = Record::writeDate(time()); } if (!$this->ini) { $this->_precision = Yii::$app->params['precision']; $item = Item::findByPk($this->item_id, $this->valuedate); if (is_null($item)) { $this->iVatRate = 0; } else { $this->iVatRate = $item->vat; } //for vat resons... //if ($this->rate == 0) { $this->rate = Currates::GetRate($this->currency_id, $this->valuedate); //} if ($this->doc_rate == 0) { $doc = Docs::findOne($this->doc_id); $this->doc_rate = Currates::GetRate($doc->currency_id, $this->valuedate); } $this->ini != $this->ini; } }
/** * 执行远程服务器任务集合 * 对于目标机器更多的时候是一台机器完成一组命令,而不是每条命令逐台机器执行 * * @param $version * @throws \Exception */ private function _updateRemoteServers($version) { $cmd = []; // pre-release task if ($preRelease = WalleTask::getRemoteTaskCommand($this->conf->pre_release, $version)) { $cmd[] = $preRelease; } // link if ($linkCmd = $this->walleFolder->getLinkCommand($version)) { $cmd[] = $linkCmd; } // post-release task if ($postRelease = WalleTask::getRemoteTaskCommand($this->conf->post_release, $version)) { $cmd[] = $postRelease; } $sTime = Command::getMs(); // run the task package $ret = $this->walleTask->runRemoteTaskCommandPackage($cmd); // 记录执行时间 $duration = Command::getMs() - $sTime; Record::saveRecord($this->walleTask, $this->task->id, Record::ACTION_UPDATE_REMOTE, $duration); if (!$ret) { throw new \Exception('全量更新服务器出错'); } return true; }
/** * @return \yii\db\ActiveQuery */ public function getRecord() { return $this->hasOne(Record::className(), ['user_id' => 'id']); }
public function index() { $data = Record::where('estado', 'ready')->get(); $fields = $this->fields(); return view($this->root . '/' . $this->module . '/list', compact('data', 'fields')); }
public function getRecords() { return $this->hasMany(Record::className(), ['window_id' => 'id'])->inverseOf('window'); }
public function actionList() { $data = Record::find()->all(); return $this->render('list', ['data' => $data]); }
/** * @inheritdoc */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), ['fullName' => Yii::t('app', 'Full Name')]); }
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 actionMerge() { $source = Yii::$app->request->post('source'); $src = Yii::$app->request->post('src'); Record::updateAll(array('department_id' => $src), 'department_id in (' . $source . ')'); //更新对话记录的科室 Department::deleteAll('id in (' . $source . ') and id<>' . $src); //删除源科室 $result = array(); $result['status'] = 1; $result['message'] = '合并成功'; return $this->renderJson($result); }