Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1189 | Rev 1192 | 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) {
66 efrain 268
            $.ajax({
935 geraldo 269
                'dataType': 'json',
270
                'accept': 'application/json',
271
                'method': 'post',
272
                'url': $('#form').attr('action'),
273
                'data': $('#form').serialize()
66 efrain 274
            }).done(function(response) {
935 geraldo 275
                NProgress.start();
276
                if (response['success']) {
277
                    $.fn.showSuccess(response['data']);
278
                    $('#modal').modal('hide');
279
                    gridTable.api().ajax.reload(null, false);
280
                } else {
281
                    validator.resetForm();
282
                    if (jQuery.type(response['data']) == 'string') {
283
                        $.fn.showError(response['data']);
284
                    } else {
285
                        $.each(response['data'], function(fieldname, errors) {
286
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
66 efrain 287
                        });
935 geraldo 288
                    }
66 efrain 289
                }
935 geraldo 290
            }).fail(function(jqXHR, textStatus, errorThrown) {
66 efrain 291
                $.fn.showError(textStatus);
292
            }).always(function() {
293
                NProgress.done();
294
            });
935 geraldo 295
            return false;
296
        },
297
        invalidHandler: function(form, validator) {}
298
    });
299
    $('body').on('click', 'button.btn-add', function(e) {
300
        e.preventDefault();
301
        NProgress.start();
302
        $.ajax({
303
            'dataType': 'json',
304
            'accept': 'application/json',
305
            'method': 'get',
306
            'url': '$routeAdd',
307
        }).done(function(response) {
308
            if (response['success']) {
309
                $('span[id="form-title"]').html('LABEL_ADD');
310
                $('#form').attr('action', '$routeAdd');
311
                $('#form #name').val('');
312
                $('#form #status').bootstrapToggle('on');
313
                CKEDITOR.instances.functions.setData('');
314
                CKEDITOR.instances.objectives.setData('');
1170 geraldo 315
                competencies = response['data']['competencies'];
316
                competencies_type = response['data']['competency_types'];
1187 geraldo 317
                dependents = response['data']['jobs_description'];
1186 geraldo 318
                renderData([]);
1170 geraldo 319
                setCompetencySelect();
1187 geraldo 320
                setDependentSelect();
935 geraldo 321
                validator.resetForm();
322
                $('#custom-tabs #custom-tabs-general-tab').tab('show');
323
                $('#modal').modal('show');
324
            } else {
325
                $.fn.showError(response['data']);
326
            }
327
        }).fail(function(jqXHR, textStatus, errorThrown) {
328
            $.fn.showError(textStatus);
329
        }).always(function() {
330
            NProgress.done();
66 efrain 331
        });
935 geraldo 332
    });
333
    $('body').on('click', 'button.btn-edit', function(e) {
334
        e.preventDefault();
335
        NProgress.start();
336
        var action = $(this).data('href');
337
        $.ajax({
338
            'dataType': 'json',
339
            'accept': 'application/json',
340
            'method': 'get',
341
            'url': action,
342
        }).done(function(response) {
343
            if (response['success']) {
344
                $('span[id="form-title"]').html('LABEL_EDIT');
345
                $('#form').attr('action', action);
346
                $('#form #name').val(response['data']['name']);
347
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
348
                CKEDITOR.instances.functions.setData(response['data']['functions']);
349
                CKEDITOR.instances.objectives.setData(response['data']['objectives']);
350
                $('#tableCompetencies tbody').empty();
1186 geraldo 351
                competencies = response['data']['competencies'];
352
                competencies_type = response['data']['competency_types'];
353
                competencies_selected = response['data']['competencies_selected'];
1187 geraldo 354
                dependents = response['data']['jobs_description'];
1186 geraldo 355
                renderData(competencies_selected);
356
                setCompetencySelect();
1187 geraldo 357
                setDependentSelect();
935 geraldo 358
                $('#job_description_id_boss').val(response['data']['job_description_id_boss']);
359
                validator.resetForm();
360
                $('#custom-tabs #custom-tabs-general-tab').tab('show');
361
                $('#modal').modal('show');
362
            } else {
363
                $.fn.showError(response['data']);
364
            }
365
        }).fail(function(jqXHR, textStatus, errorThrown) {
366
            $.fn.showError(textStatus);
367
        }).always(function() {
368
            NProgress.done();
66 efrain 369
        });
935 geraldo 370
    });
371
    $('body').on('click', 'button.btn-refresh', function(e) {
372
        e.preventDefault();
373
        gridTable.api().ajax.reload(null, false);
374
    });
375
    $('body').on('click', 'button.btn-cancel', function(e) {
376
        e.preventDefault();
377
        $('#modal').modal('hide');
378
        $('#div-listing').show();
379
    });
380
    $('body').on('click', 'button.btn-import', function(e) {
381
        e.preventDefault();
382
        NProgress.start();
383
        $.ajax({
384
            'dataType': 'json',
385
            'method': 'post',
386
            'url': '$routeImport',
387
        }).done(function(response) {
388
            if (response['success']) {
389
                $.fn.showSuccess(response['data']);
390
                gridTable.api().ajax.reload(null, false);
391
            } else {
392
                $.fn.showError(response['data']);
393
            }
394
        }).fail(function(jqXHR, textStatus, errorThrown) {
395
            $.fn.showError(textStatus);
396
        }).always(function() {
397
            NProgress.done();
66 efrain 398
        });
935 geraldo 399
        return false;
66 efrain 400
    });
935 geraldo 401
    $('#form #status').bootstrapToggle({
402
        'on': 'LABEL_ACTIVE',
403
        'off': 'LABEL_INACTIVE',
404
        'width': '160px',
405
        'height': '40px'
406
    });
407
    CKEDITOR.replace('functions');
408
    CKEDITOR.replace('objectives');
1175 geraldo 409
    /**
1187 geraldo 410
     * Clicked select competency
1175 geraldo 411
     */
412
    $('body').on('click', 'button[id="btn-select-competency"]', function(e) {
1176 geraldo 413
        console.log('ee')
1175 geraldo 414
        if ($("#select-competency").val() == "") {
415
            $.fn.showError('LABEL_ERROR_SELECT_COMPETENCY');
416
        } else {
1176 geraldo 417
            competencies_selected.push(competencies.filter((item) => item.competency_id == $("#select-competency").val() ? item : false)[0]);
1175 geraldo 418
            renderData(competencies_selected);
1178 geraldo 419
            setCompetencySelect();
1175 geraldo 420
        }
421
    });
1187 geraldo 422
 
423
    /**
424
     * Clicked select dependent
425
     */
426
    $('body').on('click', 'button[id="btn-select-dependent"]', function(e) {
427
        console.log('ee')
428
        if ($("#select-dependent").val() == "") {
429
            $.fn.showError('LABEL_ERROR_SELECT_DEPENDENT');
430
        } else {
431
            dependents_selected.push(dependents.filter((item) => item.job_description_id == $("#select-dependent").val() ? item : false)[0]);
432
            renderDependentData(dependents_selected);
433
            setDependentSelect();
434
        }
435
    });
436
 
437
    /**
438
     * Clicked remove dependent
439
     */
440
    $('body').on('click', 'button.btn-delete-dependent', function(e) {
441
        var job_description_id = $(this).data('dependent');
442
        bootbox.confirm({
443
            title: "LABEL_DELETE LABEL_DEPENDENT",
444
            message: "LABEL_QUESTION_DELETE",
445
            buttons: {
446
                cancel: {
447
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
448
                },
449
                confirm: {
450
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
451
                }
452
            },
453
            callback: function(result) {
454
                if (result) {
455
                     dependents_selected = dependents_selected.filter((item) => item.job_description_id != job_description_id);
456
                     renderDependentData(dependents_selected);
457
            return setDependentSelect();
458
                }
459
            }
460
        });
461
    });
462
 
1170 geraldo 463
    const setCompetencySelect = () => {
1177 geraldo 464
        $('#select-competency').children().remove();
465
        $('#select-competency').append($('<option>', {
466
            value: '',
467
            text: 'LABEL_SELECT'
468
        }));
1172 geraldo 469
        $.each(competencies, function(i, item) {
470
            if (!filterItemById(item.competency_id)) {
471
                var type = filterTypeById(item.competency_type_id);
472
                $('#select-competency').append($('<option>', {
473
                    value: item.competency_id,
1180 geraldo 474
                    text: type.name + ' - ' + item.name
1172 geraldo 475
                }));
476
            }
477
        });
1170 geraldo 478
    }
1187 geraldo 479
 
1188 geraldo 480
    const setDependentSelect = () => {
1187 geraldo 481
        $('#select-dependent').children().remove();
482
        $('#select-dependent').append($('<option>', {
483
            value: '',
484
            text: 'LABEL_SELECT'
485
        }));
486
        $.each(dependents, function(i, item) {
487
            if (!filterDependedItemById(item.job_description_id)) {
488
                $('#select-dependent').append($('<option>', {
489
                    value: item.job_description_id,
490
                    text: item.name
491
                }));
492
            }
493
        });
494
    }
495
 
496
 
1175 geraldo 497
    /**
498
     * Render Competencies data
499
     */
500
    const renderData = (data) => {
1178 geraldo 501
        $("#competencies-job").html($("#sectionTemplate").render(data, {
1180 geraldo 502
            getType: filterTypeById
503
        }));
1175 geraldo 504
    }
1187 geraldo 505
 
1176 geraldo 506
    /**
1187 geraldo 507
     * Render Competencies data
508
     */
509
    const renderDependentData = (data) => {
510
        $("#dependent").html($("#sectionJob").render(data));
511
    }
512
    /**
1176 geraldo 513
     * Filter competencies selected
514
     */
1172 geraldo 515
    const filterItemById = (id) => competencies_selected.filter((item) => item.competency_id == id ? item : false)[0];
1187 geraldo 516
 
517
     /**
518
     * Filter depended selected
519
     */
1191 geraldo 520
    const filterDependedItemById = (id) => dependents_selected.filter((item) => item.job_description_id == id ? item : false)[0];
1187 geraldo 521
 
1175 geraldo 522
    /**
523
     * Filter competencie type
524
     */
1172 geraldo 525
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
1180 geraldo 526
 
527
    /**
528
     * Clicked remove competency
529
     */
530
    $('body').on('click', 'button.btn-delete-competency', function(e) {
531
        var id_competency = $(this).data('competency');
532
        bootbox.confirm({
533
            title: "LABEL_DELETE LABEL_COMPETENCY",
534
            message: "LABEL_QUESTION_DELETE",
535
            buttons: {
536
                cancel: {
537
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
538
                },
539
                confirm: {
540
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
541
                }
542
            },
543
            callback: function(result) {
544
                if (result) {
545
                    removeCompetency(id_competency);
546
                }
547
            }
548
        });
549
    });
550
    /**
551
     * Clicked on edit behavior
552
     */
553
    $('body').on('click', 'button.btn-edit-behavior', function(e) {
554
        e.preventDefault();
555
        var competency_id = $(this).data('competency');
556
        var behavior_id = $(this).data('behavior');
1181 geraldo 557
        competencies_selected.map((item) => {
1180 geraldo 558
            if (item.competency_id == competency_id) {
559
                item.behaviors.map((b) => {
560
                    if (b.behavior_id == behavior_id) {
1183 geraldo 561
                        $('#form-behavior #behavior-id').val(b.behavior_id);
562
                        $('#form-behavior #behavior-competency').val(b.competency_id);
563
                        $('#form-behavior #behavior-level').val(b.level);
1180 geraldo 564
                        $('#modal-behavior h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
565
                        $('#modal-behavior').modal('show');
566
                        return;
567
                    }
568
                });
569
            }
570
        });
571
    });
572
 
573
 
574
    /**
575
     * Remove Competency
576
     */
577
    const removeCompetency = (competency_id) => {
578
        competencies_selected = competencies_selected.filter((item) => item.competency_id != competency_id);
579
        return renderData(competencies_selected);
580
    }
581
    /**
582
     * Edit item Behavior
583
     */
584
    const editBehavior = (competency_id, behavior_id, level) => {
585
        competencies_selected.map((item) => {
586
            if (item.competency_id == competency_id) {
587
                item.behaviors.map((opt) => {
588
                    if (opt.behavior_id == behavior_id) {
589
                        opt.level = level
590
                    }
591
                });
592
            }
593
        });
594
        return renderData(competencies_selected);
595
    }
596
 
597
    /**
598
     * Clicked cancel new/edit Form
599
     */
600
    $('button.btn-behavior-submit').click(function(e) {
601
        if ($("#behavior-description").val() == "") {
602
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
603
            return;
604
        } else {
605
 
606
                editBehavior($("#behavior-competency").val(), $("#behavior-id").val(), $("#behavior-level").val())
607
            $('#modal-behavior').modal('hide');
608
            return;
609
        }
610
    });
935 geraldo 611
});
1170 geraldo 612
 
66 efrain 613
JS;
614
$this->inlineScript()->captureEnd();
615
?>
616
<!-- Content Header (Page header) -->
617
<section class="content-header">
1170 geraldo 618
   <div class="container-fluid">
619
      <div class="row mb-2">
620
         <div class="col-sm-12">
621
            <h1>LABEL_JOBS_DESCRIPTION</h1>
622
         </div>
623
      </div>
624
   </div>
625
   <!-- /.container-fluid -->
66 efrain 626
</section>
627
<section class="content">
1170 geraldo 628
   <div class="container-fluid">
629
      <div class="row">
630
         <div class="col-12">
631
            <div class="card">
632
               <div class="card-body">
633
                  <table id="gridTable" class="table   table-hover">
634
                     <thead>
635
                        <tr>
636
                           <th>LABEL_NAME</th>
637
                           <th>LABEL_ACTIVE</th>
638
                           <th>LABEL_ACTIONS</th>
639
                        </tr>
640
                     </thead>
641
                     <tbody>
642
                     </tbody>
643
                  </table>
644
               </div>
645
               <div class="card-footer clearfix">
646
                  <div style="float:right;">
647
                     <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
648
                     <?php if($allowAdd) : ?>
649
                     <?php if($allowImport) : ?>
650
                     <button type="button" class="btn btn-primary btn-import"><i class="fa fa-upload"></i> LABEL_IMPORT </button>
651
                     <?php endif; ?>
652
                     <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
653
                     <?php endif; ?>
654
                  </div>
655
               </div>
656
            </div>
657
         </div>
658
      </div>
659
   </div>
660
</section>
66 efrain 661
<!-- The Modal -->
662
<div class="modal" id="modal">
1170 geraldo 663
   <div class="modal-dialog  modal-xl">
664
      <div class="modal-content">
665
         <!-- Modal Header -->
666
         <div class="modal-header">
667
            <h4 class="modal-title">LABEL_JOB_DESCRIPTION - <span id="form-title"></span></h4>
668
            <button type="button" class="close" data-dismiss="modal">&times;</button>
669
         </div>
670
         <!-- Modal body -->
671
         <div class="modal-body">
672
            <div class="card card-primary card-outline card-tabs">
673
               <div class="card-header p-0 pt-1 border-bottom-0">
674
                  <ul class="nav nav-tabs" id="custom-tabs" role="tablist">
675
                     <li class="nav-item">
676
                        <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>
677
                     </li>
678
                     <li class="nav-item">
679
                        <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>
680
                     </li>
681
                     <li class="nav-item">
1187 geraldo 682
                        <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 683
                     </li>
684
                  </ul>
685
               </div>
686
               <div class="card-body">
687
                  <?php
688
                     $form = $this->form;
689
                     $form->setAttributes([
690
                         'method'    => 'post',
691
                         'name'      => 'form',
692
                         'id'        => 'form'
693
                     ]);
73 steven 694
 
1170 geraldo 695
                     $form->prepare();
696
                     echo $this->form()->openTag($form);
697
                     ?>
698
                  <div class="tab-content" id="custom-tabs-three-tabContent">
699
                     <div class="tab-pane fade show active" id="custom-tabs-general" role="tabpanel" aria-labelledby="custom-tabs-general-tab">
700
                        <div class="row">
701
                           <div class="col-md col-sm-12 col-12">
702
                              <div class="form-group m-0">
703
                                 <?php
704
                                    $element = $form->get('name');
705
                                    $element->setOptions(['label' => 'LABEL_NAME']);
66 efrain 706
                                    $element->setAttributes(['class' => 'form-control']);
1170 geraldo 707
 
66 efrain 708
                                    echo $this->formLabel($element);
1170 geraldo 709
                                    echo $this->formText($element);
66 efrain 710
                                    ?>
1170 geraldo 711
                              </div>
712
                           </div>
713
                           <div class="col-md col-sm-12 col-12">
714
                              <div class="form-group m-0">
715
                                 <?php
716
                                    $element = $form->get('job_description_id_boss');
717
                                    $element->setOptions(['label' => 'LABEL_BOSS']);
66 efrain 718
                                    $element->setAttributes(['class' => 'form-control']);
1170 geraldo 719
 
66 efrain 720
                                    echo $this->formLabel($element);
1170 geraldo 721
                                    echo $this->formSelect($element);
66 efrain 722
                                    ?>
1170 geraldo 723
                              </div>
724
                           </div>
725
                           <div
726
                              class="col-md col-sm-12 col-12 d-flex align-items-center justify-content-center"
727
                              >
728
                              <div class="form-group m-0">
729
                                 <label>LABEL_STATUS</label>
730
                                 <br />
731
                                 <?php
732
                                    $element = $form->get('status');
733
                                    $element->setOptions(['label' => 'LABEL_STATUS']);
734
                                    // echo $this->formLabel($element);
735
                                    echo $this->formCheckbox($element);
736
                                    ?>
737
                              </div>
738
                           </div>
739
                        </div>
740
                        <div class="form-group">
741
                           <?php
742
                              $element = $form->get('objectives');
743
                              $element->setOptions(['label' => 'LABEL_OBJECTIVES']);
744
                              $element->setAttributes(['class' => 'form-control']);
745
 
746
                              echo $this->formLabel($element);
747
                              echo $this->formTextArea($element);
748
                              ?>
749
                        </div>
750
                        <div class="form-group">
751
                           <?php
752
                              $element = $form->get('functions');
753
                              $element->setOptions(['label' => 'LABEL_FUNCTIONS']);
754
                              $element->setAttributes(['class' => 'form-control']);
755
 
756
                              echo $this->formLabel($element);
757
                              echo $this->formTextArea($element);
758
                              ?>
759
                        </div>
760
                     </div>
761
                     <div class="tab-pane fade" id="custom-tabs-compentencies" role="tabpanel" aria-labelledby="custom-tabs-compentencies-tab">
762
                        <div class="row">
763
                           <div class="col-md-8 col-sm-8 col-xs-12">
764
                              <select name="select-competency" id="select-competency" class="form-control">
765
                              </select>
766
                           </div>
767
                           <div class="col-md-4 col-sm-4 col-xs-12">
768
                              <button type="button" class="btn btn-primary" id="btn-select-competency" data-toggle="tooltip" title="LABEL_ADD LABEL_COMPETENCY">LABEL_ADD LABEL_COMPETENCY</button>
769
                           </div>
770
                        </div>
1187 geraldo 771
                        <div class="row" >
772
                           <br>
773
                           <div class="col-md-12 col-sm-12 col-xs-12" id="competencies-job" style="margin-top: 10px;">
774
                           </div>
775
                        </div>
776
                     </div>
777
                     <div class="tab-pane fade" id="custom-tabs-dependent" role="tabpanel" aria-labelledby="custom-tabs-dependent-tab">
1170 geraldo 778
                        <div class="row">
1187 geraldo 779
                           <div class="col-md-8 col-sm-8 col-xs-12">
780
                              <select name="select-dependent" id="select-dependent" class="form-control">
781
                              </select>
1170 geraldo 782
                           </div>
1187 geraldo 783
                           <div class="col-md-4 col-sm-4 col-xs-12">
784
                              <button type="button" class="btn btn-primary" id="btn-select-dependent" data-toggle="tooltip" title="LABEL_ADD ">LABEL_ADD </button>
785
                           </div>
1170 geraldo 786
                        </div>
1187 geraldo 787
                        <div class="row" >
788
                           <div class="col-md-12 col-sm-12 col-xs-12"  style="margin-top: 10px;">
789
                              <table class="table table-bordered">
790
                                 <thead>
791
                                    <tr>
792
                                       <th style="width: 60%;">LABEL_NAME</th>
793
                                       <th style="width: 20%;">LABEL_ACTIONS</th>
794
                                    </tr>
795
                                 </thead>
796
                                 <tbody id="dependent"></tbody>
797
                              </table>
798
                           </div>
799
                        </div>
1170 geraldo 800
                     </div>
801
                  </div>
802
               </div>
803
            </div>
1187 geraldo 804
            <?php echo $this->form()->closeTag($form); ?>
805
            <!-- /.card -->
1170 geraldo 806
         </div>
807
      </div>
1187 geraldo 808
      <!-- Modal footer -->
809
      <div class="modal-footer">
810
         <button type="submit" form="form" class="btn btn-primary">LABEL_SAVE</button>
811
         <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
812
      </div>
1170 geraldo 813
   </div>
1187 geraldo 814
</div>
1169 geraldo 815
 
1180 geraldo 816
<!--start modal behavior-->
817
<div  id="modal-behavior" class="modal" tabindex="-1" role="dialog">
818
   <div class="modal-dialog modal-lg" role="document">
819
      <form action="#" name="form-behavior" id="form-behavior">
820
         <input type="hidden" name="behavior-id" id="behavior-id" value="" />
821
         <input type="hidden" name="behavior-competency" id="behavior-competency" value="" />
822
         <div class="modal-content">
823
            <div class="modal-header">
1185 geraldo 824
               <h4 class="modal-title">LABEL_EDIT LABEL_LEVEL</h4>
1180 geraldo 825
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
826
               <span aria-hidden="true">&times;</span>
827
               </button>
828
            </div>
829
            <div class="modal-body">
830
               <div class="form-group">
831
                  <label for="behavior-value">LABEL_LEVEL</label>
832
                  <select class="form-control" id="behavior-level" name="behavior-level">
833
                     <option value="0">LABEL_NA</option>
834
                     <option value="1">LABEL_LEVEL_ONE</option>
835
                     <option value="2">LABEL_LEVEL_TWO</option>
836
                     <option value="3">LABEL_LEVEL_THREE</option>
837
                     <option value="4">LABEL_LEVEL_FOUR</option>
838
                  </select>
839
               </div>
840
            </div>
841
            <div class="modal-footer">
842
               <button type="button" class="btn btn-primary btn-behavior-submit">LABEL_SAVE</button>
843
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
844
            </div>
845
         </div>
846
      </form>
847
   </div>
848
</div>
849
<!---end modal behavior --->
850
 
1175 geraldo 851
 <!---Template Competencies --->
852
 <script id="sectionTemplate" type="text/x-jsrender">
853
   <div class="panel panel-default" id="panel-{{:competency_id}}">
854
   <div class="panel-heading">
1184 geraldo 855
      <h4 class="panel-title" style="    font-size: 18px;">
1175 geraldo 856
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:competency_id}}" href="#collapse-{{:competency_id}}">
857
         <span class="section-name{{:competency_id}}">
1178 geraldo 858
         {{:~getType(competency_type_id).name}} - {{:name}}
1175 geraldo 859
         </span>
860
         </a>
861
      </h4>
862
   </div>
863
   <div id="collapse-{{:competency_id}}" class="panel-collapse in collapse show">
864
      <div class="panel-body">
865
         <div class="table-responsive">
866
            <table class="table table-bordered">
867
               <thead>
868
                  <tr>
1181 geraldo 869
                     <th style="width: 20%;">LABEL_ELEMENT</th>
870
                     <th style="width: 50%;">LABEL_TITLE</th>
1175 geraldo 871
                     <th style="width: 10%;">LABEL_LEVEL</th>
1181 geraldo 872
                     <th style="width: 20%;">LABEL_ACTIONS</th>
1175 geraldo 873
                  </tr>
874
               </thead>
875
               <tbody>
876
                  <tr class="tr-section">
877
                     <td class="text-left">LABEL_COMPETENCY</td>
1177 geraldo 878
                     <td class="text-left">{{:name}}</td>
1175 geraldo 879
                     <td>
880
                        {{if type == 'simple'}} Simple {{/if}}
881
                        {{if type == 'multiple'}} Multiple {{/if}}
882
                     </td>
883
                     <td>
884
 
1180 geraldo 885
                        <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 886
 
887
                     </td>
888
                  </tr>
1177 geraldo 889
                  {{for behaviors}}
1175 geraldo 890
                  <tr >
891
                     <td class="text-left">--LABEL_CONDUCT</td>
892
                     <td class="text-left">
893
                        {{:description}}
894
                     </td>
895
                     <td>
1180 geraldo 896
          {{if level == '0'}} LABEL_NA {{/if}}
897
          {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
898
          {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
899
          {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
900
          {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
901
       </td>
1175 geraldo 902
                     <td>
1180 geraldo 903
                        <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 904
 
905
                     </td>
906
                  </tr>
907
                  {{/for}}
908
               </tbody>
909
            </table>
910
         </div>
911
      </div>
912
   </div>
913
</div>
914
   </script>
1187 geraldo 915
 
916
 
917
   <script id="sectionJob" type="text/x-jsrender">
918
   <tr>
919
       <td class="text-left">{{:name}}</td>
920
       <td>
921
 
922
           <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>
923
       </td>
924
   </tr>
925
    </script>
926
 
1175 geraldo 927
   <!-- End Template Competencies-->
1169 geraldo 928
 
66 efrain 929
 
930
 
931
 
932
 
933
 
934
 
935
 
936