Ejemplo n.º 1
0
 /**
  * Finds the CustomerGroup model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CustomerGroup the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CustomerGroup::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 2
0
 /**
  * @see \yii\db\BaseActiveRecord::beforeSave($insert)
  */
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         //如果设置为默认,应该取消其它默认,默认只有一个
         if ($this->is_default) {
             CustomerGroup::updateAll(['is_default' => self::CUSTOMER_GROUP_NOT_DEFAULT]);
         }
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
                <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
                        
                <!-- 
                    <p>
                        <?php 
echo Html::a(Yii::t('customer', 'Create Customer'), ['create'], ['class' => 'btn btn-success']);
?>
                    </p>
                 -->
            
                <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'username', ['attribute' => 'gender', 'filter' => [Customer::CUSTOMER_MALE => Yii::t('common', 'Male'), Customer::CUSTOMER_FEMALE => Yii::t('common', 'Female')], 'value' => function ($model) {
    return $model->status ? Yii::t('common', 'Male') : Yii::t('common', 'Female');
}], 'birthday:date', 'email:email', ['attribute' => 'point', 'filter' => false], ['attribute' => 'customerGroup.name', 'filter' => ArrayHelper::map(CustomerGroup::find()->all(), 'id', 'name')], ['attribute' => 'status', 'filter' => [Customer::CUSTOMER_ON => Yii::t('common', 'On'), Customer::CUSTOMER_OFF => Yii::t('common', 'Off')], 'value' => function ($model) {
    return $model->status ? Yii::t('common', 'On') : Yii::t('common', 'Off');
}], 'last_login_at:datetime', ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('common', 'Opration'), 'template' => '{view} {update} {delete} {address} {new_address}', 'buttons' => ['address' => function ($url, $model, $key) {
    $url = ['/customer/customer-address/index', 'CustomerAddressSearch[customer_id]' => $model->id];
    //用户id取用户地址
    $options = ['title' => Yii::t('customer', 'View Address'), 'aria-label' => Yii::t('customer', 'View Address'), 'data-pjax' => '0', 'target' => '_blank'];
    return Html::a('<span class="ion-map"></span>', $url, $options);
}, 'new_address' => function ($url, $model, $key) {
    $url = ['/customer/customer-address/create', 'customer_id' => $model->id];
    //用户id取用户地址
    $options = ['title' => Yii::t('customer', 'Add New Address'), 'aria-label' => Yii::t('customer', 'Add New Address'), 'data-pjax' => '0', 'target' => '_blank'];
    return Html::a('<span class="ion-ios-plus"></span>', $url, $options);
}]]]]);
?>
                                
                </div>
Ejemplo n.º 4
0
 /**
  * 表关联
  */
 public function getCustomerGroup()
 {
     //管理员与其组,是一对一的关系
     return $this->hasOne(CustomerGroup::className(), ['id' => 'customer_group_id']);
 }
Ejemplo n.º 5
0
    <div class="col-md-1"></div>
    <div class="col-md-12 col-lg-6">
        <?php 
$form = ActiveForm::begin();
?>
        <?php 
echo $form->field($model, 'username')->textInput(['maxlength' => true]);
?>
        <?php 
echo $form->field($model, 'password')->passwordInput();
?>
        <?php 
echo $form->field($model, 'nickname')->textInput(['maxlength' => true]);
?>
        <?php 
echo $form->field($model, 'customer_group_id')->label(Yii::t('customer', 'Customer Group'))->dropDownList(ArrayHelper::map(CustomerGroup::find()->all(), 'id', 'name'));
?>
        <?php 
echo $form->field($model, 'gender')->dropDownList([Customer::CUSTOMER_MALE => Yii::t('common', 'Male'), Customer::CUSTOMER_FEMALE => Yii::t('common', 'Female')]);
?>
        
        <?php 
echo $form->field($model, 'birthday', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
    
        <?php 
echo $form->field($model, 'email')->textInput(['maxlength' => true]);
?>
        <?php 
echo $form->field($model, 'telephone')->textInput(['maxlength' => true]);
?>