Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15404 | Ir a la última revisión | | Ultima modificación | Ver Log |

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