示例#1
0
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         Region::deleteAll('country_id = ' . $this->id);
         City::deleteAll('country_id = ' . $this->id);
         return true;
     } else {
         return false;
     }
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 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;
 }
示例#5
0
 /**
  * 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>";
     }
 }
示例#6
0
 /**
  * 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;
 }
示例#7
0
 /**
  * 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;
 }
示例#8
0
 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;
 }
示例#9
0
                <?php 
    echo Html::hiddenInput('SaleSearch[price_from]', $model->price_from, ['id' => 'price_from']);
    ?>
                <?php 
    echo Html::hiddenInput('SaleSearch[price_to]', $model->price_to, ['id' => 'price_to']);
    ?>
            </div>
        </div>
    </div>
<?php 
} else {
    ?>
    <div class="row">
        <div class="col-xs-6 col-sm-4 col-md-2">
            <?php 
    echo $form->field($model, 'region_id')->dropDownList(Region::getList(), ['class' => 'form-control selectpicker show-tick', 'data-style' => 'form-control', 'id' => 'region_id', 'title' => Yii::t('app', 'Choose One'), 'prompt' => Yii::t('app', 'Any')]);
    ?>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-2">
            <?php 
    echo $form->field($model, 'district_id')->widget(DepDrop::classname(), ['data' => District::getList($model->region_id), 'options' => ['class' => 'form-control selectpicker show-tick', 'data-style' => 'form-control', 'id' => 'district_id', 'title' => Yii::t('app', 'Choose One'), 'prompt' => Yii::t('app', 'Any')], 'pluginOptions' => ['depends' => ['region_id'], 'placeholder' => false, 'url' => Url::to(['/ajax/district-list'])], 'pluginEvents' => ['depdrop.afterChange' => "function (event, id, value) { \$('#district_id').selectpicker('refresh'); }"]]);
    ?>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-2">
            <?php 
    echo $form->field($model, 'type_id')->dropDownList(Sale::getTypeList(), ['class' => 'form-control selectpicker show-tick', 'data-style' => 'form-control', 'title' => Yii::t('app', 'Choose One'), 'prompt' => Yii::t('app', 'Any')])->label(Yii::t('app', 'Type'));
    ?>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-2">
            <?php 
    echo Html::label($model->getAttributeLabel('bedroom'));
示例#10
0
文件: _form.php 项目: dench/resistor
            <div class="row">
                <div class="col-md-8">
                    <div class="box">
                        <div class="box-header with-border">
                            <h4 class="box-title"><?php 
echo Yii::t('app', 'Location');
?>
</h4>
                        </div>
                        <div class="box-body">

                            <div class="row">
                                <div class="col-md-6">
                                    <?php 
echo $form->field($model, 'region_id')->dropDownList(Region::getList(), ['id' => 'region_id', 'prompt' => '']);
?>
                                </div>
                                <div class="col-md-6">
                                    <?php 
echo $form->field($model, 'district_id')->widget(DepDrop::classname(), ['data' => District::getList($model->region_id), 'options' => ['id' => 'district_id'], 'pluginOptions' => ['depends' => ['region_id'], 'placeholder' => false, 'url' => Url::to(['/personal/district-list'])]]);
?>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6">
                                    <?php 
echo $form->field($model, 'address', ['template' => "{label}\n<div class=\"input-group\">{input}\n<span class=\"input-group-btn\"><button class=\"btn btn-default\" type=\"button\"><span class=\"glyphicon glyphicon-refresh\" aria-hidden=\"true\"></span></button></span></div>\n{hint}\n{error}"])->textInput(['maxlength' => true]);
?>
                                </div>
示例#11
0
    <?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 
示例#12
0
<?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 
/* @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>
示例#14
0
                <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>
示例#15
0
文件: view.php 项目: CTaiDeng/funshop
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Region */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Regions'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="region-view">

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'parent_id', 'value' => $model->parent ? $model->parent->name : '-'], 'name', 'path', 'language', ['attribute' => 'grade', 'value' => \common\models\Region::getGradeLabel($model->grade)]]]);
?>

</div>
示例#16
0
文件: _form.php 项目: dench/resistor
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\District */
/* @var $region array */
/* @var $form yii\widgets\ActiveForm */
?>

<?php 
$form = ActiveForm::begin();
?>

<div class="box">
    <div class="box-body">
        <?php 
echo $form->field($model, 'region_id')->dropDownList(Region::getList())->label(Yii::t('app', 'Region'));
?>

        <?php 
foreach ($model_content as $key => $content) {
    echo $form->field($content, "[{$key}]name")->label(Yii::t('app', 'Lang_' . $key));
}
?>
    </div>
    <div class="box-footer">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
</div>
示例#17
0
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $searchModel common\models\RegionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Regions');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="region-index">

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <!--p>
        <?php 
echo Html::a(Yii::t('app', 'Create ') . Yii::t('app', 'Region'), ['create'], ['class' => 'btn btn-success']);
?>
    </p-->

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'parent_id', 'value' => function ($model) {
    return $model->parent ? $model->parent->name : '-';
}], 'name', 'language', ['attribute' => 'grade', 'value' => function ($model) {
    return \common\models\Region::getGradeLabel($model->grade);
}, 'filter' => Html::activeDropDownList($searchModel, 'grade', \common\models\Region::getGradeLabel(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}']]]);
?>

</div>
示例#18
0
文件: index.php 项目: dench/resistor
<?php

use backend\components\SetColumn;
use common\models\District;
use common\models\Lang;
use common\models\Region;
use common\models\Sale;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel common\models\SaleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Sales');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box">
    <div class="box-body table-responsive">
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'code', 'headerOptions' => ['width' => '100']], ['class' => SetColumn::className(), 'attribute' => 'name', 'name' => 'name', 'value' => 'content.name'], ['class' => SetColumn::className(), 'attribute' => 'region_id', 'filter' => Region::getList(), 'name' => 'region.content.name'], ['class' => SetColumn::className(), 'attribute' => 'district_id', 'filter' => District::getListAll(), 'name' => 'district.content.name'], 'address', ['attribute' => 'created_at', 'format' => ['date', 'dd.MM.Y'], 'options' => ['width' => '80']], ['class' => SetColumn::className(), 'attribute' => 'top', 'filter' => Sale::getTopList(), 'name' => 'topName', 'cssClasses' => [Sale::TOP_DISABLED => 'default', Sale::TOP_ENABLED => 'success']], ['class' => SetColumn::className(), 'attribute' => 'status', 'filter' => Sale::getStatusList(), 'name' => 'statusName', 'cssClasses' => [Sale::STATUS_HIDE => 'default', Sale::STATUS_ACTIVE => 'success', Sale::STATUS_AWAITING => 'warning']], ['class' => SetColumn::className(), 'attribute' => 'sold', 'filter' => Sale::getSoldList(), 'name' => 'soldName', 'cssClasses' => [Sale::SOLD_ACTUAL => 'success', Sale::SOLD_US => 'default', Sale::SOLD_OTHER => 'default']], ['class' => 'yii\\grid\\ActionColumn', 'headerOptions' => ['width' => '70'], 'template' => '{link} {update} {delete}', 'buttons' => ['link' => function ($url, $model, $key) {
    return Html::a('<span class="fa fa-eye"></span>', Url::to(Yii::$app->params['http'] . '/' . Lang::getCurrent()->code . '/sale/' . $model->id), ['target' => '_blank']);
}]]]]);
?>
    </div>
    <div class="box-footer">
        <?php 
echo Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']);
?>
    </div>
</div>
示例#19
0
<div class="box">
    <div class="box-body">

        <?php 
$form = ActiveForm::begin(['options' => ['class' => 'item', 'id' => 'p' . $parse->id]]);
?>

        <div class="row">
            <div class="col-md-2">
                <?php 
echo $form->field($sale, 'type_id', ['template' => '{input}'])->dropDownList(Sale::getTypeList(), ['prompt' => '- ' . @$origin['type'] . ' -', 'class' => 'form-control', 'data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('type_id')]);
?>
            </div>
            <div class="col-md-2">
                <?php 
echo $form->field($sale, 'region_id', ['template' => '{input}'])->dropDownList(Region::getList(), ['class' => 'form-control', 'id' => 'region_id_' . $form->id, 'prompt' => '- ' . @$origin['region'] . ' -', 'data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('region_id')]);
?>
            </div>
            <div class="col-md-2">
                <?php 
if ($sale->region_id) {
    $district_list = District::getList($sale->region_id);
} else {
    $district_list = [];
}
echo $form->field($sale, 'district_id', ['template' => '{input}'])->widget(DepDrop::className(), ['data' => $district_list, 'options' => ['id' => 'district_id_' . $form->id, 'prompt' => '- ' . @$origin['district'] . ' -', 'data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('district_id'), 'data-value' => @$origin['district']], 'pluginOptions' => ['depends' => ['region_id_' . $form->id], 'placeholder' => false, 'url' => Url::to(['/district/list'])]]);
?>
            </div>
            <div class="col-md-2">
                <?php 
echo $form->field($sale, 'gps', ['template' => '{input}'])->textInput(['data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('gps')]);
示例#20
0
文件: index.php 项目: dench/resistor
<?php

use backend\components\SetColumn;
use common\models\District;
use common\models\Region;
use common\models\Sale;
use yii\bootstrap\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ObjectSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Objects');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box">
    <div class="box-body table-responsive">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'headerOptions' => ['width' => '50']], ['class' => SetColumn::className(), 'label' => Yii::t('app', 'Name'), 'attribute' => 'name', 'value' => 'sale.name'], ['class' => SetColumn::className(), 'attribute' => 'region_id', 'filter' => Region::getList(), 'value' => 'sale.region.content.name'], ['class' => SetColumn::className(), 'attribute' => 'district_id', 'filter' => District::getListAll(), 'value' => 'sale.district.content.name'], ['class' => SetColumn::className(), 'label' => Yii::t('app', 'Address'), 'attribute' => 'address', 'value' => 'sale.address'], ['attribute' => 'sale.created_at', 'format' => ['date', 'dd.MM.Y'], 'options' => ['width' => '80']], ['class' => SetColumn::className(), 'attribute' => 'status', 'filter' => Sale::getStatusList(), 'name' => 'statusName', 'cssClasses' => [Sale::STATUS_HIDE => 'default', Sale::STATUS_ACTIVE => 'success', Sale::STATUS_AWAITING => 'warning']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{link} {create}', 'buttons' => ['link' => function ($url, $model, $key) {
    return Html::a(Yii::t('app', 'View'), Url::toRoute(['sale/update', 'id' => $model->sale->id]), ['class' => 'btn btn-primary btn-xs']);
}, 'create' => function ($url, $model, $key) {
    return Html::a(Yii::t('app', 'Create'), Url::toRoute(['sale/create', 'object_id' => $model->id]), ['class' => 'btn btn-success btn-xs']);
}]]]]);
?>
    </div>
</div>
示例#21
0
 /**
  * Finds the Region model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Region the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Region::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#22
0
"><i class="glyphicon glyphicon-map-marker"></i></a></td>
                        <td><?php 
    echo $item->consignee;
    ?>
</td>
                        <td><?php 
    echo $item->country ? Region::findOne($item->country)->name : '';
    ?>
 <?php 
    echo $item->province ? Region::findOne($item->province)->name : '';
    ?>
 <?php 
    echo $item->city ? Region::findOne($item->city)->name : '';
    ?>
 <?php 
    echo $item->district ? Region::findOne($item->district)->name : '';
    ?>
</td>
                        <td><?php 
    echo $item->address;
    ?>
</td>
                        <td><?php 
    echo $item->mobile;
    ?>
</td>
                        <td class="setup"><a class="update" href="<?php 
    echo Yii::$app->urlManager->createUrl(['address/update', 'id' => $item->id]);
    ?>
">修改</a>&nbsp;|&nbsp;<a class="delete" href="<?php 
    echo Yii::$app->urlManager->createUrl(['address/delete', 'id' => $item->id]);
示例#23
0
文件: Sale.php 项目: dench/resistor
 public function getRegion()
 {
     return $this->hasOne(Region::className(), ['id' => 'region_id']);
 }
示例#24
0
 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);
 }
示例#25
0
?>
</td>
                    </tr>
                    <tr>
                        <td class="tl">收货地址:</td>
                        <td> <?php 
echo $model->country ? Region::findOne($model->country)->name : '';
?>
 <?php 
echo $model->province ? Region::findOne($model->province)->name : '';
?>
 <?php 
echo $model->city ? Region::findOne($model->city)->name : '';
?>
 <?php 
echo $model->district ? Region::findOne($model->district)->name : '';
?>
&nbsp;&nbsp;<?php 
echo $model->address;
?>
&nbsp;(<?php 
echo $model->mobile;
?>
)
                            <p><a class="graybtn" target="_blank" href="<?php 
echo Yii::$app->urlManager->createUrl(['/order']);
?>
">进入我的订单</a></p></td>
                    </tr>
                    </tbody>
                </table>
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegions()
 {
     return $this->hasMany(Region::className(), ['island_id' => 'island_id']);
 }
示例#27
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDistrict0()
 {
     return $this->hasOne(Region::className(), ['id' => 'district']);
 }
示例#28
0
文件: index.php 项目: omeke/yii2-papa
<?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>