Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16929 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15430 stevensc 1
<?php
2
 
66 efrain 3
use LeadersLinked\Model\JobDescription;
4
 
5
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
6
$currentUser    = $this->currentUserHelper();
7
 
8
$roleName = $currentUser->getUserTypeId();
9
 
15394 efrain 10
 
15443 efrain 11
$routeAdd       = $this->url('jobs-description/add');
12
$routeDatatable = $this->url('jobs-description');
13
$routeImport    = $this->url('jobs-description/import');
66 efrain 14
$routeDashboard = $this->url('dashboard');
15
 
15443 efrain 16
$allowAdd               = $acl->isAllowed($roleName, 'jobs-description/add') ? 1 : 0;
17
$allowEdit              = $acl->isAllowed($roleName, 'jobs-description/edit') ? 1 : 0;
18
$allowDelete            = $acl->isAllowed($roleName, 'jobs-description/delete') ? 1 : 0;
19
$allowReport            = $acl->isAllowed($roleName, 'jobs-description/report') ? 1 : 0;
20
$allowImport            = $acl->isAllowed($roleName, 'jobs-description/import') ? 1 : 0;
66 efrain 21
 
22
 
16822 efrain 23
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
24
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
16842 efrain 25
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-maxlength/bootstrap-maxlength.min.js'));
15394 efrain 26
 
27
 
16929 efrain 28
 
29
 
30
 
16822 efrain 31
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
32
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
15394 efrain 33
 
16822 efrain 34
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
35
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
36
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
37
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
15394 efrain 38
 
16822 efrain 39
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
40
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
66 efrain 41
 
15394 efrain 42
 
43
 
1227 geraldo 44
 
16822 efrain 45
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.js'));
46
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/i18n/es.js'));
47
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.css'));
48
 
16927 efrain 49
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap5-theme/select2-bootstrap-5-theme.css'));
16822 efrain 50
 
15394 efrain 51
// JsRender //
16822 efrain 52
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.min.js'));
15394 efrain 53
 
16822 efrain 54
$this->inlineScript()->appendFile($this->basePath('assets/vendors/orgchart/js/jquery.orgchart.js'));
55
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/orgchart/css/jquery.orgchart.css'));
15394 efrain 56
 
16845 efrain 57
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootbox/bootbox.all.js'));
16787 efrain 58
 
15394 efrain 59
$status_active = JobDescription::STATUS_ACTIVE;
16778 efrain 60
$status_inactive = JobDescription::STATUS_INACTIVE;
15394 efrain 61
 
16787 efrain 62
$this->headStyle()->captureStart();
63
echo <<<CSS
64
div.orgchart
65
{
66
    width: 100%;
67
    height: 600px
68
}
69
CSS;
70
$this->headStyle()->captureEnd();
71
 
72
 
15394 efrain 73
$this->inlineScript()->captureStart();
74
echo <<<JS
75
 
76
 
77
jQuery(document).ready(function($) {
78
 
16770 efrain 79
 
80
 
15443 efrain 81
    var competencies_selected = new Array();
82
    var behaviors = new Array();
83
    var competency_types = new Array();
84
    var competencies = new Array();
15394 efrain 85
 
86
    var allowEdit = $allowEdit;
87
    var allowDelete = $allowDelete;
88
    var allowReport = $allowReport;
89
 
90
 
16787 efrain 91
    var datasource = {};
92
    var dataactions = [];
93
    var oc = null;
94
 
15394 efrain 95
    $.fn.renderCompetencies = function() {
96
        if(competencies_selected.length > 0) {
16766 efrain 97
 
98
 
15394 efrain 99
            $('#renderCompetencies').html($('#competencyTemplate').render(competencies_selected, {
100
                getCompetencyType: (uuid) => competency_types.filter((item) => item.uuid == uuid ? item : false)[0],
101
                getCompetency: (uuid) => competencies.filter((item) => item.uuid == uuid ? item : false)[0],
102
                getBehavior: (uuid) => behaviors.filter((item) => item.uuid == uuid ? item : false)[0]
103
            }));
104
        } else {
105
            $('#renderCompetencies').html('');
106
        }
107
    }
108
 
109
    $.fn.comboCompetencies = function() {
110
        $('#select-competency').children().remove();
111
        $.each(competency_types, function(i, competency_type) {
112
            competencies_filtered = competencies.filter((item) => item.competency_type_uuid == competency_type.uuid ? item : false)
113
            $.each(competencies_filtered, function(i, competency) {
114
 
115
 
116
                selected = competencies_selected.filter((item) => item.uuid == competency.uuid ? item : false)[0];
117
                if(!selected) {
118
                    $('#select-competency').append($('<option>', {
119
                        value: competency.uuid,
120
                        text: competency_type.name +  ' - ' + competency.name
121
                    }));
122
                }
123
 
124
            });
125
        });
126
 
127
    }
128
 
129
 
130
 
131
 
132
 
16787 efrain 133
    $.fn.recursiveTree = function(parent_branch, parent_item) {
134
        $.each(parent_item, function(i, item) {
135
            dataactions.push({
136
                'uuid' : item['uuid'],
137
                'link_report' : item['link_report'],
138
                'link_edit' : item['link_edit'],
139
                'link_delete' : item['link_delete'],
140
            })
16779 efrain 141
 
16787 efrain 142
            var branch  = {
143
                'uuid' : item['uuid'],
144
                'name' : item['name'],
145
                'children' : [
16770 efrain 146
 
16787 efrain 147
                ]
148
            }
16770 efrain 149
 
16787 efrain 150
            if(item.children.length > 0) {
151
                $.fn.recursiveTree(branch, item.children);
152
            }
16779 efrain 153
 
16787 efrain 154
            parent_branch.children.push(branch)
16779 efrain 155
 
16787 efrain 156
        });
16770 efrain 157
 
16787 efrain 158
    }
16770 efrain 159
 
160
 
161
 
162
 
163
    $.fn.refreshTree = function() {
164
        NProgress.start();
165
        $.ajax({
166
            'dataType': 'json',
167
            'accept': 'application/json',
168
            'method': 'get',
169
            'url': '$routeDatatable',
170
        }).done(function(response) {
171
            if (response['success']) {
16787 efrain 172
                dataactions = [];
173
                datasource = {
174
                    'uuid' : 'n-a',
175
                    'name' : '$company_name',
176
                    'children' : [
177
 
178
                    ]
179
                }
180
 
181
 
182
                $.fn.recursiveTree(datasource, response['data']['items']);
183
 
184
 
185
 
186
                oc.init({ 'data': datasource });
187
                oc.\$chart.find('.node').on('mouseover', function(e) {
188
                    e.preventDefault();
189
 
190
                    $('.horizontalEdge').hide();
191
                    $('.verticalEdge').hide();
16770 efrain 192
                });
16787 efrain 193
 
194
                oc.\$chart.find('.node').on('click', function() {
195
                    var message = $(this).children('.title').text();
196
 
197
 
198
                    if(!allowEdit && !allowDelete && !allowReport) {
199
                        return;
200
                    }
201
 
202
 
203
                    var uuid = $(this).attr('id');
204
                    var link_report = '';
205
                    var link_edit = '';
206
                    var link_delete = '';
207
 
208
                    $.each(dataactions, function(i, item) {
209
                        if(uuid == item.uuid) {
210
                            link_report = item.link_report;
211
                            link_edit = item.link_edit;
212
                            link_delete = item.link_delete;
213
                        }
214
                    });
215
 
216
                    var buttons =  {}
217
 
218
                    buttons.cancel = {
219
                        label: 'LABEL_CANCEL',
16845 efrain 220
                        className: 'btn-secondary',
16787 efrain 221
                        callback: function(){
222
                            console.log('CANCEL clicked');
223
                        }
224
                    };
225
 
226
 
227
                    if(allowEdit && link_edit) {
228
                        buttons.edit = {
229
                            label: 'LABEL_EDIT',
16845 efrain 230
                            className: ' btn-primary',
16787 efrain 231
                            callback: function(){
232
 
233
                                setTimeout(() => {
234
                                    $.fn.editJobDescription(link_edit);
235
                                },  250);
236
 
237
                            }
238
                        };
239
                    }
240
                    if(allowDelete && link_delete) {
241
                        buttons.delete = {
242
                            label: 'LABEL_DELETE',
16845 efrain 243
                            className: 'btn-danger',
16787 efrain 244
                            callback: function(){
245
                                setTimeout(() => {
246
                                    $.fn.deleteJobDescription(link_delete);
247
                                },  250);
248
 
249
 
250
 
251
 
252
                            }
253
                        };
254
                    }
255
 
256
                    if(allowReport && link_report) {
257
                        buttons.report = {
258
                            label: 'LABEL_REPORT',
16845 efrain 259
                            className: 'btn-info',
16787 efrain 260
                            callback: function() {
261
                                setTimeout(() => {
262
                                    $.fn.reportJobDescription(link_report);
263
                                },  250);
264
                            }
265
                        };
266
                    }
267
 
268
 
16845 efrain 269
 
270
 
16787 efrain 271
                    let dialog = bootbox.dialog({
272
                        title: 'LABEL_JOB_DESCRIPTION',
273
                        message: message,
274
                        size: 'large',
275
                        buttons: buttons,
276
                    });
277
                    dialog.show();
278
 
279
                });
280
 
16770 efrain 281
            } else {
282
                $.fn.showError(response['data']);
283
            }
284
        }).fail(function(jqXHR, textStatus, errorThrown) {
285
            $.fn.showError(textStatus);
286
         }).always(function() {
287
            NProgress.done();
288
        });
289
    }
290
 
15394 efrain 291
    var validator = $('#form').validate({
292
        debug: true,
293
        onclick: false,
294
        onkeyup: false,
295
        ignore: [],
296
        rules: {
297
            'name': {
298
                required: true,
299
                maxlength: 64,
300
            },
301
            'functions': {
302
                required: true,
15443 efrain 303
                maxlength: 1024,
15394 efrain 304
            },
305
            'objectives': {
15443 efrain 306
               required: true,
307
                maxlength: 1024,
15394 efrain 308
            },
309
            'status': {
310
                required: false,
311
            },
16787 efrain 312
            'job_description_id_boss' : {
313
                required: false,
314
            },
15394 efrain 315
        },
316
        submitHandler: function(form) {
317
 
16778 efrain 318
 
319
 
15394 efrain 320
            var data = {
321
                name : $('#form #name').val(),
322
                functions : $('#form #functions').val(),
323
                objectives : $('#form #objectives').val(),
16778 efrain 324
                status :  $('#form #status').prop('checked') ?  '$status_active' : '$status_inactive',
16787 efrain 325
                job_description_id_boss: $('#form #job_description_id_boss').val(),
15394 efrain 326
                competencies_selected : new Array(),
327
            };
328
 
329
 
330
            $.each(competencies_selected, function(i, c) {
331
                $.each(c.behaviors, function(i, b) {
332
                    data.competencies_selected.push({'competency_uuid' : c.uuid, 'behavior_uuid' : b.uuid, 'level' : b.level});
333
                });
334
            });
335
 
336
 
337
            NProgress.start();
338
            $.ajax({
339
                'dataType': 'json',
340
                'accept': 'application/json',
341
                'method': 'post',
342
                'url': $('#form').attr('action'),
343
                'data': data,
344
            }).done(function(response) {
345
                if (response['success']) {
346
                    $.fn.showSuccess(response['data']);
347
                    $('#row-lists').show();
348
                    $('#row-form').hide();
16770 efrain 349
                    $.fn.refreshTree();
15394 efrain 350
                } else {
351
                    validator.resetForm();
352
                    if (jQuery.type(response['data']) == 'string') {
353
                        $.fn.showError(response['data']);
354
                    } else {
355
                        $.each(response['data'], function(fieldname, errors) {
356
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
357
                        });
358
                    }
359
                }
360
            }).fail(function(jqXHR, textStatus, errorThrown) {
361
                $.fn.showError(textStatus);
362
            }).always(function() {
363
                NProgress.done();
364
            });
365
            return false;
366
        },
367
        invalidHandler: function(form, validator) {}
368
    });
369
 
16770 efrain 370
    $('body').on('click', 'button.btn-refresh', function(e) {
15394 efrain 371
        e.preventDefault();
16770 efrain 372
        $.fn.refreshTree();
373
    });
374
 
375
    $('body').on('click', 'button.btn-cancel', function(e) {
376
        e.preventDefault();
377
        $('#row-lists').show();
378
        $('#row-form').hide();
379
        $('#div-listing').show();
380
    });
381
 
382
    $('body').on('click', 'button.btn-import', function(e) {
383
        e.preventDefault();
15394 efrain 384
        NProgress.start();
385
        $.ajax({
386
            'dataType': 'json',
16770 efrain 387
            'method': 'post',
388
            'url': '$routeImport',
389
        }).done(function(response) {
390
            if (response['success']) {
391
                $.fn.showSuccess(response['data']);
392
                $.fn.refreshTree();
393
            } else {
394
                $.fn.showError(response['data']);
395
            }
396
        }).fail(function(jqXHR, textStatus, errorThrown) {
397
            $.fn.showError(textStatus);
398
        }).always(function() {
399
            NProgress.done();
400
        });
401
        return false;
402
    });
403
 
404
    $('body').on('click', 'button.btn-add-job-description', function(e) {
405
        e.preventDefault();
406
 
16787 efrain 407
        var action = $(this).data('link');
15394 efrain 408
 
16787 efrain 409
        NProgress.start();
410
        $.ajax({
411
            'dataType': 'json',
412
            'accept': 'application/json',
413
            'method': 'get',
414
            'url' : '$routeAdd',
415
        }).done(function(response) {
16778 efrain 416
 
16787 efrain 417
            if (response['success']) {
418
                behaviors = response['data']['behaviors'];
419
                competency_types = response['data']['competency_types'];
420
                competencies = response['data']['competencies'];
16778 efrain 421
 
422
 
16787 efrain 423
                competencies_selected = [];
424
                $.each(competencies, function(i, competency) {
425
                    $.each(competency.behaviors, function(j, behavior) {
426
                        competencies[i].behaviors[j].level = 0;
16770 efrain 427
                    });
16787 efrain 428
                });
16778 efrain 429
 
16787 efrain 430
                $.fn.renderCompetencies();
431
                $.fn.comboCompetencies();
16778 efrain 432
 
16840 efrain 433
 
16787 efrain 434
                $('#form').attr('action', action);
435
                $('#form #name').val('');
436
                $('#form #status').bootstrapToggle('on');
16778 efrain 437
 
16787 efrain 438
                $('#form #functions').val('');
439
                $('#form #objectives').val('');
440
 
441
 
442
                $('#job_description_id_boss').empty();
443
                $.each(response['data']['jobs_description'], function(id, text) {
444
 
445
                    var option = new Option(text, id, false, false);
446
                    $('#job_description_id_boss').append(option).trigger('change');
447
                });
448
                $('#job_description_id_boss').trigger('change');
449
                $('#job_description_id_boss').val('').trigger('change');
16778 efrain 450
 
16787 efrain 451
                validator.resetForm();
16778 efrain 452
 
453
 
16787 efrain 454
                $('#custom-tabs #custom-tabs-general-tab').tab('show');
455
                $('#row-lists').hide();
456
                $('#row-form').show();
16778 efrain 457
 
16787 efrain 458
            } else   {
459
                $.fn.showError(response['data']);
460
            }
16778 efrain 461
 
16787 efrain 462
        }).fail(function(jqXHR, textStatus, errorThrown) {
463
            $.fn.showError(textStatus);
464
        }).always(function() {
465
            NProgress.done();
466
        });
467
    });
15394 efrain 468
 
16787 efrain 469
    $.fn.deleteJobDescription = function(action)
470
    {
16822 efrain 471
        swal.fire({
472
            title: 'LABEL_ARE_YOU_SURE',
473
            icon: 'question',
474
            cancelButtonText: 'LABEL_NO',
475
            showCancelButton: true,
476
            confirmButtonText: 'LABEL_YES'
477
          }).then((result) => {
478
            if (result.isConfirmed) {
16787 efrain 479
                    NProgress.start();
480
                    $.ajax({
481
                        'dataType'  : 'json',
482
                        'accept'    : 'application/json',
483
                        'method'    : 'post',
484
                        'url'       :  action,
485
                    }).done(function(response) {
486
                        if(response['success']) {
487
                            $.fn.showSuccess(response['data']);
488
                            $.fn.refreshTree();
489
                        } else {
490
                            $.fn.showError(response['data']);
491
                        }
492
                    }).fail(function( jqXHR, textStatus, errorThrown) {
493
                        $.fn.showError(textStatus);
494
                    }).always(function() {
495
                        NProgress.done();
496
                    });
16845 efrain 497
 
16787 efrain 498
            }
499
        });
16778 efrain 500
    }
15394 efrain 501
 
16787 efrain 502
    $.fn.editJobDescription = function(action)
503
    {
504
        NProgress.start();
15394 efrain 505
 
506
        $.ajax({
507
            'dataType': 'json',
16770 efrain 508
            'accept': 'application/json',
509
            'method': 'get',
510
            'url': action,
15394 efrain 511
        }).done(function(response) {
512
            if (response['success']) {
16840 efrain 513
 
16770 efrain 514
                $('#form').attr('action', action);
16787 efrain 515
                $('#form #id').val(response['data']['id']);
16770 efrain 516
                $('#form #name').val(response['data']['name']);
517
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
518
 
519
                $('#form #functions').val(response['data']['functions']);
520
                $('#form #objectives').val(response['data']['objectives']);
521
 
522
                behaviors = response['data']['behaviors'];
523
                competency_types = response['data']['competency_types'];
524
 
525
                competencies = response['data']['competencies'];
526
                competencies_selected = response['data']['competencies_selected'];
16787 efrain 527
 
528
                $('#job_description_id_boss').empty();
529
                $.each(response['data']['jobs_description'], function(id, text) {
530
 
531
                    var option = new Option(text, id, false, false);
532
                    $('#job_description_id_boss').append(option).trigger('change');
533
                });
534
 
535
                $('#job_description_id_boss').trigger('change');
536
                $('#job_description_id_boss').val(response['data']['job_description_id_boss']).trigger('change');
537
 
16770 efrain 538
 
539
                $.fn.renderCompetencies();
540
                $.fn.comboCompetencies();
541
 
542
 
543
                validator.resetForm();
544
                $('#custom-tabs #custom-tabs-general-tab').tab('show');
545
                $('#row-lists').hide();
546
                $('#row-form').show();
15394 efrain 547
            } else {
548
                $.fn.showError(response['data']);
549
            }
550
        }).fail(function(jqXHR, textStatus, errorThrown) {
551
            $.fn.showError(textStatus);
552
        }).always(function() {
553
            NProgress.done();
554
        });
16787 efrain 555
    }
15394 efrain 556
 
16787 efrain 557
    $.fn.reportJobDescription = function(action)
558
    {
16770 efrain 559
        window.open(action, '_blank');
15443 efrain 560
 
16787 efrain 561
    }
15394 efrain 562
 
563
    $('body').on('click', 'button[id="btn-select-competency"]', function(e) {
564
        var competency_uuid = $('#select-competency').val();
565
 
566
        if (competency_uuid.length == '') {
567
            $.fn.showError('ERROR_SELECT_COMPETENCY_IS_EMPTY');
568
        } else {
569
 
570
            competency = competencies.filter((item) => item.uuid == competency_uuid ? item : false)[0];
571
            if(competency) {
572
 
573
                var competency_selected = {
574
                    uuid : competency.uuid,
575
                    competency_type_uuid: competency.competency_type_uuid,
576
                    behaviors : new Array(),
577
                }
578
 
579
                $.each(competency.behaviors, function(index, uuid) {
580
                    competency_selected.behaviors.push({uuid: uuid, level: 0});
581
 
582
                })
583
 
584
 
585
                competencies_selected.push(competency_selected);
586
 
587
                $.fn.renderCompetencies();
588
                $.fn.comboCompetencies();
589
            }
590
        }
591
    });
592
 
16845 efrain 593
/*
16770 efrain 594
    $('body').on('click', 'i.btn-delete-job-description', function(e) {
15394 efrain 595
        e.preventDefault();
16777 efrain 596
        var action = $(this).data('link');
597
 
16822 efrain 598
          swal.fire({
599
            title: 'LABEL_ARE_YOU_SURE',
600
            icon: 'question',
601
            cancelButtonText: 'LABEL_NO',
602
            showCancelButton: true,
603
            confirmButtonText: 'LABEL_YES'
604
          }).then((result) => {
605
            if (result.isConfirmed) {
16777 efrain 606
                    NProgress.start();
607
                    $.ajax({
608
                        'dataType': 'json',
609
                        'accept': 'application/json',
610
                        'method': 'post',
611
                        'url': action,
612
                    }).done(function(response) {
613
                        if (response['success']) {
614
                            $.fn.showSuccess(response['data']);
615
                           $.fn.refreshTree();
616
                        } else {
617
                            $.fn.showError(response['data']);
618
                        }
619
                    }).fail(function(jqXHR, textStatus, errorThrown) {
620
                        $.fn.showError(textStatus);
621
                    }).always(function() {
622
                        NProgress.done();
623
                    });
16845 efrain 624
 
15394 efrain 625
            }
626
        });
16777 efrain 627
 
628
 
629
 
16845 efrain 630
    });*/
15394 efrain 631
 
16770 efrain 632
    $('body').on('click', 'button.btn-delete-job-description-competency', function(e) {
15394 efrain 633
        e.preventDefault();
634
 
635
        var uuid = $(this).data('competency');
16822 efrain 636
          swal.fire({
637
            title: 'LABEL_COMPETENCY_DELETE_TITLE',
15394 efrain 638
            message: 'LABEL_COMPETENCY_DELETE_MESSAGE',
16822 efrain 639
            icon: 'question',
640
            cancelButtonText: 'LABEL_NO',
641
            showCancelButton: true,
642
            confirmButtonText: 'LABEL_YES'
643
          }).then((result) => {
644
            if (result.isConfirmed) {
15394 efrain 645
                    competencies_selected = competencies_selected.filter((item) => item.uuid != uuid ? item : false);
646
 
647
 
648
                    $.fn.renderCompetencies();
649
                    $.fn.comboCompetencies();
650
 
651
            }
652
        });
653
    });
654
 
16770 efrain 655
    $('body').on('click','button.btn-edit-job-description-behavior', function(e) {
15394 efrain 656
        e.preventDefault();
657
 
658
        var competency_uuid = $(this).closest('div.panel-competency').data('competency');
659
        var behavior_uuid = $(this).data('behavior');
660
 
661
 
662
        competency_selected = competencies_selected.filter((item) => item.uuid == competency_uuid ? item : false)[0];
663
        if(competency_selected) {
664
            console.log(competency_selected);
665
 
666
            behavior = competency_selected .behaviors.filter((item) => item.uuid  == behavior_uuid ? item : false)[0];
667
            if(behavior) {
668
 
669
                $('#form-behavior #competency-uuid').val(competency_uuid);
670
                $('#form-behavior #behavior-uuid').val(behavior_uuid);
671
                $('#form-behavior #level').val(behavior.level);
672
 
673
                $('#modal-behavior').modal('show');
674
            }
675
 
676
        }
677
    });
678
 
679
    $('body').on('click','button.btn-behavior-submit', function(e) {
680
         e.preventDefault();
681
         $('#modal-behavior').modal('hide');
682
 
683
         var competency_uuid = $('#form-behavior #competency-uuid').val();
684
         var behavior_uuid = $('#form-behavior #behavior-uuid').val();
685
         var level = $('#form-behavior #level').val();
686
 
687
        competency_selected = competencies_selected.filter((item) => item.uuid == competency_uuid ? item : false)[0];
688
        if(competency_selected) {
689
            behavior = competency_selected .behaviors.filter((item) => item.uuid  == behavior_uuid ? item : false)[0];
690
            if(behavior) {
691
                behavior.level = level;
692
                $.fn.renderCompetencies();
693
            }
694
 
695
        }
696
 
697
    });
698
 
16770 efrain 699
    $('body').on('click', 'button.btn-edit-job-description-cancel', function(e) {
15394 efrain 700
        $('#row-lists').show();
701
        $('#row-form').hide();
702
    });
703
 
704
    $('#form #status').bootstrapToggle({
705
        'on': 'LABEL_ACTIVE',
706
        'off': 'LABEL_INACTIVE',
707
        'width': '160px',
708
        'height': '40px'
709
    });
710
 
15443 efrain 711
    $('#form #functions').maxlength({
712
        alwaysShow: true,
713
         validate: true
714
    });
715
 
716
    $('#form #objectives').maxlength({
717
        alwaysShow: true,
718
        validate: true
719
    });
720
 
16770 efrain 721
    $('#select-competency').select2({
16918 efrain 722
        theme: 'bootstrap-5',
15394 efrain 723
        width: '100%',
724
    });
725
 
16791 efrain 726
    $('#job_description_id_boss').select2({
16918 efrain 727
        theme: 'bootstrap-5',
16787 efrain 728
        width: '100%',
729
    });
15394 efrain 730
 
731
 
16787 efrain 732
    oc = $('#chart-container').orgchart({
733
        'data' : datasource,
734
        'nodeId': 'uuid' ,
735
    });
15394 efrain 736
 
16787 efrain 737
 
738
 
739
 
740
    $.fn.refreshTree();
15394 efrain 741
});
742
 
14184 stevensc 743
JS;
66 efrain 744
$this->inlineScript()->captureEnd();
15394 efrain 745
?>
16770 efrain 746
 
747
 
14185 stevensc 748
 
16845 efrain 749
    <div class="container">
750
        <div class="row" id="row-lists">
16891 efrain 751
            <div class="col-12 mt-3">
15430 stevensc 752
                <div class="card">
16845 efrain 753
                	<div class="card-header">
754
                		<h6 class="card-title">LABEL_JOBS_DESCRIPTION</h6>
755
                	</div>
15430 stevensc 756
                    <div class="card-body">
16791 efrain 757
						<div id="chart-container" style="width: 100%; height: 600px">
758
            		 	</div>
15430 stevensc 759
                    </div>
760
                    <div class="card-footer clearfix">
16776 efrain 761
                		<div  style="float:right;" >
16992 efrain 762
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
15430 stevensc 763
                            <?php if ($allowAdd) : ?>
764
                                <?php if ($allowImport) : ?>
765
                                    <button type="button" class="btn btn-primary btn-import"><i class="fa fa-upload"></i> LABEL_IMPORT </button>
766
                                <?php endif; ?>
16770 efrain 767
                                <button type="button" class="btn btn-primary btn-add-job-description" data-link="<?php echo $routeAdd ?>"><i class="fa fa-plus"></i> LABEL_ADD </button>
15430 stevensc 768
                            <?php endif; ?>
769
                        </div>
770
                    </div>
771
                </div>
772
            </div>
773
        </div>
16845 efrain 774
 
15394 efrain 775
 
16845 efrain 776
 
777
 
778
	<div class="card"  id="row-form" style="display:none">
16776 efrain 779
        <div class="card-header">
16845 efrain 780
            <h6 class="modal-title">LABEL_JOB_DESCRIPTION</h6>
15430 stevensc 781
        </div>
16845 efrain 782
   		<?php
783
        $form = $this->form;
784
        $form->setAttributes([
785
            'method'    => 'post',
786
            'name'      => 'form',
787
            'id'        => 'form'
788
        ]);
15430 stevensc 789
 
16845 efrain 790
        $form->prepare();
791
        echo $this->form()->openTag($form);
15430 stevensc 792
 
16845 efrain 793
        $element = $form->get('competencies');
794
        echo $this->formHidden($element);
15430 stevensc 795
 
16845 efrain 796
        ?>
797
 		<div class="card-body">
798
 
799
			<ul class="nav nav-tabs" id="myTab" role="tablist">
800
              <li class="nav-item">
801
                <a class="nav-link active" id="custom-tabs-general-tab" data-bs-toggle="tab" href="#custom-tabs-general" role="tab" aria-controls="home" aria-selected="true">LABEL_GENERAL</a>
802
              </li>
803
              <li class="nav-item">
804
                <a class="nav-link" id="custom-tabs-compentencies-tab" data-bs-toggle="tab" href="#custom-tabs-compentencies" role="tab" aria-controls="custom-tabs-compentencies" aria-selected="false">LABEL_COMPETENCIES</a>
805
              </li>
15430 stevensc 806
 
16845 efrain 807
            </ul>
808
            <div class="tab-content border border-top-0 p-3" id="myTabContent">
809
              <div class="tab-pane fade show active" id="custom-tabs-general" role="tabpanel" aria-labelledby="custom-tabs-general-tab">
15430 stevensc 810
 
16845 efrain 811
 				<div class="row">
812
                                <div class="col-12 mt-3">
813
                           			<?php
814
                                    $element = $form->get('name');
815
                                    $element->setOptions(['label' => 'LABEL_NAME']);
816
                                    $element->setAttributes(['class' => 'form-control']);
15430 stevensc 817
 
16845 efrain 818
                                    echo $this->formLabel($element);
819
                                    echo $this->formText($element);
820
                                    ?>
821
                               	</div>
822
                          	</div>
823
                          	<div class="row">
824
                                <div class="col-12 mt-3">
15430 stevensc 825
                                        <label>LABEL_STATUS</label>
826
                                        <br />
827
                                        <?php
828
                                        $element = $form->get('status');
829
                                        $element->setOptions(['label' => 'LABEL_STATUS']);
830
                                        // echo $this->formLabel($element);
831
                                        echo $this->formCheckbox($element);
832
                                        ?>
16845 efrain 833
 
15430 stevensc 834
                                </div>
835
                            </div>
16845 efrain 836
                          	<div class="row">
837
                                <div class="col-12 mt-3">
15430 stevensc 838
                                <?php
839
                                $element = $form->get('objectives');
840
                                $element->setOptions(['label' => 'LABEL_OBJECTIVES']);
841
                                $element->setAttributes(['class' => 'form-control']);
842
 
843
                                echo $this->formLabel($element);
844
                                echo $this->formTextArea($element);
845
                                ?>
16845 efrain 846
                                </div>
15430 stevensc 847
                            </div>
16845 efrain 848
                          	<div class="row">
849
                                <div class="col-12 mt-3">
15430 stevensc 850
                                <?php
851
                                $element = $form->get('functions');
852
                                $element->setOptions(['label' => 'LABEL_FUNCTIONS']);
853
                                $element->setAttributes(['class' => 'form-control']);
854
 
855
                                echo $this->formLabel($element);
856
                                echo $this->formTextArea($element);
857
                                ?>
16845 efrain 858
                                </div>
15430 stevensc 859
                            </div>
16845 efrain 860
                          	<div class="row">
861
                                <div class="col-12 mt-3">
16787 efrain 862
                                <?php
863
                                $element = $form->get('job_description_id_boss');
864
                                $element->setOptions(['label' => 'LABEL_BOSS']);
865
                                $element->setAttributes(['class' => 'form-control']);
866
 
867
                                echo $this->formLabel($element);
868
                                echo $this->formSelect($element);
869
                                ?>
15430 stevensc 870
                                </div>
871
                            </div>
16845 efrain 872
 
873
 
874
              </div>
875
              <div class="tab-pane fade" id="custom-tabs-compentencies" role="tabpanel" aria-labelledby="custom-tabs-compentencies-tab">
876
 
877
           		<div class="row">
878
                	<div class="col-md-8 col-sm-8 col-xs-12 mt-3">
879
                 		<select id="select-competency" class="form-control"> </select>
880
               		</div>
881
                 	<div class="col-md-4 col-sm-4 col-xs-12 mt-3">
882
                 		<button type="button" class="btn btn-primary" id="btn-select-competency" data-toggle="tooltip" title="LABEL_ADD LABEL_COMPETENCY">LABEL_ADD LABEL_COMPETENCY</button>
883
             		</div>
884
              	</div>
885
                <div class="row">
886
             		<div class="col-12 mt-3" id="renderCompetencies">
887
             		</div>
888
            	</div>
889
 
890
              </div>
891
 
15394 efrain 892
            </div>
16845 efrain 893
 
16776 efrain 894
 
15430 stevensc 895
        </div>
16845 efrain 896
        <div class="card-footer text-right">
15430 stevensc 897
            <button type="submit" form="form" class="btn btn-primary">LABEL_SAVE</button>
16770 efrain 898
            <button type="button" class="btn btn-danger btn-edit-job-description-cancel">Cerrar</button>
15430 stevensc 899
        </div>
16845 efrain 900
         <?php echo $this->form()->closeTag($form); ?>
16776 efrain 901
	</div>
902
 
903
 
16845 efrain 904
 </div>
15394 efrain 905
 
906
 
907
<!--start modal behavior-->
15430 stevensc 908
<div id="modal-behavior" class="modal" tabindex="-1" role="dialog">
16778 efrain 909
	<form action="#" name="form-behavior" id="form-behavior">
910
        <div class="modal-dialog " role="document">
911
    		<input type="hidden" id="behavior-uuid" name="behavior-uuid" value="" />
912
       		<input type="hidden" id="competency-uuid" name="competency-uuid value="" />
913
       		<div class=" modal-content">
914
                <div class="modal-header">
16845 efrain 915
                    <h6 class="modal-title">LABEL_EDIT LABEL_LEVEL</h6>
16864 efrain 916
                     <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
16778 efrain 917
                </div>
918
                <div class="modal-body">
16845 efrain 919
             		<div class="row">
920
                		<div class="col-12 mt-3">
921
                              <label for="behavior-value">LABEL_LEVEL</label>
922
                              <input type="number" step="1" min="0" max="100" id="level" name="level">
923
                        </div>
924
                    </div>
925
               	</div>
16891 efrain 926
             	<div class="modal-footer text-right">
16845 efrain 927
                	<button type="button" class="btn btn-primary btn-behavior-submit">LABEL_SAVE</button>
16864 efrain 928
                 	<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close">LABEL_CLOSE</button>
16845 efrain 929
 
16778 efrain 930
            	</div>
931
        	</div>
932
    	</div>
933
	</form>
15394 efrain 934
</div>
15436 stevensc 935
 
15394 efrain 936
 
15443 efrain 937
 
15430 stevensc 938
<!---Template Competencies --->
939
<script id="competencyTemplate" type="text/x-jsrender">
940
    <div class="panel panel-default panel-competency" id="panel-{{:uuid}}" data-competency="{{:uuid}}">
15394 efrain 941
   <div class="panel-heading">
16845 efrain 942
      <h6 class="panel-title" style="    font-size: 18px;">
15394 efrain 943
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:uuid}}" href="#collapse-{{:uuid}}">
944
         <span class="section-name{{:uuid}}">
945
            {{:~getCompetencyType(competency_type_uuid).name}} - {{:~getCompetency(uuid).name}}
946
         </span>
947
         </a>
16845 efrain 948
      </h6>
15394 efrain 949
   </div>
950
   <div id="collapse-{{:uuid}}" class="panel-collapse in collapse show">
951
      <div class="panel-body">
952
         <div class="table-responsive">
953
            <table class="table table-bordered">
954
               <thead>
955
                  <tr>
956
                     <th style="width: 20%;">LABEL_ELEMENT</th>
957
                     <th style="width: 50%;">LABEL_TITLE</th>
958
                     <th style="width: 10%;">LABEL_LEVEL</th>
959
                     <th style="width: 20%;">LABEL_ACTIONS</th>
960
                  </tr>
961
               </thead>
962
               <tbody>
963
                  <tr>
964
                     <td class="text-left">LABEL_COMPETENCY</td>
965
                     <td class="text-left">{{:name}}</td>
966
                     <td>
967
                     </td>
968
                     <td>
16770 efrain 969
                        <button  type="button" class="btn btn-default btn-delete-job-description-competency" data-competency="{{:uuid}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_COMPETENCY"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_COMPETENCY </button>
15394 efrain 970
                     </td>
971
                  </tr>
972
                  {{for behaviors}}
973
                  <tr >
974
                     <td class="text-left">--LABEL_BEHAVIOR</td>
975
                     <td class="text-left">
976
                       {{:~getBehavior(uuid).description}}
977
                     </td>
15443 efrain 978
                     <td class="text-right">
979
                        {{:level}}
980
                     </td>
15394 efrain 981
                     <td>
16770 efrain 982
                        <button type="button"  class="btn btn-default btn-edit-job-description-behavior" data-behavior="{{:uuid}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_LEVEL"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_LEVEL</button>
15443 efrain 983
                     </td>
984
                  </tr>
985
                  {{/for}}
986
               </tbody>
987
            </table>
988
         </div>
989
      </div>
990
   </div>
991
</div>
992
</script>
993
 
994
<script id="competencyTemplateWithLevel" type="text/x-jsrender">
995
 <div class="panel panel-default panel-competency" id="panel-{{:uuid}}" data-competency="{{:uuid}}">
996
   <div class="panel-heading">
16845 efrain 997
      <h6 class="panel-title" style="    font-size: 18px;">
15443 efrain 998
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:uuid}}" href="#collapse-{{:uuid}}">
999
         <span class="section-name{{:uuid}}">
1000
            {{:~getCompetencyType(competency_type_uuid).name}} - {{:~getCompetency(uuid).name}}
1001
         </span>
1002
         </a>
16845 efrain 1003
      </h6>
15443 efrain 1004
   </div>
1005
   <div id="collapse-{{:uuid}}" class="panel-collapse in collapse show">
1006
      <div class="panel-body">
1007
         <div class="table-responsive">
1008
            <table class="table table-bordered">
1009
               <thead>
1010
                  <tr>
1011
                     <th style="width: 20%;">LABEL_ELEMENT</th>
1012
                     <th style="width: 50%;">LABEL_TITLE</th>
1013
                     <th style="width: 10%;">LABEL_LEVEL</th>
1014
                     <th style="width: 20%;">LABEL_ACTIONS</th>
1015
                  </tr>
1016
               </thead>
1017
               <tbody>
1018
                  <tr>
1019
                     <td class="text-left">LABEL_COMPETENCY</td>
1020
                     <td class="text-left">{{:name}}</td>
1021
                     <td>
1022
                     </td>
1023
                     <td>
16770 efrain 1024
                        <button  type="button" class="btn btn-default btn-delete-job-description-competency" data-competency="{{:uuid}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_COMPETENCY"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_COMPETENCY </button>
15443 efrain 1025
                     </td>
1026
                  </tr>
1027
                  {{for behaviors}}
1028
                  <tr >
1029
                     <td class="text-left">--LABEL_BEHAVIOR</td>
1030
                     <td class="text-left">
1031
                       {{:~getBehavior(uuid).description}}
1032
                     </td>
1033
                     <td>
15394 efrain 1034
                        {{if level == '0'}} LABEL_NA {{/if}}
1035
                        {{if level == '1' }} LABEL_LEVEL_ONE {{/if}}
1036
                        {{if level == '2' }} LABEL_LEVEL_TWO {{/if}}
1037
                        {{if level == '3' }} LABEL_LEVEL_THREE {{/if}}
1038
                        {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}}
1039
                     </td>
1040
                     <td>
16770 efrain 1041
                        <button type="button"  class="btn btn-default btn-edit-job-description-behavior" data-behavior="{{:uuid}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_LEVEL"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_LEVEL</button>
15394 efrain 1042
                     </td>
1043
                  </tr>
1044
                  {{/for}}
1045
               </tbody>
1046
            </table>
1047
         </div>
1048
      </div>
1049
   </div>
1050
</div>
1051
</script>
1052
 
16770 efrain 1053
<script id="listJobDescriptionTemplate" type="text/x-jsrender">
16779 efrain 1054
	<li data-id="{{:uuid}}" >
1055
        <div class="content">
1056
 
1057
 
1058
 
1059
        <div class="sidebar {{if status == '<?php echo JobDescription::STATUS_INACTIVE ?>' }} sidebar-inactive {{/if}}">
1060
 
16778 efrain 1061
        {{>name}}
16779 efrain 1062
        <div class="float-right right-sidebar">
16778 efrain 1063
            {{if status == '<?php echo JobDescription::STATUS_ACTIVE ?>' }}
16770 efrain 1064
            {{if link_add }}
1065
            <i class="fa fa-plus btn-add-job-description" data-link="{{:link_add}}"></i>&nbsp;
1066
            {{/if}}
16778 efrain 1067
            {{/if}}
16770 efrain 1068
            {{if link_edit }}
16906 efrain 1069
            <i class="fa-pen btn-edit-job-description" data-link="{{:link_edit}}"></i>&nbsp;
16770 efrain 1070
            {{/if}}
1071
            {{if link_delete }}
1072
            <i class="fa fa-trash btn-delete-job-description" data-link="{{:link_delete}}"></i>&nbsp;
1073
            {{/if}}
16778 efrain 1074
            {{if status == '<?php echo JobDescription::STATUS_ACTIVE ?>' }}
16770 efrain 1075
            {{if link_report }}
1076
            <i class="fa fa-file-o btn-pdf-job-description" data-link="{{:link_report}}"></i>&nbsp;
1077
            {{/if}}
16778 efrain 1078
            {{/if}}
16770 efrain 1079
        </div>
16779 efrain 1080
        </div>
1081
        </div>
16770 efrain 1082
        <ol>
1083
	   {{for children tmpl="#listJobDescriptionTemplate"/}}
1084
	   </ol>
1085
	</li>
1086
</script>
15394 efrain 1087