/** * @inherit */ public function init() { parent::init(); $this->registerTranslations(); Reports::$classes_list = $this->_report_classes; Reports::$module = $this; }
/** * Creates a new Reports model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $report = Reports::instantiate([]); if (!$report->isAllowed('create')) { throw new \yii\web\ForbiddenHttpException(Yii::t('reportmanager', 'Access restricted')); } if ($report->load(Yii::$app->request->post()) && $report->save()) { return $this->redirect(['update', 'id' => $report->id]); } else { return $this->render('create', ['model' => $report]); } }
/** * @return \yii\db\ActiveQuery */ public function getReport() { return $this->hasOne(Reports::className(), ['id' => 'report_id']); }
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'class_name')->dropDownList(array_combine(Reports::$classes_list, array_map(function ($v) { return $v::getModelLabel(); }, Reports::$classes_list)), ['maxlength' => true]); ?> <?php echo $form->field($model, 'group_id')->dropDownList(ArrayHelper::map($model->getGroupList(), 'id', 'name')); ?> <?php echo $form->field($model, 'show')->radioList(Reports::listShowOptions()); ?> <?php if (in_array($model->show, ['graph', 'both'])) { ?> <div class="panel panel-default"> <div class="panel-body"> <?php echo $form->field($model, 'graph_x')->dropDownList(ArrayHelper::map($model->columns, 'alias', 'label')); ?> </div> </div> <?php