Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 862 Rev 863
Línea 51... Línea 51...
51
 
51
 
Línea 52... Línea 52...
52
$status_active = \LeadersLinked\Model\Competency::STATUS_ACTIVE;
52
$status_active = \LeadersLinked\Model\Competency::STATUS_ACTIVE;
53
 
53
 
54
$this->inlineScript()->captureStart();
54
$this->inlineScript()->captureStart();
55
echo <<<JS
-
 
56
    jQuery( document ).ready(function( $ ) {
55
echo <<<JS
57
 
56
    jQuery(document).ready(function($) {
58
$.validator.setDefaults({
57
    $.validator.setDefaults({
59
            debug: true,
58
        debug: true,
60
            highlight: function(element) {
59
        highlight: function(element) {
61
                $(element).addClass('is-invalid');
60
            $(element).addClass('is-invalid');
62
            },
61
        },
63
            unhighlight: function(element) {
62
        unhighlight: function(element) {
64
                $(element).removeClass('is-invalid');
63
            $(element).removeClass('is-invalid');
65
            },
64
        },
66
            errorElement: 'span',
65
        errorElement: 'span',
67
            errorClass: 'error invalid-feedback',
66
        errorClass: 'error invalid-feedback',
68
            errorPlacement: function(error, element) {
67
        errorPlacement: function(error, element) {
69
                const child = element.children(':first-child');
68
            const child = element.children(':first-child');
70
                if(element[0].localName == 'input'){
69
            if (element[0].localName == 'input') {
71
                    let _error = error
70
                let _error = error
72
                    _error[0].style.display = 'block'
-
 
73
                    _error.insertBefore(element);
71
                _error[0].style.display = 'block'
74
                }
72
                _error.insertBefore(element);
75
                else if(element.parent('.form-group').length) {
73
            } else if (element.parent('.form-group').length) {
76
                    error.insertAfter(element);
74
                error.insertAfter(element);
77
                } else if(element.parent('.toggle').length) {
75
            } else if (element.parent('.toggle').length) {
78
                    error.insertAfter(element.parent().parent());
76
                error.insertAfter(element.parent().parent());
79
                } else {
-
 
80
                    error.insertAfter(element.parent());
77
            } else {
81
                }
78
                error.insertAfter(element.parent());
82
            }
-
 
83
        });
79
            }
84
    
80
        }
85
    
81
    });
86
        $.fn.showFormErrorValidator = function(fieldname, errors) {
82
    $.fn.showFormErrorValidator = function(fieldname, errors) {
87
            var field = $(fieldname);
83
        var field = $(fieldname);
88
            if(field) {
84
        if (field) {
89
                $(field).addClass('is-invalid');
85
            $(field).addClass('is-invalid');
90
                var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
86
            var error = $('<span id="' + fieldname + '-error" class="error invalid-feedback">' + errors + '</div>');
91
                if(field.parent('.form-group').length) {
87
            if (field.parent('.form-group').length) {
92
                    error.insertAfter(field);
88
                error.insertAfter(field);
-
 
89
            } else if (field.parent('.toggle').length) {
-
 
90
                error.insertAfter(field.parent().parent());
-
 
91
            } else {
-
 
92
                error.insertAfter(field.parent());
-
 
93
            }
-
 
94
        }
-
 
95
    };
-
 
96
    var allowEdit = $allowEdit;
-
 
97
    var allowDelete = $allowDelete;
-
 
98
    var gridTable = $('#gridTable').dataTable({
-
 
99
        'processing': true,
-
 
100
        'serverSide': true,
-
 
101
        'searching': true,
-
 
102
        'order': [
-
 
103
            [0, 'asc']
-
 
104
        ],
-
 
105
        'ordering': true,
-
 
106
        'ordenable': true,
-
 
107
        'responsive': true,
-
 
108
        'select': false,
-
 
109
        'paging': true,
-
 
110
        'pagingType': 'simple_numbers',
-
 
111
        'ajax': {
-
 
112
            'url': '$routeDatatable',
-
 
113
            'type': 'get',
-
 
114
            'beforeSend': function(request) {
-
 
115
                NProgress.start();
-
 
116
            },
-
 
117
            'dataFilter': function(response) {
-
 
118
                var response = jQuery.parseJSON(response);
-
 
119
                var json = {};
-
 
120
                json.recordsTotal = 0;
-
 
121
                json.recordsFiltered = 0;
-
 
122
                json.data = [];
-
 
123
                if (response.success) {
-
 
124
                    json.recordsTotal = response.data.total;
93
                } else  if(field.parent('.toggle').length) {
125
                    json.recordsFiltered = response.data.total;
94
                    error.insertAfter(field.parent().parent());
126
                    json.data = response.data.items;
95
                } else {
127
                } else {
-
 
128
                    $.fn.showError(response.data)
96
                    error.insertAfter(field.parent());
129
                }
97
                }
130
                return JSON.stringify(json);
98
            }
-
 
99
        };
-
 
100
 
-
 
101
 
-
 
102
 
-
 
103
 
-
 
104
        var allowEdit   = $allowEdit;
-
 
105
        var allowDelete = $allowDelete;
-
 
106
        
-
 
107
        var gridTable = $('#gridTable').dataTable( {
-
 
108
            'processing': true,
-
 
109
            'serverSide': true,
-
 
110
            'searching': true,
-
 
111
            'order': [[ 0, 'asc' ]],
-
 
112
            'ordering':  true,
-
 
113
            'ordenable' : true,
-
 
114
            'responsive': true,
-
 
115
            'select' : false,
-
 
116
        	'paging': true,
-
 
117
            'pagingType': 'simple_numbers',
-
 
118
    		'ajax': {
-
 
119
    			'url' : '$routeDatatable',
-
 
120
    			'type' : 'get',
-
 
121
                'beforeSend': function (request) {
-
 
122
                  NProgress.start();
-
 
123
                },
-
 
124
                'dataFilter': function(response) {
-
 
125
                    var response = jQuery.parseJSON( response );
-
 
126
                    
-
 
127
                    var json                = {};
-
 
128
                    json.recordsTotal       = 0;
-
 
129
                    json.recordsFiltered    = 0;
-
 
130
                    json.data               = [];
-
 
131
                    
-
 
132
                    
-
 
133
                    if(response.success) {
-
 
134
                        json.recordsTotal       = response.data.total;
-
 
135
                        json.recordsFiltered    = response.data.total;
-
 
136
                        json.data               = response.data.items;
-
 
137
                    } else {
-
 
138
                        $.fn.showError(response.data)
-
 
139
                    }
-
 
140
                    
-
 
141
                    return JSON.stringify( json );
-
 
142
                }
131
            }
143
    		},
132
        },
144
            'language' : {
133
        'language': {
145
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
134
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
146
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
135
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
147
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
136
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
148
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
137
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
149
                'sInfo':           'LABEL_DATATABLE_SINFO',
138
            'sInfo': 'LABEL_DATATABLE_SINFO',
150
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
139
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
151
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
140
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
152
                'sInfoPostFix':    '',
141
            'sInfoPostFix': '',
153
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
142
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
154
                'sUrl':            '',
143
            'sUrl': '',
155
                'sInfoThousands':  ',',
144
            'sInfoThousands': ',',
156
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
145
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
157
                'oPaginate': {
146
            'oPaginate': {
158
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
147
                'sFirst': 'LABEL_DATATABLE_SFIRST',
159
                    'sLast':     'LABEL_DATATABLE_SLAST',
148
                'sLast': 'LABEL_DATATABLE_SLAST',
160
                    'sNext':     'LABEL_DATATABLE_SNEXT',
-
 
161
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
-
 
162
                },
-
 
163
                'oAria': {
-
 
164
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
-
 
165
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
149
                'sNext': 'LABEL_DATATABLE_SNEXT',
166
                },
-
 
167
            },
150
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
168
            'drawCallback': function( settings ) {
-
 
169
                NProgress.done();
-
 
170
                $('button.btn-delete').confirmation({
151
            },
171
                    rootSelector: 'button.btn-delete',
-
 
172
                    title : 'LABEL_ARE_YOU_SURE',
-
 
173
                    singleton : true,
152
            'oAria': {
174
                    btnOkLabel: 'LABEL_YES',
-
 
175
                    btnCancelLabel: 'LABEL_NO',
-
 
176
                    onConfirm: function(value) {
-
 
177
                        action = $(this).data('href');
-
 
178
                        NProgress.start();
-
 
179
                        $.ajax({
-
 
180
                            'dataType'  : 'json',
-
 
181
                            'accept'    : 'application/json',
-
 
182
                            'method'    : 'post',
-
 
183
                            'url'       :  action,
-
 
184
                        }).done(function(response) {
-
 
185
                            if(response['success']) {
-
 
186
                                $.fn.showSuccess(response['data']);
-
 
187
                                gridTable.api().ajax.reload(null, false);
-
 
188
                            } else {
-
 
189
                                $.fn.showError(response['data']);
-
 
190
                            }
-
 
191
                        }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
192
                            $.fn.showError(textStatus);
-
 
193
                        }).always(function() {
-
 
194
                            NProgress.done();
-
 
195
                        });
-
 
196
                    },
153
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
-
 
154
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
-
 
155
            },
197
                });
156
        },
-
 
157
        'drawCallback': function(settings) {
-
 
158
            NProgress.done();
-
 
159
            $('button.btn-delete').confirmation({
198
            },
160
                rootSelector: 'button.btn-delete',
199
            'aoColumns': [
161
                title: 'LABEL_ARE_YOU_SURE',
200
                { 'mDataProp': 'type' },
162
                singleton: true,
201
                { 'mDataProp': 'name' },
163
                btnOkLabel: 'LABEL_YES',
202
                { 'mDataProp': 'status' },
164
                btnCancelLabel: 'LABEL_NO',
203
                { 'mDataProp': 'actions' },
165
                onConfirm: function(value) {
204
    	    ],
166
                    action = $(this).data('href');
205
            'columnDefs': [
167
                    NProgress.start();
206
                {
168
                    $.ajax({
-
 
169
                        'dataType': 'json',
-
 
170
                        'accept': 'application/json',
-
 
171
                        'method': 'post',
-
 
172
                        'url': action,
-
 
173
                    }).done(function(response) {
-
 
174
                        if (response['success']) {
207
                    'targets': 0,
175
                            $.fn.showSuccess(response['data']);
-
 
176
                            gridTable.api().ajax.reload(null, false);
208
                    'className' : 'text-vertical-middle',
177
                        } else {
-
 
178
                            $.fn.showError(response['data']);
-
 
179
                        }
209
                },
180
                    }).fail(function(jqXHR, textStatus, errorThrown) {
210
                {
181
                        $.fn.showError(textStatus);
-
 
182
                    }).always(function() {
211
                    'targets': 1,
183
                        NProgress.done();
-
 
184
                    });
-
 
185
                },
-
 
186
            });
-
 
187
        },
-
 
188
        'aoColumns': [{
212
                    'className' : 'text-vertical-middle',
189
                'mDataProp': 'type'
-
 
190
            },
-
 
191
            {
-
 
192
                'mDataProp': 'name'
-
 
193
            },
-
 
194
            {
-
 
195
                'mDataProp': 'status'
-
 
196
            },
-
 
197
            {
-
 
198
                'mDataProp': 'actions'
-
 
199
            },
-
 
200
        ],
-
 
201
        'columnDefs': [{
-
 
202
                'targets': 0,
-
 
203
                'className': 'text-vertical-middle',
-
 
204
            },
-
 
205
            {
-
 
206
                'targets': 1,
-
 
207
                'className': 'text-vertical-middle',
213
                },
208
            },
214
                {
209
            {
215
                    'targets': -2,
210
                'targets': -2,
216
                    'orderable': false,
211
                'orderable': false,
217
                    'className' : 'text-center',
-
 
218
                      'render' : function ( data, type, row ) {
212
                'className': 'text-center',
219
                      
213
                'render': function(data, type, row) {
220
                        checked = data == 'a' ? ' checked="checked" ' : '';
214
                    checked = data == 'a' ? ' checked="checked" ' : '';
221
                        return '<div class="checkbox checkbox-success">' +
215
                    return '<div class="checkbox checkbox-success">' +
-
 
216
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
-
 
217
                        '<label ></label></div>';
-
 
218
                }
-
 
219
            },
-
 
220
            {
-
 
221
                'targets': -1,
-
 
222
                'orderable': false,
-
 
223
                'render': function(data, type, row) {
-
 
224
                    s = '';
222
                            '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
225
                    if (allowEdit) {
223
                            '<label ></label></div>';
-
 
224
                    }
-
 
225
                },
-
 
226
                {
-
 
227
                    'targets': -1,
-
 
228
                    'orderable': false,
-
 
229
                    'render' : function ( data, type, row ) {
-
 
230
                        s = '';
-
 
231
                        
-
 
232
                        if(allowEdit) {
-
 
233
                            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;';
226
                        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;';
234
                        }
227
                    }
235
                        if(allowDelete) {
-
 
236
                            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;';
-
 
237
                        }
228
                    if (allowDelete) {
-
 
229
                        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;';
238
                        return s;
230
                    }
239
                    }
231
                    return s;
240
                }
232
                }
241
              ],
-
 
242
        });
233
            }
243
 
234
        ],
244
 
235
    });
245
        var validator = $('#form').validate({
236
    var validator = $('#form').validate({
246
            debug: true,
237
        debug: true,
247
            onclick: false,
238
        onclick: false,
248
            onkeyup: false,
239
        onkeyup: false,
249
            ignore: [],
240
        ignore: [],
250
            rules: {
241
        rules: {
251
                'competency_type_id': {
242
            'competency_type_id': {
252
                    required: true,
243
                required: true,
253
                },
244
            },
254
                'name': {
245
            'name': {
255
                    required: true,
246
                required: true,
256
                    maxlength:128,
247
                maxlength: 128,
257
                },
248
            },
258
                'description': {
249
            'description': {
259
                    updateCkeditor:function() {
-
 
260
                        CKEDITOR.instances.description.updateElement();
-
 
261
                    },
-
 
262
                    required: true,
-
 
263
                },
-
 
264
 
-
 
265
                'status': {
-
 
266
                    required: false,
250
                updateCkeditor: function() {
-
 
251
                    CKEDITOR.instances.description.updateElement();
267
                    
252
                },
268
                },
-
 
269
            },
-
 
270
            submitHandler: function(form)
-
 
271
            {
-
 
272
                $.ajax({
-
 
273
                    'dataType'  : 'json',
-
 
274
                    'accept'    : 'application/json',
-
 
275
                    'method'    : 'post',
-
 
276
                    'url'       :  $('#form').attr('action'),
-
 
277
                    'data'      :  $('#form').serialize()
-
 
278
                }).done(function(response) {
-
 
279
                    NProgress.start();
-
 
280
                    if(response['success']) {
-
 
281
                        $.fn.showSuccess(response['data']);
-
 
282
                        
-
 
283
                        $('#modal').modal('hide');
-
 
284
 
-
 
285
                        
-
 
286
                         gridTable.api().ajax.reload(null, false);
-
 
287
                    } else {
-
 
288
                        validator.resetForm();
-
 
289
                        if(jQuery.type(response['data']) == 'string') {
-
 
290
                            $.fn.showError(response['data']);
-
 
291
                        } else  {
-
 
292
                            $.each(response['data'], function( fieldname, errors ) {
-
 
293
                                $.fn.showFormErrorValidator('#form #' + fieldname, errors);
-
 
294
                            });
253
                required: true,
295
                        }
-
 
296
                    }
-
 
297
                }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
298
                   $.fn.showError(textStatus);
-
 
299
                }).always(function() {
-
 
300
                    NProgress.done();
254
            },
301
                });
255
            'status': {
302
                return false;
-
 
303
            },
-
 
304
            invalidHandler: function(form, validator) {
-
 
305
            
256
                required: false,
306
            }
-
 
307
        });
-
 
308
        
-
 
309
        $('body').on('click', 'button.btn-add', function(e) {
-
 
310
            e.preventDefault();
-
 
311
 
-
 
312
            $('span[id="form-title"]').html('LABEL_ADD');
-
 
313
            $('#form').attr('action', '$routeAdd');
-
 
314
            $('#form #name').val('');
-
 
315
            $('#form #competency_type_id').val('').trigger('change');
-
 
316
            $('#form #status').bootstrapToggle('on');
-
 
317
            CKEDITOR.instances.description.setData('');
257
            },
318
 
-
 
319
            validator.resetForm();
-
 
320
            $('#modal').modal('show');
-
 
321
 
-
 
322
            return false;
-
 
323
        });
-
 
324
        
-
 
325
        $('body').on('click', 'button.btn-edit', function(e) {
-
 
326
            e.preventDefault();
-
 
327
            NProgress.start();
-
 
328
            var action = $(this).data('href');
258
        },
329
 
259
        submitHandler: function(form) {
-
 
260
            $.ajax({
330
            $.ajax({
261
                'dataType': 'json',
331
                'dataType'  : 'json',
262
                'accept': 'application/json',
-
 
263
                'method': 'post',
332
                'method'    : 'get',
264
                'url': $('#form').attr('action'),
333
                'url'       :  action,
-
 
334
            }).done(function(response) {
-
 
335
                if(response['success']) {
-
 
336
 
-
 
337
                    $('span[id="form-title"]').html('LABEL_EDIT');
-
 
338
                    $('#form').attr('action', action);
-
 
339
                    $('#form #name').val(response['data']['name']);
-
 
340
                    $('#form #competency_type_id').val(response['data']['competency_type_id']).trigger('change');
-
 
341
                    $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
-
 
342
                    CKEDITOR.instances.description.setData(response['data']['description']);
-
 
343
                    validator.resetForm();
-
 
344
                    
-
 
345
                    $('#modal').modal('show');
-
 
346
 
-
 
347
                } else {
-
 
348
                    $.fn.showError(response['data']);
-
 
349
                }
-
 
350
            }).fail(function( jqXHR, textStatus, errorThrown) {
-
 
351
                $.fn.showError(textStatus);
-
 
352
            }).always(function() {
-
 
353
                NProgress.done();
-
 
354
            });
-
 
355
 
-
 
356
            return false;
-
 
357
        });
-
 
358
 
-
 
359
        $('body').on('click', 'button.btn-refresh', function(e) {
-
 
360
            e.preventDefault();
-
 
361
            gridTable.api().ajax.reload(null, false);
-
 
362
 
-
 
363
            return false;
-
 
364
        });
-
 
365
 
-
 
366
        $('body').on('click', 'button.btn-import', function(e) {
-
 
367
            e.preventDefault();
265
                'data': $('#form').serialize()
368
 
-
 
369
            NProgress.start();
-
 
370
 
-
 
371
 
-
 
372
            $.ajax({
-
 
373
                'dataType'  : 'json',
-
 
374
                'method'    : 'post',
-
 
375
                'url'       : '$routeImport',
266
            }).done(function(response) {
376
            }).done(function(response) {
267
                NProgress.start();
-
 
268
                if (response['success']) {
377
                if(response['success']) {
269
                    $.fn.showSuccess(response['data']);
378
                    $.fn.showSuccess(response['data']);
270
                    $('#modal').modal('hide');
-
 
271
                    gridTable.api().ajax.reload(null, false);
-
 
272
                } else {
379
                    gridTable.api().ajax.reload(null, false);
273
                    validator.resetForm();
-
 
274
                    if (jQuery.type(response['data']) == 'string') {
-
 
275
                        $.fn.showError(response['data']);
-
 
276
                    } else {
-
 
277
                        $.each(response['data'], function(fieldname, errors) {
-
 
278
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
380
                } else {
279
                        });
381
                    $.fn.showError(response['data']);
280
                    }
382
                }
281
                }
383
            }).fail(function( jqXHR, textStatus, errorThrown) {
282
            }).fail(function(jqXHR, textStatus, errorThrown) {
384
                $.fn.showError(textStatus);
283
                $.fn.showError(textStatus);
385
            }).always(function() {
284
            }).always(function() {
386
                NProgress.done();
-
 
387
            });
285
                NProgress.done();
-
 
286
            });
-
 
287
            return false;
-
 
288
        },
-
 
289
        invalidHandler: function(form, validator) {}
-
 
290
    });
-
 
291
    $('body').on('click', 'button.btn-add', function(e) {
-
 
292
        e.preventDefault();
-
 
293
        $('span[id="form-title"]').html('LABEL_ADD');
-
 
294
        $('#form').attr('action', '$routeAdd');
-
 
295
        $('#form #name').val('');
-
 
296
        $('#form #competency_type_id').val('').trigger('change');
-
 
297
        $('#form #status').bootstrapToggle('on');
-
 
298
        CKEDITOR.instances.description.setData('');
-
 
299
        validator.resetForm();
-
 
300
        $('#modal').modal('show');
-
 
301
        return false;
-
 
302
    });
-
 
303
    $('body').on('click', 'button.btn-edit', function(e) {
-
 
304
        e.preventDefault();
-
 
305
        NProgress.start();
-
 
306
        var action = $(this).data('href');
-
 
307
        $.ajax({
-
 
308
            'dataType': 'json',
-
 
309
            'method': 'get',
-
 
310
            'url': action,
-
 
311
        }).done(function(response) {
-
 
312
            if (response['success']) {
-
 
313
                $('span[id="form-title"]').html('LABEL_EDIT');
-
 
314
                $('#form').attr('action', action);
-
 
315
                $('#form #name').val(response['data']['name']);
-
 
316
                $('#form #competency_type_id').val(response['data']['competency_type_id']).trigger('change');
-
 
317
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
-
 
318
                CKEDITOR.instances.description.setData(response['data']['description']);
-
 
319
                validator.resetForm();
-
 
320
                $('#modal').modal('show');
-
 
321
            } else {
-
 
322
                $.fn.showError(response['data']);
-
 
323
            }
-
 
324
        }).fail(function(jqXHR, textStatus, errorThrown) {
-
 
325
            $.fn.showError(textStatus);
388
 
326
        }).always(function() {
-
 
327
            NProgress.done();
389
            return false;
328
        });
-
 
329
        return false;
-
 
330
    });
-
 
331
    $('body').on('click', 'button.btn-refresh', function(e) {
-
 
332
        e.preventDefault();
390
        });
333
        gridTable.api().ajax.reload(null, false);
391
        
334
        return false;
392
 
335
    });
-
 
336
    $('body').on('click', 'button.btn-import', function(e) {
-
 
337
        e.preventDefault();
-
 
338
        NProgress.start();
393
        $('body').on('click', 'button.btn-cancel', function(e) {
339
        $.ajax({
-
 
340
            'dataType': 'json',
-
 
341
            'method': 'post',
-
 
342
            'url': '$routeImport',
-
 
343
        }).done(function(response) {
-
 
344
            if (response['success']) {
-
 
345
                $.fn.showSuccess(response['data']);
-
 
346
                gridTable.api().ajax.reload(null, false);
394
            e.preventDefault();
347
            } else {
395
            $('#modal').modal('hide');
-
 
396
        });
348
                $.fn.showError(response['data']);
397
 
349
            }
-
 
350
        }).fail(function(jqXHR, textStatus, errorThrown) {
398
        $('#form #competency_type_id').select2({
351
            $.fn.showError(textStatus);
399
            theme: 'bootstrap4',
352
        }).always(function() {
-
 
353
            NProgress.done();
400
            width: '100%',
354
        });
-
 
355
        return false;
-
 
356
    });
-
 
357
    $('body').on('click', 'button.btn-cancel', function(e) {
401
        });
358
        e.preventDefault();
-
 
359
        $('#modal').modal('hide');
-
 
360
    });
-
 
361
    $('#form #competency_type_id').select2({
402
 
362
        theme: 'bootstrap4',
403
 
363
        width: '100%',
-
 
364
    });
-
 
365
    $('#form #status').bootstrapToggle({
-
 
366
        'on': 'LABEL_ACTIVE',
-
 
367
        'off': 'LABEL_INACTIVE',
-
 
368
        'width': '160px',
404
 
369
        'height': '40px'
405
        $('#form #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
-
 
406
        CKEDITOR.replace( 'description' );
-
 
407
 
370
    });
408
 
371
    CKEDITOR.replace('description');
409
     /**
372
    /**
410
     * Clicked on add new conduct
373
     * Clicked on add new conduct
411
     */
374
     */
412
    $('body').on('click', 'button[id="btn-add-conduct"]', function(e) {
375
    $('body').on('click', 'button[id="btn-add-conduct"]', function(e) {
413
        e.preventDefault();
376
        e.preventDefault();
414
        validatorFormSection.resetForm();
377
        validatorFormConduct.resetForm();
415
        $('#form-conduct #conduct-id').val('');
378
        $('#form-conduct #conduct-id').val('');
416
        $('#form-conduct #conduct-description').val('');
379
        $('#form-conduct #conduct-description').val('');
417
        $('#form-conduct #conduct-level').val('0');
380
        $('#form-conduct #conduct-level').val('0');
Línea 427... Línea 390...
427
        var conduct;
390
        var conduct;
428
        var showForm = false;
391
        var showForm = false;
429
        for (i = 0; i < objFormGenerator.conducts.length; i++) {
392
        for (i = 0; i < objFormGenerator.conducts.length; i++) {
430
            conduct = objFormGenerator.conducts[i];
393
            conduct = objFormGenerator.conducts[i];
431
            if (slug == conduct.slug_conduct) {
394
            if (slug == conduct.slug_conduct) {
432
                validatorFormSection.resetForm();
395
                validatorFormConduct.resetForm();
433
                $('#form-conduct #conduct-id').val(conduct.slug_conduct);
396
                $('#form-conduct #conduct-id').val(conduct.slug_conduct);
434
                $('#form-conduct #conduct-description').val(conduct.description);
397
                $('#form-conduct #conduct-description').val(conduct.description);
435
                $('#form-conduct #conduct-level').val(conduct.level);
398
                $('#form-conduct #conduct-level').val(conduct.level);
436
                return;
399
                return;
437
            }
400
            }
Línea 457... Línea 420...
457
                confirm: {
420
                confirm: {
458
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
421
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
459
                }
422
                }
460
            },
423
            },
461
            callback: function(result) {
424
            callback: function(result) {
462
                if (result) {
425
                if (result) {}
463
 
-
 
464
                }
-
 
465
            }
426
            }
466
        });
427
        });
467
    });
428
    });
468
 
429
    /**
-
 
430
     * Validate rules form conduct
469
 
431
     */
-
 
432
    var validatorFormConduct = $("#form-conduct").validate({
-
 
433
        ignore: [],
-
 
434
        errorClass: 'help-block',
-
 
435
        errorElement: 'span',
-
 
436
        rules: {
-
 
437
            'conduct-description': {
-
 
438
                required: false,
-
 
439
            },
-
 
440
            'conduct-level': {
-
 
441
                required: true,
-
 
442
            },
-
 
443
        },
-
 
444
        highlight: function(element) {
-
 
445
            $(element).closest('.form-group').addClass('has-error');
-
 
446
        },
-
 
447
        unhighlight: function(element) {
-
 
448
            $(element).closest('.form-group').removeClass('has-error');
-
 
449
        },
-
 
450
        errorPlacement: function(error, element) {
-
 
451
            if (element.attr("data-error-container")) {
-
 
452
                error.appendTo(element.attr("data-error-container"));
-
 
453
            } else {
-
 
454
                error.insertAfter(element);
-
 
455
            }
-
 
456
        },
-
 
457
        invalidHandler: function(form, validator) {
-
 
458
            if (!validator.numberOfInvalids())
-
 
459
                return;
-
 
460
            $('html, body').animate({
-
 
461
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
462
            }, 1000);
-
 
463
        },
-
 
464
        submitHandler: function(form) {
-
 
465
            var id = $('#form-conduct #conduct-id').val();
-
 
466
            if (id) {} else {}
-
 
467
            $('#modal-conduct').modal('hide');
-
 
468
            return false;
-
 
469
        }
470
    });
470
    });
-
 
471
});
471
JS;
472
JS;
472
$this->inlineScript()->captureEnd();
473
$this->inlineScript()->captureEnd();
473
?>
474
?>