Blame view

frontend/views/ajax/users.php 3.83 KB
fdc1c9de   Yarik   test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  <?php
      use backend\models\UserSearch;
      use common\models\User;
      use yii\bootstrap\BootstrapAsset;
      use yii\bootstrap\BootstrapPluginAsset;
      use yii\bootstrap\BootstrapThemeAsset;
      use yii\data\ActiveDataProvider;
      use yii\grid\ActionColumn;
      use yii\grid\GridView;
      use yii\helpers\ArrayHelper;
      use yii\helpers\Html;
      use yii\web\View;
      use yii\widgets\Pjax;
  
      /**
       * @var View               $this
       * @var ActiveDataProvider $dataProvider
       * @var UserSearch         $model
       */
  ?>
  <?php
      BootstrapPluginAsset::register($this);
      $pjax = Pjax::begin([
          'enablePushState' => false,
          'id' => 'pjax-user',
      ]);
      $js = "$('.user_search_modal_input').tooltip({placement: 'top', title: function() { return $(this).data('error'); }, trigger: 'manual'});
          $('.user_search_modal_input').tooltip('show');";
      $this->registerJs($js);
      echo GridView::widget([
          'id' => 'grid-user',
          'dataProvider' => $dataProvider,
          'filterModel'  => $model,
          'summary' => 'Найдено пользователей: {totalCount}',
          'rowOptions' => [
              'class' => 'user_search_modal_row',
          ],
          'columns'      => [
              [
                  'attribute' => 'id',
                  'filter'    => Html::activeInput('number', $model, 'id', [
                      'class'      => 'user_search_modal_input user_search_modal_input_id',
                      'data-error' => $model->hasErrors('id') ? $model->getFirstError('id') : '',
                  ]),
              ],
              [
                  'attribute' => 'userInfo.image',
                  'content'   => function($model, $key, $index, $column) {
                      /**
                       * @var User $model
                       */
                      if(!empty( $model->userInfo->image )) {
                          return Html::tag('div', Html::img($model->userInfo->image, [ 'width' => '100px' ]), [ 'class' => 'user_search_modal_item_image' ]);
                      } else {
                          return Html::tag('div', Html::img('/images/avatar-bg.png', [ 'width' => '100px' ]), [ 'class' => 'user_search_modal_item_image' ]);
                      }
                  },
              ],
              [
                  'attribute' => 'firstname',
3ddcc442   Yarik   test
61
62
63
                  'content' => function($model, $key, $index, $column) {
                      return Html::a($model->firstname, ['performer/common', 'performer_id' => $model->id], ['target' => '_blank', 'data-pjax' => 0]);
                  },
fdc1c9de   Yarik   test
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
                  'filter' => Html::activeInput('text', $model, 'name_search'),
              ],
              [
                  'attribute' => 'lastname',
                  'filter' => Html::activeInput('text', $model, 'surname_search'),
              ],
              [
                  'attribute' => 'specialization',
                  'content' => function($model, $key, $index, $column) {
                      if(!empty($model->specializations)) {
                          return implode(', ', ArrayHelper::getColumn($model->specializations, 'specialization_name'));
                      } else {
                          return false;
                      }
                  },
                  'filterOptions' => [
                      'class' => 'user_search_modal_specialization',
                  ],
                  'label' => Yii::t('app', 'Специализация'),
              ],
              [
                  'class' => ActionColumn::className(),
                  'buttons' => [
                      'apply' => function($url, $model, $key) {
                          return Html::tag('span', '', ['class' => 'user_search_modal_tick']);
                      }
                  ],
                  'template' => '{apply}',
              ]
          ],
          'options'      => [
              'class' => 'grid-view user_search_modal_grid',
          ],
      ]);
      Pjax::end();
  ?>