Proyectos de Subversion LeadersLinked - Backend

Rev

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