Proyectos de Subversion LeadersLinked - Backend

Rev

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