Rev 1 | Rev 16891 | 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();
$routeReports = $this->url('microlearning/reports/progress');
$roleName = $currentUser->getUserTypeId();
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
$this->headStyle()->captureStart();
echo <<<CSS
#tableStudents {
display: flex;
flex-flow: column;
width: 100%;
}
#tableStudents thead {
flex: 0 0 auto;
}
#tableStudents tbody {
flex: 1 1 auto;
display: block;
overflow-y: auto;
overflow-x: hidden;
}
#tableStudents tr {
width: 100%;
display: table;
table-layout: fixed;
}
CSS;
$this->headStyle()->captureEnd();
$this->inlineScript()->captureStart();
echo <<<JS
jQuery( document ).ready(function( $ ) {
$.fn.changeFilter = function() {
NProgress.start();
$.ajax({
'dataType' : 'json',
'accept' : 'application/json',
'method' : 'get',
'url' : $('#form-filter').attr('action'),
'data' : $('#form-filter').serialize(),
}).done(function(response) {
if(response['success']) {
$('#tableStudents tbody').empty();
$.each(response['data'], function(id, item) {
var percentaje = 0;
if(item['total_capsules_completed'] > 0 && item['total_capsules'] > 0) {
percentaje = parseInt ( ( item['total_capsules_completed'] * 100 ) / item['total_capsules'] );
}
var s = '<tr>';
s = s + '<td style="width: 32%">';
s = s + $.trim(item['first_name'] + ' ' + item['last_name'] ) + '<br>';
s = s + item['email'] ;
s = s + '</td>';
s = s + '<td style="width: 10%" class="text-right">' + item['total_capsules'] + '</td>';
s = s + '<td style="width: 10%" class="text-right">' + item['total_capsules_completed'] + '</td>';
s = s + '<td style="width: 10%" class="text-right">' + item['total_capsules_incomplete'] + '</td>';
s = s + '<td style="width: 10%" >' + item['first_date'] + '<br>' + item['first_time'] + '</td>';
s = s + '<td style="width: 10%" >' + item['last_date'] + '<br>' + item['last_time'] + '</td>';
s = s + '<td style="width: 10%" >';
s = s + '<div class="progress progress-xs progress-striped active">';
s = s + '<div class="progress-bar bg-primary" style="width: ' + percentaje + '%"></div>';
s = s + '</div>';
s = s + '</td>';
s = s + '<td style="width: 8%" class="text-right">' + percentaje + '%</td>';
s = s + '</tr>';
$('#tableStudents tbody').append(s);
});
} else {
if(jQuery.type(response['data']) == 'string') {
$.fn.showError(response['data']);
} else {
$.each(response['data'], function( fieldname, errors ) {
$.fn.showFormErrorValidator('#form-slide-video-edit #' + fieldname, errors);
});
}
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
return false;
}
$('#form-filter #company_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$('#form-filter #function_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$('#form-filter #group_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$('#form-filter #institution_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$('#form-filter #program_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$('#form-filter #partner_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$('#form-filter #sector_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$('#form-filter #student_type_id').change(function(e) {
e.preventDefault();
$.fn.changeFilter();
});
$.fn.changeFilter();
});
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_REPORTS</h1>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card card-primary collapsed-card">
<div class="card-header">
<h3 class="card-title">LABEL_FILTERS</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-filter"></i></button>
</div>
<!-- /.card-tools -->
</div>
<!-- /.card-header -->
<div class="card-body">
<form name="form-filter" id="form-filter" action="<?php echo $routeReports ?>">
<?php
$fields = [
[
'label' => 'LABEL_COMPANIES',
'name' => 'company_id',
],
[
'label' => 'LABEL_FUNCTIONS',
'name' => 'function_id',
],
[
'label' => 'LABEL_GROUPS',
'name' => 'group_id',
],
[
'label' => 'LABEL_INSTITUTIONS',
'name' => 'institution_id',
],
[
'label' => 'LABEL_PROGRAMS',
'name' => 'program_id',
],
[
'label' => 'LABEL_PARTNERS',
'name' => 'partner_id',
],
[
'label' => 'LABEL_SECTORS',
'name' => 'sector_id',
],
[
'label' => 'LABEL_STUDENT_TYPES',
'name' => 'student_type_id',
],
];
$column = 0;
foreach($fields as $field) :
if($column == 0) {
echo '<div class="row">';
}
$column++;
?>
<div class="col-md-6 col-sm-12">
<div class="form-group">
<?php
$element = $form->get( $field['name'] );
$element->setOptions(['label' => $field['label'] ]);
$element->setAttributes(['class' => 'form-control']);
echo $this->formLabel($element);
echo $this->formSelect($element);
?>
</div>
</div>
<?php
if($column == 2) {
$column = 0;
echo '</div>';
}
?>
<?php endforeach; ?>
<?php if($column) {
echo '</div>';
}
?>
</form>
</div>
<!-- /.card-body -->
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<!-- /.card-header -->
<div class="card-body p-0">
<table class="table table-responsive" id="tableStudents" >
<thead>
<tr>
<th style="width: 32%"> </th>
<th style="width: 30%" colspan="3" class="text-center">LABEL_CAPSULES</th>
<th style="width: 20%" colspan="2" class="text-center">LABEL_DATE</th>
<th style="width: 10%"> </th>
<th style="width: 8%"> </th>
</tr>
<tr>
<th style="width: 32%">LABEL_REPORTS_STUDENT</th>
<th style="width: 10%" class="text-right">LABEL_REPORTS_CAPSULES_TOTAL</th>
<th style="width: 10%" class="text-right">LABEL_REPORTS_CAPSULES_COMPLETED</th>
<th style="width: 10%" class="text-right">LABEL_REPORTS_CAPSULES_INCOMPLETED</th>
<th style="width: 10%">LABEL_REPORTS_FIRST_DATE</th>
<th style="width: 10%">LABEL_REPORTS_LAST_DATE</th>
<th style="width: 10%">LABEL_REPORTS_PROGRESS</th>
<th style="width: 8%" class="text-right">%</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
</div>
</div>
</div>
</section>