public function actionKlavaro() { if (Yii::$app->getRequest()->getQueryParam('user')) { $user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user')); if (Yii::$app->getRequest()->getQueryParam('presize') && Yii::$app->getRequest()->getQueryParam('speed') !== null && Yii::$app->getRequest()->getQueryParam('eng_ru') && Yii::$app->getRequest()->getQueryParam('cat')) { $act = new DiaryActs(); $act->model_id = 13; $act->user_id = $user->id; if ((double) Yii::$app->getRequest()->getQueryParam('presize') > 95 && (double) Yii::$app->getRequest()->getQueryParam('speed') > 30) { $act->mark = 2; } elseif ((double) Yii::$app->getRequest()->getQueryParam('presize') > 95) { $act->mark = 1; } else { $act->mark = 0; } //var_dump($act); if ($act->save(false)) { $klav_done = new Klavaro(); $klav_done->presize = (double) Yii::$app->getRequest()->getQueryParam('presize'); $klav_done->speed = (double) Yii::$app->getRequest()->getQueryParam('speed'); if (Categories::find()->where("name like '" . trim(Yii::$app->getRequest()->getQueryParam('eng_ru') . "'"))->one()) { // return var_dump(Categories::find()->where(['name' => Yii::$app->getRequest()->getQueryParam('cat')])->one()->id); $klav_done->eng_ru = Categories::find()->where("name like '" . trim(Yii::$app->getRequest()->getQueryParam('eng_ru') . "'"))->one()->id; } else { return "Раскладка!"; } if (Categories::find()->where("name like '" . trim(Yii::$app->getRequest()->getQueryParam('cat') . "'"))->one()) { // return var_dump(Categories::find()->where(['name' => Yii::$app->getRequest()->getQueryParam('cat')])->one()->id); $klav_done->cat_id = Categories::find()->where("name like '" . trim(Yii::$app->getRequest()->getQueryParam('cat') . "'"))->one()->id; } else { return "Категория!"; } $klav_done->act_id = $act->id; //return var_dump($klav_done); if ($klav_done->save(false)) { return 'Получи ' . $act->mark . ' баллов!'; } else { return 'Ошибка klav'; } } else { return 'Ошибка act'; } } return $this->renderPartial('klavaro', ['user' => $user]); } return 'Доступ запрещён'; }
- <?php echo round($mark->avg, 2); ?> - <?php echo $mark->cnt; ?> </p> <?php } else { ?> <p style="color: red"><?php echo $i + 1; ?> . <?php echo \app\models\MarkUser::findOne($mark->user_id)->name; ?> - <?php echo round($mark->avg, 2); ?> - <?php echo $mark->cnt; ?> </p> <?php } $i++; ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getUser() { return $this->hasOne(MarkUser::className(), ['id' => 'user_id']); }
<title><?php echo Html::encode($this->title); ?> </title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin(['brandLabel' => 'Оцени себя, ' . $this->context->current_user->name . ',<span style="color:yellow"> В твоём кошельке ' . round(\app\models\MarkUser::findOne($this->context->current_user->id)->money) . ' Р</span>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'Группы', 'url' => ['default/']], ['label' => 'Статистика', 'url' => ['default/']]]]); NavBar::end(); ?> <div class="container"> <?php echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <?php echo $content; ?> </div> </div> <footer class="footer">
/** * Проверка юзера * @param $cuser * @return bool */ private function userIfUserLegal($cuser) { $max_id = MarkUser::find()->select('MAX(id)')->scalar(); $i = 0; while ($i <= $max_id) { $i++; if ($user = MarkUser::findOne($i)) { if (md5($user->id) == $cuser) { $this->current_user = $user; return true; } } } return false; }
function actionTelephone() { if (Yii::$app->getRequest()->getQueryParam('user')) { //return Yii::$app->getRequest()->getQueryParam('user'); $user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user')); try { $tells = TelBasemts::find()->select(['id, nom_tel, COUNT(*) as cnt'])->where(['user_id' => 8])->groupBy('nom_tel')->orderBy('cnt DESC')->limit(50)->all(); } catch (\ErrorException $e) { return $e->getMessage(); } //return var_dump($tells); return $this->renderPartial('telephone', ['user' => $user, 'tells' => $tells]); } }