Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1185 | Rev 1187 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
66 efrain 1
<?php
2
use LeadersLinked\Model\JobDescription;
3
 
4
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
5
$currentUser    = $this->currentUserHelper();
6
 
7
$roleName = $currentUser->getUserTypeId();
8
 
9
 
10
$routeAdd       = $this->url('settings/jobs-description/add');
11
$routeDatatable = $this->url('settings/jobs-description');
846 geraldo 12
$routeImport    = $this->url('settings/jobs-description/import');
66 efrain 13
$routeDashboard = $this->url('dashboard');
14
 
15
$allowAdd               = $acl->isAllowed($roleName, 'settings/jobs-description/add') ? 1 : 0;
16
$allowEdit              = $acl->isAllowed($roleName, 'settings/jobs-description/edit') ? 1 : 0;
17
$allowDelete            = $acl->isAllowed($roleName, 'settings/jobs-description/delete') ? 1 : 0;
561 geraldo 18
$allowReport            = $acl->isAllowed($roleName, 'settings/jobs-description/report') ? 1 : 0;
846 geraldo 19
$allowImport            = $acl->isAllowed($roleName, 'settings/jobs-description/import') ? 1 : 0;
66 efrain 20
 
21
 
22
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
23
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
24
 
25
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
26
 
27
 
28
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
29
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
30
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
31
 
32
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
33
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
34
 
35
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
36
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
37
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
38
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
39
 
40
 
41
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
42
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
43
 
44
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
45
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
46
 
1175 geraldo 47
// bootbox Alert //
48
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
66 efrain 49
 
1175 geraldo 50
// JsRender //
51
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
52
 
53
 
54
// Page Styles
55
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
56
 
57
 
66 efrain 58
$status_active = JobDescription::STATUS_ACTIVE;
59
 
60
$this->inlineScript()->captureStart();
61
echo <<<JS
1170 geraldo 62
 
63
var competencies = [];
1180 geraldo 64
var competencies_type = [];
1170 geraldo 65
var subordinates = [];
66
var competencies_selected = [];
67
var subordinates_selected = [];
1167 geraldo 68
jQuery(document).ready(function($) {
935 geraldo 69
    $.validator.setDefaults({
70
        debug: true,
71
        highlight: function(element) {
72
            $(element).addClass('is-invalid');
73
        },
74
        unhighlight: function(element) {
75
            $(element).removeClass('is-invalid');
76
        },
77
        errorElement: 'span',
78
        errorClass: 'error invalid-feedback',
79
        errorPlacement: function(error, element) {
80
            if (element.parent('.form-group').length) {
81
                error.insertAfter(element);
82
            } else if (element.parent('.toggle').length) {
83
                error.insertAfter(element.parent().parent());
84
            } else {
85
                error.insertAfter(element.parent());
86
            }
87
        }
88
    });
89
    $.fn.showFormErrorValidator = function(fieldname, errors) {
90
        var field = $(fieldname);
91
        if (field) {
92
            $(field).addClass('is-invalid');
93
            var error = $('<span id="' + fieldname + '-error" class="error invalid-feedback">' + errors + '</div>');
94
            if (field.parent('.form-group').length) {
95
                error.insertAfter(field);
96
            } else if (field.parent('.toggle').length) {
97
                error.insertAfter(field.parent().parent());
98
            } else {
99
                error.insertAfter(field.parent());
100
            }
101
        }
102
    };
103
    var allowEdit = $allowEdit;
104
    var allowDelete = $allowDelete;
105
    var allowReport = $allowReport;
106
    var gridTable = $('#gridTable').dataTable({
107
        'processing': true,
108
        'serverSide': true,
109
        'searching': true,
110
        'order': [
111
            [0, 'asc']
112
        ],
113
        'ordering': true,
114
        'ordenable': true,
115
        'responsive': true,
116
        'select': false,
117
        'paging': true,
118
        'pagingType': 'simple_numbers',
119
        'ajax': {
120
            'url': '$routeDatatable',
121
            'type': 'get',
122
            'beforeSend': function(request) {
123
                NProgress.start();
66 efrain 124
            },
935 geraldo 125
            'dataFilter': function(response) {
126
                var response = jQuery.parseJSON(response);
127
                var json = {};
128
                json.recordsTotal = 0;
129
                json.recordsFiltered = 0;
130
                json.data = [];
131
                if (response.success) {
132
                    json.recordsTotal = response.data.total;
133
                    json.recordsFiltered = response.data.total;
134
                    json.data = response.data.items;
66 efrain 135
                } else {
935 geraldo 136
                    $.fn.showError(response.data)
66 efrain 137
                }
935 geraldo 138
                return JSON.stringify(json);
66 efrain 139
            }
935 geraldo 140
        },
141
        'language': {
142
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
143
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
144
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
145
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
146
            'sInfo': 'LABEL_DATATABLE_SINFO',
147
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
148
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
149
            'sInfoPostFix': '',
150
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
151
            'sUrl': '',
152
            'sInfoThousands': ',',
153
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
154
            'oPaginate': {
155
                'sFirst': 'LABEL_DATATABLE_SFIRST',
156
                'sLast': 'LABEL_DATATABLE_SLAST',
157
                'sNext': 'LABEL_DATATABLE_SNEXT',
158
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
159
            },
160
            'oAria': {
161
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
162
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
163
            },
164
        },
165
        'drawCallback': function(settings) {
166
            NProgress.done();
167
            $('button.btn-delete').confirmation({
168
                rootSelector: 'button.btn-delete',
169
                title: 'LABEL_ARE_YOU_SURE',
170
                singleton: true,
171
                btnOkLabel: 'LABEL_YES',
172
                btnCancelLabel: 'LABEL_NO',
173
                onConfirm: function(value) {
174
                    action = $(this).data('href');
175
                    NProgress.start();
176
                    $.ajax({
177
                        'dataType': 'json',
178
                        'accept': 'application/json',
179
                        'method': 'post',
180
                        'url': action,
181
                    }).done(function(response) {
182
                        if (response['success']) {
183
                            $.fn.showSuccess(response['data']);
184
                            gridTable.api().ajax.reload(null, false);
185
                        } else {
186
                            $.fn.showError(response['data']);
187
                        }
188
                    }).fail(function(jqXHR, textStatus, errorThrown) {
189
                        $.fn.showError(textStatus);
190
                    }).always(function() {
191
                        NProgress.done();
192
                    });
66 efrain 193
                },
935 geraldo 194
            });
195
        },
196
        'aoColumns': [{
197
                'mDataProp': 'name'
198
            },
199
            {
200
                'mDataProp': 'status'
201
            },
202
            {
203
                'mDataProp': 'actions'
204
            },
205
        ],
206
        'columnDefs': [{
207
                'targets': 0,
208
                'className': 'text-vertical-middle',
209
            },
210
            {
211
                'targets': -2,
212
                'orderable': false,
213
                'className': 'text-center',
214
                'render': function(data, type, row) {
215
                    checked = data == 'a' ? ' checked="checked" ' : '';
216
                    return '<div class="checkbox checkbox-success">' +
217
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
218
                        '<label ></label></div>';
66 efrain 219
                }
220
            },
935 geraldo 221
            {
222
                'targets': -1,
223
                'orderable': false,
224
                'render': function(data, type, row) {
225
                    s = '';
226
                    if (allowEdit) {
227
                        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;';
66 efrain 228
                    }
935 geraldo 229
                    if (allowDelete) {
230
                        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;';
66 efrain 231
                    }
935 geraldo 232
                    if (allowReport) {
233
                        s = s + '<a class="btn btn-default btn-pdf" href="' + data['link_report'] + '" target="_blank" data-toggle="tooltip" title="LABEL_PDF"><i class="fa fa-file-o"></i> LABEL_PDF </button>&nbsp;';
234
                    }
235
                    return s;
66 efrain 236
                }
935 geraldo 237
            }
238
        ],
239
    });
240
    var validator = $('#form').validate({
241
        debug: true,
242
        onclick: false,
243
        onkeyup: false,
244
        ignore: [],
245
        rules: {
246
            'name': {
247
                required: true,
248
                maxlength: 64,
249
            },
250
            'functions': {
251
                updateCkeditor: function() {
252
                    CKEDITOR.instances.functions.updateElement();
66 efrain 253
                },
935 geraldo 254
                required: true,
255
            },
256
            'objectives': {
257
                updateCkeditor: function() {
258
                    CKEDITOR.instances.objectives.updateElement();
66 efrain 259
                },
935 geraldo 260
                required: true,
66 efrain 261
            },
935 geraldo 262
            'status': {
263
                required: false,
66 efrain 264
            },
935 geraldo 265
        },
266
        submitHandler: function(form) {
66 efrain 267
            $.ajax({
935 geraldo 268
                'dataType': 'json',
269
                'accept': 'application/json',
270
                'method': 'post',
271
                'url': $('#form').attr('action'),
272
                'data': $('#form').serialize()
66 efrain 273
            }).done(function(response) {
935 geraldo 274
                NProgress.start();
275
                if (response['success']) {
276
                    $.fn.showSuccess(response['data']);
277
                    $('#modal').modal('hide');
278
                    gridTable.api().ajax.reload(null, false);
279
                } else {
280
                    validator.resetForm();
281
                    if (jQuery.type(response['data']) == 'string') {
282
                        $.fn.showError(response['data']);
283
                    } else {
284
                        $.each(response['data'], function(fieldname, errors) {
285
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
66 efrain 286
                        });
935 geraldo 287
                    }
66 efrain 288
                }
935 geraldo 289
            }).fail(function(jqXHR, textStatus, errorThrown) {
66 efrain 290
                $.fn.showError(textStatus);
291
            }).always(function() {
292
                NProgress.done();
293
            });
935 geraldo 294
            return false;
295
        },
296
        invalidHandler: function(form, validator) {}
297
    });
298
    $('body').on('click', 'button.btn-add', function(e) {
299
        e.preventDefault();
300
        NProgress.start();
301
        $.ajax({
302
            'dataType': 'json',
303
            'accept': 'application/json',
304
            'method': 'get',
305
            'url': '$routeAdd',
306
        }).done(function(response) {
307
            if (response['success']) {
308
                $('span[id="form-title"]').html('LABEL_ADD');
309
                $('#form').attr('action', '$routeAdd');
310
                $('#form #name').val('');
311
                $('#form #status').bootstrapToggle('on');
312
                CKEDITOR.instances.functions.setData('');
313
                CKEDITOR.instances.objectives.setData('');
1170 geraldo 314
                competencies = response['data']['competencies'];
315
                competencies_type = response['data']['competency_types'];
1186 geraldo 316
                renderData([]);
1170 geraldo 317
                setCompetencySelect();
935 geraldo 318
                var s = '';
319
                var first = true;
1169 geraldo 320
                $.each(response['data']['competency_types'], function(index, rowCompetencyType) {
321
                    first = true;
322
                    $.each(response['data']['competencies'], function(index, rowCompetency) {
323
                        if (rowCompetencyType['competency_type_id'] == rowCompetency['competency_type_id']) {
324
                            if (first) {
325
                                first = false;
326
                                s = '<tr>' +
327
                                    '<td><big><b>' + rowCompetencyType['name'] + '</b></big></td>' +
328
                                    '</tr>';
329
                                $('#tableCompetencies tbody').append(s)
330
                            }
331
                            s = '<tr>' +
332
                                '<td> ' +
333
                                '<div class="custom-control custom-checkbox">' +
334
                                '<input class="custom-control-input" type="checkbox"  name="competency_level' + rowCompetency['competency_id'] + '" id="competency_level' + rowCompetency['competency_id'] + '" value="1">' +
335
                                '<label for="competency_level' + rowCompetency['competency_id'] + '" class="custom-control-label">' + rowCompetency['name'] + '</label>' +
336
                                '</div>' +
337
                                '<td>';
338
                            $('#tableCompetencies tbody').append(s)
339
                        }
340
                    });
341
                });
935 geraldo 342
                $('#tableSubordinates tbody').empty();
343
                $('#job_description_id_boss option:not(:first)').remove();
344
                $.each(response['data']['jobs_description'], function(index, rowJobDescription) {
345
                    $('#job_description_id_boss').append(new Option(rowJobDescription['name'], rowJobDescription['job_description_id']));
346
                    s = '<tr>' +
347
                        '<td>' +
348
                        '<div class="custom-control custom-checkbox">' +
349
                        '<input class="custom-control-input" type="checkbox" name="job_description_id_subordinate' + rowJobDescription['job_description_id'] + '" id="job_description_id_subordinate' + rowJobDescription['job_description_id'] + '" value="1">' +
350
                        '<label for="job_description_id_subordinate' + rowJobDescription['job_description_id'] + '" class="custom-control-label">' + rowJobDescription['name'] + '</label>' +
351
                        '</div>' +
352
                        '</td>' +
353
                        '</tr>';
354
                    $('#tableSubordinates tbody').append(s)
355
                });
356
                validator.resetForm();
357
                $('#custom-tabs #custom-tabs-general-tab').tab('show');
358
                $('#modal').modal('show');
359
            } else {
360
                $.fn.showError(response['data']);
361
            }
362
        }).fail(function(jqXHR, textStatus, errorThrown) {
363
            $.fn.showError(textStatus);
364
        }).always(function() {
365
            NProgress.done();
66 efrain 366
        });
935 geraldo 367
    });
368
    $('body').on('click', 'button.btn-edit', function(e) {
369
        e.preventDefault();
370
        NProgress.start();
371
        var action = $(this).data('href');
372
        $.ajax({
373
            'dataType': 'json',
374
            'accept': 'application/json',
375
            'method': 'get',
376
            'url': action,
377
        }).done(function(response) {
378
            if (response['success']) {
379
                $('span[id="form-title"]').html('LABEL_EDIT');
380
                $('#form').attr('action', action);
381
                $('#form #name').val(response['data']['name']);
382
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
383
                CKEDITOR.instances.functions.setData(response['data']['functions']);
384
                CKEDITOR.instances.objectives.setData(response['data']['objectives']);
385
                $('#tableCompetencies tbody').empty();
386
                var s = '';
387
                var first = true;
1186 geraldo 388
 
389
                competencies = response['data']['competencies'];
390
                competencies_type = response['data']['competency_types'];
391
                competencies_selected = response['data']['competencies_selected'];
392
                renderData(competencies_selected);
393
                setCompetencySelect();
394
 
935 geraldo 395
                $('#tableSubordinates tbody').empty();
396
                $('#job_description_id_boss option:not(:first)').remove();
397
                $.each(response['data']['jobs_description'], function(index, rowJobDescription) {
398
                    $('#job_description_id_boss').append(new Option(rowJobDescription['name'], rowJobDescription['job_description_id']));
399
                    checked = '';
400
                    if ($.isArray(response['data']['subordinates'])) {
401
                        if ($.inArray(rowJobDescription['job_description_id'], response['data']['subordinates']) != -1) {
402
                            checked = ' checked="checked" ';
403
                        }
404
                    }
405
                    s = '<tr>' +
406
                        '<td>' +
407
                        '<div class="custom-control custom-checkbox">' +
408
                        '<input class="custom-control-input" type="checkbox" ' + checked + ' name="job_description_id_subordinate' + rowJobDescription['job_description_id'] + '" id="job_description_id_subordinate' + rowJobDescription['job_description_id'] + '" value="1">' +
409
                        '<label for="job_description_id_subordinate' + rowJobDescription['job_description_id'] + '" class="custom-control-label">' + rowJobDescription['name'] + '</label>' +
410
                        '</div>' +
411
                        '</td>' +
412
                        '</tr>';
413
                    $('#tableSubordinates tbody').append(s)
414
                });
415
                $('#job_description_id_boss').val(response['data']['job_description_id_boss']);
416
                validator.resetForm();
417
                $('#custom-tabs #custom-tabs-general-tab').tab('show');
418
                $('#modal').modal('show');
419
            } else {
420
                $.fn.showError(response['data']);
421
            }
422
        }).fail(function(jqXHR, textStatus, errorThrown) {
423
            $.fn.showError(textStatus);
424
        }).always(function() {
425
            NProgress.done();
66 efrain 426
        });
935 geraldo 427
    });
428
    $('body').on('click', 'button.btn-refresh', function(e) {
429
        e.preventDefault();
430
        gridTable.api().ajax.reload(null, false);
431
    });
432
    $('body').on('click', 'button.btn-cancel', function(e) {
433
        e.preventDefault();
434
        $('#modal').modal('hide');
435
        $('#div-listing').show();
436
    });
437
    $('body').on('click', 'button.btn-import', function(e) {
438
        e.preventDefault();
439
        NProgress.start();
440
        $.ajax({
441
            'dataType': 'json',
442
            'method': 'post',
443
            'url': '$routeImport',
444
        }).done(function(response) {
445
            if (response['success']) {
446
                $.fn.showSuccess(response['data']);
447
                gridTable.api().ajax.reload(null, false);
448
            } else {
449
                $.fn.showError(response['data']);
450
            }
451
        }).fail(function(jqXHR, textStatus, errorThrown) {
452
            $.fn.showError(textStatus);
453
        }).always(function() {
454
            NProgress.done();
66 efrain 455
        });
935 geraldo 456
        return false;
66 efrain 457
    });
935 geraldo 458
    $('#form #status').bootstrapToggle({
459
        'on': 'LABEL_ACTIVE',
460
        'off': 'LABEL_INACTIVE',
461
        'width': '160px',
462
        'height': '40px'
463
    });
464
    CKEDITOR.replace('functions');
465
    CKEDITOR.replace('objectives');
1175 geraldo 466
    /**
467
     * Clicked cancel new/edit Form
468
     */
469
    $('body').on('click', 'button[id="btn-select-competency"]', function(e) {
1176 geraldo 470
        console.log('ee')
1175 geraldo 471
        if ($("#select-competency").val() == "") {
472
            $.fn.showError('LABEL_ERROR_SELECT_COMPETENCY');
473
        } else {
1176 geraldo 474
            competencies_selected.push(competencies.filter((item) => item.competency_id == $("#select-competency").val() ? item : false)[0]);
1175 geraldo 475
            renderData(competencies_selected);
1178 geraldo 476
            setCompetencySelect();
1175 geraldo 477
        }
478
    });
1170 geraldo 479
    const setCompetencySelect = () => {
1177 geraldo 480
        $('#select-competency').children().remove();
481
        $('#select-competency').append($('<option>', {
482
            value: '',
483
            text: 'LABEL_SELECT'
484
        }));
1172 geraldo 485
        $.each(competencies, function(i, item) {
486
            if (!filterItemById(item.competency_id)) {
487
                var type = filterTypeById(item.competency_type_id);
488
                $('#select-competency').append($('<option>', {
489
                    value: item.competency_id,
1180 geraldo 490
                    text: type.name + ' - ' + item.name
1172 geraldo 491
                }));
492
            }
493
        });
1170 geraldo 494
    }
1175 geraldo 495
    /**
496
     * Render Competencies data
497
     */
498
    const renderData = (data) => {
1178 geraldo 499
        $("#competencies-job").html($("#sectionTemplate").render(data, {
1180 geraldo 500
            getType: filterTypeById
501
        }));
1175 geraldo 502
    }
1176 geraldo 503
    /**
504
     * Filter competencies selected
505
     */
1172 geraldo 506
    const filterItemById = (id) => competencies_selected.filter((item) => item.competency_id == id ? item : false)[0];
1175 geraldo 507
    /**
508
     * Filter competencie type
509
     */
1172 geraldo 510
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
1180 geraldo 511
 
512
    /**
513
     * Clicked remove competency
514
     */
515
    $('body').on('click', 'button.btn-delete-competency', function(e) {
516
        var id_competency = $(this).data('competency');
517
        bootbox.confirm({
518
            title: "LABEL_DELETE LABEL_COMPETENCY",
519
            message: "LABEL_QUESTION_DELETE",
520
            buttons: {
521
                cancel: {
522
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
523
                },
524
                confirm: {
525
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
526
                }
527
            },
528
            callback: function(result) {
529
                if (result) {
530
                    removeCompetency(id_competency);
531
                }
532
            }
533
        });
534
    });
535
    /**
536
     * Clicked on edit behavior
537
     */
538
    $('body').on('click', 'button.btn-edit-behavior', function(e) {
539
        e.preventDefault();
540
        var competency_id = $(this).data('competency');
541
        var behavior_id = $(this).data('behavior');
1181 geraldo 542
        competencies_selected.map((item) => {
1180 geraldo 543
            if (item.competency_id == competency_id) {
544
                item.behaviors.map((b) => {
545
                    if (b.behavior_id == behavior_id) {
1183 geraldo 546
                        $('#form-behavior #behavior-id').val(b.behavior_id);
547
                        $('#form-behavior #behavior-competency').val(b.competency_id);
548
                        $('#form-behavior #behavior-level').val(b.level);
1180 geraldo 549
                        $('#modal-behavior h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
550
                        $('#modal-behavior').modal('show');
551
                        return;
552
                    }
553
                });
554
            }
555
        });
556
    });
557
 
558
 
559
    /**
560
     * Remove Competency
561
     */
562
    const removeCompetency = (competency_id) => {
563
        competencies_selected = competencies_selected.filter((item) => item.competency_id != competency_id);
564
        return renderData(competencies_selected);
565
    }
566
    /**
567
     * Edit item Behavior
568
     */
569
    const editBehavior = (competency_id, behavior_id, level) => {
570
        competencies_selected.map((item) => {
571
            if (item.competency_id == competency_id) {
572
                item.behaviors.map((opt) => {
573
                    if (opt.behavior_id == behavior_id) {
574
                        opt.level = level
575
                    }
576
                });
577
            }
578
        });
579
        return renderData(competencies_selected);
580
    }
581
 
582
    /**
583
     * Clicked cancel new/edit Form
584
     */
585
    $('button.btn-behavior-submit').click(function(e) {
586
        if ($("#behavior-description").val() == "") {
587
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
588
            return;
589
        } else {
590
 
591
                editBehavior($("#behavior-competency").val(), $("#behavior-id").val(), $("#behavior-level").val())
592
            $('#modal-behavior').modal('hide');
593
            return;
594
        }
595
    });
935 geraldo 596
});
1170 geraldo 597
 
66 efrain 598
JS;
599
$this->inlineScript()->captureEnd();
600
?>
601
<!-- Content Header (Page header) -->
602
<section class="content-header">
1170 geraldo 603
   <div class="container-fluid">
604
      <div class="row mb-2">
605
         <div class="col-sm-12">
606
            <h1>LABEL_JOBS_DESCRIPTION</h1>
607
         </div>
608
      </div>
609
   </div>
610
   <!-- /.container-fluid -->
66 efrain 611
</section>
612
<section class="content">
1170 geraldo 613
   <div class="container-fluid">
614
      <div class="row">
615
         <div class="col-12">
616
            <div class="card">
617
               <div class="card-body">
618
                  <table id="gridTable" class="table   table-hover">
619
                     <thead>
620
                        <tr>
621
                           <th>LABEL_NAME</th>
622
                           <th>LABEL_ACTIVE</th>
623
                           <th>LABEL_ACTIONS</th>
624
                        </tr>
625
                     </thead>
626
                     <tbody>
627
                     </tbody>
628
                  </table>
629
               </div>
630
               <div class="card-footer clearfix">
631
                  <div style="float:right;">
632
                     <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
633
                     <?php if($allowAdd) : ?>
634
                     <?php if($allowImport) : ?>
635
                     <button type="button" class="btn btn-primary btn-import"><i class="fa fa-upload"></i> LABEL_IMPORT </button>
636
                     <?php endif; ?>
637
                     <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
638
                     <?php endif; ?>
639
                  </div>
640
               </div>
641
            </div>
642
         </div>
643
      </div>
644
   </div>
645
</section>
66 efrain 646
<!-- The Modal -->
647
<div class="modal" id="modal">
1170 geraldo 648
   <div class="modal-dialog  modal-xl">
649
      <div class="modal-content">
650
         <!-- Modal Header -->
651
         <div class="modal-header">
652
            <h4 class="modal-title">LABEL_JOB_DESCRIPTION - <span id="form-title"></span></h4>
653
            <button type="button" class="close" data-dismiss="modal">&times;</button>
654
         </div>
655
         <!-- Modal body -->
656
         <div class="modal-body">
657
            <div class="card card-primary card-outline card-tabs">
658
               <div class="card-header p-0 pt-1 border-bottom-0">
659
                  <ul class="nav nav-tabs" id="custom-tabs" role="tablist">
660
                     <li class="nav-item">
661
                        <a class="nav-link active" id="custom-tabs-general-tab" data-toggle="pill" href="#custom-tabs-general" role="tab" aria-controls="custom-tabs-general" aria-selected="true">LABEL_GENERAL</a>
662
                     </li>
663
                     <li class="nav-item">
664
                        <a class="nav-link" id="custom-tabs-compentencies-tab" data-toggle="pill" href="#custom-tabs-compentencies" role="tab" aria-controls="custom-tabs-compentencies" aria-selected="false">LABEL_COMPETENCIES</a>
665
                     </li>
666
                     <li class="nav-item">
667
                        <a class="nav-link" id="custom-tabs-subordinates-tab" data-toggle="pill" href="#custom-tabs-subordinates" role="tab" aria-controls="custom-tabs-subordinates" aria-selected="false">LABEL_SUBORDINATES</a>
668
                     </li>
669
                  </ul>
670
               </div>
671
               <div class="card-body">
672
                  <?php
673
                     $form = $this->form;
674
                     $form->setAttributes([
675
                         'method'    => 'post',
676
                         'name'      => 'form',
677
                         'id'        => 'form'
678
                     ]);
73 steven 679
 
1170 geraldo 680
                     $form->prepare();
681
                     echo $this->form()->openTag($form);
682
                     ?>
683
                  <div class="tab-content" id="custom-tabs-three-tabContent">
684
                     <div class="tab-pane fade show active" id="custom-tabs-general" role="tabpanel" aria-labelledby="custom-tabs-general-tab">
685
                        <div class="row">
686
                           <div class="col-md col-sm-12 col-12">
687
                              <div class="form-group m-0">
688
                                 <?php
689
                                    $element = $form->get('name');
690
                                    $element->setOptions(['label' => 'LABEL_NAME']);
66 efrain 691
                                    $element->setAttributes(['class' => 'form-control']);
1170 geraldo 692
 
66 efrain 693
                                    echo $this->formLabel($element);
1170 geraldo 694
                                    echo $this->formText($element);
66 efrain 695
                                    ?>
1170 geraldo 696
                              </div>
697
                           </div>
698
                           <div class="col-md col-sm-12 col-12">
699
                              <div class="form-group m-0">
700
                                 <?php
701
                                    $element = $form->get('job_description_id_boss');
702
                                    $element->setOptions(['label' => 'LABEL_BOSS']);
66 efrain 703
                                    $element->setAttributes(['class' => 'form-control']);
1170 geraldo 704
 
66 efrain 705
                                    echo $this->formLabel($element);
1170 geraldo 706
                                    echo $this->formSelect($element);
66 efrain 707
                                    ?>
1170 geraldo 708
                              </div>
709
                           </div>
710
                           <div
711
                              class="col-md col-sm-12 col-12 d-flex align-items-center justify-content-center"
712
                              >
713
                              <div class="form-group m-0">
714
                                 <label>LABEL_STATUS</label>
715
                                 <br />
716
                                 <?php
717
                                    $element = $form->get('status');
718
                                    $element->setOptions(['label' => 'LABEL_STATUS']);
719
                                    // echo $this->formLabel($element);
720
                                    echo $this->formCheckbox($element);
721
                                    ?>
722
                              </div>
723
                           </div>
724
                        </div>
725
                        <div class="form-group">
726
                           <?php
727
                              $element = $form->get('objectives');
728
                              $element->setOptions(['label' => 'LABEL_OBJECTIVES']);
729
                              $element->setAttributes(['class' => 'form-control']);
730
 
731
                              echo $this->formLabel($element);
732
                              echo $this->formTextArea($element);
733
                              ?>
734
                        </div>
735
                        <div class="form-group">
736
                           <?php
737
                              $element = $form->get('functions');
738
                              $element->setOptions(['label' => 'LABEL_FUNCTIONS']);
739
                              $element->setAttributes(['class' => 'form-control']);
740
 
741
                              echo $this->formLabel($element);
742
                              echo $this->formTextArea($element);
743
                              ?>
744
                        </div>
745
                     </div>
746
                     <div class="tab-pane fade" id="custom-tabs-compentencies" role="tabpanel" aria-labelledby="custom-tabs-compentencies-tab">
747
                        <div class="row">
748
                           <div class="col-md-8 col-sm-8 col-xs-12">
749
                              <select name="select-competency" id="select-competency" class="form-control">
750
                              </select>
751
                           </div>
752
                           <div class="col-md-4 col-sm-4 col-xs-12">
753
                              <button type="button" class="btn btn-primary" id="btn-select-competency" data-toggle="tooltip" title="LABEL_ADD LABEL_COMPETENCY">LABEL_ADD LABEL_COMPETENCY</button>
754
                           </div>
755
                        </div>
756
                        <div class="row">
1182 geraldo 757
                            <br>
1184 geraldo 758
                           <div class="col-md-12 col-sm-12 col-xs-12" id="competencies-job" style="    margin-top: 10px;">
1175 geraldo 759
 
1170 geraldo 760
                           </div>
761
                        </div>
762
                     </div>
763
                     <div class="tab-pane fade" id="custom-tabs-subordinates" role="tabpanel" aria-labelledby="custom-tabs-subordinates-tab">
764
                        <table class="table table-hover"  id="tableSubordinates">
765
                           <thead>
766
                              <tr>
767
                                 <th>LABEL_SUBORDINATE</th>
768
                              </tr>
769
                           </thead>
770
                           <tbody>
771
                           </tbody>
772
                        </table>
773
                     </div>
774
                  </div>
775
               </div>
776
               <?php echo $this->form()->closeTag($form); ?>
777
               <!-- /.card -->
778
            </div>
779
         </div>
780
         <!-- Modal footer -->
781
         <div class="modal-footer">
782
            <button type="submit" form="form" class="btn btn-primary">LABEL_SAVE</button>
783
            <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
784
         </div>
785
      </div>
786
   </div>
787
</div>
1169 geraldo 788
 
1180 geraldo 789
<!--start modal behavior-->
790
<div  id="modal-behavior" class="modal" tabindex="-1" role="dialog">
791
   <div class="modal-dialog modal-lg" role="document">
792
      <form action="#" name="form-behavior" id="form-behavior">
793
         <input type="hidden" name="behavior-id" id="behavior-id" value="" />
794
         <input type="hidden" name="behavior-competency" id="behavior-competency" value="" />
795
         <div class="modal-content">
796
            <div class="modal-header">
1185 geraldo 797
               <h4 class="modal-title">LABEL_EDIT LABEL_LEVEL</h4>
1180 geraldo 798
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
799
               <span aria-hidden="true">&times;</span>
800
               </button>
801
            </div>
802
            <div class="modal-body">
803
               <div class="form-group">
804
                  <label for="behavior-value">LABEL_LEVEL</label>
805
                  <select class="form-control" id="behavior-level" name="behavior-level">
806
                     <option value="0">LABEL_NA</option>
807
                     <option value="1">LABEL_LEVEL_ONE</option>
808
                     <option value="2">LABEL_LEVEL_TWO</option>
809
                     <option value="3">LABEL_LEVEL_THREE</option>
810
                     <option value="4">LABEL_LEVEL_FOUR</option>
811
                  </select>
812
               </div>
813
            </div>
814
            <div class="modal-footer">
815
               <button type="button" class="btn btn-primary btn-behavior-submit">LABEL_SAVE</button>
816
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
817
            </div>
818
         </div>
819
      </form>
820
   </div>
821
</div>
822
<!---end modal behavior --->
823
 
1175 geraldo 824
 <!---Template Competencies --->
825
 <script id="sectionTemplate" type="text/x-jsrender">
826
   <div class="panel panel-default" id="panel-{{:competency_id}}">
827
   <div class="panel-heading">
1184 geraldo 828
      <h4 class="panel-title" style="    font-size: 18px;">
1175 geraldo 829
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:competency_id}}" href="#collapse-{{:competency_id}}">
830
         <span class="section-name{{:competency_id}}">
1178 geraldo 831
         {{:~getType(competency_type_id).name}} - {{:name}}
1175 geraldo 832
         </span>
833
         </a>
834
      </h4>
835
   </div>
836
   <div id="collapse-{{:competency_id}}" class="panel-collapse in collapse show">
837
      <div class="panel-body">
838
         <div class="table-responsive">
839
            <table class="table table-bordered">
840
               <thead>
841
                  <tr>
1181 geraldo 842
                     <th style="width: 20%;">LABEL_ELEMENT</th>
843
                     <th style="width: 50%;">LABEL_TITLE</th>
1175 geraldo 844
                     <th style="width: 10%;">LABEL_LEVEL</th>
1181 geraldo 845
                     <th style="width: 20%;">LABEL_ACTIONS</th>
1175 geraldo 846
                  </tr>
847
               </thead>
848
               <tbody>
849
                  <tr class="tr-section">
850
                     <td class="text-left">LABEL_COMPETENCY</td>
1177 geraldo 851
                     <td class="text-left">{{:name}}</td>
1175 geraldo 852
                     <td>
853
                        {{if type == 'simple'}} Simple {{/if}}
854
                        {{if type == 'multiple'}} Multiple {{/if}}
855
                     </td>
856
                     <td>
857
 
1180 geraldo 858
                        <button  type="button" class="btn btn-default btn-delete-competency" data-competency="{{:competency_id}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_COMPETENCY"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_COMPETENCY </button>
1175 geraldo 859
 
860
                     </td>
861
                  </tr>
1177 geraldo 862
                  {{for behaviors}}
1175 geraldo 863
                  <tr >
864
                     <td class="text-left">--LABEL_CONDUCT</td>
865
                     <td class="text-left">
866
                        {{:description}}
867
                     </td>
868
                     <td>
1180 geraldo 869
          {{if level == '0'}} LABEL_NA {{/if}}
870
          {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
871
          {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
872
          {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
873
          {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
874
       </td>
1175 geraldo 875
                     <td>
1180 geraldo 876
                        <button type="button"  class="btn btn-default btn-edit-behavior" data-competency="{{:competency_id}}" data-behavior="{{:behavior_id}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_LEVEL"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_LEVEL</button>
1175 geraldo 877
 
878
                     </td>
879
                  </tr>
880
                  {{/for}}
881
               </tbody>
882
            </table>
883
         </div>
884
      </div>
885
   </div>
886
</div>
887
   </script>
888
   <!-- End Template Competencies-->
1169 geraldo 889
 
66 efrain 890
 
891
 
892
 
893
 
894
 
895
 
896
 
897