示例#1
0
<div class="train-users-index">

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

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'train_id', 'value' => function ($searchModel) {
    return app\models\Train::getOneTrainNameById($searchModel->train_id);
}], ['attribute' => 'user_id', 'value' => function ($searchModel) {
    return app\models\Users::getOneUserNameById($searchModel->user_id);
}], ['label' => '请假', 'value' => function ($searchModel) {
    return app\models\Attendance::getCount($searchModel->train_id, $searchModel->user_id, app\models\Attendance::LEAVE);
}], ['label' => '迟到', 'value' => function ($searchModel) {
    return app\models\Attendance::getCount($searchModel->train_id, $searchModel->user_id, app\models\Attendance::LATER);
}], ['label' => '早退', 'value' => function ($searchModel) {
    return app\models\Attendance::getCount($searchModel->train_id, $searchModel->user_id, app\models\Attendance::ABSENCES);
}], ['label' => '旷课', 'value' => function ($searchModel) {
    return app\models\Attendance::getCount($searchModel->train_id, $searchModel->user_id, app\models\Attendance::EARLY);
}], ['label' => '操作', 'format' => 'html', 'value' => function ($searchModel) {
    $url = Html::a('更新考勤', ['Admin/attendance/', 'AttendanceSearch[user_id]' => $searchModel->user_id, 'AttendanceSearch[train_id]' => $searchModel->train_id]);
    return $url;
}]]]);
?>

</div>