116 |
efrain |
1 |
<?php
|
|
|
2 |
$acl = $this->viewModel()->getRoot()->getVariable('acl');
|
|
|
3 |
$currentUser = $this->currentUserHelper();
|
|
|
4 |
$roleName = $currentUser->getUserTypeId();
|
|
|
5 |
|
|
|
6 |
$routeDatatable = $this->url('self-evaluation/users');
|
|
|
7 |
|
|
|
8 |
$allowAdd = $acl->isAllowed($roleName, 'self-evaluation/users/add') ? 1 : 0;
|
|
|
9 |
$allowDelete = $acl->isAllowed($roleName, 'self-evaluation/users/delete') ? 1 : 0;
|
|
|
10 |
|
|
|
11 |
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
|
|
|
12 |
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
|
|
|
19 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
|
|
|
20 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
|
|
|
21 |
|
|
|
22 |
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
|
|
|
23 |
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
|
|
|
24 |
|
|
|
25 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
|
|
|
26 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
|
|
|
27 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
|
|
|
28 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
|
|
|
32 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
|
|
|
33 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
|
|
|
38 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
|
|
|
39 |
|
|
|
40 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
|
|
|
41 |
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
$this->inlineScript()->captureStart();
|
|
|
45 |
echo <<<JS
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
jQuery( document ).ready(function( $ ) {
|
|
|
49 |
|
|
|
50 |
var allowAdd = $allowAdd;
|
|
|
51 |
var allowDelete = $allowDelete
|
|
|
52 |
|
|
|
53 |
var gridTable = $('#gridTable').dataTable( {
|
|
|
54 |
'processing': true,
|
|
|
55 |
'serverSide': true,
|
|
|
56 |
'searching': true,
|
|
|
57 |
'order': [[ 1, 'asc' ]],
|
|
|
58 |
'ordering': true,
|
|
|
59 |
'ordenable' : true,
|
|
|
60 |
'responsive': true,
|
|
|
61 |
'select' : false,
|
|
|
62 |
'paging': true,
|
|
|
63 |
'pagingType': 'simple_numbers',
|
|
|
64 |
'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, 'All'] ],
|
|
|
65 |
|
|
|
66 |
'ajax': {
|
|
|
67 |
'url' : '$routeDatatable',
|
|
|
68 |
'type' : 'get',
|
|
|
69 |
'data': function ( d ) {
|
|
|
70 |
d.form_uuid = $('#form-filter #form_uuid').val();
|
|
|
71 |
|
|
|
72 |
},
|
|
|
73 |
'beforeSend': function (request) {
|
|
|
74 |
NProgress.start();
|
|
|
75 |
},
|
|
|
76 |
'dataFilter': function(response) {
|
|
|
77 |
var response = jQuery.parseJSON( response );
|
|
|
78 |
|
|
|
79 |
var json = {};
|
|
|
80 |
json.recordsTotal = 0;
|
|
|
81 |
json.recordsFiltered = 0;
|
|
|
82 |
json.data = [];
|
|
|
83 |
|
|
|
84 |
if(response.success) {
|
|
|
85 |
json.recordsTotal = response.data.total;
|
|
|
86 |
json.recordsFiltered = response.data.total;
|
|
|
87 |
json.data = response.data.items;
|
|
|
88 |
} else {
|
|
|
89 |
$.fn.showError(response.data)
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
return JSON.stringify( json );
|
|
|
93 |
}
|
|
|
94 |
},
|
|
|
95 |
'language' : {
|
|
|
96 |
'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
|
|
|
97 |
'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
|
|
|
98 |
'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
|
|
|
99 |
'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
|
|
|
100 |
'sInfo': 'LABEL_DATATABLE_SINFO',
|
|
|
101 |
'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
|
|
|
102 |
'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
|
|
|
103 |
'sInfoPostFix': '',
|
|
|
104 |
'sSearch': 'LABEL_DATATABLE_SSEARCH',
|
|
|
105 |
'sUrl': '',
|
|
|
106 |
'sInfoThousands': ',',
|
|
|
107 |
'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
|
|
|
108 |
'oPaginate': {
|
|
|
109 |
'sFirst': 'LABEL_DATATABLE_SFIRST',
|
|
|
110 |
'sLast': 'LABEL_DATATABLE_SLAST',
|
|
|
111 |
'sNext': 'LABEL_DATATABLE_SNEXT',
|
|
|
112 |
'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
|
|
|
113 |
},
|
|
|
114 |
'oAria': {
|
|
|
115 |
'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
|
|
|
116 |
'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
|
|
|
117 |
},
|
|
|
118 |
},
|
|
|
119 |
'drawCallback': function( settings ) {
|
|
|
120 |
NProgress.done();
|
|
|
121 |
$('button.btn-delete').confirmation({
|
|
|
122 |
rootSelector: 'button.btn-delete',
|
|
|
123 |
title : 'LABEL_ARE_YOU_SURE',
|
|
|
124 |
singleton : true,
|
|
|
125 |
btnOkLabel: 'LABEL_YES',
|
|
|
126 |
btnCancelLabel: 'LABEL_NO',
|
|
|
127 |
onConfirm: function(value) {
|
|
|
128 |
action = $(this).data('href');
|
|
|
129 |
NProgress.start();
|
|
|
130 |
$.ajax({
|
|
|
131 |
'dataType' : 'json',
|
|
|
132 |
'accept' : 'application/json',
|
|
|
133 |
'method' : 'post',
|
|
|
134 |
'url' : action,
|
|
|
135 |
}).done(function(response) {
|
|
|
136 |
if(response['success']) {
|
|
|
137 |
$.fn.showSuccess(response['data']);
|
|
|
138 |
gridTable.api().ajax.reload(null, false);
|
|
|
139 |
} else {
|
|
|
140 |
$.fn.showError(response['data']);
|
|
|
141 |
}
|
|
|
142 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
143 |
$.fn.showError(textStatus);
|
|
|
144 |
}).always(function() {
|
|
|
145 |
NProgress.done();
|
|
|
146 |
});
|
|
|
147 |
},
|
|
|
148 |
});
|
|
|
149 |
$('button.btn-add').click(function(e) {
|
|
|
150 |
|
|
|
151 |
action = $(this).data('href');
|
|
|
152 |
NProgress.start();
|
|
|
153 |
$.ajax({
|
|
|
154 |
'dataType' : 'json',
|
|
|
155 |
'accept' : 'application/json',
|
|
|
156 |
'method' : 'post',
|
|
|
157 |
'url' : action,
|
|
|
158 |
}).done(function(response) {
|
|
|
159 |
if(response['success']) {
|
|
|
160 |
$.fn.showSuccess(response['data']);
|
|
|
161 |
gridTable.api().ajax.reload(null, false);
|
|
|
162 |
} else {
|
|
|
163 |
$.fn.showError(response['data']);
|
|
|
164 |
}
|
|
|
165 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
166 |
$.fn.showError(textStatus);
|
|
|
167 |
}).always(function() {
|
|
|
168 |
NProgress.done();
|
|
|
169 |
});
|
|
|
170 |
});
|
|
|
171 |
|
|
|
172 |
},
|
|
|
173 |
'aoColumns': [
|
|
|
174 |
{ 'mDataProp': 'first_name' },
|
|
|
175 |
{ 'mDataProp': 'last_name' },
|
|
|
176 |
{ 'mDataProp': 'email' },
|
|
|
177 |
{ 'mDataProp': 'actions' },
|
|
|
178 |
],
|
|
|
179 |
'columnDefs': [
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
{
|
|
|
183 |
'targets': -1,
|
|
|
184 |
'orderable': false,
|
|
|
185 |
'render' : function ( data, type, row ) {
|
|
|
186 |
s = '';
|
|
|
187 |
|
|
|
188 |
if(allowDelete && data['link_delete'] ) {
|
|
|
189 |
s = s + '<button class="btn btn-danger btn-sm btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-times"></i> LABEL_DELETE </button> ';
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
if(allowAdd && data['link_add'] ) {
|
|
|
193 |
s = s + '<button class="btn btn-primary btn-sm btn-add" data-href="' + data['link_add']+ '" data-toggle="tooltip" title="LABEL_ADD"><i class="fa fa-plus"></i> LABEL_ADD </button> ';
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
return s;
|
|
|
197 |
}
|
|
|
198 |
}
|
|
|
199 |
],
|
|
|
200 |
});
|
|
|
201 |
|
|
|
202 |
$('#form-filter #form_uuid').change(function(e) {
|
|
|
203 |
e.preventDefault();
|
|
|
204 |
|
|
|
205 |
gridTable.api().ajax.reload(null, false);
|
|
|
206 |
})
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
$('body').on('click', 'button.btn-refresh', function(e) {
|
|
|
210 |
e.preventDefault();
|
|
|
211 |
gridTable.api().ajax.reload(null, false);
|
|
|
212 |
});
|
|
|
213 |
});
|
|
|
214 |
JS;
|
|
|
215 |
$this->inlineScript()->captureEnd();
|
|
|
216 |
?>
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
<!-- Content Header (Page header) -->
|
|
|
220 |
<section class="content-header">
|
|
|
221 |
<div class="container-fluid">
|
|
|
222 |
<div class="row mb-2">
|
|
|
223 |
<div class="col-sm-12">
|
|
|
224 |
<h1>LABEL_USERS_FOR_FORMS</h1>
|
|
|
225 |
</div>
|
|
|
226 |
</div>
|
|
|
227 |
</div><!-- /.container-fluid -->
|
|
|
228 |
</section>
|
|
|
229 |
|
|
|
230 |
<section class="content">
|
|
|
231 |
<div class="container-fluid">
|
|
|
232 |
<div class="row">
|
|
|
233 |
<div class="col-12">
|
|
|
234 |
<div class="card">
|
|
|
235 |
<div class="card-header">
|
|
|
236 |
<?php
|
|
|
237 |
$form = $this->form;
|
|
|
238 |
$form->setAttributes([
|
|
|
239 |
'name' => 'form-filter',
|
|
|
240 |
'id' => 'form-filter',
|
|
|
241 |
]);
|
|
|
242 |
|
|
|
243 |
$form->prepare();
|
|
|
244 |
echo $this->form()->openTag($form);
|
|
|
245 |
?>
|
|
|
246 |
<div class="row">
|
|
|
247 |
<div class="col-md-6 col-sm-12">
|
|
|
248 |
<div class="form-group">
|
|
|
249 |
<?php
|
|
|
250 |
$element = $form->get('form_uuid');
|
|
|
251 |
|
|
|
252 |
$element->setOptions(['label' => 'LABEL_FORM']);
|
|
|
253 |
|
|
|
254 |
$element->setAttributes(['class' => 'form-control']);
|
|
|
255 |
echo $this->formLabel($element);
|
|
|
256 |
echo $this->formSelect($element);
|
|
|
257 |
?>
|
|
|
258 |
</div>
|
|
|
259 |
</div>
|
|
|
260 |
|
|
|
261 |
</div>
|
|
|
262 |
<?php echo $this->form()->closeTag($form); ?>
|
|
|
263 |
</div>
|
|
|
264 |
<div class="card-body">
|
|
|
265 |
<table id="gridTable" class="table table-hover">
|
|
|
266 |
<thead>
|
|
|
267 |
<tr>
|
|
|
268 |
<th>LABEL_FIRST_NAME</th>
|
|
|
269 |
<th>LABEL_LAST_NAME</th>
|
|
|
270 |
<th>LABEL_EMAIL</th>
|
|
|
271 |
<th>LABEL_ACTIONS</th>
|
|
|
272 |
</tr>
|
|
|
273 |
</thead>
|
|
|
274 |
<tbody>
|
|
|
275 |
</tbody>
|
|
|
276 |
</table>
|
|
|
277 |
</div>
|
|
|
278 |
</div>
|
|
|
279 |
</div>
|
|
|
280 |
</div>
|
|
|
281 |
</div>
|
|
|
282 |
</section>
|