Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Station::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, 'enabled' => $this->enabled, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'detail', $this->detail]);
     return $dataProvider;
 }
Exemple #2
0
    $model->end_at = date('Y-m-d H:i', $model->end_at);
    $start_at = $model->start_at;
    $end_at = $model->end_at;
} else {
    $start_at = date('Y-m-d H:i', time());
    $end_at = date('Y-m-d H:i', time());
}
?>

<div class="coupon-form">

    <?php 
$form = ActiveForm::begin();
$fieldGroups = [];
$fields = [];
$stations = \core\models\Station::findAll(['enabled' => 1]);
$stationArray = ArrayHelper::map($stations, 'id', 'name');
$fields[] = $form->field($model, 'star_id')->dropDownList($stationArray);
$fields[] = $form->field($model, 'total')->textInput(['maxlength' => true]);
$fields[] = $form->field($model, 'desc')->textarea(['maxlength' => true]);
$fields[] = $form->field($model, 'status')->dropDownList([1 => '是', 0 => '否']);
$fields[] = $form->field($model, 'start_at')->widget(DateTimePicker::className(), ['options' => ['value' => $start_at], 'pluginOptions' => ['language' => 'zh-CN', 'autoclose' => true]]);
$fields[] = $form->field($model, 'end_at')->widget(DateTimePicker::className(), ['options' => ['value' => $end_at], 'pluginOptions' => ['language' => 'zh-CN', 'autoclose' => true]]);
$fieldGroups[] = ['label' => Yii::t('marketing', 'Coupon Info'), 'content' => implode('', $fields)];
$fields = [];
$fields[] = $form->field($model, 'total_price')->textInput(['maxlength' => true]);
$fields[] = $form->field($model, 'qty')->textInput(['maxlength' => true]);
$root = \common\models\Tree::find()->where(['name' => '商品分类'])->one();
$categories = $root->children(1)->all();
$categories = ArrayHelper::map($categories, 'id', 'name');
$fields[] = $form->field($model, 'category_id')->widget(Select2::classname(), ['data' => $categories, 'language' => 'en', 'pluginOptions' => ['placeholder' => 'Select a state ...'], 'options' => ['multiple' => true]]);
Exemple #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStation()
 {
     return $this->hasOne(Station::className(), ['id' => 'station_id']);
 }
 /**
  * Finds the Station model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Station the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Station::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }