Example #1
0
        <?php 
echo Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', 'amount', ['attribute' => 'start_at', 'format' => ['date', 'php:Y-m-d H:i:s'], 'headerOptions' => ['width' => '100']], ['attribute' => 'end_at', 'format' => ['date', 'php:Y-m-d H:i:s'], 'headerOptions' => ['width' => '100']], 'invest_people', 'invest_sum', 'virtual_amonnt', 'virtual_invest_people', ['attribute' => 'create_at', 'format' => ['date', 'php:Y-m-d H:i:s'], 'headerOptions' => ['width' => '100']], ['attribute' => 'update_at', 'format' => ['date', 'php:Y-m-d H:i:s'], 'headerOptions' => ['width' => '100']], ['attribute' => 'status', 'format' => 'html', 'headerOptions' => ['width' => '120'], 'value' => function ($model) {
    if ($model->status === $model::STATUS_UNLOCK) {
        $class = 'label-success';
    } elseif ($model->status === $model::STATUS_LOCK) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', Product::getArrayStatus(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], ['attribute' => 'type', 'format' => 'html', 'value' => function ($model) {
    if ($model->type === $model::TYPE_PRO) {
        return '<span class="label label-success">' . $model->typeLabel . '</span>';
    } elseif ($model->type === $model::TYPE_THIRD) {
        return '<span class="label label-warning">' . $model->typeLabel . '</span>';
    } else {
        $class = 'label-danger';
    }
}, 'filter' => Html::activeDropDownList($searchModel, 'type', Product::getArrayTypes(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], ['attribute' => 'create_user_id', 'value' => function ($model) {
    return $model->createUser ? $model->createUser->username : '******';
}], ['attribute' => 'ocreditor', 'value' => function ($model) {
    return $model->ocreditor ? $model->typeocUser->username : '******';
}], ['attribute' => 'maxcreditor', 'value' => function ($model) {
    return $model->maxcreditor ? $model->typemaxUser->username : '******';
}, 'headerOptions' => ['width' => '100']], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{view}{lock}{unlock}{update}{delete}{list}{thirdlist}', 'buttons' => ['update' => function ($url, $model, $key) {
    return $model->start_at > strtotime("now") ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => '编辑']) : '';