/**
  * Creates a new Code model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Code();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $count = $model->count;
         $codes = [];
         for ($i = 0; $i < $count; $i++) {
             $codeModel = clone $model;
             $codeModel->code = Code::generateCode();
             $codeModel->used = 0;
             $codeModel->save();
             $codes[] = $codeModel->z_b_id . str_pad($codeModel->z_p_id, 3, '0', STR_PAD_LEFT) . $codeModel->code;
         }
         return $this->render('create-summary', ['codes' => $codes, 'bank' => Bank::findOne($codeModel->z_b_id), 'count' => $count]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #2
0
 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;
 }
예제 #3
0
 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;
 }
 /**
  * Finds the Bank model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Bank the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Bank::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #5
0
echo Html::a('Neuer Benutzertext', ['user-text/create/' . $type], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'ut_id', ['attribute' => 'p_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Group', 'p_id', 'bezeichnung', true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->p_id) {
        return 'Alle';
    }
    $group = \app\models\Group::findOne($model->p_id);
    return $group ? $group->bezeichnung : $model->p_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 'b_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Bank', 'b_id', 'bezeichnung', true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->b_id) {
        return 'Alle';
    }
    $group = \app\models\Bank::findOne($model->b_id);
    return $group ? $group->bezeichnung : $model->b_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 'l_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => InputHelper::getDropdownOptions('app\\models\\Language', 'l_id', 'name', true, true, true), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'value' => function ($model, $key, $index, $widget) {
    if (!$model->b_id) {
        return 'Default';
    }
    $group = \app\models\Language::findOne($model->l_id);
    return $group ? $group->name : $model->l_id;
}, 'filterInputOptions' => ['placeholder' => 'Bitte wählen Sie'], 'format' => 'raw'], ['attribute' => 't_id', 'value' => function ($model, $key, $index, $widget) {
    $group = \app\models\Text::findOne($model->t_id);
    return $group ? $group->name : $model->t_id;
}, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>
예제 #6
0
 public function groupNotLocked($attribute)
 {
     $bank = Bank::findOne($this->z_b_id);
     if ($bank->isLocked($this->{$attribute})) {
         $this->addError($attribute, "Code ist ungültig. Die Gruppe ist für die ausgewählte Bank gesperrt.");
         return false;
     }
     return true;
 }
 public function actionQuestionnaire($bezeichnung, $groupId, $langId)
 {
     $is_locked = Settings::getSetting('locked');
     if ($is_locked == 1) {
         return $this->render('error', ['name' => 'Fehler', 'message' => 'Das System ist gesperrt. Bei Fragen wenden sie sich bitte an Emotion Banking.']);
     }
     try {
         $bankKlasse = Bank::findOne(['b_id' => $bezeichnung])->klasse;
         $questionnaire = Form::findOne(['f_klasse' => $bankKlasse, 'f_p_id' => $groupId]);
         if (empty($questionnaire)) {
             throw new ErrorException('Es gibt keinen Fragebogen für ihre Banken-, bzw. Kundengruppenauswahl');
         }
         $code = $questionnaire->createSpecificCode($bezeichnung);
         if ($code->hasErrors()) {
             return $this->render('error', ['name' => 'Fehler', 'message' => $code->getLastErrorMessage()]);
         }
     } catch (ErrorException $e) {
         return $this->render('error', ['name' => 'Fehler', 'message' => $e->getMessage()]);
     }
     $codeString = $code->__toString();
     if ($codeString !== null) {
         $warning = '';
         $model = new AnketForm();
         $model->code = $codeString;
         $model->language = $langId;
         if ($langId != "default") {
             $lanuage = Language::findOne($langId);
             if (empty($lanuage)) {
                 $warning = "Die angegebene Sprache " . $langId . " kann nicht gefunden werden. Es wird die Standardsprache angezeigt";
             }
         }
         if ($code !== false && ($code = $model->validateCode())) {
             $model->processCode($code);
             $data = Yii::$app->session['anketData'];
             $text = UserText::getText($data['group']['p_id'], $data['bank']['b_id'], $data['lang'], true);
             if (is_null($text)) {
                 return $this->render('error', ['name' => 'Fehler', 'message' => 'kein Starttext für diese Sprache gefunden']);
             }
             return $this->render('welcome', ['text' => $text, 'code' => $data["original"], 'warning' => $warning, 'style' => $data['style']]);
         } else {
             return $this->render('error', ['name' => 'Fehler', 'message' => 'Bank gesperrt, Code ungültig oder bereits verwendet. Anmeldung fehlgeschlagen']);
         }
     } else {
         $this->redirect(['/site/index']);
     }
     $data = Yii::$app->session['anketData'];
     $form = Form::findOne($data['form']);
     $questions = $form->getQuestions($bank_id = $data["bank"]["b_id"]);
     //default
     $status = 0;
     //code not needed.
     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;
     } else {
         $data = Yii::$app->session['anketData'];
         $text = UserText::getText($data['group']['p_id'], $data['bank']['b_id'], $data['lang'], true);
         if (is_null($text)) {
             return $this->render('error', ['name' => 'Fehler', 'message' => 'kein Starttext für diese Sprache gefunden']);
         }
         return $this->render('welcome', ['text' => $text, 'code' => $data["original"], 'style' => $data["style"]]);
     }
     Yii::$app->session['anketData'] = $data;
     if (!($status < $form->getQuestionsCount($questions))) {
         $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']]);
 }