Rev 16929 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
$acl = $this->viewModel()->getRoot()->getVariable('acl');
$currentUser = $this->currentUserHelper();
$roleName = $currentUser->getUserTypeId();
$routeDatatable = $this->url( 'activities-center/recruitment-and-selection');
$allowTakeaTest = $acl->isAllowed($roleName, 'activities-center/recruitment-and-selection/take-a-test') ? 1 : 0;
$allowReport = $acl->isAllowed($roleName, 'activities-center/recruitment-and-selection/report') ? 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-maxlength/bootstrap-maxlength.min.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->inlineScript()->appendFile($this->basePath('assets/vendors/moment/moment-with-locales.min.js'));
//$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
//$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap-datepicker/js/bootstrap-datepicker.es.js'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap-datepicker/css/bootstrap-datepicker.css'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.min.css'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap5-theme/select2-bootstrap-5-theme.css'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.min.js'));
// JsRender //
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.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->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-input-number/input-number-format.jquery.js'));
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jquery-wizard/jquery.smartWizard.min.js'));
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/jquery-wizard/smart_wizard_all.min.css'));
//$this->headLink()->appendStylesheet($this->basePath('css/activity-center-accordion.css'));
$this->inlineScript()->captureStart();
echo <<<JS
jQuery( document ).ready(function( $ ) {
var allowTakeaTest = $allowTakeaTest;
var allowReport = $allowReport
var competencies_selected = new Array();
var subordinates_selected = new Array();
var competency_types = new Array();
var competencies = new Array();
var behaviors = new Array();
$.fn.renderJobDescription = function(data) {
$('#div-job-description').html($('#job-description-template').render(data));
}
$.fn.renderCompetencies = function() {
if(competencies_selected.length > 0) {
$('#accordion').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 {
$('#accordion').empty();
}
$('.collapse.show').each(function(){
$(this).siblings('.card-header').find('.btn i').attr('class', 'fa fa-minus');
});
$('.collapse').on('show.bs.collapse', function(){
$(this).parent().find('.card-header .btn i').attr('class', 'fa fa-minus');
}).on('hide.bs.collapse', function(){
$(this).parent().find('.card-header .btn i').attr('class', 'fa fa-plus');
});
}
var gridTable = $('#gridTable').dataTable( {
'processing': true,
'serverSide': true,
'searching': true,
'search' : {
'search' : '$search',
},
'order': [[ 1, 'asc' ]],
'ordering': true,
'ordenable' : true,
'responsive': true,
'select' : false,
'paging': true,
'pagingType': 'simple_numbers',
'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, 'All'] ],
'ajax': {
'url' : '$routeDatatable',
'type' : 'get',
'data': function ( d ) {
},
'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();
},
'aoColumns': [
{ 'mDataProp': 'last_date' },
{ 'mDataProp': 'type' },
{ 'mDataProp': 'vacancy' },
{ 'mDataProp': 'candidate' },
{ 'mDataProp': 'status' },
],
'columnDefs': [
{
'targets': 1,
'render' : function ( data, type, row ) {
var s = row['type'];
if (allowTakeaTest && row['actions']['link_take_a_test']) {
s = s + '<br><button class="btn btn-default btn-take-the-test" data-href="' + row['actions']['link_take_a_test'] + '" data-toggle="tooltip" title="LABEL_PERFORMANCE_EVALUATION_TAKE_TEST"><i class="fa fa-pen"></i> LABEL_PERFORMANCE_EVALUATION_TAKE_TEST </button> ';
}
if (allowReport && row['actions']['link_pdf']) {
s = s + '<br><button class="btn btn-default btn-pdf" data-href="' + row['actions']['link_pdf'] + '" data-toggle="tooltip" title="LABEL_PDF"><i class="fa fa-pdf"></i> LABEL_PDF </button> ';
}
return s;
}
},
],
});
$('body').on('click', 'button.btn-save', function(e) {
e.preventDefault();
var ok = $('#comment').val().trim().length > 0
$.each($('input.input-behavior-comment'), function(index, element) {
ok = ok && $(element).val().trim().length > 0;
});
if(!ok) {
$.fn.showError('ERROR_PERFORMANCE_SOMEONE_COMMENT_IS_EMPTY');
return false;
}
swal.fire({
title: 'LABEL_ARE_YOU_SURE',
message: 'LABEL_RECRUITMENT_AND_SELECTION_TEST_IS_COMPLETED',
icon: 'question',
cancelButtonText: 'LABEL_NO',
showCancelButton: true,
confirmButtonText: 'LABEL_YES'
}).then((result) => {
if (result.isConfirmed) {
var data = new Array()
data['status'] = $('#status').val();
data['comment'] = $('#comment').val().trim();
data['points'] = $('#points').val();
$.each($('input.input-behavior-comment'), function(index, element) {
k = $(this).attr('name');
v = $(this).val().trim();
data[k] = v;
});
$.each($('input.input-behavior-level'), function(index, element) {
k = $(this).attr('name');
v = $(this).val();
data[k] = v;
});
var action = $('#form').attr('action');
$.ajax({
'dataType': 'json',
'accept': 'application/json',
'method': 'post',
'url': action,
'data' : $('#form').serialize()
}).done(function(response) {
if (response['success']) {
$('#row-test').hide();
$('#row-header').show();
$('#row-table').show();
gridTable.api().ajax.reload(null, false);
} else {
$.fn.showError(response['data']);
}
}).fail(function(jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
});
}
});
});
$('body').on('click', 'button.btn-refresh', function(e) {
e.preventDefault();
gridTable.api().ajax.reload(null, false);
});
$('body').on('click', 'button.btn-pdf', function(e) {
e.preventDefault();
var action = $(this).data('href');
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.btn-cancel', function(e) {
e.preventDefault();
$('#row-test').hide();
$('#row-header').show();
$('#row-table').show();
});
$('body').on('click', 'button.btn-take-the-test', function(e) {
e.preventDefault();
var action = $(this).data('href');
$.getJSON(action, function(response) {
if(response['success']) {
$('#form').attr('action', action);
behaviors = response['data']['behaviors'];
competency_types = response['data']['competency_types'];
competencies = response['data']['competencies'];
competencies_selected = response['data']['competencies_selected'];
subordinates_selected = response['data']['subordinates_selected'];
$.fn.renderCompetencies();
$('#form-title').html( response['data']['name'])
var data = {
name: response['data']['name'],
functions : response['data']['functions'],
objectives : response['data']['objectives'],
form : response['data']['form'],
type : response['data']['type'],
interviewer : response['data']['interviewer'],
candidate : response['data']['candidate'],
last_date : response['data']['last_date'],
}
$.fn.renderJobDescription(data);
$('input.input-behavior-level').inputNumberFormat({decimal: 0});
$('input.input-behavior-level').change(function(e) {
e.preventDefault();
var v = parseInt($(this).val());
if(isNaN(v)) {
$(this).val('0');
} else {
if(v > 100) {
$(this).val('100');
}
}
});
$('#comment').val('');
$('#points').val('');
$('#row-header').hide();
$('#row-table').hide();
$('#row-test').show();
$('#stepwizard').smartWizard('reset');
} else {
$.fn.showError(response['data'])
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
});
$('body').on('click', 'button.btn-delete', function(e) {
e.preventDefault();
var action = $(this).data('href');
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']);
gridTable.api().ajax.reload(null, false);
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
}
});
});
$('#form #comment').maxlength({
alwaysShow: true,
validate: true
});
$('#points').inputNumberFormat({decimal: 0});
$('#points').change(function(e) {
e.preventDefault();
var v = parseInt($(this).val());
if(isNaN(v)) {
$(this).val('0');
} else {
if(v > 100) {
$(this).val('100');
}
}
});
$('#stepwizard').smartWizard({
selected: 0,
// autoAdjustHeight: false,
theme: 'arrows', // basic, arrows, square, round, dots
transition: {
animation:'none'
},
lang: {
next: 'LABEL_NEXT',
previous: 'LABEL_PREVIOUS',
},
toolbar: {
showNextButton: true, // show/hide a Next button
showPreviousButton: true, // show/hide a Previous button
position: 'bottom', // none/ top/ both bottom
extraHtml: `<button type="button" class="btn btn-primary btn-save">LABEL_SAVE</button>`
+ `<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>`
},
anchor: {
enableNavigation: true, // Enable/Disable anchor navigation
enableNavigationAlways: false, // Activates all anchors clickable always
enableDoneState: true, // Add done state on visited steps
markPreviousStepsAsDone: true, // When a step selected by url hash, all previous steps are marked done
unDoneOnBackNavigation: true, // While navigate back, done state will be cleared
enableDoneStateNavigation: true // Enable/Disable the done state navigation
},
});
$('#stepwizard').smartWizard('reset');
});
JS;
$this->inlineScript()->captureEnd();
?>
<div class="container">
<div class="card" id="row-table">
<div class="card-header">
LABEL_RECRUITMENT_AND_SELECTION
</div>
<div class="card-body">
<div class="row">
<div class="col-12 mt-3">
<table id="gridTable" class="table table-bordered">
<thead>
<tr>
<th style="width:15%">LABEL_LAST_DATE</th>
<th style="width:35%">LABEL_TYPE</th>
<th style="width:35%">LABEL_VACANCY</th>
<th style="width:35%">LABEL_CANDIDATE</th>
<th style="width:15%">LABEL_STATUS</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<div class="card-footer text-right">
<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH </button>
</div>
</div>
<?php
$form->setAttributes([
'method' => 'post',
'name' => 'form',
'id' => 'form',
]);
$form->prepare();
echo $this->form()->openTag($form);
?>
<div class="row" id="row-test" style="display: none;">
<div class="col-12 mt-3">
<h6 class="text-center" id="form-title"></h6>
<div id="stepwizard" class="border border-gray p-4 mt-2">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="#step-1">
<div class="num">1</div>
LABEL_GENERAL
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#step-2">
<div class="num">2</div>
LABEL_COMPETENCIES
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#step-3">
<span class="num">3</span>
LABEL_CONCLUTION
</a>
</li>
</ul>
<div class="tab-content">
<div id="step-1" class="tab-pane" role="tabpanel" aria-labelledby="step-1">
<div class="row">
<div class="col-mt-3">
<h5 id="interview"></h5>
<div id="div-job-description"></div>
</div>
</div>
</div>
<div id="step-2" class="tab-pane" role="tabpanel" aria-labelledby="step-2">
<div class="row">
<div class="col-mt-3">
<div class="accordion" id="accordion" style="height: 500px; overflow-y: auto;"></div>
</div>
</div>
</div>
<div id="step-3" class="tab-pane" role="tabpanel" aria-labelledby="step-3">
<div class="row">
<div class="col-mt-3">
<?php
$element = $form->get('comment');
$element->setOptions(['label' => 'LABEL_COMMENT']);
$element->setAttributes(['class' => 'form-control']);
echo $this->formLabel($element);
echo $this->formTextArea($element);
?>
</div>
</div>
<div class="row">
<div class="col-mt-3">
<?php
$element = $form->get('points');
$element->setAttributes(['class' => 'form-control']);
$element->setOptions(['label' => 'LABEL_EVALUATION']);
echo $this->formLabel($element);
echo $this->formNumber($element);
?>
</div>
</div>
<div class="row">
<div class="col-mt-3">
<?php
$element = $form->get('status');
$element->setOptions(['label' => 'LABEL_STATUS']);
$element->setAttributes(['class' => 'form-control']);
echo $this->formLabel($element);
echo $this->formSelect($element);
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php echo $this->form()->closeTag($form); ?>
</div>
</div>
<script id="job-description-template" type="text/x-jsrender">
<div class="card">
<div class="card-body">
<table class="table table-bordered">
<tr>
<th>LABEL_LAST_DATE</th>
<th>LABEL_TYPE</th>
</tr>
<tr>
<td>{{:last_date}}</td>
<td>{{:type}}</td>
</tr>
<tr>
<th>LABEL_INTERVIEWED_BY</th>
<th>LABEL_CANDIDATE</th>
</tr>
<tr>
<td>{{:interviewer}}</td>
<td>{{:candidate}}</td>
</tr>
</table>
<br/>
<p class="card-text"><b>LABEL_OBJECTIVES</b></p>
<p class="card-text">{{:objectives}}</p>
<p class="card-text"><b>LABEL_FUNCTIONS</b></p>
<p class="card-text">{{:functions}}</p>
</div>
</div>
</script>
<script id="competencyTemplate" type="text/x-jsrender">
<div class="accordion-item">
<h2 class="accordion-header" id="heading-{{:uuid}}">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-{{:uuid}}" aria-expanded="true" aria-controls="collapseOne">
{{:~getCompetencyType(competency_type_uuid).name}} - {{:~getCompetency(uuid).name}}
</button>
</h2>
<div id="collapse-{{:uuid}}" class="accordion-collapse collapse " aria-labelledby="headingOne" data-bs-parent="#accordion">
<div class="accordion-body">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th style="width: 30%;">LABEL_ELEMENT</th>
<th style="width: 50%;">LABEL_TITLE</th>
<th style="width: 10%;">LABEL_LEVEL</th>
<th style="width: 10%;">LABEL_POINTS</th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-left">LABEL_COMPETENCY</td>
<td class="text-left">{{:name}}</td>
<td> </td>
<td> </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 class="text-right">
<input type="number" class="form-control input-behavior-level " value="0" step="1" min="0" max="100" name="{{:competency_uuid}}-{{:uuid}}-points" id="{{:competency_uuid}}-{{:uuid}}-points" ></input>
</td>
</tr>
<tr >
<td colspan="4">
LABEL_COMMENT
<input type="text" class="form-control input-behavior-comment" value="" maxlength="128" name="{{:competency_uuid}}-{{:uuid}}-comment" id="{{:competency_uuid}}-{{:uuid}}-comment" ></input>
</td>
</tr >
{{/for}}
</tbody>
</table>
</div>
</div>
</div>
</div>
</script>