Proyectos de Subversion LeadersLinked - Backend

Rev

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

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