Proyectos de Subversion LeadersLinked - Backend

Rev

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