1 |
www |
1 |
<?php
|
|
|
2 |
$acl = $this->viewModel()->getRoot()->getVariable('acl');
|
|
|
3 |
$currentUser = $this->currentUserHelper();
|
|
|
4 |
|
|
|
5 |
$roleName = $currentUser->getUserTypeId();
|
|
|
6 |
|
|
|
7 |
$routeAdd = $this->url('microlearning/settings/institutions/add');
|
|
|
8 |
$routeDatatable = $this->url('microlearning/settings/institutions');
|
|
|
9 |
$routeDashboard = $this->url('dashboard');
|
|
|
10 |
|
|
|
11 |
$allowAdd = $acl->isAllowed($roleName, 'microlearning/settings/institutions/add') ? 1 : 0;
|
|
|
12 |
$allowEdit = $acl->isAllowed($roleName, 'microlearning/settings/institutions/edit') ? 1 : 0;
|
|
|
13 |
$allowDelete = $acl->isAllowed($roleName, 'microlearning/settings/institutions/delete') ? 1 : 0;
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.min.js'));
|
|
|
17 |
|
|
|
18 |
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
|
|
|
19 |
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
|
|
|
23 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
|
|
|
24 |
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
|
|
|
25 |
|
|
|
26 |
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
|
|
|
27 |
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
|
|
|
28 |
|
|
|
29 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
|
|
|
30 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
|
|
|
31 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
|
|
|
32 |
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
|
|
|
33 |
|
|
|
34 |
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
|
|
|
35 |
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
$this->inlineScript()->captureStart();
|
|
|
40 |
echo <<<JS
|
|
|
41 |
jQuery( document ).ready(function( $ ) {
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
$.validator.setDefaults({
|
|
|
45 |
debug: true,
|
|
|
46 |
highlight: function(element) {
|
|
|
47 |
$(element).addClass('is-invalid');
|
|
|
48 |
},
|
|
|
49 |
unhighlight: function(element) {
|
|
|
50 |
$(element).removeClass('is-invalid');
|
|
|
51 |
},
|
|
|
52 |
errorElement: 'span',
|
|
|
53 |
errorClass: 'error invalid-feedback',
|
|
|
54 |
errorPlacement: function(error, element) {
|
|
|
55 |
if(element.parent('.form-group').length) {
|
|
|
56 |
error.insertAfter(element);
|
|
|
57 |
} else if(element.parent('.toggle').length) {
|
|
|
58 |
error.insertAfter(element.parent().parent());
|
|
|
59 |
} else {
|
|
|
60 |
error.insertAfter(element.parent());
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
});
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
$.fn.showFormErrorValidator = function(fieldname, errors) {
|
|
|
67 |
var field = $(fieldname);
|
|
|
68 |
if(field) {
|
|
|
69 |
$(field).addClass('is-invalid');
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
|
|
|
73 |
if(field.parent('.form-group').length) {
|
|
|
74 |
error.insertAfter(field);
|
|
|
75 |
} else if(field.parent('.toggle').length) {
|
|
|
76 |
error.insertAfter(field.parent().parent());
|
|
|
77 |
} else {
|
|
|
78 |
error.insertAfter(field.parent());
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
};
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
var allowEdit = $allowEdit;
|
|
|
87 |
var allowDelete = $allowDelete;
|
|
|
88 |
|
|
|
89 |
var gridTable = $('#gridTable').dataTable( {
|
|
|
90 |
'processing': true,
|
|
|
91 |
'serverSide': true,
|
|
|
92 |
'searching': true,
|
|
|
93 |
'order': [[ 0, 'asc' ]],
|
|
|
94 |
'ordering': true,
|
|
|
95 |
'ordenable' : true,
|
|
|
96 |
'responsive': true,
|
|
|
97 |
'select' : false,
|
|
|
98 |
'paging': true,
|
|
|
99 |
'pagingType': 'simple_numbers',
|
|
|
100 |
'ajax': {
|
|
|
101 |
'url' : '$routeDatatable',
|
|
|
102 |
'type' : 'get',
|
|
|
103 |
'beforeSend': function (request) {
|
|
|
104 |
NProgress.start();
|
|
|
105 |
},
|
|
|
106 |
'dataFilter': function(response) {
|
|
|
107 |
var response = jQuery.parseJSON( response );
|
|
|
108 |
|
|
|
109 |
var json = {};
|
|
|
110 |
json.recordsTotal = 0;
|
|
|
111 |
json.recordsFiltered = 0;
|
|
|
112 |
json.data = [];
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
if(response.success) {
|
|
|
116 |
json.recordsTotal = response.data.total;
|
|
|
117 |
json.recordsFiltered = response.data.total;
|
|
|
118 |
json.data = response.data.items;
|
|
|
119 |
} else {
|
|
|
120 |
$.fn.showError(response.data)
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
return JSON.stringify( json );
|
|
|
124 |
}
|
|
|
125 |
},
|
|
|
126 |
'language' : {
|
|
|
127 |
'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
|
|
|
128 |
'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
|
|
|
129 |
'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
|
|
|
130 |
'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
|
|
|
131 |
'sInfo': 'LABEL_DATATABLE_SINFO',
|
|
|
132 |
'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
|
|
|
133 |
'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
|
|
|
134 |
'sInfoPostFix': '',
|
|
|
135 |
'sSearch': 'LABEL_DATATABLE_SSEARCH',
|
|
|
136 |
'sUrl': '',
|
|
|
137 |
'sInfoThousands': ',',
|
|
|
138 |
'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
|
|
|
139 |
'oPaginate': {
|
|
|
140 |
'sFirst': 'LABEL_DATATABLE_SFIRST',
|
|
|
141 |
'sLast': 'LABEL_DATATABLE_SLAST',
|
|
|
142 |
'sNext': 'LABEL_DATATABLE_SNEXT',
|
|
|
143 |
'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
|
|
|
144 |
},
|
|
|
145 |
'oAria': {
|
|
|
146 |
'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
|
|
|
147 |
'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
|
|
|
148 |
},
|
|
|
149 |
},
|
|
|
150 |
'drawCallback': function( settings ) {
|
|
|
151 |
NProgress.done();
|
|
|
152 |
$('button.btn-delete').confirmation({
|
|
|
153 |
rootSelector: 'button.btn-delete',
|
|
|
154 |
title : 'LABEL_ARE_YOU_SURE',
|
|
|
155 |
singleton : true,
|
|
|
156 |
btnOkLabel: 'LABEL_YES',
|
|
|
157 |
btnCancelLabel: 'LABEL_NO',
|
|
|
158 |
onConfirm: function(value) {
|
|
|
159 |
action = $(this).data('href');
|
|
|
160 |
NProgress.start();
|
|
|
161 |
$.ajax({
|
|
|
162 |
'dataType' : 'json',
|
|
|
163 |
'accept' : 'application/json',
|
|
|
164 |
'method' : 'post',
|
|
|
165 |
'url' : action,
|
|
|
166 |
}).done(function(response) {
|
|
|
167 |
if(response['success']) {
|
|
|
168 |
$.fn.showSuccess(response['data']);
|
|
|
169 |
gridTable.api().ajax.reload(null, false);
|
|
|
170 |
} else {
|
|
|
171 |
$.fn.showError(response['data']);
|
|
|
172 |
}
|
|
|
173 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
174 |
$.fn.showError(textStatus);
|
|
|
175 |
}).always(function() {
|
|
|
176 |
NProgress.done();
|
|
|
177 |
});
|
|
|
178 |
},
|
|
|
179 |
});
|
|
|
180 |
},
|
|
|
181 |
'aoColumns': [
|
|
|
182 |
{ 'mDataProp': 'name' },
|
|
|
183 |
{ 'mDataProp': 'actions' },
|
|
|
184 |
],
|
|
|
185 |
'columnDefs': [
|
|
|
186 |
{
|
|
|
187 |
'targets': 0,
|
|
|
188 |
'className' : 'text-vertical-middle',
|
|
|
189 |
},
|
|
|
190 |
{
|
|
|
191 |
'targets': -1,
|
|
|
192 |
'orderable': false,
|
|
|
193 |
'render' : function ( data, type, row ) {
|
|
|
194 |
s = '';
|
|
|
195 |
|
|
|
196 |
if(allowEdit) {
|
|
|
197 |
s = s + '<button class="btn btn-primary btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';
|
|
|
198 |
}
|
|
|
199 |
if(allowDelete) {
|
|
|
200 |
s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button> ';
|
|
|
201 |
}
|
|
|
202 |
return s;
|
|
|
203 |
}
|
|
|
204 |
}
|
|
|
205 |
],
|
|
|
206 |
});
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
var validator = $('#form').validate({
|
|
|
210 |
debug: true,
|
|
|
211 |
onclick: false,
|
|
|
212 |
onkeyup: false,
|
|
|
213 |
ignore: [],
|
|
|
214 |
rules: {
|
|
|
215 |
'name': {
|
|
|
216 |
required: true,
|
|
|
217 |
maxlength: 128,
|
|
|
218 |
},
|
|
|
219 |
},
|
|
|
220 |
submitHandler: function(form)
|
|
|
221 |
{
|
|
|
222 |
$.ajax({
|
|
|
223 |
'dataType' : 'json',
|
|
|
224 |
'accept' : 'application/json',
|
|
|
225 |
'method' : 'post',
|
|
|
226 |
'url' : $('#form').attr('action'),
|
|
|
227 |
'data' : $('#form').serialize()
|
|
|
228 |
}).done(function(response) {
|
|
|
229 |
NProgress.start();
|
|
|
230 |
if(response['success']) {
|
|
|
231 |
$.fn.showSuccess(response['data']);
|
|
|
232 |
|
|
|
233 |
$('#modal').modal( 'hide');
|
|
|
234 |
|
|
|
235 |
gridTable.api().ajax.reload(null, false);
|
|
|
236 |
} else {
|
|
|
237 |
validator.resetForm();
|
|
|
238 |
if(jQuery.type(response['data']) == 'string') {
|
|
|
239 |
$.fn.showError(response['data']);
|
|
|
240 |
} else {
|
|
|
241 |
$.each(response['data'], function( fieldname, errors ) {
|
|
|
242 |
$.fn.showFormErrorValidator('#form #' + fieldname, errors);
|
|
|
243 |
});
|
|
|
244 |
}
|
|
|
245 |
}
|
|
|
246 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
247 |
$.fn.showError(textStatus);
|
|
|
248 |
}).always(function() {
|
|
|
249 |
NProgress.done();
|
|
|
250 |
});
|
|
|
251 |
return false;
|
|
|
252 |
},
|
|
|
253 |
invalidHandler: function(form, validator) {
|
|
|
254 |
|
|
|
255 |
}
|
|
|
256 |
});
|
|
|
257 |
|
|
|
258 |
$('body').on('click', 'button.btn-add', function(e) {
|
|
|
259 |
e.preventDefault();
|
|
|
260 |
|
|
|
261 |
$('span[id="form-title"]').html('LABEL_ADD');
|
|
|
262 |
$('#form').attr('action', '$routeAdd');
|
|
|
263 |
$('#form #name').val('');
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
validator.resetForm();
|
|
|
268 |
$('#modal').modal('show');
|
|
|
269 |
});
|
|
|
270 |
|
|
|
271 |
$('body').on('click', 'button.btn-edit', function(e) {
|
|
|
272 |
e.preventDefault();
|
|
|
273 |
NProgress.start();
|
|
|
274 |
var action = $(this).data('href');
|
|
|
275 |
|
|
|
276 |
$.ajax({
|
|
|
277 |
'dataType' : 'json',
|
|
|
278 |
'accept' : 'application/json',
|
|
|
279 |
'method' : 'get',
|
|
|
280 |
'url' : action,
|
|
|
281 |
}).done(function(response) {
|
|
|
282 |
if(response['success']) {
|
|
|
283 |
|
|
|
284 |
$('span[id="form-title"]').html('LABEL_EDIT');
|
|
|
285 |
$('#form').attr('action', action);
|
|
|
286 |
$('#form #name').val(response['data']['name']);
|
|
|
287 |
validator.resetForm();
|
|
|
288 |
|
|
|
289 |
$('#modal').modal('show');
|
|
|
290 |
} else {
|
|
|
291 |
$.fn.showError(response['data']);
|
|
|
292 |
}
|
|
|
293 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
294 |
$.fn.showError(textStatus);
|
|
|
295 |
}).always(function() {
|
|
|
296 |
NProgress.done();
|
|
|
297 |
});
|
|
|
298 |
});
|
|
|
299 |
|
|
|
300 |
$('body').on('click', 'button.btn-refresh', function(e) {
|
|
|
301 |
e.preventDefault();
|
|
|
302 |
gridTable.api().ajax.reload(null, false);
|
|
|
303 |
});
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
$('body').on('click', 'button.btn-cancel', function(e) {
|
|
|
307 |
e.preventDefault();
|
|
|
308 |
$('#modal').modal('hide');
|
|
|
309 |
});
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
});
|
|
|
313 |
JS;
|
|
|
314 |
$this->inlineScript()->captureEnd();
|
|
|
315 |
?>
|
|
|
316 |
|
|
|
317 |
<!-- Content Header (Page header) -->
|
|
|
318 |
<section class="content-header">
|
|
|
319 |
<div class="container-fluid">
|
|
|
320 |
<div class="row mb-2">
|
|
|
321 |
<div class="col-sm-12">
|
|
|
322 |
<h1>LABEL_INSTITUTIONS</h1>
|
|
|
323 |
</div>
|
|
|
324 |
</div>
|
|
|
325 |
</div><!-- /.container-fluid -->
|
|
|
326 |
</section>
|
|
|
327 |
|
|
|
328 |
<section class="content">
|
|
|
329 |
<div class="container-fluid">
|
|
|
330 |
<div class="row">
|
|
|
331 |
<div class="col-12">
|
|
|
332 |
<div class="card">
|
|
|
333 |
<div class="card-body">
|
20 |
steven |
334 |
<table id="gridTable" class="table table-hover">
|
1 |
www |
335 |
<thead>
|
|
|
336 |
<tr>
|
|
|
337 |
<th>LABEL_NAME</th>
|
|
|
338 |
<th>LABEL_ACTIONS</th>
|
|
|
339 |
</tr>
|
|
|
340 |
</thead>
|
|
|
341 |
<tbody>
|
|
|
342 |
</tbody>
|
|
|
343 |
</table>
|
|
|
344 |
</div>
|
|
|
345 |
<div class="card-footer clearfix">
|
|
|
346 |
<div style="float:right;">
|
|
|
347 |
<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
|
|
|
348 |
<?php if($allowAdd) : ?>
|
|
|
349 |
<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
|
|
|
350 |
<?php endif; ?>
|
|
|
351 |
</div>
|
|
|
352 |
</div>
|
|
|
353 |
</div>
|
|
|
354 |
</div>
|
|
|
355 |
</div>
|
|
|
356 |
</div>
|
|
|
357 |
</section>
|
|
|
358 |
|
|
|
359 |
<!-- The Modal -->
|
|
|
360 |
<div class="modal" id="modal">
|
|
|
361 |
<div class="modal-dialog modal-xl">
|
|
|
362 |
<div class="modal-content">
|
|
|
363 |
|
|
|
364 |
<!-- Modal Header -->
|
|
|
365 |
<div class="modal-header">
|
|
|
366 |
<h4 class="modal-title">LABEL_INSTITUTIONS - <span id="form-title"></span></h4>
|
|
|
367 |
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
|
368 |
</div>
|
|
|
369 |
|
|
|
370 |
<!-- Modal body -->
|
|
|
371 |
<div class="modal-body">
|
|
|
372 |
<?php
|
|
|
373 |
$form = $this->form;
|
|
|
374 |
$form->setAttributes([
|
|
|
375 |
'method' => 'post',
|
|
|
376 |
'name' => 'form',
|
|
|
377 |
'id' => 'form'
|
|
|
378 |
]);
|
|
|
379 |
|
|
|
380 |
$form->prepare();
|
|
|
381 |
echo $this->form()->openTag($form);
|
|
|
382 |
?>
|
|
|
383 |
<div class="form-group">
|
|
|
384 |
<?php
|
|
|
385 |
$element = $form->get('name');
|
|
|
386 |
$element->setOptions(['label' => 'LABEL_NAME']);
|
|
|
387 |
$element->setAttributes(['class' => 'form-control']);
|
|
|
388 |
|
|
|
389 |
echo $this->formLabel($element);
|
|
|
390 |
echo $this->formText($element);
|
|
|
391 |
?>
|
|
|
392 |
</div>
|
|
|
393 |
|
|
|
394 |
|
|
|
395 |
<div class="form-group">
|
|
|
396 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
|
|
397 |
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
|
|
|
398 |
</div>
|
|
|
399 |
<?php echo $this->form()->closeTag($form); ?>
|
|
|
400 |
</div>
|
|
|
401 |
|
|
|
402 |
<!-- Modal footer -->
|
|
|
403 |
<div class="modal-footer">
|
|
|
404 |
<button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
|
|
|
405 |
</div>
|
|
|
406 |
|
|
|
407 |
</div>
|
|
|
408 |
</div>
|
|
|
409 |
</div>
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
|
415 |
|