Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 4130 | Rev 4132 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3896 stevensc 1
<?php
1 www 2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
 
8
$routeAdd       = $this->url('settings/competencies/add');
9
$routeDatatable = $this->url('settings/competencies');
28 efrain 10
$routeImport    = $this->url('settings/competencies/import');
1 www 11
 
1107 geraldo 12
 
13
$routeAddBehavior    = $this->url('settings/behaviors/add');
14
 
1108 geraldo 15
 
1107 geraldo 16
$routeImport    = $this->url('settings/competencies/import');
17
 
18
 
28 efrain 19
$allowAdd       = $acl->isAllowed($roleName, 'settings/competencies/add') ? 1 : 0;
20
$allowEdit      = $acl->isAllowed($roleName, 'settings/competencies/edit') ? 1 : 0;
21
$allowDelete    = $acl->isAllowed($roleName, 'settings/competencies/delete') ? 1 : 0;
22
$allowImport    = $acl->isAllowed($roleName, 'settings/competencies/import') ? 1 : 0;
1 www 23
 
24
 
25
 
26
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
27
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
28
 
29
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
30
 
31
 
32
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
34
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
35
 
36
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
38
 
39
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
40
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
41
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
42
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
43
 
44
 
45
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
46
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
47
 
48
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
49
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
50
 
51
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.js'));
52
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/i18n/es.js'));
53
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.css'));
54
 
55
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.css'));
56
 
874 geraldo 57
// JsRender //
58
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
1 www 59
 
883 geraldo 60
// bootbox Alert //
61
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
1 www 62
 
883 geraldo 63
 
1 www 64
$status_active = \LeadersLinked\Model\Competency::STATUS_ACTIVE;
65
 
66
$this->inlineScript()->captureStart();
67
echo <<<JS
877 geraldo 68
let behaviors = [];
69
jQuery(document).ready(function($) {
863 geraldo 70
    $.validator.setDefaults({
71
        debug: true,
72
        highlight: function(element) {
73
            $(element).addClass('is-invalid');
74
        },
75
        unhighlight: function(element) {
76
            $(element).removeClass('is-invalid');
77
        },
78
        errorElement: 'span',
79
        errorClass: 'error invalid-feedback',
80
        errorPlacement: function(error, element) {
81
            const child = element.children(':first-child');
82
            if (element[0].localName == 'input') {
83
                let _error = error
84
                _error[0].style.display = 'block'
85
                _error.insertBefore(element);
86
            } else if (element.parent('.form-group').length) {
87
                error.insertAfter(element);
88
            } else if (element.parent('.toggle').length) {
89
                error.insertAfter(element.parent().parent());
90
            } else {
91
                error.insertAfter(element.parent());
92
            }
93
        }
94
    });
95
    $.fn.showFormErrorValidator = function(fieldname, errors) {
96
        var field = $(fieldname);
97
        if (field) {
98
            $(field).addClass('is-invalid');
99
            var error = $('<span id="' + fieldname + '-error" class="error invalid-feedback">' + errors + '</div>');
100
            if (field.parent('.form-group').length) {
101
                error.insertAfter(field);
102
            } else if (field.parent('.toggle').length) {
103
                error.insertAfter(field.parent().parent());
104
            } else {
105
                error.insertAfter(field.parent());
106
            }
107
        }
108
    };
109
    var allowEdit = $allowEdit;
110
    var allowDelete = $allowDelete;
111
    var gridTable = $('#gridTable').dataTable({
112
        'processing': true,
113
        'serverSide': true,
114
        'searching': true,
115
        'order': [
116
            [0, 'asc']
117
        ],
118
        'ordering': true,
119
        'ordenable': true,
120
        'responsive': true,
121
        'select': false,
122
        'paging': true,
123
        'pagingType': 'simple_numbers',
124
        'ajax': {
125
            'url': '$routeDatatable',
126
            'type': 'get',
127
            'beforeSend': function(request) {
128
                NProgress.start();
1 www 129
            },
863 geraldo 130
            'dataFilter': function(response) {
131
                var response = jQuery.parseJSON(response);
132
                var json = {};
133
                json.recordsTotal = 0;
134
                json.recordsFiltered = 0;
135
                json.data = [];
136
                if (response.success) {
137
                    json.recordsTotal = response.data.total;
138
                    json.recordsFiltered = response.data.total;
139
                    json.data = response.data.items;
1 www 140
                } else {
863 geraldo 141
                    $.fn.showError(response.data)
1 www 142
                }
863 geraldo 143
                return JSON.stringify(json);
1 www 144
            }
863 geraldo 145
        },
146
        'language': {
147
            'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
148
            'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
149
            'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
150
            'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
151
            'sInfo': 'LABEL_DATATABLE_SINFO',
152
            'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
153
            'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
154
            'sInfoPostFix': '',
155
            'sSearch': 'LABEL_DATATABLE_SSEARCH',
156
            'sUrl': '',
157
            'sInfoThousands': ',',
158
            'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
159
            'oPaginate': {
160
                'sFirst': 'LABEL_DATATABLE_SFIRST',
161
                'sLast': 'LABEL_DATATABLE_SLAST',
162
                'sNext': 'LABEL_DATATABLE_SNEXT',
163
                'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
164
            },
165
            'oAria': {
166
                'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
167
                'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
168
            },
169
        },
4116 stevensc 170
        'drawCallback': function(settings) {
171
            NProgress.done();
172
            $('button.btn-delete').confirmation({
173
                rootSelector: 'button.btn-delete',
174
                title: 'LABEL_ARE_YOU_SURE',
175
                singleton: true,
176
                btnOkLabel: 'LABEL_YES',
177
                btnCancelLabel: 'LABEL_NO',
178
                onConfirm: function(value) {
179
                    action = $(this).data('href');
180
                    NProgress.start();
181
                    $.ajax({
182
                        'dataType': 'json',
183
                        'accept': 'application/json',
184
                        'method': 'post',
185
                        'url': action,
186
                    }).done(function(response) {
187
                        if (response['success']) {
188
                            $.fn.showSuccess(response['data']);
189
                            gridTable.api().ajax.reload(null, false);
190
                        } else {
191
                            $.fn.showError(response['data']);
192
                        }
193
                    }).fail(function(jqXHR, textStatus, errorThrown) {
194
                        $.fn.showError(textStatus);
195
                    }).always(function() {
196
                        NProgress.done();
197
                    });
198
                }
199
            });
200
        },
863 geraldo 201
        'aoColumns': [{
202
                'mDataProp': 'type'
203
            },
204
            {
205
                'mDataProp': 'name'
206
            },
207
            {
208
                'mDataProp': 'status'
209
            },
210
            {
211
                'mDataProp': 'actions'
212
            },
213
        ],
214
        'columnDefs': [{
215
                'targets': 0,
216
                'className': 'text-vertical-middle',
217
            },
218
            {
219
                'targets': 1,
220
                'className': 'text-vertical-middle',
221
            },
222
            {
223
                'targets': -2,
224
                'orderable': false,
225
                'className': 'text-center',
226
                'render': function(data, type, row) {
227
                    checked = data == 'a' ? ' checked="checked" ' : '';
228
                    return '<div class="checkbox checkbox-success">' +
229
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
230
                        '<label ></label></div>';
1 www 231
                }
232
            },
863 geraldo 233
            {
234
                'targets': -1,
235
                'orderable': false,
236
                'render': function(data, type, row) {
237
                    s = '';
238
                    if (allowEdit) {
239
                        s = s + '<button class="btn btn-primary btn-edit" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
1 www 240
                    }
863 geraldo 241
                    if (allowDelete) {
4131 stevensc 242
                        s = s + '<button
4130 stevensc 243
                                class="btn btn-danger btn-delete"
244
                                data-href="' + data['link_delete'] + '"
245
                                data-toggle="delete-confirmation"
246
                                data-popout="true"
247
                                title="LABEL_DELETE"
248
                            >
249
                                <i class="fa fa-trash"></i>
250
                                LABEL_DELETE
251
                            </button>&nbsp;';
1 www 252
                    }
863 geraldo 253
                    return s;
1 www 254
                }
863 geraldo 255
            }
256
        ],
257
    });
258
    var validator = $('#form').validate({
259
        debug: true,
260
        onclick: false,
261
        onkeyup: false,
262
        ignore: [],
263
        rules: {
264
            'competency_type_id': {
265
                required: true,
266
            },
267
            'name': {
268
                required: true,
269
                maxlength: 128,
270
            },
271
            'description': {
272
                updateCkeditor: function() {
273
                    CKEDITOR.instances.description.updateElement();
1 www 274
                },
863 geraldo 275
                required: true,
1 www 276
            },
863 geraldo 277
            'status': {
278
                required: false,
1 www 279
            },
863 geraldo 280
        },
281
        submitHandler: function(form) {
893 geraldo 282
            if (behaviors.length == 0) {
1085 geraldo 283
                $.fn.showError('ERROR_NOT_OBSERVABLE_CONDUCT');
893 geraldo 284
            } else {
891 geraldo 285
                $.ajax({
893 geraldo 286
                    'dataType': 'json',
287
                    'accept': 'application/json',
288
                    'method': 'post',
289
                    'url': $('#form').attr('action'),
290
                    'data': {
291
                        'name': $('#name').val(),
292
                        'description': $('#description').val(),
293
                        'competency_type_id': $('#competency_type_id').val(),
294
                        'status': $('#status').val(),
295
                        'behaviors': JSON.stringify(behaviors)
296
                    }
297
                }).done(function(response) {
298
                    NProgress.start();
299
                    if (response['success']) {
300
                        $.fn.showSuccess(response['data']);
301
                        $('#row-form').hide();
302
                        $('#row-list').show();
303
                        gridTable.api().ajax.reload(null, false);
863 geraldo 304
                    } else {
893 geraldo 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
                        }
863 geraldo 313
                    }
893 geraldo 314
                }).fail(function(jqXHR, textStatus, errorThrown) {
315
                    $.fn.showError(textStatus);
316
                }).always(function() {
317
                    NProgress.done();
318
                });
891 geraldo 319
            }
28 efrain 320
            return false;
863 geraldo 321
        },
322
        invalidHandler: function(form, validator) {}
323
    });
324
    $('body').on('click', 'button.btn-add', function(e) {
325
        e.preventDefault();
326
        $('span[id="form-title"]').html('LABEL_ADD');
327
        $('#form').attr('action', '$routeAdd');
328
        $('#form #name').val('');
329
        $('#form #competency_type_id').val('').trigger('change');
330
        $('#form #status').bootstrapToggle('on');
1115 geraldo 331
        behaviors = [];
863 geraldo 332
        CKEDITOR.instances.description.setData('');
333
        validator.resetForm();
866 geraldo 334
        $('#row-form').show();
873 geraldo 335
        $('#row-list').hide();
1132 geraldo 336
        renderData([]);
863 geraldo 337
        return false;
338
    });
339
    $('body').on('click', 'button.btn-edit', function(e) {
340
        e.preventDefault();
341
        NProgress.start();
342
        var action = $(this).data('href');
343
        $.ajax({
344
            'dataType': 'json',
345
            'method': 'get',
346
            'url': action,
347
        }).done(function(response) {
348
            if (response['success']) {
349
                $('span[id="form-title"]').html('LABEL_EDIT');
350
                $('#form').attr('action', action);
351
                $('#form #name').val(response['data']['name']);
352
                $('#form #competency_type_id').val(response['data']['competency_type_id']).trigger('change');
353
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
354
                CKEDITOR.instances.description.setData(response['data']['description']);
1115 geraldo 355
                behaviors = response['data']['behaviors'] || [];
901 geraldo 356
                renderData(behaviors);
863 geraldo 357
                validator.resetForm();
866 geraldo 358
                $('#row-form').show();
873 geraldo 359
                $('#row-list').hide();
863 geraldo 360
            } else {
361
                $.fn.showError(response['data']);
362
            }
363
        }).fail(function(jqXHR, textStatus, errorThrown) {
364
            $.fn.showError(textStatus);
365
        }).always(function() {
366
            NProgress.done();
28 efrain 367
        });
863 geraldo 368
        return false;
369
    });
370
    $('body').on('click', 'button.btn-refresh', function(e) {
371
        e.preventDefault();
372
        gridTable.api().ajax.reload(null, false);
373
        return false;
374
    });
375
    $('body').on('click', 'button.btn-import', function(e) {
376
        e.preventDefault();
377
        NProgress.start();
378
        $.ajax({
379
            'dataType': 'json',
380
            'method': 'post',
381
            'url': '$routeImport',
382
        }).done(function(response) {
383
            if (response['success']) {
384
                $.fn.showSuccess(response['data']);
385
                gridTable.api().ajax.reload(null, false);
386
            } else {
387
                $.fn.showError(response['data']);
388
            }
389
        }).fail(function(jqXHR, textStatus, errorThrown) {
390
            $.fn.showError(textStatus);
391
        }).always(function() {
392
            NProgress.done();
1 www 393
        });
863 geraldo 394
        return false;
395
    });
396
    $('body').on('click', 'button.btn-cancel', function(e) {
397
        e.preventDefault();
398
        $('#modal').modal('hide');
399
    });
400
    $('#form #competency_type_id').select2({
401
        theme: 'bootstrap4',
402
        width: '100%',
403
    });
1226 geraldo 404
 
405
    $('#select-conduct').select2({
406
        theme: 'bootstrap4',
407
        width: '100%',
408
    });
409
 
863 geraldo 410
    $('#form #status').bootstrapToggle({
411
        'on': 'LABEL_ACTIVE',
412
        'off': 'LABEL_INACTIVE',
413
        'width': '160px',
414
        'height': '40px'
415
    });
3842 stevensc 416
    CKEDITOR.replace('description', {
417
        toolbar: [
418
            { name: 'editing', items: [ 'Scayt' ] },
419
            { name: 'links', items: [ 'Link', 'Unlink'] },
420
            { name: 'paragraph', items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote' ] },
421
            { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Strike', 'RemoveFormat' ] },
422
            '/',
423
            { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar' ] },
424
            { name: 'styles', items: [ 'Styles', 'Format' ] },
425
            { name: 'tools', items: [ 'Maximize' ] }
426
        ],
3926 stevensc 427
        removePlugins: 'elementspath,Anchor',
3842 stevensc 428
        heigth: 100
429
    });
863 geraldo 430
    /**
862 geraldo 431
     * Clicked on add new conduct
432
     */
433
    $('body').on('click', 'button[id="btn-add-conduct"]', function(e) {
434
        e.preventDefault();
435
        $('#form-conduct #conduct-id').val('');
436
        $('#form-conduct #conduct-description').val('');
437
        $('#modal-conduct h4[class="modal-title"]').html('LABEL_ADD LABEL_CONDUCT');
438
        $('#modal-conduct').modal('show');
1 www 439
    });
862 geraldo 440
    /**
441
     * Clicked on edit conduct
442
     */
443
    $('body').on('click', 'button.btn-edit-conduct', function(e) {
444
        e.preventDefault();
877 geraldo 445
        var id = $(this).data('conduct');
446
        behaviors.map((item) => {
447
            if (item.id == id) {
882 geraldo 448
                $('#form-conduct #conduct-id').val(item.id);
449
                $('#form-conduct #conduct-description').val(item.description);
877 geraldo 450
                $('#modal-conduct h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
451
                $('#modal-conduct').modal('show');
862 geraldo 452
                return;
453
            }
877 geraldo 454
        });
862 geraldo 455
    });
456
    /**
457
     * Clicked on remove conduct
458
     */
459
    $('body').on('click', 'button.btn-delete-conduct', function(e) {
460
        e.preventDefault();
888 geraldo 461
        var id = $(this).data('conduct');
862 geraldo 462
        bootbox.confirm({
463
            title: "LABEL_DELETE LABEL_CONDUCT",
464
            message: "LABEL_QUESTION_DELETE",
465
            buttons: {
466
                cancel: {
467
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
468
                },
469
                confirm: {
470
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
471
                }
472
            },
473
            callback: function(result) {
886 geraldo 474
                if (result) {
888 geraldo 475
                    removeBehavior(id);
886 geraldo 476
                }
862 geraldo 477
            }
478
        });
479
    });
863 geraldo 480
    /**
879 geraldo 481
     * Clicked cancel new/edit Form
863 geraldo 482
     */
879 geraldo 483
    $('button.btn-conduct-submit').click(function(e) {
893 geraldo 484
        if ($("#conduct-description").val() == "") {
1085 geraldo 485
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
883 geraldo 486
            return;
893 geraldo 487
        } else {
3896 stevensc 488
            $("#conduct-id").val() == ""
489
                ?addBehavior($("#conduct-description").val())
490
                :editBehavior($("#conduct-id").val(), $("#conduct-description").val())
893 geraldo 491
            $('#modal-conduct').modal('hide');
492
            return;
863 geraldo 493
        }
862 geraldo 494
    });
873 geraldo 495
    /**
496
     * Clicked cancel new/edit Form
497
     */
498
    $('button.btn-edit-cancel').click(function(e) {
499
        e.preventDefault();
500
        $('#row-form').hide();
501
        $('#row-list').show();
502
    });
874 geraldo 503
    /**
504
     * Add Behavior to array
505
     */
1101 geraldo 506
    const addBehavior = (description) => {
1113 geraldo 507
        $.ajax({
1115 geraldo 508
            'dataType': 'json',
509
            'accept': 'application/json',
510
            'method': 'post',
511
            'url': '$routeAddBehavior',
512
            'data': {
513
                'description': description
514
            }
515
        }).done(function(response) {
516
            if (response['success']) {
517
                behaviors.push({
1133 geraldo 518
                    'id': response['uuid'],
1115 geraldo 519
                    'description': description
520
                });
521
                renderData(behaviors);
522
            } else {
523
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
524
            }
878 geraldo 525
        });
874 geraldo 526
    }
527
    /**
528
     * Edit item behavior
529
     */
1101 geraldo 530
    const editBehavior = (id, description) => {
1115 geraldo 531
        $.ajax({
532
            'dataType': 'json',
533
            'accept': 'application/json',
534
            'method': 'post',
535
            'url': '/settings/behaviors/edit/' + id,
536
            'data': {
537
                'description': description
874 geraldo 538
            }
1115 geraldo 539
        }).done(function(response) {
540
            if (response['success']) {
541
                behaviors.map((item) => {
542
                    if (item.id == id) {
543
                        item.description = description;
544
                    }
545
                });
546
                renderData(behaviors);
547
            } else {
548
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
549
            }
874 geraldo 550
        });
551
    }
552
    /**
553
     * Remove behavior
554
     */
877 geraldo 555
    const removeBehavior = (id) => {
3896 stevensc 556
        $.ajax({
557
            'dataType': 'json',
558
            'accept': 'application/json',
3908 stevensc 559
            'method': 'post',
3896 stevensc 560
            'url': '/settings/behaviors/delete/' + id,
561
        })
562
        .done(function(response) {
563
            if (response['success']) {
564
                behaviors = behaviors.filter((item) => item.id != id);
565
                renderData(behaviors);
566
            } else {
567
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
568
            }
569
        })
874 geraldo 570
    }
877 geraldo 571
    /**
874 geraldo 572
     * Render Sections data
573
     */
1129 geraldo 574
    const renderData = (data) => {
575
        getAllBehaviors();
1133 geraldo 576
        data.length > 0 ?
577
            $("#rows").html($("#behaviorTemplate").render(data)) :
1132 geraldo 578
            $("#rows").html('')
1129 geraldo 579
    }
1127 geraldo 580
    /**
581
     * get alls Behavios
582
     */
1129 geraldo 583
    const getAllBehaviors = () => {
1154 geraldo 584
        $('#select-conduct').children().remove();
585
        $('#select-conduct').append($('<option>', {
586
            value: '',
587
            text: 'LABEL_SELECT'
588
        }));
1127 geraldo 589
        $.getJSON("/settings/behaviors", function(data) {
590
            $.each(data.data, function(i, item) {
1162 geraldo 591
                console.log(filterItemById(item.uuid));
1163 geraldo 592
                if (!filterItemById(item.uuid)) {
1129 geraldo 593
                    $('#select-conduct').append($('<option>', {
1133 geraldo 594
                        value: item.uuid,
595
                        text: item.description
596
                    }));
1129 geraldo 597
                }
1127 geraldo 598
            });
1115 geraldo 599
        });
600
    }
1127 geraldo 601
    /**
602
     * Clicked cancel new/edit Form
603
     */
1128 geraldo 604
    $('body').on('click', 'button[id="btn-select-conduct"]', function(e) {
1127 geraldo 605
        if ($("#select-conduct").val() == "") {
606
            $.fn.showError('LABEL_ERROR_SELECT_CONDUCT');
607
        } else {
608
            behaviors.push({
609
                'id': $("#select-conduct").val(),
610
                'description': $('select[name="select-conduct"] option:selected').text()
611
            });
612
            renderData(behaviors);
613
        }
614
    });
1161 geraldo 615
    /**
616
     * Filter section selected
617
     */
618
    const filterItemById = (id) => behaviors.filter((item) => item.id == id ? item : false)[0];
863 geraldo 619
});
1115 geraldo 620
 
1 www 621
JS;
622
$this->inlineScript()->captureEnd();
623
?>
3896 stevensc 624
 
1 www 625
<!-- Content Header (Page header) -->
626
<section class="content-header">
3896 stevensc 627
    <div class="container-fluid">
628
        <div class="row mb-2">
629
            <div class="col-sm-12">
630
                <h1>LABEL_COMPETENCIES</h1>
631
            </div>
632
        </div>
633
    </div>
634
    <!-- /.container-fluid -->
1 www 635
</section>
873 geraldo 636
<section class="content" id="row-list">
3896 stevensc 637
    <div class="container-fluid">
638
        <div class="row">
639
            <div class="col-12">
640
                <div class="card">
641
                    <div class="card-body">
642
                        <table id="gridTable" class="table   table-hover">
643
                            <thead>
644
                                <tr>
645
                                    <th>LABEL_TYPE</th>
646
                                    <th>LABEL_NAME</th>
647
                                    <th>LABEL_ACTIVE</th>
648
                                    <th>LABEL_ACTIONS</th>
649
                                </tr>
650
                            </thead>
651
                            <tbody>
652
                            </tbody>
653
                        </table>
654
                    </div>
655
                    <div class="card-footer clearfix">
656
                        <div style="float:right;">
657
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
658
                            <?php if ($allowImport) : ?>
659
                                <button type="button" class="btn btn-primary btn-import"><i class="fa fa-upload"></i> LABEL_IMPORT </button>
660
                            <?php endif; ?>
661
                            <?php if ($allowAdd) : ?>
662
                                <button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
663
                            <?php endif; ?>
664
                        </div>
665
                    </div>
666
                </div>
890 geraldo 667
            </div>
3896 stevensc 668
        </div>
669
    </div>
890 geraldo 670
</section>
865 geraldo 671
<!-- The Form creation -->
672
<section class="content" id="row-form" style="display: none">
3896 stevensc 673
    <div class="container-fluid">
674
        <div class="row">
675
            <div class="col-md-12 col-sm-12 col-12">
676
                <div class="panel">
677
                    <div class="panel-body">
1110 geraldo 678
                        <?php
3896 stevensc 679
                        $form = $this->form;
680
                        $form->setAttributes([
681
                            'method'    => 'post',
682
                            'name'      => 'form',
683
                            'id'        => 'form'
684
                        ]);
685
 
686
                        $form->prepare();
687
                        echo $this->form()->openTag($form);
688
                        ?>
1111 geraldo 689
                        <div class="row">
3896 stevensc 690
                            <div class="col-md-4 col-sm-12 col-12">
691
                                <div class="from-group">
692
                                    <?php
693
                                    $element = $form->get('competency_type_id');
694
                                    $element->setOptions(['label' => 'LABEL_TYPE']);
695
 
696
                                    echo $this->formLabel($element);
697
                                    echo $this->formSelect($element);
698
                                    ?>
699
                                </div>
700
                            </div>
701
                            <div class="col-md-4 col-sm-12 col-12">
702
                                <div class="from-group">
703
                                    <?php
704
                                    $element = $form->get('name');
705
                                    $element->setOptions(['label' => 'LABEL_NAME']);
706
                                    $element->setAttributes(['class' => 'form-control']);
707
 
708
                                    echo $this->formLabel($element);
709
                                    echo $this->formText($element);
710
                                    ?>
711
                                </div>
712
                            </div>
713
                            <div class="col-md-4 col-sm-12 col-12">
714
                                <div class="from-group">
715
                                    <label>LABEL_STATUS</label>
716
                                    <br />
717
                                    <?php
718
                                    $element = $form->get('status');
719
                                    $element->setOptions(['label' => 'LABEL_STATUS']);
720
                                    // echo $this->formLabel($element);
721
                                    echo $this->formCheckbox($element);
722
                                    ?>
723
                                </div>
724
                            </div>
725
                            <div class="col-md-12 col-sm-12 col-12">
726
                                <div class="form-group">
727
                                    <?php
728
                                    $element = $form->get('description');
729
                                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
730
                                    $element->setAttributes(['class' => 'form-control']);
731
 
732
                                    echo $this->formLabel($element);
733
                                    echo $this->formTextArea($element);
734
                                    ?>
735
                                </div>
736
                            </div>
737
                            <?php echo $this->form()->closeTag($form); ?>
738
                            <div class="col-md-12 col-sm-12 col-12">
739
                                <div class="form-group">
740
                                    <div class="row">
741
                                        <div class="col-md-4 col-sm-4 col-xs-12">
742
                                            <select name="select-conduct" id="select-conduct" class="form-control">
743
                                            </select>
744
                                        </div>
745
                                        <div class="col-md-4 col-sm-4 col-xs-12">
746
                                            <button type="button" class="btn btn-primary" id="btn-select-conduct" data-toggle="tooltip" title="LABEL_ADD LABEL_CONDUCT">LABEL_ADD LABEL_CONDUCT</button>
747
                                        </div>
748
                                        <div class="col-md-4 col-sm-4 col-xs-12 text-right">
749
                                            <button type="button" class="btn btn-primary" id="btn-add-conduct" data-toggle="tooltip" title="LABEL_NEWS LABEL_CONDUCT"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_NEWS LABEL_CONDUCT</button>
750
                                        </div>
751
                                    </div>
752
                                </div>
753
                            </div>
1111 geraldo 754
                        </div>
3896 stevensc 755
                        <div class="col-xs-12 col-md-12">
756
                            <br />
757
                            <div class="table-responsive">
758
                                <table class="table table-bordered">
759
                                    <thead>
760
                                        <tr>
761
                                            <th style="width: 60%;">LABEL_DESCRIPTION</th>
762
                                            <th style="width: 20%;">LABEL_ACTIONS</th>
763
                                        </tr>
764
                                    </thead>
765
                                    <tbody id="rows"></tbody>
766
                                </table>
767
                            </div>
768
                            <div class="col-xs-12 col-md-12">
769
                                <div class="form-group">
770
                                    <button type="submit" form="form" class="btn btn-primary">LABEL_SAVE</button>
771
                                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
772
                                </div>
773
                            </div>
774
                        </div>
775
                    </div>
776
                </div>
865 geraldo 777
            </div>
3896 stevensc 778
        </div>
865 geraldo 779
</section>
890 geraldo 780
<!---end form--->
781
<!--start modal conduct-->
3896 stevensc 782
<div id="modal-conduct" class="modal" tabindex="-1" role="dialog">
783
    <div class="modal-dialog modal-lg" role="document">
784
        <form action="#" name="form-conduct" id="form-conduct">
785
            <input type="hidden" name="conduct-id" id="conduct-id" value="" />
786
            <input type="hidden" name="conduct-competencia" id="conduct-competencia" value="" />
787
            <div class="modal-content">
788
                <div class="modal-header">
789
                    <h4 class="modal-title">LABEL_ADD LABEL_CONDUCT</h4>
790
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
791
                        <span aria-hidden="true">&times;</span>
792
                    </button>
793
                </div>
794
                <div class="modal-body">
795
                    <div class="form-group">
796
                        <label for="conduct-name">LABEL_DESCRIPTION</label>
797
                        <input type="text" name="conduct-description" id="conduct-description" class="form-control" maxlength="200" value="" />
798
                    </div>
799
                </div>
800
                <div class="modal-footer">
801
                    <button type="button" class="btn btn-primary btn-conduct-submit">LABEL_SAVE</button>
802
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
803
                </div>
861 geraldo 804
            </div>
3896 stevensc 805
        </form>
806
    </div>
861 geraldo 807
</div>
890 geraldo 808
<!---end modal conduct --->
809
<!--start template--->
874 geraldo 810
<script id="behaviorTemplate" type="text/x-jsrender">
3896 stevensc 811
    <tr>
1105 geraldo 812
       <td class="text-left">{{:description}}</td>
890 geraldo 813
       <td>
814
           <button class="btn btn-default btn-edit-conduct" data-conduct="{{:id}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT</button>
815
           <button class="btn btn-default btn-delete-conduct" data-conduct="{{:id}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE</button>
816
       </td>
817
   </tr>
818
</script>
819
<!--end template--->