Blame view

frontend/views/ajax/users.php 3.95 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
  <?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,
ada119c9   Yarik   test
25
          'id' => 'pjax-user_'.\Yii::$app->security->generateRandomString(3),
fdc1c9de   Yarik   test
26
27
28
29
30
31
32
33
      ]);
      $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,
aa08967c   Виталий   git
34
          'summary' => '<div class="title_addUsers">Найдено пользователей: {totalCount}</div>',
fdc1c9de   Yarik   test
35
36
37
38
39
40
41
42
43
44
45
46
47
          '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',
aa08967c   Виталий   git
48
                  'contentOptions' => ['class' => 'fix_add_user_img_'],
fdc1c9de   Yarik   test
49
50
51
52
53
54
55
                  '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 {
aa08967c   Виталий   git
56
                          return Html::tag('div', Html::img('/images/avatar-bg.png'), [ 'class' => 'user_search_modal_item_image' ]);
fdc1c9de   Yarik   test
57
58
59
60
61
                      }
                  },
              ],
              [
                  'attribute' => 'firstname',
3ddcc442   Yarik   test
62
63
64
                  '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
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
100
                  '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();
  ?>