Proyectos de Subversion LeadersLinked - Backend

Rev

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