Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16822 Rev 16832
Línea 12... Línea 12...
12
$allowAdd               = $acl->isAllowed($roleName, 'settings/hobbies-and-interests/add') ? 1 : 0;
12
$allowAdd               = $acl->isAllowed($roleName, 'settings/hobbies-and-interests/add') ? 1 : 0;
13
$allowEdit              = $acl->isAllowed($roleName, 'settings/hobbies-and-interests/edit') ? 1 : 0;
13
$allowEdit              = $acl->isAllowed($roleName, 'settings/hobbies-and-interests/edit') ? 1 : 0;
14
$allowDelete            = $acl->isAllowed($roleName, 'settings/hobbies-and-interests/delete') ? 1 : 0;
14
$allowDelete            = $acl->isAllowed($roleName, 'settings/hobbies-and-interests/delete') ? 1 : 0;
Línea 15... Línea -...
15
 
-
 
16
 
-
 
17
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
-
 
18
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
15
 
Línea -... Línea 16...
-
 
16
 
-
 
17
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
-
 
18
 
19
 
19
 
20
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
20
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
21
 
21
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
Línea -... Línea 22...
-
 
22
 
-
 
23
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
22
 
24
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
23
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
25
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));
Línea 24... Línea 26...
24
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
26
 
25
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));
27
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
26
 
28
 
27
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
29
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
Línea 28... Línea -...
28
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
-
 
29
 
30
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
30
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
31
 
Línea 31... Línea 32...
31
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
32
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
Línea 32... Línea 33...
32
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
33
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
33
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
34
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
34
 
35
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
35
 
36
 
36
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
37
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
38
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
38
 
39
 
39
 
40
 
40
 
41
 
41
 
42
 
Línea 64... Línea 65...
64
                } else {
65
                } else {
65
                    error.insertAfter(element.parent());
66
                    error.insertAfter(element.parent());
66
                }
67
                }
67
            }
68
            }
68
        });
69
        });
69
    
70
        
70
    
71
        
71
        $.fn.showFormErrorValidator = function(fieldname, errors) {
72
        $.fn.showFormErrorValidator = function(fieldname, errors) {
72
            var field = $(fieldname);
73
            var field = $(fieldname);
73
            if(field) {
74
            if(field) {
74
                $(field).addClass('is-invalid');
75
                $(field).addClass('is-invalid');
75
    
76
                
76
 
77
                
77
                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
78
                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
78
                if(field.parent('.form-group').length) {
79
                if(field.parent('.form-group').length) {
79
                    error.insertAfter(field);
80
                    error.insertAfter(field);
80
                } else  if(field.parent('.toggle').length) {
81
                } else  if(field.parent('.toggle').length) {
81
                    error.insertAfter(field.parent().parent());
82
                    error.insertAfter(field.parent().parent());
82
                } else {
83
                } else {
83
                    error.insertAfter(field.parent());
84
                    error.insertAfter(field.parent());
84
                }
85
                }
85
            }
86
            }
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',
-
 
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');
-
 
352
        });
-
 
353
        
-
 
354
        
-
 
355
        $('#form #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
-
 
356
        CKEDITOR.replace( 'description')
87
    });
357
    });
88
JS;
358
JS;
89
$this->inlineScript()->captureEnd();
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_HOBBIES_AND_INTERESTS</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>
-
 
467
      		<?php echo $this->form()->closeTag($form); ?>
-
 
468
 
-
 
469
    	</div>
-
 
470
	</div>
-
 
471
</div>   			
-
 
472
			
Línea 90... Línea -...
90
 
-
 
91
$js = <<<JS
-
 
92
const urlsVar = {
-
 
93
        linkTable: '$routeDatatable',
-
 
94
        addUrl: '$routeAdd',
-
 
95
        allowAdd: '$allowAdd',
-
 
96
        allowEdit: '$allowEdit',
-
 
97
        allowDelete: '$allowDelete',
-
 
98
   }
-
 
Línea 99... Línea -...
99
JS;
-
 
100
 
-
 
101
$this->inlineScript()->appendScript($js);
-
 
Línea 102... Línea -...
102
$this->inlineScript()->appendFile('/react-bundles/settings/hobbies-and-interests/hobbiesAndInterestsBundle.js');
-
 
103
?>
-
 
104
 
-
 
105
<!-- Content Header (Page header) -->
473
 
-
 
474