/
usergroups_view.php
181 lines (164 loc) · 7.65 KB
/
usergroups_view.php
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
61
62
63
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/**
* This file render the list of user groups
* It use the Label Sets model search method to build the data provider.
*
* @var UserGroup $model the UserGroup model
* @var int $pageSize
*/
?>
<div class="col-lg-12">
<div class="h4"><?php
if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) {
eT('My user groups');
}
?>
</div>
<div class="row">
<div class="col-lg-12 content-right">
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider' => $model->searchMine(true),
'id' => 'usergroups-grid-mine',
'emptyText' => gT('No user groups found.'),
'htmlOptions' => ['class' => 'table-responsive grid-view-ls'],
'selectionChanged' => "function(id){window.location='" . Yii::app()->urlManager->createUrl('userGroup/viewGroup/ugid') . '/' . "' + $.fn.yiiGridView.getSelection(id.split(',', 1));}",
'ajaxUpdate' => 'usergroups-grid-mine',
'template' => "{items}\n<div id='tokenListPager'><div class=\"col-sm-4\" id=\"massive-action-container\"></div><div class=\"col-sm-4 pager-container ls-ba \">{pager}</div><div class=\"col-sm-4 summary-container\">{summary}</div></div>",
'summaryText' => gT('Displaying {start}-{end} of {count} result(s).') . ' ' . sprintf(
gT('%s rows per page'),
CHtml::dropDownList(
'pageSize',
$pageSize,
Yii::app()->params['pageSizeOptions'],
array(
'class' => 'changePageSize form-control',
'style' => 'display: inline; width: auto'
))),
'columns' => array(
array(
'header' => gT('Actions'),
'name' => 'actions',
'type' => 'raw',
'value' => '$data->buttons',
'htmlOptions' => array('class' => 'text-left'),
),
array(
'header' => gT('User group ID'),
'name' => 'usergroup_id',
'value' => '$data->ugid',
'htmlOptions' => array('class' => ''),
),
array(
'header' => gT('Name'),
'name' => 'name',
'value' => '$data->name',
'htmlOptions' => array('class' => ''),
),
array(
'header' => gT('Description'),
'name' => 'description',
'value' => '$data->description',
'htmlOptions' => array('class' => ''),
),
array(
'header' => gT('Owner'),
'name' => 'owner',
'value' => '$data->owner ? $data->owner->users_name : gT("(Deleted user)")',
'htmlOptions' => array('class' => ''),
),
array(
'header' => gT('Members'),
'name' => 'members',
'value' => '$data->countUsers',
'htmlOptions' => array('class' => ''),
),
),
));
?>
</div>
</div>
<div class="h4"><?php
if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) {
eT('Groups to which I belong');
}
?>
</div>
<div class="row">
<div class="col-lg-12 content-right">
<?php
if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider' => $model->searchMine(false),
'id' => 'usergroups-grid-belong-to',
'emptyText' => gT('No user groups found.'),
'template' => "{items}\n<div id='tokenListPager'><div class=\"col-sm-4\" id=\"massive-action-container\"></div><div class=\"col-sm-4 pager-container ls-ba \">{pager}</div><div class=\"col-sm-4 summary-container\">{summary}</div></div>",
'summaryText' => gT('Displaying {start}-{end} of {count} result(s).') . ' ' . sprintf(
gT('%s rows per page'),
CHtml::dropDownList(
'pageSize',
$pageSize,
Yii::app()->params['pageSizeOptions'],
array(
'class' => 'changePageSize form-control',
'style' => 'display: inline; width: auto'
)
)
),
'columns' => $model->columns,
'htmlOptions' => ['class' => 'table-responsive grid-view-ls'],
'selectionChanged' => "function(id){window.location='" . Yii::app()->urlManager->createUrl('userGroup/viewGroup/ugid') . '/' . "' + $.fn.yiiGridView.getSelection(id.split(',', 1));}",
'ajaxUpdate' => 'usergroups-grid-belong-to',
));
}
?>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" id="delete-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<?php
Yii::app()->getController()->renderPartial(
'/layouts/partial_modals/modal_header',
['modalTitle' => gT('Delete this user group')]
);
?>
<div class="modal-body">
<?= CHtml::form(
array("userGroup/deleteGroup"),
'post',
array('class' => '', 'id' => 'delete-modal-form', 'name' => 'delete-modal-form')
) ?>
<p><?= gT('Are you sure you want to delete this user group?') ?></p>
<input type="hidden" name="ugid" id="delete-ugid" value=""/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-cancel" data-dismiss="modal"><?= gT('Cancel') ?></button>
<button type="button" class="btn btn-danger" id="confirm-deletion"><?= gT('Delete') ?></button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
jQuery(function ($) {
// To update rows per page via ajax
$(document).on("change", '#pageSize', function () {
$.fn.yiiGridView.update('usergroups-grid-mine', {data: {pageSize: $(this).val()}});
$.fn.yiiGridView.update('usergroups-grid-belong-to', {data: {pageSize: $(this).val()}});
});
//Delete button
$(document).ready(function () {
$('.action__delete-group').on('click', function (event) {
event.stopPropagation();
event.preventDefault();
$('#delete-modal').modal('show');
$('#delete-ugid').val($(this).data('ugid'));
$('#confirm-deletion').on('click', function () {
$('#delete-modal-form').submit();
});
});
});
});
</script>