1 | <?php |
||
2 | |||
3 | use yii\web\View; |
||
4 | use yii\helpers\{Html, Url}; |
||
5 | use yii\widgets\DetailView; |
||
6 | use app\models\User; |
||
7 | use Itstructure\RbacModule\interfaces\RbacIdentityInterface; |
||
8 | use Itstructure\MFUploader\Module as MFUModule; |
||
9 | |||
10 | /* @var $this View */ |
||
11 | /* @var $model User|RbacIdentityInterface */ |
||
12 | |||
13 | $this->title = Yii::t('users', 'User') . ': ' . $model->first_name; |
||
14 | $this->params['breadcrumbs'][] = [ |
||
15 | 'label' => Yii::t('users', 'Users'), |
||
16 | 'url' => [ |
||
17 | $this->params['urlPrefix'].'index' |
||
18 | ] |
||
19 | ]; |
||
20 | $this->params['breadcrumbs'][] = $this->title; |
||
21 | ?> |
||
22 | <div class="users-view"> |
||
23 | |||
24 | <p> |
||
25 | <?php echo Html::a(Yii::t('app', 'Update'), [ |
||
26 | $this->params['urlPrefix'].'update', |
||
27 | 'id' => $model->id |
||
28 | ], [ |
||
29 | 'class' => 'btn btn-primary' |
||
30 | ]) ?> |
||
31 | |||
32 | <?php echo Html::a(Yii::t('app', 'Delete'), [ |
||
33 | $this->params['urlPrefix'].'delete', |
||
34 | 'id' => $model->id |
||
35 | ], [ |
||
36 | 'class' => 'btn btn-danger', |
||
37 | 'data' => [ |
||
38 | 'confirm' => Yii::t('app', 'Are you sure you want to do this action?'), |
||
39 | 'method' => 'post', |
||
40 | ], |
||
41 | ]) ?> |
||
42 | </p> |
||
43 | |||
44 | <?php echo DetailView::widget([ |
||
45 | 'model' => $model, |
||
46 | 'attributes' => [ |
||
47 | 'avatar' => [ |
||
48 | 'label' => Yii::t('users', 'Avatar'), |
||
49 | 'value' => function ($model) { |
||
50 | /* @var $model User */ |
||
51 | $thumbnailModel = $model->getThumbnailModel(); |
||
52 | return $thumbnailModel == null ? '' : Html::a(Html::img($model->getAvatar()), Url::to($thumbnailModel->getThumbUrl(MFUModule::THUMB_ALIAS_LARGE)), [ |
||
53 | 'target' => '_blank' |
||
54 | ]); |
||
55 | }, |
||
56 | 'format' => 'raw', |
||
57 | ], |
||
58 | 'id' => [ |
||
59 | 'attribute' => 'id', |
||
60 | 'label' => Yii::t('app', 'ID') |
||
61 | ], |
||
62 | 'first_name' => [ |
||
63 | 'attribute' => 'first_name', |
||
64 | 'label' => Yii::t('users', 'First Name') |
||
65 | ], |
||
66 | 'last_name' => [ |
||
67 | 'attribute' => 'last_name', |
||
68 | 'label' => Yii::t('users', 'Last Name') |
||
69 | ], |
||
70 | 'patronymic' => [ |
||
71 | 'attribute' => 'patronymic', |
||
72 | 'label' => Yii::t('users', 'Patronymic') |
||
73 | ], |
||
74 | 'login' => [ |
||
75 | 'attribute' => 'login', |
||
76 | 'label' => Yii::t('users', 'Login') |
||
77 | ], |
||
78 | 'email' => [ |
||
79 | 'label' => Yii::t('users', 'Email'), |
||
80 | 'value' => function ($model) { |
||
81 | return '<a href="mailto:'.$model->email.'">'.$model->email.'</a>'; |
||
82 | }, |
||
83 | 'format' => 'raw', |
||
84 | ], |
||
85 | 'phone' => [ |
||
86 | 'attribute' => 'phone', |
||
87 | 'label' => Yii::t('users', 'Phone') |
||
88 | ], |
||
89 | 'status' => [ |
||
90 | 'label' => Yii::t('users', 'Status'), |
||
91 | 'value' => isset($model->status) && !empty($model->status) ? function($data) { |
||
92 | if ($data->status == 1){ |
||
93 | return '<i class="fa fa-check-circle text-success"> ' . Yii::t('app', 'Active') . '</i>'; |
||
94 | } else { |
||
95 | return '<i class="fa fa-times text-danger"> ' . Yii::t('app', 'Blocked') . '</i>'; |
||
96 | } |
||
97 | } : Yii::t('users', 'No status'), |
||
98 | 'format' => 'raw', |
||
99 | ], |
||
100 | 'public' => [ |
||
101 | 'label' => Yii::t('users', 'Publicity'), |
||
102 | 'value' => isset($model->public) && !empty($model->public) ? function($data) { |
||
103 | if ($data->public == 1){ |
||
104 | return '<i class="fa fa-folder-open-o text-primary"> ' . Yii::t('app', 'Public') . '</i>'; |
||
105 | } else { |
||
106 | return '<i class="fa fa-minus-circle text-warning"> ' . Yii::t('app', 'Private') . '</i>'; |
||
107 | } |
||
108 | } : '<i class="fa fa-minus-circle text-warning"> ' . Yii::t('app', 'Private'), |
||
109 | 'format' => 'raw', |
||
110 | ], |
||
111 | 'roles' => [ |
||
112 | 'attribute' => 'roles', |
||
113 | 'label' => Yii::t('users', 'Roles'), |
||
114 | 'value' => function($model) { |
||
115 | /* @var $model RbacIdentityInterface */ |
||
116 | $roles = $model->getRoles(); |
||
117 | |||
118 | if (empty($roles)) {return Yii::t('users', 'No roles');} |
||
119 | |||
120 | return implode('<br>', array_map(function ($data) { |
||
121 | |||
122 | return Html::a($data, Url::to([ |
||
123 | '/'.$this->params['shortLanguage'].'/rbac/roles/view', |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
124 | 'id' => $data |
||
125 | ]), |
||
126 | [ |
||
127 | 'target' => '_blank' |
||
128 | ]); |
||
129 | |||
130 | }, array_keys($roles))); |
||
131 | }, |
||
132 | 'format' => 'raw', |
||
133 | ], |
||
134 | 'position' => [ |
||
135 | 'label' => Yii::t('users', 'Position'), |
||
136 | 'value' => function ($model) { |
||
137 | /* @var $model \app\models\User */ |
||
138 | return empty($model->position) ? '' : $model->position->{'name_'.$this->params['shortLanguage']}; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
139 | } |
||
140 | ], |
||
141 | 'about' => [ |
||
142 | 'label' => Yii::t('users', 'About'), |
||
143 | 'value' => function ($model) { |
||
144 | return $model->about; |
||
145 | }, |
||
146 | 'format' => 'raw', |
||
147 | ], |
||
148 | 'created_at' => [ |
||
149 | 'attribute' => 'created_at', |
||
150 | 'format' => ['date', 'dd.MM.Y HH:mm:ss'], |
||
151 | 'label' => Yii::t('app', 'Created date') |
||
152 | ], |
||
153 | 'updated_at' => [ |
||
154 | 'attribute' => 'updated_at', |
||
155 | 'format' => ['date', 'dd.MM.Y HH:mm:ss'], |
||
156 | 'label' => Yii::t('app', 'Updated date') |
||
157 | ], |
||
158 | ] |
||
159 | ]) ?> |
||
160 | |||
161 | </div> |
||
162 |