Rev 15066 | Rev 15074 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php$acl = $this->viewModel()->getRoot()->getVariable('acl');$currentUser = $this->currentUserHelper();$roleName = $currentUser->getUserTypeId();$routeAdd = $this->url('performance-evaluation/forms/add');$routeDatatable = $this->url('performance-evaluation/forms');$routeDashboard = $this->url('dashboard');$allowAdd = $acl->isAllowed($roleName, 'performance-evaluation/forms/add') ? 1 : 0;$allowEdit = $acl->isAllowed($roleName, 'performance-evaluation/forms/edit') ? 1 : 0;$allowDelete = $acl->isAllowed($roleName, 'performance-evaluation/forms/delete') ? 1 : 0;$allowReport = $acl->isAllowed($roleName, 'performance-evaluation/forms/report') ? 1 : 0;$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));$this->inlineScript()->appendFile($this->basePath('plugins/jquery-input-number/input-number-format.jquery.js'));// bootbox Alert //$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));// JsRender //$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));// Page Styles$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));$status_active = \LeadersLinked\Model\CompanyPerformanceEvaluationForm::STATUS_ACTIVE;$status_inactive = \LeadersLinked\Model\CompanyPerformanceEvaluationForm::STATUS_INACTIVE;$this->inlineScript()->captureStart();echo <<<JSjQuery(document).ready(function($) {var allowEdit = $allowEdit;var allowDelete = $allowDelete;var allowReport = $allowReport;var sections = [];var competencies_type = [];/*** Get rows and set data table*/var tableForm = $('#gridTable').dataTable({'processing': true,'serverSide': true,'searching': true,'order': [[0, 'asc']],'ordering': true,'ordenable': true,'responsive': true,'select': false,'paging': true,'pagingType': 'simple_numbers','ajax': {'url': '$routeDatatable','type': 'get','beforeSend': function(request) {NProgress.start();},'dataFilter': function(response) {var response = jQuery.parseJSON(response);var json = {};json.recordsTotal = 0;json.recordsFiltered = 0;json.data = [];if (response.success) {json.recordsTotal = response.data.total;json.recordsFiltered = response.data.total;json.data = response.data.items;} else {$.fn.showError(response.data)}return JSON.stringify(json);}},'language': {'sProcessing': 'LABEL_DATATABLE_SPROCESSING','sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU','sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS','sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE','sInfo': 'LABEL_DATATABLE_SINFO','sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY','sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED','sInfoPostFix': '','sSearch': 'LABEL_DATATABLE_SSEARCH','sUrl': '','sInfoThousands': ',','sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS','oPaginate': {'sFirst': 'LABEL_DATATABLE_SFIRST','sLast': 'LABEL_DATATABLE_SLAST','sNext': 'LABEL_DATATABLE_SNEXT','sPrevious': 'LABEL_DATATABLE_SPREVIOUS'},'oAria': {'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING','sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'},},'drawCallback': function(settings) {NProgress.done();$('button.btn-delete').confirmation({rootSelector: 'button.btn-delete',title: 'LABEL_ARE_YOU_SURE',singleton: true,btnOkLabel: 'LABEL_YES',btnCancelLabel: 'LABEL_NO',onConfirm: function(value) {action = $(this).data('href');NProgress.start();$.ajax({'dataType': 'json','accept': 'application/json','method': 'post','url': action,}).done(function(response) {if (response['success']) {$.fn.showSuccess(response['data']);tableForm.fnDraw();} else {$.fn.showError(response['data']);}}).fail(function(jqXHR, textStatus, errorThrown) {$.fn.showError(textStatus);}).always(function() {NProgress.done();});},});},'aoColumns': [{'mDataProp': 'name'},{'mDataProp': 'job_description'},{'mDataProp': 'status'},{'mDataProp': 'actions'},],'columnDefs': [{'targets': 0,'className': 'text-vertical-middle',},{'targets': 1,'className': 'text-vertical-middle',},{'targets': -2,'orderable': false,'className': 'text-center','render': function(data, type, row) {checked = data == 'a' ? ' checked="checked" ' : '';return '<div class="checkbox checkbox-success">' +'<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +'<label ></label></div>';}},{'targets': -1,'orderable': false,'render': function(data, type, row) {s = '';if (allowEdit) {s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';}if (allowDelete) {s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete'] + '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button> ';}if (allowReport) {s = s + '<a class="btn btn-default btn-pdf" href="' + data['link_report'] + '" target="_blank" data-toggle="tooltip" title="LABEL_PDF"><i class="fa fa-file-o"></i> LABEL_PDF </button> ';}return s;}}],});/*** Clicked on edit form*/$('body').on('click', 'button.btn-edit-form', function(e) {e.preventDefault();renderCompetenciesData([]);form_id = $(this).data('id')var action = $(this).data('href');$.ajax({'dataType': 'json','accept': 'application/json','method': 'get','url': action,}).done(function(response) {if (response['success']) {$("#rows").html('');sections = [];$('#form-main').attr('action', action);$('#form-main #form-name').val(response['data']['name']);$('#form-main #job_description_id').val(response['data']['job_description_id']).trigger('change');$('#form-main #form-status').val(response['data']['status']);CKEDITOR.instances['form-description'].setData(response['data']['description']);sections = response['data']['content'] || [];renderData(sections);$('#row-lists').hide();$('#row-form').show();} else {$.fn.showError(response['message'] || 'ERROR_UNKNOWN');}}).fail(function(jqXHR, textStatus, errorThrown) {$.fn.showError(textStatus);});});/*** Clicked new Form*/$('button.btn-add-form').click(function(e) {$("#rows").html('');sections = [];$('#form-main').attr('action', '$routeAdd');$('#form-main #form-name').val('');$('#form-main #job_description_id').val('').trigger('change');$('#form-main #form-status').val('$status_active');CKEDITOR.instances['form-description'].setData('');renderCompetenciesData([]);$('#row-lists').hide();$('#row-form').show();$('#form-main #form-name').focus();return;});/*** Clicked cancel new/edit Form*/$('button.btn-edit-cancel').click(function(e) {$('#row-form').hide();$('#row-lists').show();return;});/*** Clicked save and continue new Form*/$('button.btn-form-save-continue').click(function(e) {for (var instanceName in CKEDITOR.instances) {CKEDITOR.instances[instanceName].updateElement();}saveData(1);});/*** Clicked save and close new/edit Form*/$('button.btn-form-save-close').click(function(e) {for (var instanceName in CKEDITOR.instances) {CKEDITOR.instances[instanceName].updateElement();}saveData(0);});/*** Save Form Data*/const saveData = (action) => {if ($('#form-name').val() == '') {$.fn.showError('ERROR_ENTER_NAME');} else if ($('#form-description').val() == '') {$.fn.showError('ERROR_ENTER_DESCRIPTION');} else if ($('#form-text').val() == '') {$.fn.showError('ERROR_ENTER_TEXT');} else if ($('#form-status').val() == '') {$.fn.showError('ERROR_SELECT_STATUS');} else if ($('#job_description_id').val() == '') {$.fn.showError('ERROR_SELECT_JOB_DESCRIPTION');} else {$.ajax({'dataType': 'json','method': 'post','url': $('#form-main').attr('action'),'data': {'name': $('#form-main #form-name').val(),'job_description_id': $('#form-main #job_description_id').val(),'status': $('#form-main #form-status').val(),'description': $('#form-main #form-description').val(),'content': JSON.stringify(sections)},}).done(function(response) {if (response['success']) {$.fn.showSuccess(response['data']);if (action == 1) {$('#form-main').attr('action', response['action_edit']);} else {$('#row-form').hide();$('#row-lists').show();/*---------- Reset Form -------- */$('#form-main')[0].reset();/*--------Reset Sections ----------*/sections = [];tableForm.fnDraw();}return;} else {$.fn.showError(response['message'] || 'ERROR_UNKNOWN');return;}});}}/*** Remove Html Tags*/const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')/**/*** Clicked refresh button*/$('button.btn-refresh').click(function(e) {tableForm.fnDraw();return;});/*** Initialize select Jobdescription*/$('#job_description_id').select2({theme: 'bootstrap4',width: '100%',});/*** On change selecte JobDescription*/$('#job_description_id').on('change', function() {if ($("#job_description_id").val() != '') {$.getJSON("/settings/jobs-description/edit/" + $("#job_description_id").val(), function(response) {if (response['success']) {competencies_type = response['data']['competency_types'];renderCompetenciesData(response['data']['competencies_selected']);}});}});/*** Filter competencie type*/const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];/*** Render Competencies data*/const renderCompetenciesData = (data) => {if (data.length > 0) {$("#competencies-to-job").show();$("#rows-job-competencies").html($("#sectionCompetencies").render(data, {getType: filterTypeById}));} else {$("#competencies-to-job").hide();$("#rows-job-competencies").html('');}}});JS;$this->inlineScript()->captureEnd();?><!-- Content Header (Page header) --><section class="content-header"><div class="container-fluid"><div class="row mb-2"><div class="col-sm-12"><h1>LABEL_PERFORMANCE_EVALUATION</h1></div></div></div><!-- /.container-fluid --></section><section class="content"><div class="container-fluid" id="row-lists"><div class="row"><div class="col-12"><div class="card"><div class="card-body"><table id="gridTable" class="table table-hover"><thead><tr><th style="width:25%">LABEL_NAME</th><th style="width:20%">LABEL_JOB_DESCRIPTION</th><th style="width:10%">LABEL_ACTIVE</th><th style="width:25%">LABEL_ACTIONS</th></tr></thead><tbody></tbody></table></div><div class="card-footer clearfix"><div style="float:right;"><button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button><?php if ($allowAdd) : ?><button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button><?php endif; ?></div></div></div></div></div></div><!-- Create/Edit Form --><div class="row" id="row-form" style="display: none; padding: 16px;"><div class="col-xs-12 col-md-12"><form action="#" name="form-main" id="form-main"><div class="form-group"><label for="form-name">LABEL_FIRST_NAME</label><input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" /></div><div class="form-group"><label for="job_description_id">LABEL_POSITION_EVALUATED</label><select name="job_description_id" id="job_description_id" class="form-control"><option value="">LABEL_SELECT</option><?php foreach ($jobsDescription as $rs): ?><option value="<?php echo $rs->uuid;?>"><?php echo $rs->name;?></option><?php endforeach; ?></select></div><div class="form-group"><label for="form-description">LABEL_DESCRIPTION</label><!-- ckeditor --><textarea name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea></div><div class="form-group"><label for="form-status">LABEL_STATUS</label><select name="form-status" id="form-status" class="form-control"><option value="<?php echo $status_inactive; ?>">LABEL_INACTIVE</option><option value="<?php echo $status_active; ?>">LABEL_ACTIVE</option></select></div><br /><div class="row"><div class="col-xs-12 col-md-12"><div class="panel-group" id="rows"></div></div></div><div class="form-group" id="competencies-to-job" style="display:none"><div class="row"><div class="col-xs-12 col-md-12"><hr><h4 style="font-size: 18px;font-weight: bold;">LABEL_COMPETENCIES_TO_JOB:</h4><br><div class="panel-group" id="rows-job-competencies"></div></div></div></div><div class="form-group"><button type="button" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button><button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button><button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button></div></form></div></div><!-- Create/Edit Form--><!---Template Competencies ---><script id="sectionCompetencies" type="text/x-jsrender"><div class="panel panel-default" id="panel-{{:competency_id}}"><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-{{:competency_id}}" href="#collapse-{{:competency_id}}"><span class="competency-name{{:competency_id}}">{{:~getType(competency_type_id).name}} - {{:name}}</span></a></h4></div><div id="collapse-{{:competency_id}}" class="panel-collapse in collapse show"><div class="panel-body"><div class="table-responsive"><table class="table table-bordered"><thead><tr><th style="width: 80%;">LABEL_CONDUCT</th><th style="width: 20%;">LABEL_LEVEL</th></tr></thead><tbody>{{for behaviors}}<tr ><td class="text-left">{{: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></tr>{{/for}}</tbody></table></div></div></div></div></script><!-- End Template Competencies--></section>