Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16840 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

use LeadersLinked\Model\JobDescription;

$acl            = $this->viewModel()->getRoot()->getVariable('acl');
$currentUser    = $this->currentUserHelper();

$roleName = $currentUser->getUserTypeId();


$routeAdd       = $this->url('jobs-description/add');
$routeDatatable = $this->url('jobs-description');
$routeImport    = $this->url('jobs-description/import');
$routeDashboard = $this->url('dashboard');

$allowAdd               = $acl->isAllowed($roleName, 'jobs-description/add') ? 1 : 0;
$allowEdit              = $acl->isAllowed($roleName, 'jobs-description/edit') ? 1 : 0;
$allowDelete            = $acl->isAllowed($roleName, 'jobs-description/delete') ? 1 : 0;
$allowReport            = $acl->isAllowed($roleName, 'jobs-description/report') ? 1 : 0;
$allowImport            = $acl->isAllowed($roleName, 'jobs-description/import') ? 1 : 0;


$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));

$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-maxlenght/bootstrap-maxlength.min.js'));


$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/jquery.validate.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/additional-methods.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-validation/localization/messages_es.js'));

$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));

$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));


$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));






$this->headLink()->appendStylesheet($this->basePath('css/jquery-sortable.css'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-sortable/jquery-sortable.js'));


$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/i18n/es.js'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.css'));

$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap4-theme/select2-bootstrap4.css'));


// bootbox Alert //


// JsRender //
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.min.js'));


$status_active = JobDescription::STATUS_ACTIVE;
$status_inactive = JobDescription::STATUS_INACTIVE;

$this->inlineScript()->captureStart();
echo <<<JS


jQuery(document).ready(function($) {



    var competencies_selected = new Array(); 
    var behaviors = new Array();
    var competency_types = new Array(); 
    var competencies = new Array(); 

    var allowEdit = $allowEdit;
    var allowDelete = $allowDelete;
    var allowReport = $allowReport;


    $.fn.renderCompetencies = function() {
        if(competencies_selected.length > 0) {


            $('#renderCompetencies').html($('#competencyTemplate').render(competencies_selected, {
                getCompetencyType: (uuid) => competency_types.filter((item) => item.uuid == uuid ? item : false)[0],
                getCompetency: (uuid) => competencies.filter((item) => item.uuid == uuid ? item : false)[0],
                getBehavior: (uuid) => behaviors.filter((item) => item.uuid == uuid ? item : false)[0]
            }));
        } else {
            $('#renderCompetencies').html('');
        }
    }

    $.fn.comboCompetencies = function() {
        $('#select-competency').children().remove();
        $.each(competency_types, function(i, competency_type) {
            competencies_filtered = competencies.filter((item) => item.competency_type_uuid == competency_type.uuid ? item : false)
            $.each(competencies_filtered, function(i, competency) {


                selected = competencies_selected.filter((item) => item.uuid == competency.uuid ? item : false)[0];
                if(!selected) {
                    $('#select-competency').append($('<option>', {
                        value: competency.uuid,
                        text: competency_type.name +  ' - ' + competency.name
                    }));
                }

            });
        });    

    }



    $.validator.setDefaults({
        debug: true,
        highlight: function(element) {
            $(element).addClass('is-invalid');
        },
        unhighlight: function(element) {
            $(element).removeClass('is-invalid');
        },
        errorElement: 'span',
        errorClass: 'error invalid-feedback',
        errorPlacement: function(error, element) {
            if (element.parent('.form-group').length) {
                error.insertAfter(element);
            } else if (element.parent('.toggle').length) {
                error.insertAfter(element.parent().parent());
            } else {
                error.insertAfter(element.parent());
            }
        }
    });

    $.fn.showFormErrorValidator = function(fieldname, errors) {
        var field = $(fieldname);
        if (field) {
            $(field).addClass('is-invalid');
            var error = $('<span id="' + fieldname + '-error" class="error invalid-feedback">' + errors + '</div>');
            if (field.parent('.form-group').length) {
                error.insertAfter(field);
            } else if (field.parent('.toggle').length) {
                error.insertAfter(field.parent().parent());
            } else {
                error.insertAfter(field.parent());
            }
        }
    };

    $.groupSortable = null;




    $.fn.setGroupSortable = function(html) {

        $('#ol-jobs-descriptions').html(html);
        $.groupSortable =  $('#ol-jobs-descriptions').sortable({

            onDragStart: function(\$item, container, _super) {
                //\$item.find('ol.dropdown-menu').sortable('disable');
                _super(\$item, container);
            },
            onDrop: function(\$item, container, _super) {

                var data = $.groupSortable.sortable('serialize').get();
                var jsonString = JSON.stringify(data, null, ' ');

                $.ajax({
                    'dataType': 'json',
                    'accept': 'application/json',
                    'method': 'post',
                    'url': '$routeDatatable',
                    'data': {
                        data: jsonString
                    }
                }).done(function(response) {


                    if (!response['success']) {
                        $.fn.showError(response['data']);
                    }
                }).fail(function(jqXHR, textStatus, errorThrown) {
                    $.fn.showError(textStatus);
                })


                //\$item.find('ol.dropdown-menu').sortable('enable');
                _super(\$item, container);

                //console.log($(\$item).data('id'));
                // console.log(\$item);
            }
        });

    },

    $.fn.recursiveTree = function(items) {
        var s  = '';     
        $.each(items, function(i, item) {
            s = s + $('#listJobDescriptionTemplate').render(item);

        });
        return s;
    };

    $.fn.refreshTree = function() {
        NProgress.start();
        $.ajax({
            'dataType': 'json',
            'accept': 'application/json',
            'method': 'get',
            'url': '$routeDatatable',
        }).done(function(response) {
            if (response['success']) {
                if(response['data'].items.length == 0) {
                    $('#divNoRecordsAvailable').show();
                } else {
                    $('#divNoRecordsAvailable').hide();

                }

                var s = ''; 
                $.each(response['data'], function(i, item) {
                    s = s +  $.fn.recursiveTree(item);
                });
    
                $.fn.setGroupSortable(s);
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function(jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
         }).always(function() {
            NProgress.done();
        });
    }

    var validator = $('#form').validate({
        debug: true,
        onclick: false,
        onkeyup: false,
        ignore: [],
        rules: {
            'name': {
                required: true,
                maxlength: 64,
            },
            'functions': {
                required: true,
                maxlength: 1024,
            },
            'objectives': {
               required: true,
                maxlength: 1024,
            },
            'status': {
                required: false,
            },
        },
        submitHandler: function(form) {
    

  
            var data = {
                name : $('#form #name').val(),
                functions : $('#form #functions').val(),
                objectives : $('#form #objectives').val(),
                status :  $('#form #status').prop('checked') ?  '$status_active' : '$status_inactive',
                competencies_selected : new Array(),
            };


            $.each(competencies_selected, function(i, c) {
                $.each(c.behaviors, function(i, b) {
                    data.competencies_selected.push({'competency_uuid' : c.uuid, 'behavior_uuid' : b.uuid, 'level' : b.level});
                });
            });


            NProgress.start();
            $.ajax({
                'dataType': 'json',
                'accept': 'application/json',
                'method': 'post',
                'url': $('#form').attr('action'),
                'data': data,
            }).done(function(response) {
                if (response['success']) {
                    $.fn.showSuccess(response['data']);
                    $('#row-lists').show();
                    $('#row-form').hide();
                    $.fn.refreshTree();
                } else {
                    validator.resetForm();
                    if (jQuery.type(response['data']) == 'string') {
                        $.fn.showError(response['data']);
                    } else {
                        $.each(response['data'], function(fieldname, errors) {
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
                        });
                    }
                }
            }).fail(function(jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
            });
            return false;
        },
        invalidHandler: function(form, validator) {}
    });

    $('body').on('click', 'button.btn-refresh', function(e) {
        e.preventDefault();
        $.fn.refreshTree();
    });

    $('body').on('click', 'button.btn-cancel', function(e) {
        e.preventDefault();
        $('#row-lists').show();
        $('#row-form').hide();
        $('#div-listing').show();
    });

    $('body').on('click', 'button.btn-import', function(e) {
        e.preventDefault();
        NProgress.start();
        $.ajax({
            'dataType': 'json',
            'method': 'post',
            'url': '$routeImport',
        }).done(function(response) {
            if (response['success']) {
                $.fn.showSuccess(response['data']);
                $.fn.refreshTree();
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function(jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });
        return false;
    });

    $('body').on('click', 'button.btn-add-job-description', function(e) {
        e.preventDefault();

        var link = $(this).data('link');
        $.fn.defaultValuesAdd(link);

        return false
    });

    $('body').on('click', 'i.btn-add-job-description', function(e) {
        e.preventDefault();


        var link = $(this).data('link');
        $.fn.defaultValuesAdd(link);
       
        return false
    });

    $.fn.defaultValuesAdd = function(action) {


        setTimeout(() => {
            NProgress.start();
            $.ajax({
                'dataType': 'json',
                'accept': 'application/json',
                'method': 'get',
                'url' : action,
            }).done(function(response) {
    
                if (response['success']) {
    
    
                    behaviors = response['data']['behaviors'];
                    competency_types = response['data']['competency_types'];
                    competencies = response['data']['competencies'];
    
    
                    competencies_selected = [];
    
    
                    $.each(competencies, function(i, competency) {
                        $.each(competency.behaviors, function(j, behavior) {
                            competencies[i].behaviors[j].level = 0;
                        });
                    });
    
                    $.fn.renderCompetencies();
                    $.fn.comboCompetencies();
    
                    
                    $('#form').attr('action', action);
                    $('#form #name').val('');
                    $('#form #status').bootstrapToggle('on');
                        
                    $('#form #functions').val('');
                    $('#form #objectives').val('');
    
                    validator.resetForm();
    
    
                    $('#custom-tabs #custom-tabs-general-tab').tab('show');
                    $('#row-lists').hide();
                    $('#row-form').show();
    
               } else   {                      
                    $.fn.showError(response['data']);
                }
    
            }).fail(function(jqXHR, textStatus, errorThrown) {
                $.fn.showError(textStatus);
            }).always(function() {
                NProgress.done();
            });
        }, 100);

    }



    $('body').on('click', 'i.btn-edit-job-description', function(e) {
        e.preventDefault();
        NProgress.start();
        var action = $(this).data('link');
        $.ajax({
            'dataType': 'json',
            'accept': 'application/json',
            'method': 'get',
            'url': action,
        }).done(function(response) {
            if (response['success']) {
                
                $('#form').attr('action', action);
                $('#form #name').val(response['data']['name']);
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
               
                $('#form #functions').val(response['data']['functions']);
                $('#form #objectives').val(response['data']['objectives']);

                behaviors = response['data']['behaviors'];
                competency_types = response['data']['competency_types'];

                competencies = response['data']['competencies'];
                competencies_selected = response['data']['competencies_selected'];
               
                $.fn.renderCompetencies();
                $.fn.comboCompetencies();
                      
                              
                validator.resetForm();
                $('#custom-tabs #custom-tabs-general-tab').tab('show');
                $('#row-lists').hide();
                $('#row-form').show();
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function(jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });
    });

    $('body').on('click', 'i.btn-pdf-job-description', function(e) {
        e.preventDefault();
        var action   = $(this).data('link');

        window.open(action, '_blank');

        /*
        NProgress.start(); 
        $.ajax({
            'dataType'  : 'json',
            'method'    : 'get',
            'url'       :  action,
        }).done(function(response) {
            if(response['success']) {
                var anchor = window.document.createElement("a");
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
                anchor.download = response['data']['basename'];
                document.body.appendChild(anchor);
                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
                document.body.removeChild(anchor);
            } else {
                $.fn.showError(response['data']);
            }
        }).fail(function( jqXHR, textStatus, errorThrown) {
            $.fn.showError(textStatus);
        }).always(function() {
            NProgress.done();
        });*/
    });

    $('body').on('click', 'button[id="btn-select-competency"]', function(e) {
        var competency_uuid = $('#select-competency').val();

        if (competency_uuid.length == '') {
            $.fn.showError('ERROR_SELECT_COMPETENCY_IS_EMPTY');
        } else {
            
            competency = competencies.filter((item) => item.uuid == competency_uuid ? item : false)[0];
            if(competency) {

                var competency_selected = {
                    uuid : competency.uuid, 
                    competency_type_uuid: competency.competency_type_uuid,
                    behaviors : new Array(),
                }

                $.each(competency.behaviors, function(index, uuid) {
                    competency_selected.behaviors.push({uuid: uuid, level: 0});
    
                })


                competencies_selected.push(competency_selected);

                $.fn.renderCompetencies();
                $.fn.comboCompetencies();
            }
        }
    });

    $('body').on('click', 'i.btn-delete-job-description', function(e) {
        e.preventDefault();
        var action = $(this).data('link');

          swal.fire({
            title: 'LABEL_ARE_YOU_SURE',
            icon: 'question',
            cancelButtonText: 'LABEL_NO',
            showCancelButton: true,
            confirmButtonText: 'LABEL_YES'
          }).then((result) => {
            if (result.isConfirmed) {

                    NProgress.start();
                    $.ajax({
                        'dataType': 'json',
                        'accept': 'application/json',
                        'method': 'post',
                        'url': action,
                    }).done(function(response) {
                        if (response['success']) {
                            $.fn.showSuccess(response['data']);
                           $.fn.refreshTree();
                        } else {
                            $.fn.showError(response['data']);
                        }
                    }).fail(function(jqXHR, textStatus, errorThrown) {
                        $.fn.showError(textStatus);
                    }).always(function() {
                        NProgress.done();
                    });

            }
          }); 


       

    });

    $('body').on('click', 'button.btn-delete-job-description-competency', function(e) {
        e.preventDefault();
    
        var uuid = $(this).data('competency');

          swal.fire({
             title: 'LABEL_COMPETENCY_DELETE_TITLE',
            message: 'LABEL_COMPETENCY_DELETE_MESSAGE',
            icon: 'question',
            cancelButtonText: 'LABEL_NO',
            showCancelButton: true,
            confirmButtonText: 'LABEL_YES'
          }).then((result) => {
            if (result.isConfirmed) {

                competencies_selected = competencies_selected.filter((item) => item.uuid != uuid ? item : false);
       
                
                    $.fn.renderCompetencies();
                    $.fn.comboCompetencies();
            }
          }); 


    });

    $('body').on('click','button.btn-edit-job-description-behavior', function(e) {
        e.preventDefault();

        var competency_uuid = $(this).closest('div.panel-competency').data('competency');
        var behavior_uuid = $(this).data('behavior');


        competency_selected = competencies_selected.filter((item) => item.uuid == competency_uuid ? item : false)[0];
        if(competency_selected) {
            console.log(competency_selected);

            behavior = competency_selected .behaviors.filter((item) => item.uuid  == behavior_uuid ? item : false)[0];
            if(behavior) {

                console.log(behavior);
                $('#form-behavior #competency-uuid').val(competency_uuid);
                $('#form-behavior #behavior-uuid').val(behavior_uuid);          
                $('#form-behavior #level').val(behavior.level);

                $('#modal-behavior').modal('show');
            }

        }
    });

    $('body').on('click','button.btn-behavior-submit', function(e) {
         e.preventDefault();
         $('#modal-behavior').modal('hide');

         var competency_uuid = $('#form-behavior #competency-uuid').val();
         var behavior_uuid = $('#form-behavior #behavior-uuid').val();          
         var level = $('#form-behavior #level').val();

        competency_selected = competencies_selected.filter((item) => item.uuid == competency_uuid ? item : false)[0];
        if(competency_selected) {
            behavior = competency_selected .behaviors.filter((item) => item.uuid  == behavior_uuid ? item : false)[0];
            if(behavior) {
                behavior.level = level;
                $.fn.renderCompetencies();
            }

        }

    });

    $('body').on('click', 'button.btn-edit-job-description-cancel', function(e) {
        $('#row-lists').show();
        $('#row-form').hide();
    });

    $('#form #status').bootstrapToggle({
        'on': 'LABEL_ACTIVE',
        'off': 'LABEL_INACTIVE',
        'width': '160px',
        'height': '40px'
    });

    $('#form #functions').maxlength({
        alwaysShow: true,
         validate: true
    });

    $('#form #objectives').maxlength({
        alwaysShow: true,
        validate: true
    });

    $('#select-competency').select2({
        theme: 'bootstrap4',
        width: '100%',
    });



    $.fn.refreshTree();    

});

JS;
$this->inlineScript()->captureEnd();
?>


<section class="content" id="row-lists" style="margin-bottom: 20px">

    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-12">
                    <h1>LABEL_JOBS_DESCRIPTION</h1>
                </div>
            </div>
        </div>
        <!-- /.container-fluid -->
    </div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                          <div id="divNoRecordsAvailable" class="text-center" style="display: none"><h3>LABEL_NO_RECORDS_AVAILABLE</h3></div>
                         <div id="ol-jobs-descriptions-container" style="background-color: rgba(0, 0, 0, .03); width: 100%; height: 600px; scroll: auto; overflow: auto;">
                                         <ol id="ol-jobs-descriptions" class="default vertical" style="padding-left: 0px;">

                                </ol>
                
                         </div>
                        
                 
            
                    </div>
                    <div class="card-footer clearfix">
                                <div  style="float:right;" >
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
                            <?php if ($allowAdd) : ?>
                                <?php if ($allowImport) : ?>
                                    <button type="button" class="btn btn-primary btn-import"><i class="fa fa-upload"></i> LABEL_IMPORT </button>
                                <?php endif; ?>
                                <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>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<section id="row-form" style="display:none">
        <div class="card">
        <div class="card-header">
            <h4 class="modal-title">LABEL_JOB_DESCRIPTION</h4>
        </div>
                <div class="card-body">
            <div class="card card-primary card-outline card-tabs">
                <div class="card-header p-0 pt-1 border-bottom-0">
                    <ul class="nav nav-tabs" id="custom-tabs" role="tablist">
                        <li class="nav-item">
                            <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>
                        </li>
                        <li class="nav-item">
                            <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>
                        </li>
                    </ul>
                </div>
                <div class="card-body">
                    <?php
                    $form = $this->form;
                    $form->setAttributes([
                        'method'    => 'post',
                        'name'      => 'form',
                        'id'        => 'form'
                    ]);

                    $form->prepare();
                    echo $this->form()->openTag($form);


                    $element = $form->get('competencies');
                    echo $this->formHidden($element);


                    ?>

                    <div class="tab-content" id="custom-tabs-three-tabContent">
                        <div class="tab-pane fade show active" id="custom-tabs-general" role="tabpanel" aria-labelledby="custom-tabs-general-tab">
                            <div class="row">
                                <div class="col-md col-sm-12 col-12">
                                    <div class="form-group m-0">
                                        <?php
                                        $element = $form->get('name');
                                        $element->setOptions(['label' => 'LABEL_NAME']);
                                        $element->setAttributes(['class' => 'form-control']);

                                        echo $this->formLabel($element);
                                        echo $this->formText($element);
                                        ?>
                                    </div>
                                </div>
                                <div class="col-md col-sm-12 col-12 d-flex align-items-center justify-content-center">
                                    <div class="form-group m-0">
                                        <label>LABEL_STATUS</label>
                                        <br />
                                        <?php
                                        $element = $form->get('status');
                                        $element->setOptions(['label' => 'LABEL_STATUS']);
                                        // echo $this->formLabel($element);
                                        echo $this->formCheckbox($element);
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <?php
                                $element = $form->get('objectives');
                                $element->setOptions(['label' => 'LABEL_OBJECTIVES']);
                                $element->setAttributes(['class' => 'form-control']);

                                echo $this->formLabel($element);
                                echo $this->formTextArea($element);
                                ?>
                            </div>
                            <div class="form-group">
                                <?php
                                $element = $form->get('functions');
                                $element->setOptions(['label' => 'LABEL_FUNCTIONS']);
                                $element->setAttributes(['class' => 'form-control']);

                                echo $this->formLabel($element);
                                echo $this->formTextArea($element);
                                ?>
                            </div>
                        </div>
                        <div class="tab-pane fade" id="custom-tabs-compentencies" role="tabpanel" aria-labelledby="custom-tabs-compentencies-tab">
                            <div class="row">
                                <div class="col-md-8 col-sm-8 col-xs-12">
                                    <select id="select-competency" class="form-control"> </select>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-12">
                                    <button type="button" class="btn btn-primary" id="btn-select-competency" data-toggle="tooltip" title="LABEL_ADD LABEL_COMPETENCY">LABEL_ADD LABEL_COMPETENCY</button>
                                </div>
                            </div>
                            <div class="row">
                                <br>
                                <div class="col-md-12 col-sm-12 col-xs-12" id="renderCompetencies" style="margin-top: 10px;">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <?php echo $this->form()->closeTag($form); ?>

        </div>
        <div class="card-footer clearfix">
            <button type="submit" form="form" class="btn btn-primary">LABEL_SAVE</button>
            <button type="button" class="btn btn-danger btn-edit-job-description-cancel">Cerrar</button>
        </div>
        </div>


</section>


<!--start modal behavior-->
<div id="modal-behavior" class="modal" tabindex="-1" role="dialog">
        <form action="#" name="form-behavior" id="form-behavior">
        <div class="modal-dialog " role="document">
                <input type="hidden" id="behavior-uuid" name="behavior-uuid" value="" />
                <input type="hidden" id="competency-uuid" name="competency-uuid value="" />
                <div class=" modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">LABEL_EDIT LABEL_LEVEL</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                       <div class="form-group">
                          <label for="behavior-value">LABEL_LEVEL</label>
                          <input type="number" step="1" min="0" max="100" id="level" name="level">
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary btn-behavior-submit">LABEL_SAVE</button>
                        <button type="button" class="btn btn-light" data-dismiss="modal">LABEL_CLOSE</button>
                    </div>
                </div>
                </div>
        </div>
        </form>
</div>



<!---Template Competencies --->
<script id="competencyTemplate" type="text/x-jsrender">
    <div class="panel panel-default panel-competency" id="panel-{{:uuid}}" data-competency="{{:uuid}}">
   <div class="panel-heading">
      <h4 class="panel-title" style="    font-size: 18px;">
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:uuid}}" href="#collapse-{{:uuid}}">
         <span class="section-name{{:uuid}}">
            {{:~getCompetencyType(competency_type_uuid).name}} - {{:~getCompetency(uuid).name}}
         </span>
         </a>
      </h4>
   </div>
   <div id="collapse-{{:uuid}}" class="panel-collapse in collapse show">
      <div class="panel-body">
         <div class="table-responsive">
            <table class="table table-bordered">
               <thead>
                  <tr>
                     <th style="width: 20%;">LABEL_ELEMENT</th>
                     <th style="width: 50%;">LABEL_TITLE</th>
                     <th style="width: 10%;">LABEL_LEVEL</th>
                     <th style="width: 20%;">LABEL_ACTIONS</th>
                  </tr>
               </thead>
               <tbody>
                  <tr>
                     <td class="text-left">LABEL_COMPETENCY</td>
                     <td class="text-left">{{:name}}</td>
                     <td>
                     </td>
                     <td>
                        <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> 
                     </td>
                  </tr>
                  {{for behaviors}}
                  <tr >
                     <td class="text-left">--LABEL_BEHAVIOR</td>
                     <td class="text-left">
                       {{:~getBehavior(uuid).description}}
                     </td>
                     <td class="text-right">
                        {{:level}} 
                     </td>
                     <td>
                        <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> 
                     </td>
                  </tr>
                  {{/for}}
               </tbody>
            </table>
         </div>
      </div>
   </div>
</div>
</script>

<script id="competencyTemplateWithLevel" type="text/x-jsrender">
 <div class="panel panel-default panel-competency" id="panel-{{:uuid}}" data-competency="{{:uuid}}">
   <div class="panel-heading">
      <h4 class="panel-title" style="    font-size: 18px;">
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:uuid}}" href="#collapse-{{:uuid}}">
         <span class="section-name{{:uuid}}">
            {{:~getCompetencyType(competency_type_uuid).name}} - {{:~getCompetency(uuid).name}}
         </span>
         </a>
      </h4>
   </div>
   <div id="collapse-{{:uuid}}" class="panel-collapse in collapse show">
      <div class="panel-body">
         <div class="table-responsive">
            <table class="table table-bordered">
               <thead>
                  <tr>
                     <th style="width: 20%;">LABEL_ELEMENT</th>
                     <th style="width: 50%;">LABEL_TITLE</th>
                     <th style="width: 10%;">LABEL_LEVEL</th>
                     <th style="width: 20%;">LABEL_ACTIONS</th>
                  </tr>
               </thead>
               <tbody>
                  <tr>
                     <td class="text-left">LABEL_COMPETENCY</td>
                     <td class="text-left">{{:name}}</td>
                     <td>
                     </td>
                     <td>
                        <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> 
                     </td>
                  </tr>
                  {{for behaviors}}
                  <tr >
                     <td class="text-left">--LABEL_BEHAVIOR</td>
                     <td class="text-left">
                       {{:~getBehavior(uuid).description}}
                     </td>
                     <td>
                        {{if level == '0'}} LABEL_NA {{/if}} 
                        {{if level == '1' }} LABEL_LEVEL_ONE {{/if}} 
                        {{if level == '2' }} LABEL_LEVEL_TWO {{/if}} 
                        {{if level == '3' }} LABEL_LEVEL_THREE {{/if}} 
                        {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}} 
                     </td>
                     <td>
                        <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> 
                     </td>
                  </tr>
                  {{/for}}
               </tbody>
            </table>
         </div>
      </div>
   </div>
</div>
</script>

<script id="listJobDescriptionTemplate" type="text/x-jsrender">
        <li data-id="{{:uuid}}" >
        <div class="content">

 

        <div class="sidebar {{if status == '<?php echo JobDescription::STATUS_INACTIVE ?>' }} sidebar-inactive {{/if}}">

        {{>name}} 
        <div class="float-right right-sidebar">
            {{if status == '<?php echo JobDescription::STATUS_ACTIVE ?>' }} 
            {{if link_add }}
            <i class="fa fa-plus btn-add-job-description" data-link="{{:link_add}}"></i>&nbsp;
            {{/if}}
            {{/if}}
            {{if link_edit }}
            <i class="fa fa-pencil btn-edit-job-description" data-link="{{:link_edit}}"></i>&nbsp;
            {{/if}}
            {{if link_delete }}
            <i class="fa fa-trash btn-delete-job-description" data-link="{{:link_delete}}"></i>&nbsp;
            {{/if}}
            {{if status == '<?php echo JobDescription::STATUS_ACTIVE ?>' }} 
            {{if link_report }}
            <i class="fa fa-file-o btn-pdf-job-description" data-link="{{:link_report}}"></i>&nbsp;
            {{/if}}
            {{/if}}
        </div>
        </div>
        </div>
        <ol>    
           {{for children tmpl="#listJobDescriptionTemplate"/}}
           </ol> 
        </li>
</script>