public static function getMemberCodes($with_grouped = 0)
 {
     $groupedCodesArray = self::getGroupedCodes();
     /**
      * Get all answers excluding group codes
      */
     if ($with_grouped) {
         $memberAnswers = MembersQuestionsAnswers::find()->innerJoinWith('questionOption')->asArray()->all();
     } else {
         $memberAnswers = MembersQuestionsAnswers::find()->innerJoinWith('questionOption')->where(['not in', 'code_id', $groupedCodesArray['codes']])->asArray()->all();
     }
     /**
      * Run throw answers to build where arrays
      */
     $memberAnswersCodes = [];
     foreach ($memberAnswers as $answer) {
         $answer_codes = explode(',', $answer['questionOption']['code_id']);
         $codes = MappingQuestionsCodes::find()->where(['id' => $answer_codes])->asArray()->all();
         foreach ($codes as $code) {
             $memberAnswersCodes[$code['id']] = $code['code'];
         }
     }
     return $memberAnswersCodes;
 }
Example #2
0
?>

    <?php 
$language_items = [];
foreach ($languages as $key => $language) {
    $field = $form->field($model, "title_{$language->url}")->textInput(['maxlength' => true])->label('Title');
    if ($languageDefault->url == $language->url) {
        $field = $form->field($model, "title")->textInput(['maxlength' => true]);
    }
    $language_items[] = ['label' => Yii::t('backend', $language->name), 'content' => "<p>{$field}</p>", 'active' => $key == 0];
}
echo Tabs::widget(['items' => $language_items]);
?>

    <?php 
echo $form->field($model, 'code_id')->dropDownList(ArrayHelper::map(MappingQuestionsCodes::find()->all(), 'id', 'code'), ['multiple' => 'true', 'size' => 7, 'prompt' => 'Select Option Code']);
?>

    <?php 
echo $form->field($model, 'order')->textInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #3
0
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\backend\models\CmsPagesCategories::find()->all(), 'id', 'title'), ['multiple' => 'true', 'size' => 7])->label(Yii::t('backend', 'Select Categories'));
?>

    <?php 
echo $form->field($model, 'identifier')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'code_id')->dropDownList(ArrayHelper::map(MappingQuestionsCodes::find()->all(), 'id', 'code'), ['multiple' => 'true', 'size' => 7, 'prompt' => Yii::t('backend', 'Select Include Codes')]);
?>

    <?php 
echo $form->field($model, 'no_code_id')->dropDownList(ArrayHelper::map(MappingQuestionsCodes::find()->all(), 'id', 'code'), ['multiple' => 'true', 'size' => 7, 'prompt' => Yii::t('backend', 'Select Exclude Codes')]);
?>

    <?php 
echo $form->field($model, 'sort_order')->textInput();
?>

    <?php 
echo $form->field($model, 'main_img')->widget(FileInput::classname(), ['options' => ['multiple' => false, 'accept' => 'image/*'], 'pluginOptions' => ['previewFileType' => 'image', 'showUpload' => false]])->label(Yii::t('backend', 'Image'));
?>

    <?php 
if (!empty($model->publish_date)) {
    $model->publish_date = date('d.m.Y', strtotime($model->publish_date));
}
?>
 /**
  * Finds the MappingQuestionsCodes model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MappingQuestionsCodes the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MappingQuestionsCodes::find()->where(['id' => $id])->multilingual()->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function getMappingQuestionsCodes()
 {
     return MappingQuestionsCodes::find()->where(['id' => $this->code_id])->multilingual()->one();
 }