Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1287 | Rev 1315 | 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']);
242
                CKEDITOR.instances['form-text'].setData(response['data']['text']);
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-text'].setData('');
403
        CKEDITOR.instances['form-description'].setData('');
1243 geraldo 404
        renderCompetenciesData([]);
1085 geraldo 405
        $('#row-lists').hide();
406
        $('#row-form').show();
407
        $('#form-main #form-name').focus();
408
        return;
409
    });
410
    /**
411
     * Clicked cancel new/edit Form
412
     */
413
    $('button.btn-edit-cancel').click(function(e) {
414
        $('#row-form').hide();
415
        $('#row-lists').show();
416
        return;
417
    });
418
    /**
1092 geraldo 419
     * Clicked save and continue new Form
1085 geraldo 420
     */
1092 geraldo 421
    $('button.btn-form-save-continue').click(function(e) {
1091 geraldo 422
        for (var instanceName in CKEDITOR.instances) {
423
            CKEDITOR.instances[instanceName].updateElement();
424
        }
1095 geraldo 425
        saveData(1);
1085 geraldo 426
    });
1093 geraldo 427
    /**
428
     * Clicked save and close new/edit Form
429
     */
430
    $('button.btn-form-save-close').click(function(e) {
431
        for (var instanceName in CKEDITOR.instances) {
432
            CKEDITOR.instances[instanceName].updateElement();
1092 geraldo 433
        }
1095 geraldo 434
        saveData(0);
435
    });
1096 geraldo 436
    /**
437
     * Save Form Data
438
     */
1097 geraldo 439
    const saveData = (action) => {
1093 geraldo 440
        if ($('#form-name').val() == '') {
441
            $.fn.showError('ERROR_ENTER_NAME');
442
        } else if ($('#form-description').val() == '') {
443
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
444
        } else if ($('#form-text').val() == '') {
445
            $.fn.showError('ERROR_ENTER_TEXT');
446
        } else if ($('#form-status').val() == '') {
447
            $.fn.showError('ERROR_SELECT_STATUS');
448
        } else if ($('#job_description_id').val() == '') {
449
            $.fn.showError('ERROR_SELECT_JOB_DESCRIPTION');
450
        } else if (sections.length == 0) {
451
            $.fn.showError('ERROR_NOT_SECTIONS');
452
        } else {
453
            $.ajax({
454
                'dataType': 'json',
455
                'method': 'post',
456
                'url': $('#form-main').attr('action'),
457
                'data': {
458
                    'name': $('#form-main #form-name').val(),
459
                    'job_description_id': $('#form-main #job_description_id').val(),
460
                    'status': $('#form-main #form-status').val(),
461
                    'description': $('#form-main #form-description').val(),
462
                    'text': $('#form-main #form-text').val(),
463
                    'content': JSON.stringify(sections)
464
                },
465
            }).done(function(response) {
466
                if (response['success']) {
467
                    $.fn.showSuccess(response['data']);
1243 geraldo 468
                    if (action == 1) {
1095 geraldo 469
                        $('#form-main').attr('action', response['action_edit']);
470
                    } else {
471
                        $('#row-form').hide();
472
                        $('#row-lists').show();
473
                        /*---------- Reset Form -------- */
474
                        $('#form-main')[0].reset();
475
                        /*--------Reset Sections ----------*/
476
                        sections = [];
477
                        tableForm.fnDraw();
478
                    }
1093 geraldo 479
                    return;
480
                } else {
481
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
482
                    return;
1092 geraldo 483
                }
484
            });
485
        }
1095 geraldo 486
    }
1093 geraldo 487
    /**
488
     * Remove Html Tags
489
     */
490
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
491
    /**
492
     * Render Sections data
493
     */
494
    const renderData = (data) => {
495
        $("#rows").html($("#sectionTemplate").render(data));
496
    }
497
    /**
498
     * Add Section to array
499
     */
500
    const addSection = (title, text, type) => {
501
        sections.push({
502
            'id_section': new Date().getTime(),
503
            'title': title,
504
            'type': type,
505
            'text': text,
1243 geraldo 506
            'answer': '',
1093 geraldo 507
            'options': []
508
        });
509
        return renderData(sections);
510
    }
511
    /**
512
     * Edit item behavior
513
     */
514
    const editSection = (id, title, text, type) => {
515
        sections.map((item) => {
516
            if (item.id_section == id) {
517
                item.title = title;
518
                item.type = type;
519
                item.text = text;
520
            }
521
        });
522
        return renderData(sections);
523
    }
524
    /**
525
     * Remove behavior
526
     */
527
    const removeSection = (id) => {
528
        sections = sections.filter((item) => item.id_section != id);
529
        return renderData(sections);
530
    }
531
    /**
532
     * Add Option to array
533
     */
534
    const addOption = (id_section, title) => {
535
        sections.map((item) => {
536
            if (item.id_section == id_section) {
537
                item.options.push({
538
                    'id_section': id_section,
539
                    'id_option': new Date().getTime(),
540
                    'title': title,
1243 geraldo 541
                    'answer': ''
1093 geraldo 542
                });
543
            }
544
        });
545
        return renderData(sections);
546
    }
547
    /**
548
     * Edit item Option
549
     */
550
    const editOption = (id_section, id, title) => {
551
        sections.map((item) => {
552
            if (item.id_section == id_section) {
553
                item.options.map((opt) => {
554
                    if (opt.id_option == id) {
555
                        opt.title = title
556
                    }
557
                });
558
            }
559
        });
560
        return renderData(sections);
561
    }
562
    /**
563
     * Remove Option
564
     */
565
    const removeOption = (id_section, id) => {
566
        sections.map((item) => {
567
            if (item.id_section == id_section) {
568
                item.options = item.options.filter((opt) => opt.id_option != id) || []
569
            }
570
        });
571
        return renderData(sections);
572
    }
573
    /**
574
     * Clicked refresh button
575
     */
576
    $('button.btn-refresh').click(function(e) {
577
        tableForm.fnDraw();
578
        return;
1092 geraldo 579
    });
1243 geraldo 580
    /**
581
     * Initialize select Jobdescription
582
     */
1229 geraldo 583
    $('#job_description_id').select2({
584
        theme: 'bootstrap4',
585
        width: '100%',
586
    });
1243 geraldo 587
    /**
588
     * On change selecte JobDescription
589
     */
1239 geraldo 590
    $('#job_description_id').on('change', function() {
1243 geraldo 591
        if ($("#job_description_id").val() != '') {
1249 geraldo 592
            $.getJSON("/settings/jobs-description/edit/" + $("#job_description_id").val(), function(response) {
593
                if (response['success']) {
1247 geraldo 594
                    competencies_type = response['data']['competency_types'];
1249 geraldo 595
                    renderCompetenciesData(response['data']['competencies_selected']);
1243 geraldo 596
                }
597
            });
598
        }
599
    });
600
    /**
1247 geraldo 601
     * Filter competencie type
602
     */
603
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
604
    /**
1243 geraldo 605
     * Render Competencies data
606
     */
607
    const renderCompetenciesData = (data) => {
1254 geraldo 608
        if (data.length > 0) {
609
            $("#competencies-to-job").show();
1250 geraldo 610
            $("#rows-job-competencies").html($("#sectionCompetencies").render(data, {
1247 geraldo 611
                getType: filterTypeById
1254 geraldo 612
            }));
613
        } else {
614
            $("#competencies-to-job").hide();
1243 geraldo 615
            $("#rows-job-competencies").html('');
1254 geraldo 616
        }
1243 geraldo 617
    }
977 geraldo 618
});
619
JS;
1092 geraldo 620
 
977 geraldo 621
$this->inlineScript()->captureEnd();
622
?>
623
<!-- Content Header (Page header) -->
624
<section class="content-header">
1027 geraldo 625
   <div class="container-fluid">
626
      <div class="row mb-2">
627
         <div class="col-sm-12">
628
            <h1>LABEL_PERFORMANCE_EVALUATION</h1>
629
         </div>
630
      </div>
631
   </div>
632
   <!-- /.container-fluid -->
977 geraldo 633
</section>
634
<section class="content">
1252 geraldo 635
<div class="container-fluid" id="row-lists">
636
   <div class="row">
637
      <div class="col-12">
638
         <div class="card">
639
            <div class="card-body">
640
               <table id="gridTable" class="table   table-hover">
641
                  <thead>
642
                     <tr>
1268 geraldo 643
                        <th style="width:25%">LABEL_NAME</th>
1267 geraldo 644
                        <th style="width:20%">LABEL_JOB_DESCRIPTION</th>
1264 geraldo 645
                        <th style="width:10%">LABEL_ACTIVE</th>
646
                        <th style="width:25%">LABEL_ACTIONS</th>
1252 geraldo 647
                     </tr>
648
                  </thead>
649
                  <tbody></tbody>
650
               </table>
651
            </div>
652
            <div class="card-footer clearfix">
653
               <div style="float:right;">
654
                  <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
655
                  <?php if ($allowAdd) : ?>
656
                  <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
657
                  <?php endif; ?>
1027 geraldo 658
               </div>
977 geraldo 659
            </div>
1027 geraldo 660
         </div>
661
      </div>
662
   </div>
1252 geraldo 663
</div>
664
<!-- Create/Edit Form -->
665
<div class="row" id="row-form" style="display: none; padding: 16px;">
666
   <div class="col-xs-12 col-md-12">
667
      <form action="#" name="form-main" id="form-main">
668
         <div class="form-group">
669
            <label for="form-name">LABEL_FIRST_NAME</label>
670
            <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
671
         </div>
672
         <div class="form-group">
673
            <label for="job_description_id">LABEL_POSITION_EVALUATED</label>
674
            <select name="job_description_id" id="job_description_id" class="form-control">
675
               <option value="">LABEL_SELECT</option>
676
               <?php foreach ($jobsDescription as $rs): ?>
677
               <option value="<?php echo $rs->uuid;?>"><?php echo $rs->name;?></option>
678
               <?php endforeach; ?>
679
            </select>
680
         </div>
681
         <div class="form-group">
682
            <label for="form-description">LABEL_DESCRIPTION</label>
683
            <!--  ckeditor -->
684
            <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
685
         </div>
686
         <div class="form-group">
687
            <label for="form-text">LABEL_TEXT</label>
688
            <!--  ckeditor -->
689
            <textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
690
         </div>
691
         <div class="form-group">
692
            <label for="form-status">LABEL_STATUS</label>
693
            <select name="form-status" id="form-status" class="form-control">
694
               <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
695
               <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
696
            </select>
697
         </div>
698
         <div class="row">
699
            <div class="col-xs-12 col-md-12 text-right">
700
               <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 701
            </div>
1252 geraldo 702
         </div>
703
         <br />
704
         <div class="row">
705
            <div class="col-xs-12 col-md-12">
706
               <div class="panel-group" id="rows"></div>
1027 geraldo 707
            </div>
1252 geraldo 708
         </div>
1254 geraldo 709
         <div class="form-group" id="competencies-to-job" style="display:none">
1253 geraldo 710
            <div class="row">
711
               <div class="col-xs-12 col-md-12">
1256 geraldo 712
                  <hr>
713
                  <h4 style="font-size: 18px;font-weight: bold;">LABEL_COMPETENCIES_TO_JOB:</h4>
714
                  <br>
1253 geraldo 715
                  <div class="panel-group" id="rows-job-competencies"></div>
716
               </div>
717
            </div>
718
         </div>
719
         <div class="form-group">
1094 geraldo 720
            <button type="button" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1252 geraldo 721
            <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
722
            <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
723
         </div>
724
      </form>
725
   </div>
726
</div>
727
<!-- Create/Edit Form-->
728
<!-- section Modal -->
729
<div  id="modal-section" class="modal" tabindex="-1" role="dialog">
730
   <div class="modal-dialog modal-lg" role="document">
731
      <form action="#" name="form-section" id="form-section">
732
         <input type="hidden" name="id-section" id="id-section" />
733
         <div class="modal-content">
734
            <div class="modal-header">
735
               <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
736
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
737
               <span aria-hidden="true">&times;</span>
738
               </button>
1027 geraldo 739
            </div>
1252 geraldo 740
            <div class="modal-body">
741
               <div class="form-group">
742
                  <label for="title-section">LABEL_FIRST_NAME</label>
743
                  <input type="text" name="title-section" id="title-section" class="form-control" maxlength="50" value="" />
1027 geraldo 744
               </div>
1252 geraldo 745
               <div class="form-group">
746
                  <label for="text-section">LABEL_TEXT</label>
747
                  <textarea  name="text-section" id="text-section" rows="5" class="form-control"></textarea>
1027 geraldo 748
               </div>
1252 geraldo 749
               <div class="form-group">
750
                  <label for="type-section">LABEL_TYPE</label>
751
                  <select name="type-section" id="type-section" class="form-control">
752
                     <option value="simple">Simple</option>
753
                     <option value="multiple">Multiple</option>
754
                  </select>
1027 geraldo 755
               </div>
756
            </div>
1252 geraldo 757
            <div class="modal-footer">
758
               <button type="button" id="btn-save-section" class="btn btn-primary">LABEL_SAVE</button>
759
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
760
            </div>
761
         </div>
762
      </form>
1027 geraldo 763
   </div>
1252 geraldo 764
</div>
765
<!-- End Modal section -->
766
<!-- Modal Options -->
767
<div  id="modal-option" class="modal" tabindex="-1" role="dialog">
768
   <div class="modal-dialog modal-lg" role="document">
769
      <form action="#" name="form-option" id="form-option">
770
         <input type="hidden" name="section-option" id="section-option" value="" />
771
         <input type="hidden" name="id-option" id="id-option" value="" />
772
         <div class="modal-content">
773
            <div class="modal-header">
774
               <h4 class="modal-title">LABEL_OPTION</h4>
775
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
776
               <span aria-hidden="true">&times;</span>
777
               </button>
778
            </div>
779
            <div class="modal-body">
780
               <div class="form-group">
781
                  <label for="text-option">LABEL_TEXT</label>
782
                  <!--  ckeditor -->
783
                  <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
1027 geraldo 784
               </div>
785
            </div>
1252 geraldo 786
            <div class="modal-footer">
787
               <button type="button" class="btn btn-primary" id="btn-save-option">LABEL_SAVE</button>
788
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
789
            </div>
790
         </div>
791
      </form>
1027 geraldo 792
   </div>
1252 geraldo 793
</div>
1050 geraldo 794
 
1027 geraldo 795
   <!-- End Modal Options -->
796
   <!---Template Sections --->
797
   <script id="sectionTemplate" type="text/x-jsrender">
1045 geraldo 798
   <div class="panel panel-default" id="panel-{{:id_section}}">
799
   <div class="panel-heading">
1253 geraldo 800
   <h4 class="panel-title" style="font-size: 18px;">
1045 geraldo 801
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:id_section}}" href="#collapse-{{:id_section}}">
802
         <span class="section-name{{:id_section}}">
1088 geraldo 803
         {{:title}}
1045 geraldo 804
         </span>
805
         </a>
806
      </h4>
807
   </div>
808
   <div id="collapse-{{:id_section}}" class="panel-collapse in collapse show">
809
      <div class="panel-body">
810
         <div class="table-responsive">
811
            <table class="table table-bordered">
812
               <thead>
813
                  <tr>
814
                     <th style="width: 10%;">LABEL_ELEMENT</th>
815
                     <th style="width: 30%;">LABEL_TEXT</th>
816
                     <th style="width: 10%;">LABEL_TYPE</th>
817
                     <th style="width: 50%;">LABEL_ACTIONS</th>
818
                  </tr>
819
               </thead>
820
               <tbody>
1243 geraldo 821
                  <tr>
1045 geraldo 822
                     <td class="text-left">LABEL_SECTION</td>
823
                     <td class="text-left">{{:title}}</td>
824
                     <td>
825
                        {{if type == 'simple'}} Simple {{/if}}
826
                        {{if type == 'multiple'}} Multiple {{/if}}
827
                     </td>
828
                     <td>
1085 geraldo 829
                        <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>
830
                        <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 831
                        {{if type == 'multiple'}}
832
                        <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>
833
                        {{/if}}
834
                     </td>
835
                  </tr>
836
                  {{for options}}
837
                  <tr >
838
                     <td class="text-left">--LABEL_OPTION</td>
839
                     <td class="text-left">
840
                        {{:title}}
841
                     </td>
842
                     <td></td>
843
                     <td>
1085 geraldo 844
                        <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>
845
                        <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 846
                     </td>
847
                  </tr>
848
                  {{/for}}
849
               </tbody>
850
            </table>
851
         </div>
1027 geraldo 852
      </div>
1045 geraldo 853
   </div>
854
</div>
1027 geraldo 855
   </script>
856
   <!-- End Template Sections-->
1243 geraldo 857
 
858
  <!---Template Competencies --->
1250 geraldo 859
   <script id="sectionCompetencies" type="text/x-jsrender">
1243 geraldo 860
   <div class="panel panel-default" id="panel-{{:competency_id}}">
861
   <div class="panel-heading">
1253 geraldo 862
      <h4 class="panel-title" style="font-size: 18px;">
1243 geraldo 863
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:competency_id}}" href="#collapse-{{:competency_id}}">
864
         <span class="competency-name{{:competency_id}}">
865
         {{:~getType(competency_type_id).name}} - {{:name}}
866
         </span>
867
         </a>
868
      </h4>
869
   </div>
870
   <div id="collapse-{{:competency_id}}" class="panel-collapse in collapse show">
871
      <div class="panel-body">
872
         <div class="table-responsive">
873
            <table class="table table-bordered">
874
               <thead>
875
                  <tr>
1314 geraldo 876
                     <th style="width: 90%;">LABEL_CONDUCT</th>
1262 geraldo 877
                     <th style="width: 10%;">LABEL_LEVEL</th>
1243 geraldo 878
                  </tr>
879
               </thead>
880
               <tbody>
881
                  {{for behaviors}}
882
                  <tr >
883
                     <td class="text-left">
884
                        {{:description}}
885
                     </td>
886
                     <td>
1261 geraldo 887
                        {{if level == '0'}} LABEL_NA {{/if}}
888
                        {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
889
                        {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
890
                        {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
891
                        {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
892
                     </td>
893
 
894
 
895
                  </tr>
1243 geraldo 896
                  {{/for}}
897
               </tbody>
898
            </table>
899
         </div>
900
      </div>
901
   </div>
902
</div>
903
   </script>
904
    <!-- End Template Competencies-->
905
 
977 geraldo 906
</section>