示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MQdbm::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['qdbm_id' => $this->qdbm_id]);
     $query->andFilterWhere(['like', 'gsyf', $this->gsyf])->andFilterWhere(['like', 'qdmc', $this->qdmc])->andFilterWhere(['like', 'qdbm', $this->qdbm])->andFilterWhere(['like', 'blank', $this->blank]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Lists all MHd201509t6 models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new MHd201509t6Search();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (isset($_GET['download'])) {
         $dataProvider->setPagination(false);
         $data = $dataProvider->getModels();
         $date = date('Y-m-d-His');
         $filename = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'zqshfhd' . "-{$date}.csv";
         $rowsx = [];
         foreach ($data as $row) {
             $rows = [];
             $rows["mobile"] = $row->mobile;
             $rows["yfzx"] = $row->yfzx;
             $rows["fsc"] = $row->fsc;
             $rows["create_time"] = $row->create_time;
             $rows["hbme"] = $row->hbme;
             //$rows["status"] = $row->status;
             if ($row->status == 0) {
                 $rows["status"] = "未领";
             } else {
                 $rows["status"] = "已领";
             }
             $rows["qdbm"] = $row->qdbm;
             $qd = MQdbm::findOne(["qdbm" => $row->qdbm]);
             if (empty($qd)) {
                 $rows["gsyf"] = "--";
                 $rows["qdmc"] = "--";
             } else {
                 $rows["gsyf"] = $qd->gsyf;
                 $rows["qdmc"] = $qd->qdmc;
             }
             $rowsx[] = $rows;
         }
         //$csv = new \app\models\ECSVExport($data);
         $csv = new \app\models\ECSVExport($rowsx);
         $attributes = ['mobile', 'yfzx', 'fsc', 'hbme', 'create_time', 'hbme', 'status', 'qdbm', 'gsyf', 'qdmc'];
         $csv->setInclude($attributes);
         //$csv->setHeaders(['Score'=>'成绩']);
         //mobile  yfzx    fsc create_time status  qdbm    gsyf    qdmc
         $csv->setHeaders(['mobile' => '手机', 'yfzx' => '营服中心', 'fsc' => '分市场', 'create_time' => '时间', 'hbme' => '红包(元)', 'status' => '领取状态', 'qdbm' => '渠道编码', 'gsyf' => '归属营服', 'qdmc' => '渠道名称']);
         $csv->toCSV($filename);
         Yii::$app->response->sendFile($filename);
         return;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
示例#3
0
 /**
  * Finds the MQdbm model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MQdbm the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MQdbm::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#4
0
文件: index.php 项目: noikiy/wowewe
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['label' => '微信昵称', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    $user = $model->user;
    return empty($user) ? '' : "<img width=48 src=" . $model->user->headimgurl . "><br>" . emoji_unified_to_html(emoji_softbank_to_unified($user->nickname));
}, 'filter' => false, 'headerOptions' => array('style' => 'width:90px;')], 'mobile', 'hbme', 'create_time', ['attribute' => 'status', 'label' => '状态', 'value' => function ($model, $key, $index, $column) {
    return MHd201509t6::gethd201509t6StatusOption($model->status);
}, 'filter' => MHd201509t6::gethd201509t6StatusOption(), 'headerOptions' => array('style' => 'width:80px;')], 'qdbm', ['label' => '归属营服', 'value' => function ($model, $key, $index, $column) {
    $qdbm = strtolower(trim($model->qdbm));
    $qd = MQdbm::findOne(['qdbm' => $qdbm]);
    if (empty($qd)) {
        return "--";
    } else {
        return $qd->gsyf;
    }
}, 'headerOptions' => array('style' => 'width:120px;')], ['label' => '渠道名称', 'value' => function ($model, $key, $index, $column) {
    $qdbm = strtolower(trim($model->qdbm));
    $qd = MQdbm::findOne(['qdbm' => $qdbm]);
    if (empty($qd)) {
        return "--";
    } else {
        return $qd->qdmc;
    }
}, 'headerOptions' => array('style' => 'width:120px;')], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}', 'buttons' => ['update' => function ($url, $model) {
    if (\Yii::$app->user->identity->username == "admin") {
        return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => Yii::t('yii', 'Update'), 'data-pjax' => '0']);
    } else {
        return "";
    }
}]]]]);
?>

</div>