49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Widgets;
|
|
|
|
use Arrilot\Widgets\AbstractWidget;
|
|
use App\Http\Requests\LambdaRequest;
|
|
|
|
class TeamTrendMonthly extends AbstractWidget
|
|
{
|
|
/**
|
|
* The configuration array.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $config = [];
|
|
|
|
/**
|
|
* Treat this method as a controller action.
|
|
* Return view() or other content to display.
|
|
*/
|
|
public function run()
|
|
{
|
|
parse_str($this->config['parameters'], $params);
|
|
$response = LambdaRequest::signedrequest('post', 'metric', 'metric_report/view', $params );
|
|
$colors = ['FECD00', '01C14B', 'FF8050', '4A5CD0', '707070'];
|
|
|
|
$dates = [];
|
|
foreach($response->data->graph->values as $value) {
|
|
$value->table = [];
|
|
foreach($value->stats as $stat) {
|
|
$value->table[$stat->x] = $stat->y;
|
|
$dates[] = $stat->x;
|
|
}
|
|
}
|
|
usort($dates, function($a, $b) {
|
|
return strtotime($a) - strtotime($b);
|
|
});
|
|
$dates = array_unique($dates);
|
|
$tabledata = [];
|
|
foreach($response->data->graph->values as $value) {
|
|
$tabledata[$value->hierarchy_id]['name'] = $value->user->name;
|
|
foreach ($dates as $date) {
|
|
$tabledata[$value->hierarchy_id]['values'][$date] = array_key_exists($date, $value->table) ? $value->table[$date] : '';
|
|
}
|
|
}
|
|
return view('widgets.team_trend_monthly', ['title' => $this->config['title'], 'tabledata' => $tabledata, 'dates' => $dates]);
|
|
}
|
|
}
|