/** * Lists all BasicIndicators models. * @return mixed */ public function actionIndex() { if (\Yii::$app->user->isGuest) { return $this->goHome(); } $dataProvider = new ActiveDataProvider(['query' => BasicIndicators::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
private static function _evaluateIndicators($content, $hospitalIndicators) { $returnTable = []; preg_match_all("|\\[(.+?)\\]|m", $content, $matches); foreach ($matches[1] as $idx => $match) { preg_match_all("|([A-Za-z_]+)|", $match, $matchesIndicators); if (count($matchesIndicators) > 0) { $unit = $basicIndicators = BasicIndicators::find()->where(['name' => $matchesIndicators[1][0]])->one()->unit; } $returnTable[$matches[0][$idx]] = eval('return (' . preg_replace("|([A-Za-z_]+)|", '$hospitalIndicators->$1', $match) . ')' . ($unit == '%' ? '*100' : '') . ';') . $unit; } foreach ($returnTable as $key => $value) { $content = str_replace($key, $value, $content); } return $content; }
<div class="hospitals-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'id')->textInput(); ?> <?php echo $form->field($model, 'name')->textInput(); ?> <?php foreach (BasicIndicators::find()->select(['description', 'name'])->all() as $indicator) { ?> <?php echo $form->field($model, $indicator->name, ['showLabels' => true])->textInput()->label($indicator->description); ?> <?php } ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Utwórz' : 'Aktualizuj', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
/** * @inheritdoc */ public function rules() { return [[['nazwa', 'id_szpital', 'id_specjalizacja', 'id_data', 'id_oddzial'], 'required'], [['id_szpital', 'id_specjalizacja', 'id_data', 'id_oddzial'], 'integer'], [['nazwa'], 'string'], [BasicIndicators::find()->select('name')->column(), 'number']]; }
?> <?php echo $form->field($model, 'lang')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'numerator')->dropDownList(BasicIndicators::find()->select(['name', 'id'])->indexBy('id')->column()); ?> <?php echo $form->field($model, 'denominator')->dropDownList([0 => ''] + BasicIndicators::find()->select(['name', 'id'])->indexBy('id')->column()); ?> <?php echo $form->field($model, 'denominator_dec')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Utwórz' : 'Aktualizuj', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>