title = 'Пользователи'; ?>
Фильтры
С 'tm_start', 'value' => $tm_start, 'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control input-small'] ]) ?> по 'tm_end', 'value' => $tm_end, 'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control input-small'] ]) ?>

'form-control', 'style' => 'width: 370px;', 'placeholder' => 'Email пользователя']) ?>

$tm_start, 'tm_end' => $tm_end, 'email' => $email, 'is_vip' => !$isVIP, 'is_admin' => $isAdmin, 'with_checks' => $withChecks ], ['class' => $isVIP ? 'btn btn-success' : 'btn btn-primary', 'style' => 'width: 145px;']) ?> $tm_start, 'tm_end' => $tm_end, 'email' => $email, 'is_vip' => $isVIP, 'is_admin' => !$isAdmin, 'with_checks' => $withChecks ], ['class' => $isAdmin ? 'btn btn-success' : 'btn btn-primary', 'style' => 'width: 170px;']) ?> $tm_start, 'tm_end' => $tm_end, 'email' => $email, 'is_vip' => $isVIP, 'is_admin' => $isAdmin, 'with_checks' => !$withChecks ], ['class' => $withChecks ? 'btn btn-success' : 'btn btn-primary', 'style' => 'width: 220px;']) ?>
$dataProvider, 'rowOptions' => function(User $model) { if ($model->is_confirm) return ['class' => 'success']; }, 'columns' => [ [ 'attribute' => 'id', 'format' => 'raw', 'value' => function($model) { return Html::a($model->id, ['users/view', 'id' => $model->id]); } ], [ 'format' => 'raw', 'attribute' => 'email', 'value' => function(User $model) { $socials = []; foreach ($model->auth as $a) { $link = null; switch ($a->source) { case 'vk': $link = 'https://vk.com/id' . $a->source_id; break; case 'facebook': $link = 'https://facebook.com/' . $a->source_id; break; } if (is_null($link)) { $source = $a->source; if ($source == 'google') { $source .= ' (' . count($model->contacts) . ')'; } $socials[] = $source; } else { $socials[] = Html::a($a->source, $link); } } $username = ""; if(trim($model->email) != "") $username = $model->email; else { if(preg_match("/-/", $model->uuid)) { $username = "iOS (".$model->uuid.")"; } else { $username = "Android (".$model->uuid.")"; } } return '' . $username . '
' . join(', ', $socials); } ], 'checks', [ 'header' => 'Общая сумма платежей', 'content' => function(User $model) { return array_sum(array_map(function(Payment $payment) { return $payment->sum; }, $model->payments)); } ], [ 'header' => 'Дата регистрации', 'content' => function($model) { return join("
", [ \Yii::$app->formatter->asDate($model->tm_create, 'dd.MM.yyyy'), $model->ip ]); } ], [ 'header' => 'Поисков
всего', 'content' => function($model) { return count($model->requests); } ], [ 'header' => '%', 'content' => function($model) { $index = 0; foreach($model->requests as $r) { $index += array_sum(ArrayHelper::getColumn($r->results, 'index')); } return round(count($model->requests) ? ($index / count($model->requests)) : 0, 2); } ], [ 'header' => 'Поисков
за сегодня', 'content' => function($model) { return count(array_filter($model->requests, function($r) { return date('Y-m-d', strtotime($r->tm)) == date('Y-m-d'); })); } ], [ 'header' => '%
за сегодня', 'content' => function($model) { $index = 0; $requests = array_filter($model->requests, function($r) { return date('Y-m-d', strtotime($r->tm)) == date('Y-m-d'); }); foreach($requests as $r) { $index += array_sum(ArrayHelper::getColumn($r->results, 'index')); } return round(count($requests) ? ($index / count($requests)) : 0, 2); } ], 'comment', [ 'class' => ActionColumn::className(), 'template' => '{set-vip} {set-admin}', 'buttons' => [ 'set-vip' => function ($url, $model, $key) { return $model->is_vip ? Html::a('Убрать VIP', ['set-vip', 'id' => $model->id], ['class' => 'btn btn-danger']) : Html::a('Поставить VIP', ['set-vip', 'id' => $model->id], ['class' => 'btn btn-success']); }, 'set-admin' => function ($url, $model, $key) { return $model->is_admin ? Html::a('Убрать админа', ['set-admin', 'id' => $model->id], ['class' => 'btn btn-danger']) : Html::a('Поставить админа', ['set-admin', 'id' => $model->id], ['class' => 'btn btn-success']); } ] ], ], ]);