Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 8767 Rev 16822
Línea 1... Línea 1...
1
<?php
1
<?php 
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 34... Línea 34...
34
 
34
 
35
 
35
 
Línea 36... Línea -...
36
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
-
 
37
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
-
 
-
 
36
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
Línea 38... Línea 37...
38
 
37
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
Línea 39... Línea 38...
39
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
38
 
Línea 82... Línea 81...
82
                } else {
81
                } else {
83
                    error.insertAfter(field.parent());
82
                    error.insertAfter(field.parent());
84
                }
83
                }
85
            }
84
            }
86
        };
85
        };
-
 
86
 
-
 
87
 
-
 
88
 
-
 
89
 
-
 
90
        var allowEdit   = $allowEdit;
-
 
91
        var allowDelete = $allowDelete;
-
 
92
        
-
 
93
        var gridTable = $('#gridTable').dataTable( {
-
 
94
            'processing': true,
-
 
95
            'serverSide': true,
-
 
96
            'searching': true,
-
 
97
            'order': [[ 0, 'asc' ]],
-
 
98
            'ordering':  true,
-
 
99
            'ordenable' : true,
-
 
100
            'responsive': true,
-
 
101
            'select' : false,
-
 
102
        	'paging': true,
-
 
103
            'pagingType': 'simple_numbers',
-
 
104
    		'ajax': {
-
 
105
    			'url' : '$routeDatatable',
-
 
106
    			'type' : 'get',
-
 
107
                'beforeSend': function (request) {
-
 
108
                  NProgress.start();
-
 
109
                },
-
 
110
                'dataFilter': function(response) {
-
 
111
                    var response = jQuery.parseJSON( response );
-
 
112
                    
-
 
113
                    var json                = {};
-
 
114
                    json.recordsTotal       = 0;
-
 
115
                    json.recordsFiltered    = 0;
-
 
116
                    json.data               = [];
-
 
117
                    
-
 
118
                    
-
 
119
                    if(response.success) {
-
 
120
                        json.recordsTotal       = response.data.total;
-
 
121
                        json.recordsFiltered    = response.data.total;
-
 
122
                        json.data               = response.data.items;
-
 
123
                    } else {
-
 
124
                        $.fn.showError(response.data)
-
 
125
                    }
-
 
126
                    
-
 
127
                    return JSON.stringify( json );
-
 
128
                }
-
 
129
    		},
-
 
130
            'language' : {
-
 
131
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
-
 
132
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
-
 
133
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
-
 
134
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
-
 
135
                'sInfo':           'LABEL_DATATABLE_SINFO',
-
 
136
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
-
 
137
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
-
 
138
                'sInfoPostFix':    '',
-
 
139
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
-
 
140
                'sUrl':            '',
-
 
141
                'sInfoThousands':  ',',
-
 
142
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
-
 
143
                'oPaginate': {
-
 
144
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
-
 
145
                    'sLast':     'LABEL_DATATABLE_SLAST',
-
 
146
                    'sNext':     'LABEL_DATATABLE_SNEXT',
-
 
147
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
-
 
148
                },
-
 
149
                'oAria': {
-
 
150
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
-
 
151
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
-
 
152
                },
-
 
153
            },
-
 
154
            'drawCallback': function( settings ) {
-
 
155
                NProgress.done();
-
 
156
               
-
 
157
            },
-
 
158
            'aoColumns': [
-
 
159
                { 'mDataProp': 'name' },
-
 
160
                { 'mDataProp': 'status' },
-
 
161
                { 'mDataProp': 'actions' },
-
 
162
    	    ],
-
 
163
            'columnDefs': [
-
 
164
                {
-
 
165
                    'targets': 0,
-
 
166
                    'className' : 'text-vertical-middle',
-
 
167
                },
-
 
168
                {
-
 
169
                    'targets': -2,
-
 
170
                    'orderable': false,
-
 
171
                    'className' : 'text-center',
-
 
172
                      'render' : function ( data, type, row ) {
-
 
173
                      
-
 
174
                        checked = data == 'a'  ? 'checked' : '';
-
 
175
                        return '<div class="form-check">' +
-
 
176
                            '<input type="checkbox" class="form-check-input" disabled="" checked="' + checked + '">' +
-
 
177
                            '<label class="form-check-label" for="checkCheckedDisabled"></label></div>' ;
-
 
178
                    }
-
 
179
                },
-
 
180
                {
-
 
181
                    'targets': -1,
-
 
182
                    'orderable': false,
-
 
183
                    'render' : function ( data, type, row ) {
-
 
184
                        s = '';
-
 
185
                        
-
 
186
                        if(allowEdit) {
-
 
187
                            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;';
-
 
188
                        }
-
 
189
                        if(allowDelete) {
-
 
190
                            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;';
-
 
191
                        }
-
 
192
                        return s;
-
 
193
                    }
-
 
194
                }
-
 
195
              ],
-
 
196
        });
-
 
197
 
-
 
198
 
-
 
199
        var validator = $('#form').validate({
-
 
200
            debug: true,
-
 
201
            onclick: false,
-
 
202
            onkeyup: false,
-
 
203
            ignore: [],
-
 
204
            rules: {
-
 
205
                'name': {
-
 
206
                    required: true,
-
 
207
                    maxlength: 64,
-
 
208
                },
-
 
209
                'description': {
-
 
210
                    updateCkeditor:function() {
-
 
211
                        CKEDITOR.instances.description.updateElement();
-
 
212
                    },
-
 
213
                    required: true,
-
 
214
                },
-
 
215
                'name': {
-
 
216
                    required: false,
-
 
217
                    maxlength: 64,
-
 
218
                },
-
 
219
                
-
 
220
            },
-
 
221
            submitHandler: function(form)
-
 
222
            {
-
 
223
                $.ajax({
-
 
224
                    'dataType'  : 'json',
-
 
225
                    'accept'    : 'application/json',
-
 
226
                    'method'    : 'post',
-
 
227
                    'url'       :  $('#form').attr('action'),
-
 
228
                    'data'      :  $('#form').serialize()
-
 
229
                }).done(function(response) {
-
 
230
                    NProgress.start();
-
 
231
                    if(response['success']) {
-
 
232
                        $.fn.showSuccess(response['data']);
-
 
233
                        
-
 
234
                        $('#modal').modal('hide');
-
 
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
            $('#form #status').bootstrapToggle('on');
-
 
265
            CKEDITOR.instances.description.setData('');
-
 
266
 
-
 
267
 
-
 
268
            validator.resetForm();
-
 
269
            $('#modal').modal('show');
-
 
270
        });
-
 
271
        
-
 
272
        $('body').on('click', 'button.btn-edit', function(e) {
-
 
273
            e.preventDefault();
-
 
274
            NProgress.start();
-
 
275
            var action = $(this).data('href');
-
 
276
 
-
 
277
            $.ajax({
-
 
278
                'dataType'  : 'json',
-
 
279
                'accept'    : 'application/json',
-
 
280
                'method'    : 'get',
-
 
281
                'url'       :  action,
-
 
282
            }).done(function(response) {
-
 
283
                if(response['success']) {
-
 
284
 
-
 
285
                    $('span[id="form-title"]').html('LABEL_EDIT');
-
 
286
                    $('#form').attr('action', action);
-
 
287
                    $('#form #name').val(response['data']['name']);
-
 
288
                    $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
-
 
289
                    CKEDITOR.instances.description.setData(response['data']['description']);
-
 
290
 
-
 
291
                    validator.resetForm();
-
 
292
                    
-
 
293
                    $('#modal').modal('show');
-
 
294
                } else {
-
 
295
                    $.fn.showError(response['data']);
-
 
296
                }
-
 
297
            }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
298
                $.fn.showError(textStatus);
-
 
299
            }).always(function() {
-
 
300
                NProgress.done();
-
 
301
            });
-
 
302
        });
-
 
303
 
-
 
304
        $('body').on('click', 'button.btn-refresh', function(e) {
-
 
305
            e.preventDefault();
-
 
306
            gridTable.api().ajax.reload(null, false);
-
 
307
        });
-
 
308
        
-
 
309
 
-
 
310
        $('body').on('click', 'button.btn-cancel', function(e) {
-
 
311
            e.preventDefault();
-
 
312
            $('#modal').modal('hide');
-
 
313
        });
-
 
314
 
-
 
315
 $('body').on('click', 'button.btn-delete', function(e) { 
-
 
316
        e.preventDefault();
-
 
317
        var action = $(this).data('href');
-
 
318
 
-
 
319
 
-
 
320
          swal.fire({
-
 
321
            title: 'LABEL_ARE_YOU_SURE',
-
 
322
            icon: 'question',
-
 
323
            cancelButtonText: 'LABEL_NO',
-
 
324
            showCancelButton: true,
-
 
325
            confirmButtonText: 'LABEL_YES'
-
 
326
          }).then((result) => {
-
 
327
            if (result.isConfirmed) {
-
 
328
 
-
 
329
                    NProgress.start();
-
 
330
                    $.ajax({
-
 
331
                        'dataType'  : 'json',
-
 
332
                        'accept'    : 'application/json',
-
 
333
                        'method'    : 'post',
-
 
334
                        'url'       :  action,
-
 
335
                    }).done(function(response) {
-
 
336
                        if(response['success']) {
-
 
337
                            $.fn.showSuccess(response['data']);
-
 
338
                            gridTable.api().ajax.reload(null, false);
-
 
339
                        } else {
-
 
340
                            $.fn.showError(response['data']);
-
 
341
                        }
-
 
342
                    }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
343
                        $.fn.showError(textStatus);
-
 
344
                    }).always(function() {
-
 
345
                        NProgress.done();
-
 
346
                    });
-
 
347
            }
-
 
348
       });
-
 
349
    });
-
 
350
 
-
 
351
        $('#form #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
-
 
352
        CKEDITOR.replace( 'description');
87
    });
353
    });
88
JS;
354
JS;
89
$this->inlineScript()->captureEnd();
355
$this->inlineScript()->captureEnd();
-
 
356
?>
-
 
357
		
-
 
358
<!-- Content Header (Page header) -->
-
 
359
<section class="content-header">
-
 
360
	<div class="container-fluid">
-
 
361
    	<div class="row mb-2">
-
 
362
        	<div class="col-sm-12">
-
 
363
            	<h1>LABEL_SKILLS</h1>
-
 
364
			</div>
-
 
365
		</div>
-
 
366
	</div><!-- /.container-fluid -->
-
 
367
</section>
-
 
368
 
-
 
369
<section class="content">
-
 
370
	<div class="container-fluid">
-
 
371
    	<div class="row">
-
 
372
        	<div class="col-12">
-
 
373
				<div class="card">                    
-
 
374
					<div class="card-body">
-
 
375
        	    		<table id="gridTable" class="table   table-hover">
-
 
376
                      		<thead>
-
 
377
        						<tr>
-
 
378
                                	<th>LABEL_NAME</th>
-
 
379
                                  	<th>LABEL_ACTIVE</th>
-
 
380
                                  	<th>LABEL_ACTIONS</th>
-
 
381
                                </tr>
-
 
382
                       		</thead>
-
 
383
                         	<tbody>
-
 
384
                         	</tbody>
-
 
385
                    	</table>
-
 
386
                   	</div>
-
 
387
                   	<div class="card-footer clearfix">
-
 
388
                   		<div style="float:right;">
-
 
389
							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
-
 
390
							<?php if($allowAdd) : ?>
-
 
391
							<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
-
 
392
							<?php endif; ?>
-
 
393
						</div>
-
 
394
                 	</div>
-
 
395
          		</div>
-
 
396
           	</div>     
-
 
397
        </div>          
-
 
398
 	</div>
-
 
399
</section> 	
-
 
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_SKILLS - <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
            <!-- Modal body -->
-
 
413
      		<div class="modal-body">
-
 
414
       			 <?php 
-
 
415
                    $form = $this->form;
-
 
416
            		$form->setAttributes([
-
 
417
                        'method'    => 'post',
-
 
418
                        'name'      => 'form',
-
 
419
                        'id'        => 'form'
-
 
420
                    ]);
-
 
421
    
-
 
422
                    $form->prepare();
-
 
423
                    echo $this->form()->openTag($form);
-
 
424
                    ?>					
-
 
425
    					<div class="form-group">
-
 
426
        					<?php 
-
 
427
                            $element = $form->get('name');
-
 
428
                            $element->setOptions(['label' => 'LABEL_NAME']);
-
 
429
                            $element->setAttributes(['class' => 'form-control']); 
-
 
430
                                            
-
 
431
                            echo $this->formLabel($element);
-
 
432
                            echo $this->formText($element);
-
 
433
                            ?>
-
 
434
						</div>
-
 
435
						<div class="form-group">
-
 
436
                    	<?php 
-
 
437
                            $element = $form->get('description');
-
 
438
                            $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
-
 
439
                            $element->setAttributes(['class' => 'form-control']); 
-
 
440
 
-
 
441
                            echo $this->formLabel($element);
-
 
442
                            echo $this->formTextArea($element);
-
 
443
                        ?>
-
 
444
						</div>
-
 
445
						<div class="form-group">
-
 
446
                      	<?php 
-
 
447
                            $element = $form->get('status');
-
 
448
                            echo $this->formCheckbox($element);
-
 
449
                        ?>
-
 
450
						</div>
-
 
451
								
-
 
452
        				<div class="form-group">
-
 
453
                    		<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
-
 
454
                    		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
-
 
455
                   		</div>
-
 
456
     	      		<?php echo $this->form()->closeTag($form); ?>
-
 
457
      		</div>
-
 
458
 
-
 
459
            <!-- Modal footer -->
-
 
460
      		<div class="modal-footer">
-
 
461
        		 <button type="button" class="btn btn-light" data-bs-dismiss="modal">LABEL_CLOSE</button>
-
 
462
      		</div>
-
 
463
 
-
 
464
    	</div>
-
 
465
	</div>
-
 
466
</div>   			
-
 
467
						
-
 
468
			
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/skills/skillsBundle.js');
-
 
103
?>
-
 
104
 
-
 
105
<!-- Content Header (Page header) -->
469
 
-
 
470