/** * @return mixed the value of the given option or the default, if none */ public function getOption($name, $defaultValue = null, $returnModel = false) { $data = ['name' => $name, 'parent_class' => self::className(), 'parent_id' => $this->id]; $meta = Meta::findOne($data); if ($returnModel) { if (!isset($meta)) { $meta = new Meta(); $data['value'] = $defaultValue; $meta->load(['data' => $data], 'data'); } return $meta; } else { return isset($meta) ? $meta->value : $defaultValue; } }
public function actionClean() { Code::updateAll(['used' => 0, 'status' => 0]); Meta::deleteAll(); Result::deleteAll(); return $this->redirect(['/system/statistic']); }
public function search($params) { $query = Meta::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'child_id' => $this->child_id]); $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value])->andFilterWhere(['like', 'format', $this->format])->andFilterWhere(['like', 'parent_class', $this->parent_class])->andFilterWhere(['like', 'child_class', $this->child_class]); return $dataProvider; }
public function processCode($code) { if ($this->isCodeActive($code)) { $group = Group::findOne($code->z_p_id)->toArray(); $bank = Bank::findOne($code->z_b_id)->toArray(); $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]); Yii::$app->session['anketData'] = ['code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language]; $meta = Meta::findOne(['m_z_id' => $code->z_id]); if (!$meta) { $meta = new Meta(); $meta->m_z_id = $code->z_id; $meta->ip = $_SERVER['REMOTE_ADDR']; $meta->time_start = time(); } else { $meta->ip = $_SERVER['REMOTE_ADDR']; } $meta->save(); return true; } return false; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Meta::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, 'subprogramaid' => $this->subprogramaid, 'usuariocrea' => $this->usuariocrea, 'fechacrea' => $this->fechacrea, 'usuariomodifica' => $this->usuariomodifica, 'fechamodifica' => $this->fechamodifica]); $query->andFilterWhere(['like', 'meta', $this->meta]); return $dataProvider; }
public function processCode($fullCode) { $code = $fullCode['code']; $original = $fullCode['original']; if ($this->isCodeActive($code)) { $group = Group::findOne($code->z_p_id)->toArray(); $bank = Bank::findOne($code->z_b_id)->toArray(); $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]); $style = Style::findOne(['s_b_id' => $bank['b_id'], 's_p_id' => $group['p_id']]); if (!$style) { $style = Settings::getSetting('style'); } else { $style = $style->style; } $label = Yii::$app->params['default_next_label']; $message = Yii::$app->params['default_next_message']; if ($this->language != "default") { $language = Language::findOne($this->language); if ($language != null) { if ($language->label != '') { $label = $language->label; } if ($language->message != '') { $message = $language->message; } } } Yii::$app->session['anketData'] = ['original' => $original, 'code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language, 'style' => $style, 'label' => $label, 'message' => $message]; $meta = Meta::findOne(['m_z_id' => $code->z_id]); if (!$meta) { $meta = new Meta(); $meta->m_z_id = $code->z_id; $meta->ip = $_SERVER['REMOTE_ADDR']; $meta->time_start = time(); } else { $meta->ip = $_SERVER['REMOTE_ADDR']; } $meta->save(); return true; } return false; }
/** * @return \yii\db\ActiveQuery */ public function getMetas() { return $this->hasMany(Meta::className(), ['subprogramaid' => 'id']); }
public function getMeta() { return $this->hasOne(Meta::className(), ['m_z_id' => 'z_id']); }
/** * Finds the Meta model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Meta the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Meta::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/* @var $this yii\web\View */ /* @var $model app\models\Bank */ $this->title = $model->bezeichnung . ' - Statistik'; $this->params['breadcrumbs'][] = ['label' => 'Banken', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="bank-view"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['label' => 'Personengruppe', 'attribute' => 'bezeichnung', 'width' => '20%'], ['label' => 'Anz. Codes', 'attribute' => 'tic_count', 'pageSummary' => true, 'width' => '20%'], ['label' => 'Komplett', 'attribute' => 'bused', 'pageSummary' => true, 'width' => '20%'], ['label' => 'nur 50 oder mehr', 'attribute' => 'bused50', 'pageSummary' => true, 'width' => '20%'], ['label' => 'Gesamt in Auswertung', 'attribute' => 'busedtot', 'pageSummary' => true, 'width' => '20%']], 'showPageSummary' => true]); $codes = \app\models\Code::find()->andWhere(['used' => 1, 'z_b_id' => $model->b_id])->all(); $count = 0; $ips = array(); $time = 0; foreach ($codes as $code) { $count++; $meta = \app\models\Meta::findOne(['m_z_id' => $code->z_id]); $time += $meta->time_end - $meta->time_start; if (!isset($ips[$meta->ip])) { $ips[$meta->ip] = 1; } else { $ips[$meta->ip]++; } } $mip = ''; $max = 0; foreach ($ips as $ip => $ipc) { if ($ipc > $max) { $max = $ipc; $mip = $ip; } }
public function actionForm() { if (!isset(Yii::$app->session['anketData'])) { $this->redirect(['/site/index']); } $data = Yii::$app->session['anketData']; $form = Form::findOne($data['form']); $questions = $form->getQuestions($bank_id = $data["bank"]["b_id"]); $status = isset($data['status']) && !empty($data['status']) ? $data['status'] : Code::findOne($data['code']['z_id'])->status; if (Yii::$app->request->post('q')) { $userAnswers = Yii::$app->request->post('q'); $status = $form->saveAnswers($data['code'], $userAnswers); $data['status'] = $status; $data['code']['status'] = $status; $code = Code::findOne($data['code']['z_id']); $code->used = 0; //workaround $code->count = 1; $code->status = $status; $code->save(); } Yii::$app->session['anketData'] = $data; if (!($status < $form->getQuestionsCount($questions))) { $code = Code::findOne($data['code']['z_id']); $code->used = 1; $meta = Meta::findOne($data['code']['z_id']); $meta->time_end = time(); $meta->save(); //workaround. Doesn't affect nothing at all $code->count = 1; $code->save(); $this->redirect(['/site/end']); } return $this->render('form', ['status' => $status, 'percent' => round($status / $form->getQuestionsCount($questions) * 100), 'questions' => $questions, 'anket' => $form, 'bank' => $data['bank']['b_id'], 'style' => $data['style']]); }