public function actionRegion($id = null) { if ($id) { $model = Geo::getOne($id); //получчаем количество розничных точек в регионе $col_apteki = Apteki::find()->where(['region_id' => $id])->count(); //получаем количество Юр.лиц $col_ur_l = RegionUrL::find()->where(['id_reg' => $id])->count(); $db = new Query(); $db->from('region_ur_l'); $db->InnerJoin('ur_l', 'id_ur = ur_l.id'); $db->andWhere(['=', 'id_reg', $id]); $db->andWhere(['=', 'ur_l.regional_id', $model['regional_id']]); $col_ur_l_regpred = $db->count(); // $col_ur_l_regpred = RegionUrL::find()->where(['id_reg' => $id])->andWhere(['$model'=>])->count(); } else { $model = Geo::getAll(); } $region = new Geo(); if ($_POST['Geo']) { $model->attributes = $_POST['Geo']; if ($model->validate() && $model->save()) { return $this->render('/edit/region', ['model' => $model, 'region' => $region, 'ok' => 1, 'col_apteki' => $col_apteki, 'col_ur_l' => $col_ur_l, 'col_ur_l_regpred' => $col_ur_l_regpred]); } } if ($id) { return $this->render('/edit/region', ['model' => $model, 'col_apteki' => $col_apteki, 'col_ur_l' => $col_ur_l, 'col_ur_l_regpred' => $col_ur_l_regpred]); } else { return $this->render('region', ['model' => $model]); } }
public function actionFasten($id) { $user = Users::getOne($id); $status = $user['status']; $regions = Geo::find()->all(); $region = ArrayHelper::map($regions, 'id', 'name'); return $this->render('fasten', ['model' => $user, 'region' => $region, 'id' => $id, 'status_id' => $status, 'status' => Yii::$app->params['status_user'][$status]]); }
public function setQuery($query) { $geo = new Geo(); $geo->reset(); $geo->installGeo($this->id_okrug, $this->id_region, $this->id_city); if ($geo->arrayCity) { $where["id_city"] = $geo->arrayCity; } if ($this->id_cat) { $cat = FCategory::findOne($this->id_cat); $arrayUsers = $cat->arrayUsers; $where["id"] = $arrayUsers; } if (isset($where)) { $query = $query->where($where); } if ($this->search != "") { $query = $query->andWhere(["or like", $this->search_field, $this->search]); } return $query; }
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'manuf')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'is_active')->checkbox(); ?> <?php echo $form->field($model, 'region_id')->dropdownList(Geo::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Выберите регион']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Добавить' : 'Обновить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Добавить препарат', ['create'], ['class' => 'btn btn-success']); ?> </p> <br> <?php $reg = Geo::find()->select(['name', 'id'])->indexBy('id')->orderBy('name')->column(); echo Html::dropdownList('region', $region, $reg, ['class' => 'form-control', 'id' => 'change_reg']); ?> <script> $(document).ready(function () { $('#change_reg').change(function () { window.location.href='?region='+this.value; }); }); </script> <br> <table> <?php foreach ($model as $preparat) {
public function getGeo() { return $this->hasOne(Geo::className(), ['id' => 'geo_id']); }