| 14934 |
stevensc |
1 |
<?php
|
| 1 |
www |
2 |
$acl = $this->viewModel()->getRoot()->getVariable('acl');
|
|
|
3 |
$currentUser = $this->currentUserHelper();
|
|
|
4 |
|
|
|
5 |
$roleName = $currentUser->getUserTypeId();
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
$routeAdd = $this->url('microlearning/content/topics/add');
|
|
|
9 |
$routeDatatable = $this->url('microlearning/content/topics');
|
|
|
10 |
|
|
|
11 |
$allowAdd = $acl->isAllowed($roleName, 'microlearning/content/topics/add') ? 1 : 0;
|
|
|
12 |
$allowEdit = $acl->isAllowed($roleName, 'microlearning/content/topics/edit') ? 1 : 0;
|
|
|
13 |
$allowDelete = $acl->isAllowed($roleName, 'microlearning/content/topics/delete') ? 1 : 0;
|
|
|
14 |
|
|
|
15 |
|
| 16822 |
efrain |
16 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
|
|
|
17 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
|
| 1 |
www |
18 |
|
| 16822 |
efrain |
19 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
|
| 1 |
www |
20 |
|
|
|
21 |
|
| 16822 |
efrain |
22 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/css/fileinput.min.css'));
|
|
|
23 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.css'));
|
| 1 |
www |
24 |
|
| 16843 |
efrain |
25 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/piexif.js'));
|
|
|
26 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/plugins/sortable.js'));
|
| 16822 |
efrain |
27 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/fileinput.js'));
|
|
|
28 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/js/locales/es.js'));
|
|
|
29 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/fas/theme.js'));
|
|
|
30 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-fileinput/themes/explorer-fas/theme.js'));
|
| 1 |
www |
31 |
|
|
|
32 |
|
| 16822 |
efrain |
33 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
|
|
|
34 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
|
|
|
35 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));
|
| 1 |
www |
36 |
|
| 16822 |
efrain |
37 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
|
|
|
38 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
|
| 16905 |
efrain |
39 |
|
| 16822 |
efrain |
40 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
|
|
|
41 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
|
|
|
42 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
|
|
|
43 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
|
| 1 |
www |
44 |
|
|
|
45 |
|
| 16822 |
efrain |
46 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
|
|
|
47 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
|
| 1 |
www |
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
| 16822 |
efrain |
53 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
|
|
|
54 |
|
|
|
55 |
|
| 1 |
www |
56 |
$status_active = \LeadersLinked\Model\Degree::STATUS_ACTIVE;
|
|
|
57 |
|
| 4697 |
nelberth |
58 |
|
|
|
59 |
|
| 4737 |
nelberth |
60 |
|
| 1 |
www |
61 |
$this->inlineScript()->captureStart();
|
|
|
62 |
echo <<<JS
|
|
|
63 |
jQuery( document ).ready(function( $ ) {
|
|
|
64 |
|
|
|
65 |
$.validator.setDefaults({
|
|
|
66 |
debug: true,
|
|
|
67 |
highlight: function(element) {
|
|
|
68 |
$(element).addClass('is-invalid');
|
|
|
69 |
},
|
|
|
70 |
unhighlight: function(element) {
|
|
|
71 |
$(element).removeClass('is-invalid');
|
|
|
72 |
},
|
|
|
73 |
errorElement: 'span',
|
|
|
74 |
errorClass: 'error invalid-feedback',
|
|
|
75 |
errorPlacement: function(error, element) {
|
|
|
76 |
if(element.parent('.btn-file').length) {
|
|
|
77 |
error.insertAfter(element.parent().parent());
|
|
|
78 |
} else if(element.parent('.toggle').length) {
|
|
|
79 |
error.insertAfter(element.parent().parent());
|
|
|
80 |
} else {
|
|
|
81 |
error.insertAfter(element.parent());
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
});
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
$.fn.showFormErrorValidator = function(fieldname, errors) {
|
|
|
88 |
var field = $(fieldname);
|
|
|
89 |
if(field) {
|
|
|
90 |
$(field).addClass('is-invalid');
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
|
| 5541 |
nelberth |
94 |
/* if(element.parent('.btn-file').length) {
|
| 5539 |
nelberth |
95 |
error.insertAfter(element.parent().parent());
|
|
|
96 |
} else if(element.parent('.toggle').length) {
|
|
|
97 |
error.insertAfter(element.parent().parent());
|
|
|
98 |
} else {
|
|
|
99 |
error.insertAfter(element.parent());
|
| 5541 |
nelberth |
100 |
}*/
|
| 1 |
www |
101 |
}
|
|
|
102 |
};
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
var allowEdit = $allowEdit;
|
|
|
108 |
var allowDelete = $allowDelete;
|
|
|
109 |
|
|
|
110 |
var gridTable = $('#gridTable').dataTable( {
|
|
|
111 |
'processing': true,
|
|
|
112 |
'serverSide': true,
|
|
|
113 |
'searching': true,
|
|
|
114 |
'order': [[ 0, 'asc' ]],
|
|
|
115 |
'ordering': true,
|
|
|
116 |
'ordenable' : true,
|
|
|
117 |
'responsive': true,
|
|
|
118 |
'select' : false,
|
|
|
119 |
'paging': true,
|
|
|
120 |
'pagingType': 'simple_numbers',
|
|
|
121 |
'ajax': {
|
|
|
122 |
'url' : '$routeDatatable',
|
|
|
123 |
'type' : 'get',
|
|
|
124 |
'beforeSend': function (request) {
|
|
|
125 |
NProgress.start();
|
|
|
126 |
},
|
|
|
127 |
'dataFilter': function(response) {
|
|
|
128 |
var response = jQuery.parseJSON( response );
|
|
|
129 |
|
|
|
130 |
var json = {};
|
|
|
131 |
json.recordsTotal = 0;
|
|
|
132 |
json.recordsFiltered = 0;
|
|
|
133 |
json.data = [];
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
if(response.success) {
|
|
|
137 |
json.recordsTotal = response.data.total;
|
|
|
138 |
json.recordsFiltered = response.data.total;
|
|
|
139 |
json.data = response.data.items;
|
|
|
140 |
} else {
|
|
|
141 |
$.fn.showError(response.data)
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
return JSON.stringify( json );
|
|
|
145 |
}
|
|
|
146 |
},
|
|
|
147 |
'language' : {
|
|
|
148 |
'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
|
|
|
149 |
'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
|
|
|
150 |
'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
|
|
|
151 |
'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
|
|
|
152 |
'sInfo': 'LABEL_DATATABLE_SINFO',
|
|
|
153 |
'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
|
|
|
154 |
'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
|
|
|
155 |
'sInfoPostFix': '',
|
|
|
156 |
'sSearch': 'LABEL_DATATABLE_SSEARCH',
|
|
|
157 |
'sUrl': '',
|
|
|
158 |
'sInfoThousands': ',',
|
|
|
159 |
'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
|
|
|
160 |
'oPaginate': {
|
|
|
161 |
'sFirst': 'LABEL_DATATABLE_SFIRST',
|
|
|
162 |
'sLast': 'LABEL_DATATABLE_SLAST',
|
|
|
163 |
'sNext': 'LABEL_DATATABLE_SNEXT',
|
|
|
164 |
'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
|
|
|
165 |
},
|
|
|
166 |
'oAria': {
|
|
|
167 |
'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
|
|
|
168 |
'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
|
|
|
169 |
},
|
|
|
170 |
},
|
|
|
171 |
'drawCallback': function( settings ) {
|
|
|
172 |
NProgress.done();
|
| 16822 |
efrain |
173 |
|
| 1 |
www |
174 |
},
|
|
|
175 |
'aoColumns': [
|
|
|
176 |
{ 'mDataProp': 'name' },
|
|
|
177 |
{ 'mDataProp': 'status' },
|
|
|
178 |
{ 'mDataProp': 'image' },
|
|
|
179 |
{ 'mDataProp': 'actions' },
|
|
|
180 |
],
|
|
|
181 |
'columnDefs': [
|
|
|
182 |
{
|
|
|
183 |
'targets': 0,
|
|
|
184 |
'className' : 'text-vertical-middle',
|
|
|
185 |
},
|
|
|
186 |
{
|
|
|
187 |
'targets': -2,
|
|
|
188 |
'orderable': false,
|
|
|
189 |
'render' : function ( data, type, row ) {
|
|
|
190 |
s = ' ';
|
|
|
191 |
|
|
|
192 |
if( data ) {
|
|
|
193 |
s = s + ' <img class="btn-view-image-app" data-href="' + data + '" data-toggle="tooltip" src="'+data+'" title="LABEL_VIEW" style="width: 40px; object-fit: cover; height: 40px;" /> '
|
|
|
194 |
} else {
|
|
|
195 |
s = s + ' LABEL_IMAGE: <br>';
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
return s;
|
|
|
200 |
}
|
|
|
201 |
},
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
{
|
|
|
205 |
'targets': -1,
|
|
|
206 |
'orderable': false,
|
|
|
207 |
'render' : function ( data, type, row ) {
|
|
|
208 |
s = '';
|
|
|
209 |
|
|
|
210 |
if(allowEdit && data['link_edit'] ) {
|
|
|
211 |
s = s + '<button class="btn btn-info btn-sm btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';
|
|
|
212 |
}
|
|
|
213 |
if(allowDelete && data['link_delete'] ) {
|
|
|
214 |
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-trash"></i> LABEL_DELETE </button> ';
|
|
|
215 |
}
|
|
|
216 |
return s;
|
|
|
217 |
}
|
|
|
218 |
}
|
|
|
219 |
],
|
|
|
220 |
});
|
|
|
221 |
|
|
|
222 |
|
| 16905 |
efrain |
223 |
var validatorAdd = $('#form-add').validate({
|
| 1 |
www |
224 |
debug: true,
|
|
|
225 |
onclick: false,
|
|
|
226 |
onkeyup: false,
|
|
|
227 |
ignore: [],
|
|
|
228 |
rules: {
|
|
|
229 |
'name': {
|
|
|
230 |
required: true,
|
|
|
231 |
maxlength: 128,
|
|
|
232 |
},
|
|
|
233 |
'description': {
|
|
|
234 |
updateCkeditor:function() {
|
|
|
235 |
CKEDITOR.instances.description_add.updateElement();
|
|
|
236 |
},
|
|
|
237 |
required: true
|
|
|
238 |
},
|
|
|
239 |
'file': {
|
|
|
240 |
required: true,
|
| 16891 |
efrain |
241 |
extension: 'jpg|jpeg|png',
|
|
|
242 |
accept: 'image/jpg,image/jpeg,image/png'
|
| 1 |
www |
243 |
},
|
|
|
244 |
'order' : {
|
|
|
245 |
required: true,
|
|
|
246 |
digits: true,
|
|
|
247 |
min: 1,
|
|
|
248 |
max: 250
|
|
|
249 |
},
|
|
|
250 |
'status' : {
|
|
|
251 |
required: true,
|
|
|
252 |
},
|
|
|
253 |
},
|
|
|
254 |
submitHandler: function(form)
|
|
|
255 |
{
|
|
|
256 |
var formdata = false;
|
|
|
257 |
if (window.FormData){
|
|
|
258 |
formdata = new FormData(form); //form[0]);
|
|
|
259 |
}
|
| 5709 |
nelberth |
260 |
|
|
|
261 |
|
|
|
262 |
$('.info_noticia').prop('disabled', true);
|
| 5703 |
nelberth |
263 |
NProgress.start();
|
| 1 |
www |
264 |
$.ajax({
|
|
|
265 |
'dataType' : 'json',
|
|
|
266 |
'accept' : 'application/json',
|
|
|
267 |
'method' : 'post',
|
| 16905 |
efrain |
268 |
'url' : $('#form-add').attr('action'),
|
| 1 |
www |
269 |
'data' : formdata,
|
|
|
270 |
'processData': false,
|
|
|
271 |
'contentType': false,
|
|
|
272 |
}).done(function(response) {
|
| 5542 |
nelberth |
273 |
console.log(response)
|
|
|
274 |
if(response['success']) {
|
| 1 |
www |
275 |
$.fn.showSuccess(response['data']);
|
| 16891 |
efrain |
276 |
|
|
|
277 |
$('#row-add').hide();
|
|
|
278 |
$('#row-edit').hide();
|
|
|
279 |
$('#row-listing').show();
|
|
|
280 |
|
|
|
281 |
|
| 1 |
www |
282 |
gridTable.api().ajax.reload(null, false);
|
|
|
283 |
} else {
|
|
|
284 |
validatorAdd.resetForm();
|
|
|
285 |
if(jQuery.type(response['data']) == 'string') {
|
|
|
286 |
$.fn.showError(response['data']);
|
|
|
287 |
} else {
|
|
|
288 |
$.each(response['data'], function( fieldname, errors ) {
|
| 16905 |
efrain |
289 |
$.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
|
| 1 |
www |
290 |
});
|
|
|
291 |
}
|
|
|
292 |
}
|
|
|
293 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
| 5709 |
nelberth |
294 |
|
| 16891 |
efrain |
295 |
|
| 1 |
www |
296 |
$.fn.showError(textStatus);
|
|
|
297 |
}).always(function() {
|
| 16891 |
efrain |
298 |
|
| 1 |
www |
299 |
NProgress.done();
|
|
|
300 |
});
|
|
|
301 |
return false;
|
|
|
302 |
},
|
|
|
303 |
invalidHandler: function(form, validator) {
|
|
|
304 |
|
|
|
305 |
}
|
|
|
306 |
});
|
|
|
307 |
|
| 16905 |
efrain |
308 |
var validatorEdit = $('#form-edit').validate({
|
| 1 |
www |
309 |
debug: true,
|
|
|
310 |
onclick: false,
|
|
|
311 |
onkeyup: false,
|
|
|
312 |
ignore: [],
|
|
|
313 |
rules: {
|
|
|
314 |
'name': {
|
|
|
315 |
required: true,
|
|
|
316 |
maxlength: 128,
|
|
|
317 |
},
|
|
|
318 |
'description': {
|
|
|
319 |
updateCkeditor:function() {
|
|
|
320 |
CKEDITOR.instances.description_edit.updateElement();
|
|
|
321 |
},
|
|
|
322 |
required: true
|
|
|
323 |
},
|
|
|
324 |
'file': {
|
| 5982 |
nelberth |
325 |
required: true,
|
| 16891 |
efrain |
326 |
extension: 'jpg|jpeg|png',
|
|
|
327 |
accept: 'image/jpg,image/jpeg,image/png'
|
| 1 |
www |
328 |
},
|
|
|
329 |
'order' : {
|
|
|
330 |
required: true,
|
|
|
331 |
digits: true,
|
|
|
332 |
min: 1,
|
|
|
333 |
max: 250
|
|
|
334 |
},
|
|
|
335 |
'status' : {
|
|
|
336 |
required: true,
|
|
|
337 |
},
|
|
|
338 |
|
|
|
339 |
},
|
|
|
340 |
submitHandler: function(form)
|
|
|
341 |
{
|
|
|
342 |
var formdata = false;
|
|
|
343 |
if (window.FormData){
|
|
|
344 |
formdata = new FormData(form); //form[0]);
|
|
|
345 |
}
|
|
|
346 |
|
| 16891 |
efrain |
347 |
|
| 5982 |
nelberth |
348 |
NProgress.start();
|
| 1 |
www |
349 |
$.ajax({
|
|
|
350 |
'dataType' : 'json',
|
|
|
351 |
'accept' : 'application/json',
|
|
|
352 |
'method' : 'post',
|
| 16905 |
efrain |
353 |
'url' : $('#form-edit').attr('action'),
|
| 1 |
www |
354 |
'data' : formdata,
|
|
|
355 |
'processData': false,
|
|
|
356 |
'contentType': false,
|
|
|
357 |
}).done(function(response) {
|
|
|
358 |
if(response['success']) {
|
|
|
359 |
$.fn.showSuccess(response['data']);
|
|
|
360 |
|
| 16891 |
efrain |
361 |
|
| 1 |
www |
362 |
gridTable.api().ajax.reload(null, false);
|
| 16891 |
efrain |
363 |
|
|
|
364 |
|
|
|
365 |
$('#row-add').hide();
|
|
|
366 |
$('#row-edit').hide();
|
|
|
367 |
$('#row-listing').show();
|
|
|
368 |
|
| 1 |
www |
369 |
} else {
|
| 16891 |
efrain |
370 |
validatorEdit.resetForm();
|
| 1 |
www |
371 |
if(jQuery.type(response['data']) == 'string') {
|
|
|
372 |
$.fn.showError(response['data']);
|
|
|
373 |
} else {
|
|
|
374 |
$.each(response['data'], function( fieldname, errors ) {
|
| 16905 |
efrain |
375 |
$.fn.showFormErrorValidator('#form-edit #' + fieldname, errors);
|
| 1 |
www |
376 |
});
|
|
|
377 |
}
|
|
|
378 |
}
|
|
|
379 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
380 |
$.fn.showError(textStatus);
|
|
|
381 |
}).always(function() {
|
| 7060 |
nelberth |
382 |
|
| 16891 |
efrain |
383 |
|
| 1 |
www |
384 |
NProgress.done();
|
|
|
385 |
});
|
|
|
386 |
return false;
|
|
|
387 |
},
|
|
|
388 |
invalidHandler: function(form, validator) {
|
|
|
389 |
|
|
|
390 |
}
|
|
|
391 |
});
|
|
|
392 |
|
| 16822 |
efrain |
393 |
$('body').on('click', 'button.btn-delete', function(e) {
|
|
|
394 |
e.preventDefault();
|
|
|
395 |
var action = $(this).data('href');
|
| 1 |
www |
396 |
|
| 16822 |
efrain |
397 |
|
|
|
398 |
swal.fire({
|
|
|
399 |
title: 'LABEL_ARE_YOU_SURE',
|
|
|
400 |
icon: 'question',
|
|
|
401 |
cancelButtonText: 'LABEL_NO',
|
|
|
402 |
showCancelButton: true,
|
|
|
403 |
confirmButtonText: 'LABEL_YES'
|
|
|
404 |
}).then((result) => {
|
|
|
405 |
if (result.isConfirmed) {
|
|
|
406 |
|
|
|
407 |
NProgress.start();
|
|
|
408 |
$.ajax({
|
|
|
409 |
'dataType' : 'json',
|
|
|
410 |
'accept' : 'application/json',
|
|
|
411 |
'method' : 'post',
|
|
|
412 |
'url' : action,
|
|
|
413 |
}).done(function(response) {
|
|
|
414 |
if(response['success']) {
|
|
|
415 |
$.fn.showSuccess(response['data']);
|
|
|
416 |
gridTable.api().ajax.reload(null, false);
|
|
|
417 |
} else {
|
|
|
418 |
$.fn.showError(response['data']);
|
|
|
419 |
}
|
|
|
420 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
421 |
$.fn.showError(textStatus);
|
|
|
422 |
}).always(function() {
|
|
|
423 |
NProgress.done();
|
|
|
424 |
});
|
|
|
425 |
}
|
|
|
426 |
});
|
|
|
427 |
});
|
|
|
428 |
|
| 1 |
www |
429 |
|
|
|
430 |
$('body').on('click', '.btn-view-image-app', function(e) {
|
|
|
431 |
e.preventDefault();
|
|
|
432 |
|
|
|
433 |
$('#image-app').attr('src', $(this).data('href'));
|
| 16891 |
efrain |
434 |
$('#modalPreviewImage').modal('show');
|
| 1 |
www |
435 |
return false;
|
|
|
436 |
});
|
|
|
437 |
|
| 16905 |
efrain |
438 |
$('#form-add #order').inputNumberFormat({decimal: 0});
|
| 5741 |
nelberth |
439 |
|
| 1 |
www |
440 |
|
|
|
441 |
|
|
|
442 |
$('body').on('click', 'button.btn-add', function(e) {
|
|
|
443 |
e.preventDefault();
|
| 6015 |
nelberth |
444 |
|
| 16905 |
efrain |
445 |
$('#form-add #name').val('');
|
|
|
446 |
$('#form-add #order').val('1');
|
|
|
447 |
$('#form-add #name').val('');
|
| 1 |
www |
448 |
|
| 16905 |
efrain |
449 |
$('#form-add #status').val('');
|
|
|
450 |
$('#form-add #file').fileinput('reset');
|
|
|
451 |
$('#form-add #file').val('');
|
| 16891 |
efrain |
452 |
|
| 1 |
www |
453 |
|
|
|
454 |
|
|
|
455 |
CKEDITOR.instances.description_add.setData('');
|
|
|
456 |
validatorAdd.resetForm();
|
| 16891 |
efrain |
457 |
|
|
|
458 |
$('#row-edit').hide();
|
|
|
459 |
$('#row-listing').hide();
|
|
|
460 |
$('#row-add').show();
|
| 1 |
www |
461 |
|
| 16891 |
efrain |
462 |
|
| 5646 |
nelberth |
463 |
return false;
|
|
|
464 |
});
|
|
|
465 |
|
| 16891 |
efrain |
466 |
|
| 1 |
www |
467 |
|
| 16905 |
efrain |
468 |
$('#form-edit #order').inputNumberFormat({decimal: 0});
|
| 1 |
www |
469 |
|
| 16905 |
efrain |
470 |
$('#form-add #file').fileinput({
|
| 16891 |
efrain |
471 |
theme: 'fa',
|
|
|
472 |
language: 'es',
|
|
|
473 |
showUpload: false,
|
|
|
474 |
dropZoneEnabled: false,
|
|
|
475 |
maxFileCount: 1,
|
|
|
476 |
placeholder: 'LABEL_RECOMMENDED_SIZE $image_size',
|
|
|
477 |
allowedFileExtensions: ['jpeg', 'jpg', 'png'],
|
|
|
478 |
});
|
|
|
479 |
|
| 16905 |
efrain |
480 |
$('#form-edit #file').fileinput({
|
| 16891 |
efrain |
481 |
theme: 'fa',
|
|
|
482 |
language: 'es',
|
|
|
483 |
showUpload: false,
|
|
|
484 |
dropZoneEnabled: false,
|
|
|
485 |
maxFileCount: 1,
|
|
|
486 |
placeholder: 'LABEL_RECOMMENDED_SIZE $image_size',
|
|
|
487 |
allowedFileExtensions: ['jpeg', 'jpg', 'png'],
|
|
|
488 |
});
|
| 8591 |
nelberth |
489 |
|
| 1 |
www |
490 |
$('body').on('click', 'button.btn-edit', function(e) {
|
|
|
491 |
e.preventDefault();
|
| 6015 |
nelberth |
492 |
|
| 1 |
www |
493 |
var url = $(this).data('href');
|
| 5900 |
nelberth |
494 |
NProgress.start();
|
| 1 |
www |
495 |
$.ajax({
|
|
|
496 |
'dataType' : 'json',
|
|
|
497 |
'accept' : 'application/json',
|
|
|
498 |
'method' : 'get',
|
|
|
499 |
'url' : url,
|
|
|
500 |
}).done(function(response) {
|
|
|
501 |
if(response['success']) {
|
| 5913 |
nelberth |
502 |
console.log(response['data'])
|
| 16905 |
efrain |
503 |
$('#form-edit')[0].reset();
|
| 1 |
www |
504 |
|
| 16905 |
efrain |
505 |
$('#form-edit').attr('action',url);
|
|
|
506 |
$('#form-edit #name').val(response['data']['name']);
|
|
|
507 |
$('#form-edit #order').val(response['data']['order']);
|
| 1 |
www |
508 |
|
| 16905 |
efrain |
509 |
$('#form-edit #status').val(response['data']['status']);
|
|
|
510 |
$('#form-edit #file').fileinput('reset');
|
|
|
511 |
$('#form-edit #file').val('');
|
| 1 |
www |
512 |
|
|
|
513 |
CKEDITOR.instances.description_edit.setData(response['data']['description']);
|
|
|
514 |
validatorEdit.resetForm();
|
| 16891 |
efrain |
515 |
|
|
|
516 |
$('#row-add').hide();
|
|
|
517 |
$('#row-listing').hide();
|
|
|
518 |
$('#row-edit').show();
|
|
|
519 |
|
| 1 |
www |
520 |
} else {
|
|
|
521 |
validatorEdit.resetForm();
|
|
|
522 |
if(jQuery.type(response['data']) == 'string') {
|
|
|
523 |
$.fn.showError(response['data']);
|
|
|
524 |
} else {
|
|
|
525 |
$.each(response['data'], function( fieldname, errors ) {
|
| 16905 |
efrain |
526 |
$.fn.showFormErrorValidator('#form-edit #' + fieldname, errors);
|
| 1 |
www |
527 |
});
|
|
|
528 |
}
|
|
|
529 |
}
|
|
|
530 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
531 |
$.fn.showError(textStatus);
|
|
|
532 |
}).always(function() {
|
|
|
533 |
NProgress.done();
|
|
|
534 |
});
|
|
|
535 |
});
|
|
|
536 |
|
|
|
537 |
$('body').on('click', 'button.btn-cancel', function(e) {
|
|
|
538 |
e.preventDefault();
|
| 16891 |
efrain |
539 |
$('#row-add').hide();
|
|
|
540 |
$('#row-edit').hide();
|
|
|
541 |
$('#row-listing').show();
|
|
|
542 |
|
| 1 |
www |
543 |
});
|
|
|
544 |
|
|
|
545 |
$('body').on('click', 'button.btn-refresh', function(e) {
|
|
|
546 |
e.preventDefault();
|
|
|
547 |
gridTable.api().ajax.reload(null, false);
|
|
|
548 |
});
|
|
|
549 |
|
| 8290 |
stevensc |
550 |
CKEDITOR.replace('description_add', {
|
|
|
551 |
toolbar: [
|
|
|
552 |
{ name: 'editing', items: ['Scayt'] },
|
|
|
553 |
{ name: 'links', items: ['Link', 'Unlink'] },
|
|
|
554 |
{ name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
|
|
|
555 |
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
|
|
|
556 |
'/',
|
|
|
557 |
{ name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
|
|
|
558 |
{ name: 'styles', items: ['Styles', 'Format'] },
|
|
|
559 |
{ name: 'tools', items: ['Maximize'] }
|
|
|
560 |
],
|
|
|
561 |
removePlugins: 'elementspath,Anchor',
|
|
|
562 |
heigth: 100
|
|
|
563 |
});
|
|
|
564 |
CKEDITOR.replace('description_edit', {
|
|
|
565 |
toolbar: [
|
|
|
566 |
{ name: 'editing', items: ['Scayt'] },
|
|
|
567 |
{ name: 'links', items: ['Link', 'Unlink'] },
|
|
|
568 |
{ name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
|
|
|
569 |
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
|
|
|
570 |
'/',
|
|
|
571 |
{ name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
|
|
|
572 |
{ name: 'styles', items: ['Styles', 'Format'] },
|
|
|
573 |
{ name: 'tools', items: ['Maximize'] }
|
|
|
574 |
],
|
|
|
575 |
removePlugins: 'elementspath,Anchor',
|
|
|
576 |
heigth: 100
|
|
|
577 |
});
|
| 1 |
www |
578 |
|
| 4798 |
nelberth |
579 |
|
|
|
580 |
|
| 5202 |
nelberth |
581 |
|
| 1 |
www |
582 |
});
|
|
|
583 |
JS;
|
|
|
584 |
$this->inlineScript()->captureEnd();
|
|
|
585 |
?>
|
|
|
586 |
|
| 16891 |
efrain |
587 |
<div class="container">
|
|
|
588 |
<div class="card" id="row-listing">
|
|
|
589 |
<div class="card-header">
|
|
|
590 |
<h6 class="card-title">LABEL_TOPICS</h6>
|
|
|
591 |
</div>
|
|
|
592 |
<div class="card-body">
|
|
|
593 |
<div class="row">
|
|
|
594 |
<div class="col-12 mt-3">
|
|
|
595 |
|
|
|
596 |
<table id="gridTable" class="table table-bordered">
|
| 14934 |
stevensc |
597 |
<thead>
|
|
|
598 |
<tr>
|
|
|
599 |
<th>LABEL_NAME</th>
|
|
|
600 |
<th>LABEL_STATUS</th>
|
|
|
601 |
<th>LABEL_DETAILS</th>
|
|
|
602 |
<th>LABEL_ACTIONS</th>
|
|
|
603 |
</tr>
|
|
|
604 |
</thead>
|
|
|
605 |
<tbody>
|
|
|
606 |
</tbody>
|
|
|
607 |
</table>
|
| 16891 |
efrain |
608 |
|
|
|
609 |
</div>
|
|
|
610 |
</div>
|
|
|
611 |
</div>
|
|
|
612 |
<div class="card-footer text-right">
|
|
|
613 |
<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
|
|
|
614 |
<?php if ($allowAdd) : ?>
|
|
|
615 |
<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
|
|
|
616 |
<?php endif; ?>
|
|
|
617 |
</div>
|
| 14934 |
stevensc |
618 |
</div>
|
| 16891 |
efrain |
619 |
|
|
|
620 |
<div class="card" id="row-add" style="display:none">
|
|
|
621 |
<div class="card-header">
|
|
|
622 |
<h6 class="card-title">LABEL_ADD_TOPIC</h6>
|
|
|
623 |
</div>
|
|
|
624 |
<?php
|
| 14934 |
stevensc |
625 |
$form = $this->formAdd;
|
|
|
626 |
$form->setAttributes([
|
|
|
627 |
'method' => 'post',
|
|
|
628 |
'action' => $routeAdd,
|
| 16905 |
efrain |
629 |
'name' => 'form-add',
|
|
|
630 |
'id' => 'form-add',
|
| 14934 |
stevensc |
631 |
]);
|
| 5678 |
nelberth |
632 |
|
| 14934 |
stevensc |
633 |
$form->prepare();
|
|
|
634 |
echo $this->form()->openTag($form);
|
|
|
635 |
?>
|
| 16891 |
efrain |
636 |
<div class="card-body">
|
|
|
637 |
<div class="row">
|
|
|
638 |
<div class="col-12 mt-3">
|
|
|
639 |
<?php
|
|
|
640 |
$element = $form->get('name');
|
|
|
641 |
|
|
|
642 |
$element->setAttributes(['class' => 'form-control']);
|
|
|
643 |
$element->setOptions(['label' => 'LABEL_NAME']);
|
|
|
644 |
echo $this->formLabel($element);
|
|
|
645 |
echo $this->formText($element);
|
|
|
646 |
?>
|
|
|
647 |
</div>
|
|
|
648 |
</div>
|
|
|
649 |
|
|
|
650 |
|
|
|
651 |
<div class="row">
|
|
|
652 |
<div class="col-12 mt-3">
|
|
|
653 |
<?php
|
|
|
654 |
$element = $form->get('description');
|
|
|
655 |
$element->setAttributes(['id' => 'description_add', 'class' => 'form-control', 'rows' => '2', 'class' => 'form-control']);
|
|
|
656 |
$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
|
|
|
657 |
echo $this->formLabel($element);
|
|
|
658 |
echo $this->formTextArea($element);
|
|
|
659 |
?>
|
|
|
660 |
</div>
|
|
|
661 |
</div>
|
|
|
662 |
|
|
|
663 |
<div class="row">
|
|
|
664 |
<div class="col-12 mt-3">
|
|
|
665 |
<?php
|
|
|
666 |
$element = $form->get('order');
|
|
|
667 |
$element->setAttributes(['class' => 'form-control']);
|
|
|
668 |
$element->setOptions(['label' => 'LABEL_ORDER']);
|
|
|
669 |
echo $this->formLabel($element);
|
|
|
670 |
echo $this->formText($element);
|
|
|
671 |
?>
|
|
|
672 |
</div>
|
|
|
673 |
</div>
|
|
|
674 |
|
|
|
675 |
|
|
|
676 |
|
|
|
677 |
<div class="row">
|
|
|
678 |
<div class="col-12 mt-3">
|
|
|
679 |
<?php
|
|
|
680 |
$element = $form->get('status');
|
|
|
681 |
$element->setAttributes(['class' => 'form-control']);
|
|
|
682 |
$element->setOptions(['label' => 'LABEL_STATUS']);
|
|
|
683 |
echo $this->formLabel($element);
|
|
|
684 |
echo $this->formSelect($element);
|
|
|
685 |
|
|
|
686 |
?>
|
|
|
687 |
</div>
|
|
|
688 |
</div>
|
|
|
689 |
|
|
|
690 |
|
|
|
691 |
<div class="row">
|
|
|
692 |
<div class="col-12 mt-3">
|
|
|
693 |
<?php
|
|
|
694 |
$element = $form->get('file');
|
|
|
695 |
$element->setOptions(['label' => 'LABEL_IMAGE']);
|
|
|
696 |
$element->setAttributes(['class' => 'form-control']);
|
| 16905 |
efrain |
697 |
$element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
|
| 16891 |
efrain |
698 |
echo $this->formLabel($element);
|
|
|
699 |
echo $this->formFile($element);
|
|
|
700 |
?>
|
|
|
701 |
</div>
|
|
|
702 |
</div>
|
|
|
703 |
</div>
|
|
|
704 |
<div class="card-footer text-right">
|
|
|
705 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
|
|
706 |
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
|
|
|
707 |
</div>
|
|
|
708 |
<?php echo $this->form()->closeTag($form); ?>
|
| 14934 |
stevensc |
709 |
</div>
|
| 16891 |
efrain |
710 |
|
|
|
711 |
|
|
|
712 |
<div class="card" id="row-edit" style="display:none">
|
|
|
713 |
|
|
|
714 |
<div class="card-header">
|
|
|
715 |
<h6 class="card-title">LABEL_EDIT_TOPIC</h6>
|
|
|
716 |
</div>
|
|
|
717 |
<?php
|
| 14934 |
stevensc |
718 |
$form = $this->formEdit;
|
|
|
719 |
$form->setAttributes([
|
|
|
720 |
'method' => 'post',
|
| 16905 |
efrain |
721 |
'name' => 'form-edit',
|
|
|
722 |
'id' => 'form-edit'
|
| 14934 |
stevensc |
723 |
]);
|
| 5895 |
nelberth |
724 |
|
| 14934 |
stevensc |
725 |
$form->prepare();
|
|
|
726 |
echo $this->form()->openTag($form);
|
|
|
727 |
?>
|
| 16891 |
efrain |
728 |
|
|
|
729 |
<div class="card-body">
|
| 1 |
www |
730 |
|
| 16891 |
efrain |
731 |
<div class="row">
|
|
|
732 |
<div class="col-12 mt-3">
|
| 14934 |
stevensc |
733 |
<?php
|
|
|
734 |
$element = $form->get('description');
|
|
|
735 |
$element->setAttributes(['id' => 'description_edit', 'rows' => '2', 'class' => 'form-control', 'class' => 'form-control']);
|
|
|
736 |
$element->setOptions(['label' => 'LABEL_DESCRIPTION']);
|
|
|
737 |
echo $this->formLabel($element);
|
|
|
738 |
echo $this->formTextArea($element);
|
|
|
739 |
?>
|
| 16891 |
efrain |
740 |
</div>
|
| 14934 |
stevensc |
741 |
</div>
|
| 16891 |
efrain |
742 |
|
|
|
743 |
<div class="row">
|
|
|
744 |
<div class="col-12 mt-3">
|
| 14934 |
stevensc |
745 |
<?php
|
|
|
746 |
$element = $form->get('order');
|
|
|
747 |
$element->setAttributes(['class' => 'form-control']);
|
|
|
748 |
$element->setOptions(['label' => 'LABEL_ORDER']);
|
|
|
749 |
echo $this->formLabel($element);
|
|
|
750 |
echo $this->formText($element);
|
|
|
751 |
?>
|
| 16891 |
efrain |
752 |
</div>
|
| 14934 |
stevensc |
753 |
</div>
|
| 1 |
www |
754 |
|
| 14934 |
stevensc |
755 |
|
| 16891 |
efrain |
756 |
|
|
|
757 |
<div class="row">
|
|
|
758 |
<div class="col-12 mt-3">
|
| 14934 |
stevensc |
759 |
<?php
|
|
|
760 |
$element = $form->get('status');
|
|
|
761 |
$element->setAttributes(['class' => 'form-control']);
|
|
|
762 |
$element->setOptions(['label' => 'LABEL_STATUS']);
|
|
|
763 |
echo $this->formLabel($element);
|
|
|
764 |
echo $this->formSelect($element);
|
|
|
765 |
?>
|
| 16891 |
efrain |
766 |
</div>
|
| 14934 |
stevensc |
767 |
</div>
|
|
|
768 |
|
| 16891 |
efrain |
769 |
<div class="row">
|
|
|
770 |
<div class="col-12 mt-3">
|
|
|
771 |
<?php
|
|
|
772 |
$element = $form->get('file');
|
|
|
773 |
$element->setOptions(['label' => 'LABEL_IMAGE']);
|
|
|
774 |
$element->setAttributes(['class' => 'form-control']);
|
| 16905 |
efrain |
775 |
$element->setAttributes(['accept' => 'image/jpg,image/jpeg,image/png']);
|
| 16891 |
efrain |
776 |
echo $this->formLabel($element);
|
|
|
777 |
echo $this->formFile($element);
|
|
|
778 |
?>
|
|
|
779 |
</div>
|
|
|
780 |
</div>
|
|
|
781 |
|
|
|
782 |
|
|
|
783 |
</div>
|
|
|
784 |
|
|
|
785 |
<div class="card-footer text-right">
|
|
|
786 |
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
|
|
|
787 |
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
|
|
|
788 |
</div>
|
|
|
789 |
<?php echo $this->form()->closeTag($form); ?>
|
| 14934 |
stevensc |
790 |
</div>
|
| 16891 |
efrain |
791 |
</div>
|
| 14934 |
stevensc |
792 |
|
|
|
793 |
|
| 1 |
www |
794 |
|
|
|
795 |
<!-- The Modal -->
|
| 16891 |
efrain |
796 |
<div class="modal" id="modalPreviewImage">
|
| 1 |
www |
797 |
<div class="modal-dialog ">
|
| 14934 |
stevensc |
798 |
<div class="modal-content">
|
| 1 |
www |
799 |
|
| 14934 |
stevensc |
800 |
<!-- Modal Header -->
|
|
|
801 |
<div class="modal-header">
|
| 16845 |
efrain |
802 |
<h6 class="modal-title">LABEL_IMAGE</h6>
|
| 16822 |
efrain |
803 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
|
| 14934 |
stevensc |
804 |
</div>
|
| 1 |
www |
805 |
|
| 14934 |
stevensc |
806 |
<!-- Modal body -->
|
|
|
807 |
<div class="modal-body text-center">
|
| 1 |
www |
808 |
<img src="" class="img img-responsive" style="width: 300px; height: auto" id="image-app" />
|
| 14934 |
stevensc |
809 |
</div>
|
|
|
810 |
|
|
|
811 |
<!-- Modal footer -->
|
| 16891 |
efrain |
812 |
<div class="modal-footer text-right">
|
| 16822 |
efrain |
813 |
<button type="button" class="btn btn-light" data-bs-dismiss="modal">LABEL_CLOSE</button>
|
| 14934 |
stevensc |
814 |
</div>
|
|
|
815 |
</div>
|
| 1 |
www |
816 |
</div>
|
| 14934 |
stevensc |
817 |
</div>
|