Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15520 | Rev 16840 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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