/** * Displays a single Profile model. * @param integer $id * @return mixed */ public function actionView() { $model = $this->findModel(Yii::$app->user->id); $modelRegion = Region::find()->where(['id' => $model->region_id])->one(); $model->region = $modelRegion->name; // echo '<pre>'; // print_r($model->region); // echo '</pre>'; // exit; return $this->render('view', ['model' => $model]); }
public function actionFetchData() { $categorys = \yii\helpers\ArrayHelper::toArray(\app\models\CategoryGoogle::find()->all()); $location = \yii\helpers\ArrayHelper::toArray(\app\models\Region::find()->all()); $place = \yii\helpers\ArrayHelper::toArray(\app\models\Place::find()->all()); $placeCategory = \yii\helpers\ArrayHelper::toArray(\app\models\PlaceCategory::find()->all()); $db = ['location' => $location, 'category' => $categorys, 'place' => $place, 'place_category' => $placeCategory]; // echo '<pre>'; // print_r($db); // print_r($db); echo json_encode($db); // echo '</pre>'; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Region::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Region::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'lat' => $this->lat, 'lng' => $this->lng, 'zoom' => $this->zoom, 'radius' => $this->radius, 'provincia_id' => $this->provincia_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'codigo_postal', $this->codigo_postal]); return $dataProvider; }
/** * List Region Children for select * If deletion is successful, the browser will be redirected to the 'index' page. * @param string $id * @return mixed */ public function actionAjaxListChild($id) { //'visible' => Yii::$app->user->can('deleteYourAuth'), $countChild = Region::find()->where(['parent_id' => $id])->count(); $children = Region::find()->where(['parent_id' => $id])->all(); if ($countChild > 0) { echo "<option>" . Yii::t('app', 'Please Select') . "</option>"; foreach ($children as $child) { echo "<option value='" . $child->id . "'>" . $child->name . "</option>"; } } else { echo "<option>" . Yii::t('app', 'No Option') . "</option>"; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Region::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'note', $this->note]); return $dataProvider; }
public static function getMenuItems() { $items = []; $regions = ArrayHelper::map(Region::find()->all(), 'id', 'nameBoth'); $controller = Yii::$app->controller; foreach ($regions as $key => $value) { $arrayParams = ['MainSearch' => ['region' => $key]]; $params = array_merge(["site/index"], $arrayParams); $url = Yii::$app->urlManager->createUrl($params); $items[] = ['label' => $value, 'url' => $url]; } $arrayParams = ['MainSearch' => ['region' => -1]]; $params = array_merge(["site/index"], $arrayParams); $url = Yii::$app->urlManager->createUrl($params); $items[] = ['label' => 'Պատ. (Random)', 'url' => $url]; if (\Yii::$app->user->can('site.list')) { $items[] = ['label' => 'Գր. (Library)', 'url' => '/site/list']; } if (\Yii::$app->user->can('site.users')) { $items[] = ['label' => 'Օգտ. (Users)', 'url' => '/site/users']; } return $items; }
$form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'province_code')->textInput(['maxlength' => 32]); ?> <?php echo $form->field($model, 'province_description')->textInput(['maxlength' => 32]); ?> <?php echo $form->field($model, 'provincecol')->textInput(['maxlength' => 45]); ?> <?php echo $form->field($model, 'region_id')->dropdownList(ArrayHelper::map(Region::find()->all(), 'id', 'region_code'), ['prompt' => 'Choose a region']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
<h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Mon1str', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'region', 'value' => 'monitoring1.user.profile.region.number', 'filter' => Html::activeDropDownList($searchModel, 'region', ArrayHelper::map(\app\models\Region::find()->asArray()->all(), 'id', 'number'), ['class' => 'form-control', 'prompt' => 'Оберіть код регіону'])], ['attribute' => 'date', 'value' => 'date', 'format' => 'raw', 'width' => '350px', 'filter' => DatePicker::widget(['model' => $searchModel, 'name' => 'date', 'attribute' => 'date', 'options' => ['placeholder' => 'Оберіть місяць ...'], 'pluginOptions' => ['format' => 'yyyy-mm-dd', 'viewMode' => 'months', 'minViewMode' => 'months']])], ['class' => 'yii\\grid\\ActionColumn']]]); ?> <?php $m = Yii::$app->request->get(); $excel = ['excel']; $arrayExcel = ArrayHelper::merge($excel, $m); ?> <p> <?php echo Html::a('Емпортувати в xls', $arrayExcel, ['class' => 'btn btn-success']); ?> </p> </div>
</h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('<i class="glyphicon glyphicon-plus"></i> Створити моніторинг', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => false, 'formatter' => ['class' => 'yii\\i18n\\Formatter', 'nullDisplay' => ''], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'region', 'value' => 'user.profile.region.number', 'filter' => Html::activeDropDownList($searchModel, 'region', ArrayHelper::map(\app\models\Region::find()->asArray()->all(), 'id', 'number'), ['class' => 'form-control', 'prompt' => 'Оберіть код регіону'])], ['attribute' => 'status', 'format' => 'raw', 'contentOptions' => ['style' => 'text-align:center;'], 'value' => function ($model) { if ($model->status == 0) { return '<span class="glyphicon glyphicon-remove" style="color:red;"></span>'; } else { return '<span class="glyphicon glyphicon-ok" style="color:green"></span>'; } }, 'filter' => Html::activeDropDownList($searchModel, 'status', [0 => 'не збережено', 1 => 'збережено'], ['class' => 'form-control', 'prompt' => 'Статус'])], ['attribute' => 'date', 'value' => 'date', 'format' => 'raw', 'width' => '350px', 'filter' => DatePicker::widget(['model' => $searchModel, 'name' => 'date', 'attribute' => 'date', 'options' => ['placeholder' => 'Оберіть місяць ...'], 'pluginOptions' => ['format' => 'yyyy-mm-dd', 'viewMode' => 'months', 'minViewMode' => 'months']])], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['print' => function ($url, $model, $key) { return Html::a('<span class="glyphicon glyphicon-print"></span>', $url, ['title' => 'Друк']); }, 'update' => function ($url, $model, $key) { if (Yii::$app->user->can('admin') || $model->status == 0) { return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => 'Редагувати']); } }, 'delete' => function ($url, $model, $key) { if (Yii::$app->user->can('admin') || $model->status == 0) { return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => 'Видалити', 'data-confirm' => 'Ви впевнені, що хочете видалити цей запис?', 'data-method' => 'post']); }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Region; $regions = Region::find()->all(); $lregions = ArrayHelper::toArray($regions, ['app\\models\\Region' => ['id', 'title']]); $listOfRegions = ArrayHelper::map($lregions, 'id', 'title'); /* @var $this yii\web\View */ /* @var $model app\models\City */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="city-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'region_id')->dropDownList($listOfRegions); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
// ->all(), // 'autoFocus' => true, // 'minLength' => '1', // 'delay' => '100', //// 'change' => new \yii\web\JsExpression("function( event, ui ) { //// if(!ui.item) $('#address-region_id').val(''); //// }"), //// 'select' => new \yii\web\JsExpression("function( event, ui ) { //// $('#address-region_id').val(ui.item.id); //// }"), // ], //]); ?> <?php echo $form->field($model, 'region_name')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\Region::find()->select(['name'])->active()->orderBy('name asc')->asArray()->all(), 'name', 'name'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['allowEmptyOption' => true, 'selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'name', 'labelField' => 'name', 'searchField' => ['name']]])->hint(''); ?> <?php // echo $form->field($model, 'city_id')->textInput() ?> <?php echo $form->field($model, 'city_name')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\City::find()->select(['name'])->active()->orderBy('name asc')->asArray()->all(), 'name', 'name'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'name', 'labelField' => 'name', 'searchField' => ['name']]])->hint(''); ?> <?php /*echo $form->field($model, 'city_name')->widget(\kartik\select2\Select2::classname(), [ 'data' => \app\models\City::find() ->select(['name']) ->active()
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Region; use app\models\City; /* @var $this yii\web\View */ /* @var $model app\models\School */ /* @var $form yii\widgets\ActiveForm */ ?> <?php $region = new Region(); $regions = ArrayHelper::toArray(Region::find()->all(), ['app\\models\\Region' => ['id', 'title']]); $listOfRegions = ArrayHelper::map($regions, 'id', 'title'); $cities = ArrayHelper::toArray(City::find()->all(), ['app\\models\\City' => ['id', 'title']]); $listOfCities = ArrayHelper::map($cities, 'id', 'title'); ?> <div class="school-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php
<div class="address-index"> <h1><?php //echo Html::encode($this->title) ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p class='pull-left'> <?php echo \yii\helpers\Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'Create new'), ['create'], ['class' => 'btn btn-success']); ?> </p> <div class="clearfix"></div> <?php \yii\widgets\Pjax::begin(); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'region_id' => ['attribute' => 'region_id', 'value' => 'region.name', 'filter' => ArrayHelper::map(\app\models\Region::find()->active()->all(), 'id', 'name')], 'city_id' => ['attribute' => 'city_id', 'value' => 'city.name', 'filter' => ArrayHelper::map(\app\models\City::find()->active()->all(), 'id', 'name')], 'street', 'house', 'room', ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'white-space: nowrap;']]], 'tableOptions' => ['class' => 'table table-striped table-hover']]); ?> <?php \yii\widgets\Pjax::end(); ?> </div>
public function getAccessableOfficesWhereUserIs($role) { switch ($role) { case self::MANAGER: return $this->offices; break; case self::COMDIR: /* Коммерческий директор имеет доступ к офисам своего региона */ $offices = []; $regions = Region::find(['user_id' => 'id'])->innerJoin('questionlist_users_to_regions utr', 'utr.region_id=' . Region::tableName() . '.id', ['utr.user_id' => $this->id])->with('offices')->all(); if (!$regions) { return; } foreach ($regions as $region) { $offices = array_merge($offices, $region->offices); } return $offices; break; case self::ADMIN: /* Админ имеет доступ к всем офисам */ if (!$this->isAdmin) { return; } return Office::find()->all(); break; } }
<div class="city-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(); ?> <?php echo $form->field($model, 'name_eng')->textInput(); ?> <?php echo $form->field($model, 'region')->dropDownList(ArrayHelper::map(Region::find()->all(), 'id', 'nameBoth')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $region = Region::find($id); $region->delete(); //Region::destroy($id); return back()->with('alert-success', 'Регион ' . $region->reg_name . ' удален'); }
public function update(Request $request, $id) { $this->update_validation_rules($request); $date_open = $this->saved_date_format($request->input('date_open')); $request->merge(array('date_open' => $date_open)); $regUpdate = $request->input(); $region = Region::find($id); $region->update($regUpdate); Session::flash('flash_message', 'Data berhasil diupdate!'); return redirect('master/regions'); }
?> <?php print $form->field($model, 'plat')->checkbox(); } ?> <?php //$form->field($model, 'three_list') // ->dropDownList(ArrayHelper::map(Region::find()->all(), 'id', 'name'), ['multiple' => true]) // ?> <?php //$model2 = new Authors(); echo $form->field($model, 'three_list')->widget(Select2::classname(), ['data' => ArrayHelper::map(Region::find()->orderBy('name')->all(), 'id', 'name'), 'options' => ['placeholder' => 'Выбрать регион ...', 'multiple' => true], 'pluginOptions' => ['allowClear' => true]]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Отредактировать', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
public function findRegion($name) { return Region::find()->where(["name" => $name])->one(); }
public function actionMyBookmarks() { if (Currency::find()->where(['>', 'date', time()])->orderBy(['date' => SORT_DESC])->asArray()->one() == null) { $currency = new Currency(); if ($currency->exchangeRates()) { Yii::$app->session->setFlash('warning', 'Exchange rates might differ from actual ones'); } } $disabled_subcat = 'disabled'; $disabled_city = 'disabled'; $catList = ArrayHelper::map(Category::find()->asArray()->all(), 'id', 'name'); $regionList = ArrayHelper::map(Region::find()->asArray()->all(), 'id', 'name'); $subcatList = []; $cityList = []; $searchModel = new BookmarkSearch(); $dataProvider = $searchModel->getMyBookmarks(); $advert = new Advert(); return $this->render('my-bookmarks', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'catList' => $catList, 'subcatList' => $subcatList, 'regionList' => $regionList, 'cityList' => $cityList, 'disabled_subcat' => $disabled_subcat, 'disabled_city' => $disabled_city, 'advert' => $advert]); }
/** * Updates an existing User model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $modelUser = $this->findModel($id); $modelProfile = $this->findModelProfile($id); $roles = AuthItem::find()->all(); $arrayRoles = ArrayHelper::map($roles, 'name', 'description'); $regions = Region::find()->all(); $arrayRegions = ArrayHelper::map($regions, 'id', 'name'); if (!empty($modelUser->password_hash)) { $modelUser->password_hash = NULL; } $modelUser->worker_name = $modelProfile->worker_name; $modelUser->telephone = $modelProfile->telephone; $modelUser->head_position = $modelProfile->head_position; $modelUser->head_name = $modelProfile->head_name; $modelUser->region = $modelProfile->region_id; $modelUser->access = $modelUser->role->item_name; if ($modelUser->load(Yii::$app->request->post())) { if ($modelUser->validate()) { if ($modelUser->password_hash |= NULL) { $modelUser->setPassword($modelUser->password_hash); } else { $modelUser->password_hash = $modelUser->getOldAttribute('password_hash'); } if ($modelUser->save(false)) { $modelProfile->user_id = $modelUser->id; $modelProfile->worker_name = $modelUser->worker_name; $modelProfile->telephone = $modelUser->telephone; $modelProfile->head_position = $modelUser->head_position; $modelProfile->head_name = $modelUser->head_name; $modelProfile->region_id = $modelUser->region; if ($modelProfile->save(false)) { $auth = Yii::$app->authManager; $auth->revokeAll($modelUser->id); $role = $auth->getRole($modelUser->access); if ($auth->assign($role, $modelUser->id)) { return $this->redirect(['view', 'id' => $modelUser->id]); } } } } } return $this->render('update', ['model' => $modelUser, 'arrayRoles' => $arrayRoles, 'arrayRegions' => $arrayRegions]); }
/** * Creates a new Advert model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $user = User::findOne(['id' => Yii::$app->user->id]); // $pic = new UploadForm(); $catList = ArrayHelper::map(Category::find()->asArray()->all(), 'id', 'name'); $subcatList = ArrayHelper::map(Subcategory::find()->asArray()->all(), 'id', 'name'); $regionList = ArrayHelper::map(Region::find()->asArray()->all(), 'id', 'name'); $cityList = ArrayHelper::map(City::find()->asArray()->all(), 'id', 'name'); $model = new Advert(); if ($model->load(Yii::$app->request->post())) { if ($model->createAdvert()) { return $this->redirect(['upload']); } return $this->render('create', ['model' => $model, 'user' => $user, 'catList' => $catList, 'subcatList' => $subcatList, 'regionList' => $regionList, 'cityList' => $cityList]); } return $this->render('create', ['model' => $model, 'user' => $user, 'catList' => $catList, 'subcatList' => $subcatList, 'regionList' => $regionList, 'cityList' => $cityList]); }
use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel app\models\UserSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Users'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="user-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create User', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'username', ['attribute' => 'region', 'value' => 'profile.region.name', 'filter' => Html::activeDropDownList($searchModel, 'region', ArrayHelper::map(\app\models\Region::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Район/місто'])], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>