コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CouponType::find();
     $query->orderBy(['created_at' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if ($this->load($params) && !$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'money' => $this->money, 'min_amount' => $this->min_amount, 'type' => $this->type, 'started_at' => $this->started_at, 'ended_at' => $this->ended_at, 'min_goods_amount' => $this->min_goods_amount, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the CouponType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CouponType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CouponType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
ファイル: view.php プロジェクト: liangdabiao/funshop
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\CouponType */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Coupon Types'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="coupon-type-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', 'name', 'money', 'min_amount', ['attribute' => 'type', 'value' => \common\models\CouponType::labels($model->type)], 'min_goods_amount', 'started_at:datetime', 'ended_at:datetime', 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'created_by', 'value' => $model->createdBy->username], ['attribute' => 'updated_by', 'value' => $model->updatedBy->username]]]);
?>

</div>
コード例 #4
0
ファイル: Coupon.php プロジェクト: CTaiDeng/funshop
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCouponType()
 {
     return $this->hasOne(CouponType::className(), ['id' => 'coupon_type_id']);
 }
コード例 #5
0
ファイル: index.php プロジェクト: CTaiDeng/funshop
/* @var $searchModel common\models\CouponSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Coupons');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="coupon-index">

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

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

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'user_id', 'value' => function ($model) {
    return $model->user ? $model->user->username : '******';
}], ['attribute' => 'coupon_type_id', 'format' => 'html', 'value' => function ($model) {
    return $model->couponType ? $model->couponType->name : '-';
}, 'filter' => Html::activeDropDownList($searchModel, 'coupon_type_id', ArrayHelper::map(\common\models\CouponType::find()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], 'money', 'min_amount', 'started_at:date', 'ended_at:date', 'sn', ['attribute' => 'order_id', 'value' => function ($model) {
    return $model->order_id ? $model->order_id : '-';
}], ['attribute' => 'used_at', 'value' => function ($model) {
    return $model->used_at ? Yii::$app->formatter->asDatetime($model->used_at) : '-';
}], 'created_at:date', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}']]]);
?>

</div>
コード例 #6
0
ファイル: index.php プロジェクト: CTaiDeng/funshop
<div class="coupon-type-index">

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

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

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'name', 'money', 'min_amount', ['attribute' => 'type', 'format' => 'html', 'value' => function ($model) {
    return \common\models\CouponType::labels($model->type);
}, 'filter' => Html::activeDropDownList($searchModel, 'type', \common\models\CouponType::labels(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'PROMPT_STATUS')])], 'started_at:date', 'ended_at:date', 'created_at:date', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {delete} {car-type}', 'buttons' => ['car-type' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-usd"></span>', $url, ['title' => Yii::t('app', 'Send Coupon')]);
}], 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'view') {
        return ['view', 'id' => $model->id];
    } else {
        if ($action === 'update') {
            return ['update', 'id' => $model->id];
        } else {
            if ($action === 'delete') {
                return ['delete', 'id' => $model->id];
            } else {
                if ($action === 'car-type') {
                    return ['send', 'id' => $model->id];
                }
            }
コード例 #7
0
ファイル: _form.php プロジェクト: CTaiDeng/funshop
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 64]);
?>

    <?php 
echo $form->field($model, 'money')->textInput(['maxlength' => 10]);
?>

    <?php 
echo $form->field($model, 'min_amount')->textInput(['maxlength' => 10]);
?>

    <?php 
echo $form->field($model, 'type')->dropDownList(\common\models\CouponType::labels());
?>

    <?php 
echo $form->field($model, 'min_goods_amount')->textInput(['maxlength' => 10]);
?>

    <div class="form-group field-car-started_at">
        <?php 
echo Html::activeLabel($model, 'started_at', ['class' => 'col-lg-1 control-label']);
?>
        <div class="col-lg-3">
            <?php 
echo \yii\jui\DatePicker::widget(['model' => $model, 'attribute' => 'started_at', 'dateFormat' => 'yyyy-MM-dd']);
?>
        </div>