Proyectos de Subversion LeadersLinked - Backend

Rev

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

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