Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MActivity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'gh_id', $this->gh_id])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'descr', $this->descr])->andFilterWhere(['like', 'iids', $this->iids]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
use yii\helpers\Html;
use yii\grid\GridView;
use app\models\MActivity;
/* @var $this yii\web\View */
/* @var $searchModel app\models\MActivitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '活动管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mactivity-index">

    <!--<h1><//?= Html::encode($this->title) ?></h1>-->
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('创建活动', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => 'table-responsive'], 'tableOptions' => ['class' => 'table table-striped'], 'columns' => ['id', 'title', 'start_time', 'end_time', ['attribute' => 'status', 'value' => function ($model, $key, $index, $column) {
    return MActivity::getStatusOptionName($model->status);
}, 'filter' => MActivity::getStatusOptionName(), 'headerOptions' => array('style' => 'width:200px;')], 'iids', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Ejemplo n.º 3
0
 public function actionMobilelistxxx()
 {
     $this->layout = 'wapy';
     //        $gh_id = U::getSessionParam('gh_id');
     //        $openid = U::getSessionParam('openid');
     $gh_id = MGh::GH_XIANGYANGUNICOM;
     $openid = MGh::GH_XIANGYANGUNICOM_OPENID_KZENG;
     Yii::$app->wx->setGhId($gh_id);
     $models = MItem::find()->where(['kind' => MItem::ITEM_KIND_MOBILE])->orderBy(['price' => SORT_ASC])->all();
     $query = new \yii\db\Query();
     $query->select('*')->from(\app\models\MActivity::tableName())->where(['status' => 1])->orderBy(['id' => SORT_DESC])->all();
     $rows = $query->createCommand()->queryAll();
     foreach ($models as &$model) {
         foreach ($rows as &$row) {
             $ids = explode(",", $row['iids']);
             if (in_array($model['iid'], $ids)) {
                 $model['price'] = $model['price'] * $row['discount'] / 10;
                 $model['title_hint'] = "<span class='activity'>限时促销!</span>&nbsp;&nbsp;" . $model['title_hint'];
             }
         }
     }
     return $this->render('mobilelist', ['gh_id' => $gh_id, 'openid' => $openid, 'models' => $models]);
 }
Ejemplo n.º 4
0
 /**
  * Finds the MActivity model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return MActivity the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MActivity::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 5
0
use yii\helpers\Html;
use yii\widgets\DetailView;
use app\models\MActivity;
/* @var $this yii\web\View */
/* @var $model app\models\MActivity */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => '活动管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mactivity-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

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

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'gh_id', 'start_time', 'end_time', 'title', 'descr', ['attribute' => 'status', 'value' => MActivity::getStatusOptionName($model->status)], 'iids']]);
?>

</div>