Proyectos de Subversion LeadersLinked - Backend

Rev

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