statistics

This commit is contained in:
2019-07-01 22:19:04 -05:00
parent ee2068eda5
commit bfebdd2632
3 changed files with 45 additions and 24 deletions

View File

@@ -111,32 +111,35 @@ class SRPAdminController extends Controller
public function displayStatistics() {
$months = 3;
$approved = array();
$denied = array();
$fcLosses = array();
$lava = new Lavacharts;
$ad = new Lavacharts;
//We need a function from this library rather than recreating a new library
$srpHelper = new SRPHelper();
//Get the dates for the tab panes
$dates = $srpHelper->GetTimeFrameInMonths($months);
$dates = $srpHelper->GetTimeFrame($months);
$approved = $srpHelper->GetApprovedValue($dates['start'], $dates['end']);
$denied = $srpHelper->GetDeniedValue($dates['start'], $dates['end']);
//Get the approved requests total by month of the last 3 months
foreach($dates as $date) {
$approved[] = [
'date' => $date['start']->toFormattedDateString(),
'value' => number_format($srpHelper->GetApprovedPaidValue($date['start'], $date['end']), 2, ".", ","),
];
}
$adLava = new Lavacharts;
//Get the denied requests total by month of the last 3 months
foreach($dates as $date) {
$denied[] = [
'date' => $date['start']->toFormattedDateString(),
'value' => number_format($srpHelper->GetDeniedValue($date['start'], $date['end']), 2, ".", ","),
];
}
$ad = $adLava->DataTable();
$ad->addStringColumn('Value');
$ad->addNumberColumn('ISK');
$ad->addRow(['Approved', $approved])
->addRow(['Denied', $denied]);
$adLava->PieChart('Approved / Denied', $ad, [
'title' => 'Approved vs. Denied SRP Values',
'is3D' => true,
'slices' => [
['offset' => 0.25],
['offset' => 0.30],
]
]);
//Create chart for fc losses
$losses = $lava->DataTable();
@@ -151,9 +154,7 @@ class SRPAdminController extends Controller
$lava->BarChart('ISK', $losses);
return view('srp.admin.statistics')->with('approved', $approved)
->with('denied', $denied)
->with('losses', $losses)
->with('lava', $lava);
return view('srp.admin.statistics')->with('lava', $lava)
->with('adLava', $adLava);
}
}

View File

@@ -47,7 +47,7 @@ class SRPHelper {
return $requests;
}
public function GetApprovedPaidValue($start, $end) {
public function GetApprovedValue($start, $end) {
$requests = 0.00;
$requests = SRPShip::where(['approved' => 'Approved'])
@@ -87,6 +87,24 @@ class SRPHelper {
return $requests;
}
public function GetTimeFrame($months) {
$start = Carbon::now()->startOfMonth();
$start->hour = 23;
$start->minute = 59;
$start->second = 59;
$end = Carbon::now()->subMonths($months);
$end->hour = 23;
$end->minute = 59;
$end->second = 59;
$date = [
'start' => $start,
'end' => $end,
];
return $date;
}
/**
* Returns a set of dates from now until the amount of months has passed
*

View File

@@ -1,8 +1,10 @@
@extends('layouts.b4')
@section('content')
@barchart('ISK, 'fc_loss_div')
<div id="poll_div"></div>
{!! $lava->render('BarChart', 'ISK', 'poll_div') !!}
<div id="approved_denied"></div>
{!! Lava::render('PieChart', 'adLava', 'approved_denied') !!}
<div id="FC_Losses"></div>
{!! $lava->render('BarChart', 'ISK', 'FC_Losses') !!}
@endsection