/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Region::find(); $query->orderBy(['id' => SORT_ASC]); $dataProvider = new ActiveDataProvider(['query' => $query]); if ($this->load($params) && !$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'grade' => $this->grade]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'language', $this->language]); return $dataProvider; }
public function actionGetregion($id) { $rows = \common\models\Region::find()->where(['country_id' => $id, 'is_status' => 1])->all(); echo "<option value=''>" . Yii::t('app', '-- Select Region --') . "</option>"; if (count($rows) > 0) { foreach ($rows as $row) { echo "<option value='{$row->id}'>{$row->region}</option>"; } } else { echo ""; } }
/** * 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(['region_id' => $this->region_id, 'island_id' => $this->island_id]); $query->andFilterWhere(['like', 'region_name', $this->region_name]); 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, 'country_id' => $this->country_id, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'is_status' => $this->is_status]); $query->andFilterWhere(['like', 'region', $this->region]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Region::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public static function getData() { $data_size = 0; $data = []; foreach (Region::find()->all() as $region) { /* @var $region Region */ $data[$data_size] = ['title' => $region->name, 'folder' => true, 'expanded' => true, 'key' => 'r-' . $region->id, 'children' => []]; foreach (Group::find()->all() as $group) { /* @var $group Group */ $objects = []; foreach ($group->objects as $object) { if ($object->region_id === $region->id) { $objects[] = ['title' => $object->name, 'folder' => true, 'expanded' => false, 'count' => 2, 'key' => 'o-' . $object->id, 'children' => [['title' => 'Информация', 'key' => 'i-' . $object->id], ['title' => 'Документы', 'key' => 'd-' . $object->id]]]; } } if (sizeof($objects) > 0) { $data[$data_size]['children'][] = ['title' => $group->name, 'folder' => true, 'expanded' => false, 'count' => sizeof($objects), 'key' => 'g-' . $group->id, 'children' => $objects]; } } $data[$data_size]['count'] = sizeof($data[$data_size]['children']); $data_size++; } return $data; }
<li class="addr-li cle"> <label>国家:</label> <?php echo Html::activeDropDownList($model, 'country', ArrayHelper::map(\common\models\Region::find()->where(['parent_id' => 0])->all(), 'id', 'name'), ['prompt' => Yii::t('app', 'Please Select'), 'onchange' => ' $.post( "' . Yii::$app->urlManager->createUrl('region/ajax-list-child?id=') . '"+$(this).val(), function( data ) { $( "select#address-province" ).html( data ); });']); echo Html::activeDropDownList($model, 'province', $model->province ? ArrayHelper::map(\common\models\Region::find()->where(['parent_id' => $model->country])->all(), 'id', 'name') : ['' => Yii::t('app', 'Please Select')], ['onchange' => ' $.post( "' . Yii::$app->urlManager->createUrl('region/ajax-list-child?id=') . '"+$(this).val(), function( data ) { $( "select#address-city" ).html( data ); });']); echo Html::activeDropDownList($model, 'city', $model->city ? ArrayHelper::map(\common\models\Region::find()->where(['parent_id' => $model->province])->all(), 'id', 'name') : ['' => Yii::t('app', 'Please Select')], ['onchange' => ' $.post( "' . Yii::$app->urlManager->createUrl('region/ajax-list-child?id=') . '"+$(this).val(), function( data ) { $( "select#address-district" ).html( data ); });']); echo Html::activeDropDownList($model, 'district', $model->district ? ArrayHelper::map(\common\models\Region::find()->where(['parent_id' => $model->city])->all(), 'id', 'name') : ['' => Yii::t('app', 'Please Select')]); ?> <li> <label>街道地址:</label> <?php echo Html::activeTextInput($model, 'address', ['class' => 'txt']); ?> </li> <li> <label>邮编:</label> <?php echo Html::activeTextInput($model, 'zipcode', ['class' => 'txt']); ?> </li> <li> <label>联系电话:</label>
<?php $dataCountry = ArrayHelper::map(\common\models\Region::find()->asArray()->where(['parent_id' => 0])->all(), 'id', 'name'); echo $form->field($model, 'country')->dropDownList($dataCountry, ['prompt' => Yii::t('app', 'Please Select'), 'onchange' => ' $.post( "' . Yii::$app->urlManager->createUrl('region/ajax-list-child?id=') . '"+$(this).val(), function( data ) { $( "select#address-province" ).html( data ); });']); echo $form->field($model, 'province')->dropDownList($model->city ? ArrayHelper::map(\common\models\Region::find()->where(['parent_id' => $model->country])->all(), 'id', 'name') : [], ['onchange' => ' $.post( "' . Yii::$app->urlManager->createUrl('region/ajax-list-child?id=') . '"+$(this).val(), function( data ) { $( "select#address-city" ).html( data ); });']); echo $form->field($model, 'city')->dropDownList($model->city ? ArrayHelper::map(\common\models\Region::find()->where(['parent_id' => $model->province])->all(), 'id', 'name') : [], ['onchange' => ' $.post( "' . Yii::$app->urlManager->createUrl('region/ajax-list-child?id=') . '"+$(this).val(), function( data ) { $( "select#address-district" ).html( data ); });']); echo $form->field($model, 'district')->dropDownList($model->district ? ArrayHelper::map(\common\models\Region::find()->where(['parent_id' => $model->city])->all(), 'id', 'name') : []); ?> <?php echo $form->field($model, 'address')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'zipcode')->textInput(['maxlength' => 16]); ?> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => 32]); ?> <?php
<?php use yii\helpers\Html; use yii\bootstrap\ActiveForm; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ $this->registerCssFile('@web/css/checkout.css', ['depends' => \frontend\assets\AppAsset::className()]); $allRegion = ArrayHelper::map(\common\models\Region::find()->asArray()->all(), 'id', 'name'); $totalProduct = 0; $totalPrice = 0; foreach ($products as $product) { $totalProduct += $product->number; $totalPrice += $product->number * $product->price; } $i = 0; ?> <div id="main"> <!-- 已登录状态 开始 --> <div class="user-tip cle"> <div class="fl">Hi,<?php echo Yii::$app->user->identity->username; ?> ,请确认订单信息</div> <div class="fr"> <a class="graybtn" href="<?php echo Yii::$app->urlManager->createUrl(['/cart']); ?> ">返回购物车修改</a> </div> </div> <div class="form_main"> <?php
public static function region() { $alias = static::getCategory('region'); $temp = Region::find()->with('content')->all(); $origin = []; foreach ($temp as $t) { $origin[$t->content->name] = $t->id; } return array_merge($origin, $alias); }
/** * Lists all Region models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Region::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
/* @var $form yii\widgets\ActiveForm */ ?> <div class="province-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'province_name')->textInput(['maxlength' => true]); ?> <?php $region = Region::find()->all(); $listData = ArrayHelper::map($region, 'region_id', 'region_name'); echo $form->field($model, 'region_id')->dropDownList($listData, ['prompt' => 'Select your 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>
<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel backend\modules\ksk\models\ObjectSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Objects'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="object-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Object', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'name', ['attribute' => 'region_id', 'value' => 'region.name', 'filter' => \yii\helpers\ArrayHelper::map(\common\models\Region::find()->all(), 'id', 'name')], ['attribute' => 'group_id', 'value' => 'group.name', 'filter' => \yii\helpers\ArrayHelper::map(\common\models\Group::find()->all(), 'id', 'name')], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>