Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1255 | Rev 1260 | 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
    });
595
    /**
1247 geraldo 596
     * Filter competencie type
597
     */
598
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
599
    /**
1243 geraldo 600
     * Render Competencies data
601
     */
602
    const renderCompetenciesData = (data) => {
1254 geraldo 603
        if (data.length > 0) {
604
            $("#competencies-to-job").show();
1250 geraldo 605
            $("#rows-job-competencies").html($("#sectionCompetencies").render(data, {
1247 geraldo 606
                getType: filterTypeById
1254 geraldo 607
            }));
608
        } else {
609
            $("#competencies-to-job").hide();
1243 geraldo 610
            $("#rows-job-competencies").html('');
1254 geraldo 611
        }
1243 geraldo 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
            <label for="form-description">LABEL_DESCRIPTION</label>
678
            <!--  ckeditor -->
679
            <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
680
         </div>
681
         <div class="form-group">
682
            <label for="form-text">LABEL_TEXT</label>
683
            <!--  ckeditor -->
684
            <textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
685
         </div>
686
         <div class="form-group">
687
            <label for="form-status">LABEL_STATUS</label>
688
            <select name="form-status" id="form-status" class="form-control">
689
               <option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option>
690
               <option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option>
691
            </select>
692
         </div>
693
         <div class="row">
694
            <div class="col-xs-12 col-md-12 text-right">
695
               <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 696
            </div>
1252 geraldo 697
         </div>
698
         <br />
699
         <div class="row">
700
            <div class="col-xs-12 col-md-12">
701
               <div class="panel-group" id="rows"></div>
1027 geraldo 702
            </div>
1252 geraldo 703
         </div>
1254 geraldo 704
         <div class="form-group" id="competencies-to-job" style="display:none">
1253 geraldo 705
            <div class="row">
706
               <div class="col-xs-12 col-md-12">
1256 geraldo 707
                  <hr>
708
                  <h4 style="font-size: 18px;font-weight: bold;">LABEL_COMPETENCIES_TO_JOB:</h4>
709
                  <br>
1253 geraldo 710
                  <div class="panel-group" id="rows-job-competencies"></div>
711
               </div>
712
            </div>
713
         </div>
714
         <div class="form-group">
1094 geraldo 715
            <button type="button" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1252 geraldo 716
            <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
717
            <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
718
         </div>
719
      </form>
720
   </div>
721
</div>
722
<!-- Create/Edit Form-->
723
<!-- section Modal -->
724
<div  id="modal-section" class="modal" tabindex="-1" role="dialog">
725
   <div class="modal-dialog modal-lg" role="document">
726
      <form action="#" name="form-section" id="form-section">
727
         <input type="hidden" name="id-section" id="id-section" />
728
         <div class="modal-content">
729
            <div class="modal-header">
730
               <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
731
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
732
               <span aria-hidden="true">&times;</span>
733
               </button>
1027 geraldo 734
            </div>
1252 geraldo 735
            <div class="modal-body">
736
               <div class="form-group">
737
                  <label for="title-section">LABEL_FIRST_NAME</label>
738
                  <input type="text" name="title-section" id="title-section" class="form-control" maxlength="50" value="" />
1027 geraldo 739
               </div>
1252 geraldo 740
               <div class="form-group">
741
                  <label for="text-section">LABEL_TEXT</label>
742
                  <textarea  name="text-section" id="text-section" rows="5" class="form-control"></textarea>
1027 geraldo 743
               </div>
1252 geraldo 744
               <div class="form-group">
745
                  <label for="type-section">LABEL_TYPE</label>
746
                  <select name="type-section" id="type-section" class="form-control">
747
                     <option value="simple">Simple</option>
748
                     <option value="multiple">Multiple</option>
749
                  </select>
1027 geraldo 750
               </div>
751
            </div>
1252 geraldo 752
            <div class="modal-footer">
753
               <button type="button" id="btn-save-section" class="btn btn-primary">LABEL_SAVE</button>
754
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
755
            </div>
756
         </div>
757
      </form>
1027 geraldo 758
   </div>
1252 geraldo 759
</div>
760
<!-- End Modal section -->
761
<!-- Modal Options -->
762
<div  id="modal-option" class="modal" tabindex="-1" role="dialog">
763
   <div class="modal-dialog modal-lg" role="document">
764
      <form action="#" name="form-option" id="form-option">
765
         <input type="hidden" name="section-option" id="section-option" value="" />
766
         <input type="hidden" name="id-option" id="id-option" value="" />
767
         <div class="modal-content">
768
            <div class="modal-header">
769
               <h4 class="modal-title">LABEL_OPTION</h4>
770
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
771
               <span aria-hidden="true">&times;</span>
772
               </button>
773
            </div>
774
            <div class="modal-body">
775
               <div class="form-group">
776
                  <label for="text-option">LABEL_TEXT</label>
777
                  <!--  ckeditor -->
778
                  <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
1027 geraldo 779
               </div>
780
            </div>
1252 geraldo 781
            <div class="modal-footer">
782
               <button type="button" class="btn btn-primary" id="btn-save-option">LABEL_SAVE</button>
783
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
784
            </div>
785
         </div>
786
      </form>
1027 geraldo 787
   </div>
1252 geraldo 788
</div>
1050 geraldo 789
 
1027 geraldo 790
   <!-- End Modal Options -->
791
   <!---Template Sections --->
792
   <script id="sectionTemplate" type="text/x-jsrender">
1045 geraldo 793
   <div class="panel panel-default" id="panel-{{:id_section}}">
794
   <div class="panel-heading">
1253 geraldo 795
   <h4 class="panel-title" style="font-size: 18px;">
1045 geraldo 796
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:id_section}}" href="#collapse-{{:id_section}}">
797
         <span class="section-name{{:id_section}}">
1088 geraldo 798
         {{:title}}
1045 geraldo 799
         </span>
800
         </a>
801
      </h4>
802
   </div>
803
   <div id="collapse-{{:id_section}}" class="panel-collapse in collapse show">
804
      <div class="panel-body">
805
         <div class="table-responsive">
806
            <table class="table table-bordered">
807
               <thead>
808
                  <tr>
809
                     <th style="width: 10%;">LABEL_ELEMENT</th>
810
                     <th style="width: 30%;">LABEL_TEXT</th>
811
                     <th style="width: 10%;">LABEL_TYPE</th>
812
                     <th style="width: 50%;">LABEL_ACTIONS</th>
813
                  </tr>
814
               </thead>
815
               <tbody>
1243 geraldo 816
                  <tr>
1045 geraldo 817
                     <td class="text-left">LABEL_SECTION</td>
818
                     <td class="text-left">{{:title}}</td>
819
                     <td>
820
                        {{if type == 'simple'}} Simple {{/if}}
821
                        {{if type == 'multiple'}} Multiple {{/if}}
822
                     </td>
823
                     <td>
1085 geraldo 824
                        <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>
825
                        <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 826
                        {{if type == 'multiple'}}
827
                        <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>
828
                        {{/if}}
829
                     </td>
830
                  </tr>
831
                  {{for options}}
832
                  <tr >
833
                     <td class="text-left">--LABEL_OPTION</td>
834
                     <td class="text-left">
835
                        {{:title}}
836
                     </td>
837
                     <td></td>
838
                     <td>
1085 geraldo 839
                        <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>
840
                        <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 841
                     </td>
842
                  </tr>
843
                  {{/for}}
844
               </tbody>
845
            </table>
846
         </div>
1027 geraldo 847
      </div>
1045 geraldo 848
   </div>
849
</div>
1027 geraldo 850
   </script>
851
   <!-- End Template Sections-->
1243 geraldo 852
 
853
  <!---Template Competencies --->
1250 geraldo 854
   <script id="sectionCompetencies" type="text/x-jsrender">
1243 geraldo 855
   <div class="panel panel-default" id="panel-{{:competency_id}}">
856
   <div class="panel-heading">
1253 geraldo 857
      <h4 class="panel-title" style="font-size: 18px;">
1243 geraldo 858
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:competency_id}}" href="#collapse-{{:competency_id}}">
859
         <span class="competency-name{{:competency_id}}">
860
         {{:~getType(competency_type_id).name}} - {{:name}}
861
         </span>
862
         </a>
863
      </h4>
864
   </div>
865
   <div id="collapse-{{:competency_id}}" class="panel-collapse in collapse show">
866
      <div class="panel-body">
867
         <div class="table-responsive">
868
            <table class="table table-bordered">
869
               <thead>
870
                  <tr>
871
                     <th style="width: 20%;">LABEL_ELEMENT</th>
872
                     <th style="width: 50%;">LABEL_TITLE</th>
873
                     <th style="width: 10%;">LABEL_LEVEL</th>
874
                  </tr>
875
               </thead>
876
               <tbody>
877
                  <tr>
878
                     <td class="text-left">LABEL_COMPETENCY</td>
879
                     <td class="text-left">{{:name}}</td>
880
                     <td></td>
881
                  </tr>
882
                  {{for behaviors}}
883
                  <tr >
884
                     <td class="text-left">--LABEL_CONDUCT</td>
885
                     <td class="text-left">
886
                        {{:description}}
887
                     </td>
888
                     <td>
889
          {{if level == '0'}} LABEL_NA {{/if}}
890
          {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
891
          {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
892
          {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
893
          {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
894
       </td>
895
 
896
                  </tr>
897
                  {{/for}}
898
               </tbody>
899
            </table>
900
         </div>
901
      </div>
902
   </div>
903
</div>
904
   </script>
905
    <!-- End Template Competencies-->
906
 
977 geraldo 907
</section>