434 lines
20 KiB
PHP
434 lines
20 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => "Report"])
|
|
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
|
<link href="{{asset('assets/libs/flatpickr/flatpickr.min.css')}}" rel="stylesheet" type="text/css" />
|
|
<link href="{{asset('assets/libs/bootstrap-datepicker/bootstrap-datepicker.min.css')}}" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body class="loading" style="background:#fff">
|
|
<div class="loader text-white">
|
|
<i class="mdi mdi-loading mdi-spin mdi-48px" aria-hidden="true"></i><br />Loading
|
|
</div>
|
|
<div class="card p-2" id="graph-wrapper">
|
|
<div class="card-body p-0">
|
|
<div class="row">
|
|
<div class="col-12 pt-1">
|
|
<h4 class="header-title">{{$graph->name}}</h4>
|
|
</div>
|
|
|
|
<div class="col-6 pt-1">
|
|
<p class="text-muted"> {!!$graph->agg_type == 'team' ? '<i class="mdi mdi-account-group" aria-hidden="true"></i>' : '<i class="mdi mdi-account" aria-hidden="true"></i>' !!} {{ucwords($graph->agg_type)}} Report</p>
|
|
</div>
|
|
<div class="col-6 pt-1">
|
|
<p class="text-end" text-muted><i class="mdi mdi-chart-box-plus-outline" aria-hidden="true"></i> {{ucwords($graph->type)}} Metric</p>
|
|
</div>
|
|
<div class="col-8">
|
|
<p class="text-muted"><i class="mdi mdi-calendar" aria-hidden="true"></i> {{$graph->valid_from}} to {{$graph->valid_till}}</p>
|
|
</div>
|
|
<div class="col-4 text-end">
|
|
@if((in_array($post['type'], ['trend','leaderboard']) && !in_array($post['chart'], ['line', 'bar']) ) || ($post['type'] == 'graphical' && $graph->type == 'grouped') )
|
|
<button class="btn btn-warning btn-xs" id="email-export">Send me Email</button>
|
|
@endif
|
|
</div>
|
|
|
|
<div class="col-12 pt-1">
|
|
<div class="button-list">
|
|
@foreach($charts as $chart)
|
|
@if(sizeof($chart->charts)>0)
|
|
<a href="/form/metricreport?id={{$graph->id}}&type={{$chart->type}}&chart={{$chart->charts[0]}}&period={{$periods[0]->value}}" class="btn btn-{{$chart->type == $post['type'] ? '':'outline-' }}khaki btn-rounded btn-xs font-14">{{$chart->name}}</a>
|
|
@endif
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
<div class="col-7 pt-3">
|
|
<p class="text-end">Select Period</p>
|
|
</div>
|
|
<div class="col-5 pt-3">
|
|
<select class="form-control" id="period" name="period" style="padding: 2px 0 2px 8px;">
|
|
@foreach($periods as $v)
|
|
<option value="{{$v->value}}" {{$post['period'] == $v->value ? "selected":""}}>{{$v->label}}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
@foreach($charts as $chart)
|
|
@if($chart->type == $post['type'] && sizeof($chart->charts) > 1)
|
|
@foreach($chart->charts as $ch)
|
|
<div class="col-auto">
|
|
<a href="/form/metricreport?id={{$graph->id}}&type={{$chart->type}}&chart={{$ch}}&period={{$periods[0]->value}}" class="text-dark font-14 {{$ch == $graph->chart ? 'underline':'' }}"><i class="mdi {{$ch == 'tabular' ? 'mdi-table':'mdi-chart-'.$ch}}" aria-hidden="true"></i> {{ucwords($ch)}} chart</a>
|
|
</div>
|
|
@endforeach
|
|
@endif
|
|
@endforeach
|
|
</div>
|
|
|
|
<div class="widget-chart text-center" dir="ltr">
|
|
@switch(true)
|
|
@case($graph->chart == 'leaderboard')
|
|
<div id="cardCollpase4" class="collapse pt-3 show">
|
|
@if($graph->agg_type == 'individual')
|
|
<div class="btn-group mb-2">
|
|
<button type="button" class="btn btn-info leaderboard-prev" {{$graph->current_level==$graph->level?'disabled':''}}><i class="mdi mdi-play mdi-rotate-180 mdi-18px"></i></button>
|
|
<button type="button" class="btn btn-info">Level {{$graph->current_level}}</button>
|
|
<button type="button" class="btn btn-info leaderboard-next" {{$graph->current_level==1?'disabled':''}}><i class="mdi mdi-play mdi-18px"></i></button>
|
|
</div>
|
|
@endif
|
|
@php
|
|
$leader_id = '';
|
|
@endphp
|
|
@foreach($graph->values as $i => $val)
|
|
@if($leader_id != $val->user->id)
|
|
<div class="row mt-2">
|
|
<div class="col-3"><img src="https://ui-avatars.com/api/?background={{$i>3?$colors[4]:$colors[$i]}}&name={{$val->rank}}" class="avatar-md"></div>
|
|
<div class="col-6 text-start">{{$val->user->name}} <br /><small>{{$val->user->designation}}</small></div>
|
|
<div class="col-3"><strong>{{$graph->values[0]->rank != 0 ? ($graph->values[0]->rank == 1 ? ($graph->values[0]->score ? ceil(($val->score/$graph->values[0]->score)*100) : 0) : ($graph->values[1]->score ? ceil(($val->score/$graph->values[1]->score)*100) : 0 ) ) : 0 }}% </strong><br />{{round($val->score, 2)}}</div>
|
|
</div>
|
|
@endif
|
|
@php
|
|
$leader_id = $val->user->id;
|
|
@endphp
|
|
@endforeach
|
|
</div> <!-- end collapse-->
|
|
@break
|
|
@case($graph->type == 'simple' && $post['type'] == 'trend' && $graph->chart == 'tabular')
|
|
<div id="cardCollpase4" class="collapse pt-3 show">
|
|
<div class="table-responsive">
|
|
<table class="table table-centered table-nowrap table-borderless mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Periods</th>
|
|
<th>{{$graph->label}}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($graph->values as $i => $val)
|
|
<tr>
|
|
<td>{{$val->x}}</td>
|
|
<td>{{$val->y}}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div> <!-- .table-responsive -->
|
|
</div> <!-- end collapse-->
|
|
@break
|
|
@case($graph->type == 'grouped' && $post['type'] == 'trend' && $graph->chart == 'tabular')
|
|
<div id="cardCollpase4" class="collapse pt-3 show">
|
|
<div class="table-responsive">
|
|
<table class="table table-centered table-nowrap table-borderless mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Periods</th>
|
|
@foreach($graph->values as $met)
|
|
<th>{{$met->metric}}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($graph->values[0]->stats as $i => $stat)
|
|
<tr>
|
|
<td>{{$stat->x}}</td>
|
|
@foreach($graph->values as $met)
|
|
<td>{{isset($met->stats[$i])?$met->stats[$i]->y:0}}</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div> <!-- .table-responsive -->
|
|
</div> <!-- end collapse-->
|
|
@break
|
|
@default
|
|
<div id="chart-{{$graph->id}}" class="mt-0" data-colors="#f1556c"></div>
|
|
@if($post['type'] == 'value' || ($post['type'] == 'graphical' && $graph->chart = 'percentile' && $graph->type == 'simple' ))
|
|
<h5 class="text-muted mt-0">{{ $graph->type == 'simple' ? $graph->label : 'Total ' . $graph->name }}</h5>
|
|
<h2>{{$graph->value}}</h2>
|
|
@endif
|
|
@break
|
|
@endswitch
|
|
|
|
</div>
|
|
</div>
|
|
</div> <!-- end card -->
|
|
<style type="text/css">
|
|
.btn-xs {border-radius: 6px!important;}
|
|
.underline {border-bottom: 2px solid #B9B970;}
|
|
.loader{
|
|
position: absolute;
|
|
height: 100vh;
|
|
width: 100vw;
|
|
z-index: 999;
|
|
background-color: rgba(0,0,0,0.5);
|
|
padding-top: calc(50vh - 24px);
|
|
padding-left: calc(50vw - 24px);
|
|
}
|
|
</style>
|
|
|
|
<!-- end container -->
|
|
@include('layouts.shared/footer-script')
|
|
<!-- third party js -->
|
|
<script src="{{asset('assets/libs/flatpickr/flatpickr.min.js')}}"></script>
|
|
<script src="{{asset('assets/libs/apexcharts/apexcharts.min.js')}}"></script>
|
|
<!-- third party js ends -->
|
|
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
$('.loader').hide()
|
|
$('#period').change(function(){
|
|
let href = new URL(window.location.href);
|
|
href.searchParams.set('period', $(this).val() );
|
|
$('.loader').show()
|
|
window.location.href = href.toString()
|
|
});
|
|
|
|
$('#graph-wrapper a').click(function(event) {
|
|
event.preventDefault();
|
|
$('.loader').show()
|
|
console.log($(this).attr('href'))
|
|
let href = new URL(document.location.origin + $(this).attr('href'));
|
|
href.searchParams.set('period', $('#period').val() );
|
|
window.location.href = href.toString()
|
|
});
|
|
|
|
$('.leaderboard-next').click(function(){
|
|
let href = new URL(window.location.href);
|
|
href.searchParams.set('level', {{$graph->current_level}}-1 );
|
|
window.location.href = href.toString()
|
|
})
|
|
$('.leaderboard-prev').click(function(){
|
|
let href = new URL(window.location.href);
|
|
href.searchParams.set('level', {{$graph->current_level}}+1 );
|
|
window.location.href = href.toString()
|
|
})
|
|
|
|
$('#export').click(function(){
|
|
let href = new URL(window.location.href);
|
|
window.location.href = href.origin + '/form/metricreport' + href.search + '&download=1'
|
|
})
|
|
$('#email-export').click(function(){
|
|
let href = new URL(window.location.href);
|
|
$('.loader').show()
|
|
$.get( href.origin + '/form/metricreport' + href.search + '&download=1&email=1', function( data ) {
|
|
$('.loader').hide()
|
|
$('#graph-wrapper').prepend('<div class="alert alert-success mt-3">Email send Successfully!</div>');
|
|
});
|
|
})
|
|
|
|
let colors = {!!json_encode($colors)!!};
|
|
colors = colors.map(c => '#'+c)
|
|
let options = {}
|
|
let chart = {}
|
|
let values = []
|
|
colors.shift()
|
|
@if($graph->type == 'grouped')
|
|
@switch($post['type'])
|
|
@case('graphical')
|
|
values = {!!json_encode($graph->values)!!}
|
|
@if($post['chart'] == 'pie')
|
|
options = {
|
|
series: values.map(a => a.value),
|
|
chart: {
|
|
width: 500,
|
|
type: 'pie',
|
|
animations: {
|
|
enabled: true,
|
|
easing: 'easeinout',
|
|
speed: 2000,
|
|
}
|
|
},
|
|
labels: values.map(a => a.label),
|
|
responsive: [{
|
|
breakpoint: 480,
|
|
options: {
|
|
chart: {
|
|
width: 380
|
|
},
|
|
legend: {
|
|
position: 'bottom'
|
|
}
|
|
}
|
|
}]
|
|
};
|
|
|
|
@elseif($post['chart'] == 'bar')
|
|
options = {
|
|
series: [{
|
|
name: "{{$graph->label}}",
|
|
data: values.map(a => a.value)
|
|
}],
|
|
chart: {
|
|
height: 350,
|
|
type: '{{$post['chart']}}',
|
|
zoom: {
|
|
enabled: false
|
|
},
|
|
animations: {
|
|
enabled: true,
|
|
easing: 'easeinout',
|
|
speed: 2000,
|
|
}
|
|
},
|
|
dataLabels: {
|
|
enabled: false
|
|
},
|
|
stroke: {
|
|
curve: 'straight'
|
|
},
|
|
|
|
grid: {
|
|
row: {
|
|
colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
|
|
opacity: 0.5
|
|
},
|
|
},
|
|
xaxis: {
|
|
categories: values.map(a => a.label),
|
|
}
|
|
};
|
|
@endif
|
|
|
|
@break
|
|
|
|
@case('trend')
|
|
values = {!!json_encode($graph->values)!!}
|
|
options = {
|
|
series: values.map(m => {
|
|
return {
|
|
name: m.metric,
|
|
data: m.stats.map(a => a.y)
|
|
}
|
|
}),
|
|
// series: [{
|
|
// name: "{{$graph->label}}",
|
|
// data: values.map(a => a.y)
|
|
// }],
|
|
chart: {
|
|
height: 350,
|
|
type: '{{$post['chart']}}',
|
|
zoom: {
|
|
enabled: false
|
|
},
|
|
animations: {
|
|
enabled: true,
|
|
easing: 'easeinout',
|
|
speed: 2000,
|
|
}
|
|
},
|
|
dataLabels: {
|
|
enabled: false
|
|
},
|
|
stroke: {
|
|
curve: 'straight'
|
|
},
|
|
|
|
grid: {
|
|
row: {
|
|
colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
|
|
opacity: 0.5
|
|
},
|
|
},
|
|
xaxis: {
|
|
categories: values[0].stats.map(a => a.x),
|
|
}
|
|
};
|
|
console.log(options)
|
|
@break
|
|
|
|
@endswitch
|
|
|
|
@elseif($graph->type == 'simple')
|
|
@switch($post['type'])
|
|
@case('graphical')
|
|
options = {
|
|
series: [{{ $graph->max > 0 ? ceil(($graph->value/$graph->max)*100) : 0 }}],
|
|
chart: {
|
|
height: 250,
|
|
type: 'radialBar',
|
|
animations: {
|
|
enabled: true,
|
|
easing: 'easeinout',
|
|
speed: 2000,
|
|
}
|
|
},
|
|
plotOptions: {
|
|
radialBar: {
|
|
startAngle: -90,
|
|
endAngle: 270,
|
|
hollow: {
|
|
size: '58%',
|
|
}
|
|
},
|
|
},
|
|
fill: {
|
|
type: 'gradient',
|
|
gradient: {
|
|
shade: 'dark',
|
|
shadeIntensity: 0.15,
|
|
inverseColors: false,
|
|
opacityFrom: 1,
|
|
opacityTo: 1,
|
|
stops: [0, 50, 65, 91]
|
|
},
|
|
},
|
|
stroke: {
|
|
dashArray: 7
|
|
},
|
|
colors: colors,
|
|
labels: ['{{$graph->label}}'],
|
|
};
|
|
@break
|
|
@case('trend')
|
|
values = {!!json_encode($graph->values)!!}
|
|
options = {
|
|
series: [{
|
|
name: "{{$graph->label}}",
|
|
data: values.map(a => a.y)
|
|
}],
|
|
chart: {
|
|
height: 350,
|
|
type: '{{$post['chart']}}',
|
|
zoom: {
|
|
enabled: false
|
|
},
|
|
animations: {
|
|
enabled: true,
|
|
easing: 'easeinout',
|
|
speed: 2000,
|
|
}
|
|
},
|
|
dataLabels: {
|
|
enabled: false
|
|
},
|
|
stroke: {
|
|
curve: 'straight'
|
|
},
|
|
|
|
grid: {
|
|
row: {
|
|
colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
|
|
opacity: 0.5
|
|
},
|
|
},
|
|
xaxis: {
|
|
categories: values.map(a => a.x),
|
|
}
|
|
};
|
|
@break
|
|
|
|
@endswitch
|
|
|
|
|
|
@endif
|
|
chart = new ApexCharts(document.querySelector("#chart-{{$graph->id}}"), options);
|
|
chart.render();
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|
|
|