Rapport-Laravel/resources/views/campaign/report.blade.php

334 lines
19 KiB
PHP

@extends('layouts.vertical', ["page_title"=> "Dashboard", "mode" => $mode ?? "", "demo" => $demo ?? ""])
@section('css')
<!-- third party css -->
<link href="{{asset('assets/libs/flatpickr/flatpickr.min.css')}}" rel="stylesheet" type="text/css" />
<link href="{{asset('assets/libs/selectize/selectize.min.css')}}" rel="stylesheet" type="text/css" />
<!-- third party css end -->
@endsection
@section('content')
<div id="pageloader">
<img src="{{asset('assets/images/loader-large.gif')}}" alt="processing..." />
</div>
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<h4 class="page-title">Campaign Report</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row" id="graph-wrapper">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2"></h4>
<div class="row">
<div class="col-md-8">
<div class="button-list">
<a href="/campaign/report?id={{$post->id}}&type=details&chart=tabular&period=month-0" class="btn {{($post->type == 'details' ) ? 'btn-soft-warning' : 'btn-soft-blue' }} btn-rounded">Details</a>
<a href="/campaign/report?id={{$post->id}}&type=leaderboard&chart=leaderboard&period=month-0" class="btn {{($post->type == 'leaderboard' ) ? 'btn-soft-warning' : 'btn-soft-blue' }} btn-rounded">Leaderboard</a>
<a href="/campaign/report?id={{$post->id}}&type=myteam&chart=myteam&period=month-0" class="btn {{($post->type == 'myteam' ) ? 'btn-soft-warning' : 'btn-soft-blue' }} btn-rounded">My Team</a>
</div>
</div>
<div class="col-4 text-end">
<button class="btn btn-dark btn-xs" id="export">Export</button>
<button class="btn btn-warning btn-xs" id="email-export">Send me Email</button>
</div>
<div class="col-md-8">
</div>
<div class="col-md-4">
<div class="row mb-3">
<label for="period" class="col-6 col-xl-5 col-form-label">Select Period</label>
<div class="col-6 col-xl-7">
<select class="form-control" id="period" name="period">
@foreach($periods as $v)
<option value="{{$v->value}}" {{$post->period == $v->value ? "selected":""}}>{{$v->label}}</option>
@endforeach
<option value="custom-date" {{$post->period == $v->value ? "selected":""}}>Custom Date</option>
</select>
<div class="input-group input-group-sm" id="period-daterange-wrapper">
<input type="text" class="form-control border" id="period-daterange">
<span class="input-group-text bg-blue border-blue text-white" id="custom-date-submit">
<i class="mdi mdi-arrow-right-bold"></i>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="widget-chart text-center" dir="ltr">
@switch(true)
@case($post->type == 'leaderboard')
<div class="btn-group mb-2">
<button type="button" class="btn btn-info leaderboard-prev" {{isset($post->level) && $base_level==$post->level?'disabled':''}}><i class="mdi mdi-play mdi-rotate-180 mdi-18px"></i></button>
<button type="button" class="btn btn-info">Level {{$users[0]->level}}</button>
<button type="button" class="btn btn-info leaderboard-next" {{$users[0]->level==1?'disabled':''}}><i class="mdi mdi-play mdi-18px"></i></button>
</div>
<div id="cardCollpase4" class="collapse pt-3 show">
<div class="table-responsive">
@if(isset($users))
<table class="table table-centered table-nowrap table-borderless mb-0">
<thead class="table-light">
<tr>
<th>Rank</th>
<th colspan="2">User</th>
<th>Employee Code</th>
<th>Zone</th>
<th>Region</th>
<th>Area</th>
<th>Territory</th>
<th>Total Units</th>
<th>Total Points</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td><img src="https://ui-avatars.com/api/?background=FFFFFF&name={{$user->rank}}" class="avatar-md"></td>
<td><img src="{{isset($user->user_info->avatar) ? $user->user_info->avatar : ''}}" class="avatar-sm rounded-circle"></td>
<td>{{ $user->user_info->name }} <br/>{{$user->user_info->designation}}</td>
<td>{{ isset($user->user_info->employee_code) ? $user->user_info->employee_code:''}}</td>
<td>{{ isset($user->user_info->positions->Zone) ? $user->user_info->positions->Zone : '-' }}</td>
<td>{{ isset($user->user_info->positions->Region) ? $user->user_info->positions->Region : '-' }}</td>
<td>{{ isset($user->user_info->positions->Area) ? $user->user_info->positions->Area : '-' }}</td>
<td>{{ isset($user->user_info->positions->Territory) ? $user->user_info->positions->Territory : '-' }}</td>
<td>{{ $user->units }}</td>
<td>{{ $user->total }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div> <!-- .table-responsive -->
</div> <!-- end collapse-->
@break
@case($post->type == 'details')
<div id="cardCollpase4" class="collapse pt-3 show">
<div class="table-responsive">
@if(isset($users))
<table class="table table-centered table-nowrap table-borderless mb-0">
<thead class="table-light">
<tr>
<th colspan="2">User</th>
<th>Employee Code</th>
<th>Zone</th>
<th>Region</th>
<th>Area</th>
<th>Territory</th>
<th>Rank</th>
<th>Total Units</th>
<th>Total Points</th>
@foreach($metrics as $metric)
<th>{{$metric->name}} Units</th>
<th>{{$metric->name}} Points</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td><img src="{{isset($user->user_info->avatar) ? $user->user_info->avatar : ''}}" class="avatar-sm rounded-circle"></td>
<td>{{ $user->user_info->name }} <br/>{{$user->user_info->designation}}</td>
<td>{{ isset($user->user_info->employee_code) ? $user->user_info->employee_code:''}}</td>
<td>{{ isset($user->user_info->positions->Zone) ? $user->user_info->positions->Zone : '-' }}</td>
<td>{{ isset($user->user_info->positions->Region) ? $user->user_info->positions->Region : '-' }}</td>
<td>{{ isset($user->user_info->positions->Area) ? $user->user_info->positions->Area : '-' }}</td>
<td>{{ isset($user->user_info->positions->Territory) ? $user->user_info->positions->Territory : '-' }}</td>
<td>{{ $user->rank }}</td>
<td>{{ $user->units }}</td>
<td>{{ $user->total }}</td>
@foreach($metrics as $metric)
<td>{{ isset($user->metrics->{$metric->id}) ? $user->metrics->{$metric->id} : '-' }}</td>
<td>{{ isset($user->metric_points->{$metric->id}) ? $user->metric_points->{$metric->id} : '-' }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
@endif
</div> <!-- .table-responsive -->
</div> <!-- end collapse-->
@break
@case($post->type == 'myteam')
<div class="btn-group mb-2">
<button type="button" class="btn btn-info leaderboard-prev" {{isset($post->level) && $base_level==$post->level?'disabled':''}}><i class="mdi mdi-play mdi-rotate-180 mdi-18px"></i></button>
<button type="button" class="btn btn-info">Level {{$users[0]->level}}</button>
<button type="button" class="btn btn-info leaderboard-next" {{$users[0]->level==1?'disabled':''}}><i class="mdi mdi-play mdi-18px"></i></button>
</div>
<div id="cardCollpase4" class="collapse pt-3 show">
<div class="table-responsive">
@if(isset($users))
<table class="table table-centered table-nowrap table-borderless mb-0">
<thead class="table-light">
<tr>
<th>Rank</th>
<th colspan="2">User</th>
<th>Employee Code</th>
<th>Zone</th>
<th>Region</th>
<th>Area</th>
<th>Territory</th>
<th>Total Units</th>
<th>Total Points</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td><img src="https://ui-avatars.com/api/?background=FFFFFF&name={{$user->rank}}" class="avatar-md"></td>
<td><img src="{{isset($user->user_info->avatar) ? $user->user_info->avatar : ''}}" class="avatar-sm rounded-circle"></td>
<td>{{ $user->user_info->name }} <br/>{{$user->user_info->designation}}</td>
<td>{{ isset($user->user_info->employee_code) ? $user->user_info->employee_code:''}}</td>
<td>{{ isset($user->user_info->positions->Zone) ? $user->user_info->positions->Zone : '-' }}</td>
<td>{{ isset($user->user_info->positions->Region) ? $user->user_info->positions->Region : '-' }}</td>
<td>{{ isset($user->user_info->positions->Area) ? $user->user_info->positions->Area : '-' }}</td>
<td>{{ isset($user->user_info->positions->Territory) ? $user->user_info->positions->Territory : '-' }}</td>
<td>{{ $user->units }}</td>
<td>{{ $user->total }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div> <!-- .table-responsive -->
</div> <!-- end collapse-->
@break
@endswitch
</div>
</div>
</div> <!-- end card -->
</div> <!-- end col-->
</div>
<!-- end row -->
</div> <!-- container -->
<style type="text/css">
#pageloader {
background: rgba( 255, 255, 255, 0.8 );
display: none;
height: 100%;
position: fixed;
width: 100%;
z-index: 9999;
}
#pageloader img {
left: 50%;
margin-left: -32px;
margin-top: -32px;
position: absolute;
top: 50%;
}
</style>
@endsection
@section('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($){
$('#period-daterange-wrapper').hide()
$('#period').change(function(){
if($(this).val() == 'custom-date') {
$('#period-daterange-wrapper').show()
} else {
$('#period-daterange-wrapper').hide()
$("#pageloader").fadeIn();
let href = new URL(window.location.href);
href.searchParams.delete('refresh')
href.searchParams.set('period', $(this).val() );
window.location.href = href.toString()
}
});
$('#period-daterange').flatpickr({
altInput: true,
mode: "range",
altFormat: "F j, y",
defaultDate: 'today'
});
$('#custom-date-submit').click(function(){
$("#pageloader").fadeIn();
let href = new URL(window.location.href);
href.searchParams.delete('refresh')
href.searchParams.set('period', $('#period').val() );
href.searchParams.set('dates', $('#period-daterange').val().replace(" to ", "--"))
window.location.href = href.toString()
})
$('#graph-wrapper .button-list a').click(function(event) {
event.preventDefault();
$("#pageloader").fadeIn();
console.log($(this).attr('href'))
let href = new URL(document.location.origin + $(this).attr('href'));
href.searchParams.delete('refresh')
href.searchParams.set('period', $('#period').val() );
window.location.href = href.toString()
});
@if($post->type == 'leaderboard' || $post->type == 'myteam')
$('.leaderboard-next').click(function(){
$("#pageloader").fadeIn();
let href = new URL(window.location.href);
href.searchParams.delete('refresh')
href.searchParams.set('level', {{$users[0]->level}}-1 );
window.location.href = href.toString()
})
$('.leaderboard-prev').click(function(){
$("#pageloader").fadeIn();
let href = new URL(window.location.href);
href.searchParams.delete('refresh')
href.searchParams.set('level', {{$users[0]->level}}+1 );
window.location.href = href.toString()
})
@endif
$('#export').click(function(){
let href = new URL(window.location.href);
window.location.href = href.origin + '/campaign/export' + href.search
})
$('#email-export').click(function(){
$("#pageloader").fadeIn();
let href = new URL(window.location.href);
$.get( href.origin + '/campaign/export' + href.search + '&email=1', function( data ) {
$("#pageloader").fadeOut();
alert( "Email has been sent to your email id." );
});
})
$('#refresh-data').click(function(){
$("#pageloader").fadeIn();
window.location.href = '{!! request()->fullUrlWithQuery(['refresh' => true]) !!}'
})
});
</script>
@endsection