index.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /*
  3. * This file is part of the Dektrium project.
  4. *
  5. * (c) Dektrium project <http://github.com/dektrium>
  6. *
  7. * For the full copyright and license information, please view the LICENSE.md
  8. * file that was distributed with this source code.
  9. */
  10. use dektrium\user\models\UserSearch;
  11. use yii\data\ActiveDataProvider;
  12. use yii\grid\GridView;
  13. use yii\helpers\Html;
  14. use yii\jui\DatePicker;
  15. use yii\web\View;
  16. use yii\widgets\Pjax;
  17. /**
  18. * @var View $this
  19. * @var ActiveDataProvider $dataProvider
  20. * @var UserSearch $searchModel
  21. */
  22. $this->title = Yii::t('user', 'Manage users');
  23. $this->params['breadcrumbs'][] = $this->title;
  24. ?>
  25. <?= $this->render('/_alert', [
  26. 'module' => Yii::$app->getModule('user'),
  27. ]) ?>
  28. <?= $this->render('/admin/_menu') ?>
  29. <?php Pjax::begin() ?>
  30. <?= GridView::widget([
  31. 'dataProvider' => $dataProvider,
  32. 'filterModel' => $searchModel,
  33. 'layout' => "{items}\n{pager}",
  34. 'columns' => [
  35. // 'username',
  36. 'email:email',
  37. 'fio',
  38. // 'role',
  39. [
  40. 'attribute' => 'role_user',
  41. 'value' => function ($model) {
  42. switch ($model->role) {
  43. case 1:
  44. return 'Організатор';
  45. case 2:
  46. return 'Учасник';
  47. default:
  48. return 'Неизвестно';
  49. }
  50. },
  51. 'filter' => [
  52. 1 => 'Організатор',
  53. 2 => 'Учасник',
  54. ],
  55. ],
  56. 'at_org',
  57. [
  58. 'attribute' => 'registration_ip',
  59. 'value' => function ($model) {
  60. return $model->registration_ip == null
  61. ? '<span class="not-set">' . Yii::t('user', '(not set)') . '</span>'
  62. : $model->registration_ip;
  63. },
  64. 'format' => 'html',
  65. ],
  66. [
  67. // 'attribute' => 'created_at',
  68. 'value' => function ($model) {
  69. if (extension_loaded('intl')) {
  70. return Yii::t('user', '{0, date, MMMM dd, YYYY HH:mm}', [$model->created_at]);
  71. } else {
  72. return date('Y-m-d G:i:s', $model->created_at);
  73. }
  74. },
  75. // 'filter' => DatePicker::widget([
  76. // 'model' => $searchModel,
  77. // 'attribute' => 'created_at',
  78. // 'dateFormat' => 'php:Y-m-d',
  79. // 'options' => [
  80. // 'class' => 'form-control',
  81. // ],
  82. // ]),
  83. ],
  84. [
  85. 'header' => Yii::t('user', 'Confirmation'),
  86. 'value' => function ($model) {
  87. if ($model->isConfirmed) {
  88. return '<div class="text-center"><span class="text-success">' . Yii::t('user', 'Confirmed') . '</span></div>';
  89. } else {
  90. return Html::a(Yii::t('user', 'Confirm'), ['confirm', 'id' => $model->id], [
  91. 'class' => 'btn btn-xs btn-success btn-block',
  92. 'data-method' => 'post',
  93. 'data-confirm' => Yii::t('user', 'Are you sure you want to confirm this user?'),
  94. ]);
  95. }
  96. },
  97. 'format' => 'raw',
  98. 'visible' => Yii::$app->getModule('user')->enableConfirmation,
  99. ],
  100. [
  101. 'header' => Yii::t('app', 'Send Activation ID'),
  102. 'value' => function ($model)
  103. {
  104. return Html::a(Yii::t('app', 'Send ID'), ['send', 'id' => $model->id], [
  105. 'class' => 'btn btn-xs btn-warning btn-block',
  106. 'data-method' => 'post',
  107. 'data-confirm' => Yii::t('app', 'Are you sure you send activation?'),
  108. ]);
  109. },
  110. 'format' => 'raw',
  111. ],
  112. [
  113. 'header' => Yii::t('user', 'Block status'),
  114. 'value' => function ($model) {
  115. if ($model->isBlocked) {
  116. return Html::a(Yii::t('user', 'Unblock'), ['block', 'id' => $model->id], [
  117. 'class' => 'btn btn-xs btn-success btn-block',
  118. 'data-method' => 'post',
  119. 'data-confirm' => Yii::t('user', 'Are you sure you want to unblock this user?'),
  120. ]);
  121. } else {
  122. return Html::a(Yii::t('user', 'Block'), ['block', 'id' => $model->id], [
  123. 'class' => 'btn btn-xs btn-danger btn-block',
  124. 'data-method' => 'post',
  125. 'data-confirm' => Yii::t('user', 'Are you sure you want to block this user?'),
  126. ]);
  127. }
  128. },
  129. 'format' => 'raw',
  130. ],
  131. [
  132. 'class' => 'yii\grid\ActionColumn',
  133. 'template' => '{update} {delete}',
  134. ],
  135. ],
  136. ]); ?>
  137. <?php Pjax::end() ?>