invoiceninja/app/Ninja/Reports/ActivityReport.php

54 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2017-03-23 17:37:22 +02:00
<?php
namespace App\Ninja\Reports;
use App\Models\Activity;
use Auth;
class ActivityReport extends AbstractReport
{
2018-01-21 15:53:43 +02:00
public function getColumns()
{
return [
2018-01-23 20:32:11 +02:00
'date' => [],
'client' => [],
'user' => [],
'activity' => [],
2018-01-21 15:53:43 +02:00
];
}
2017-03-23 17:37:22 +02:00
public function run()
{
$account = Auth::user()->account;
2017-11-23 13:15:50 +02:00
$startDate = $this->startDate;;
$endDate = $this->endDate;
2018-02-27 22:52:57 +02:00
$subgroup = $this->options['subgroup'];
2017-03-23 17:37:22 +02:00
$activities = Activity::scope()
->with('client.contacts', 'user', 'invoice', 'payment', 'credit', 'task', 'expense', 'account')
2017-03-31 09:01:07 +03:00
->whereRaw("DATE(created_at) >= \"{$startDate}\" and DATE(created_at) <= \"$endDate\"")
->orderBy('id', 'desc');
2017-03-23 17:37:22 +02:00
foreach ($activities->get() as $activity) {
$client = $activity->client;
$this->data[] = [
$activity->present()->createdAt,
$client ? ($this->isExport ? $client->getDisplayName() : $client->present()->link) : '',
$activity->present()->user,
2017-11-23 13:15:50 +02:00
$this->isExport ? strip_tags($activity->getMessage()) : $activity->getMessage(),
2017-03-23 17:37:22 +02:00
];
2018-02-27 22:52:57 +02:00
if ($subgroup == 'category') {
$dimension = trans('texts.' . $activity->relatedEntityType());
} else {
$dimension = $this->getDimension($activity);
}
$this->addChartData($dimension, $activity->created_at, 1);
2018-02-27 00:07:08 +02:00
}
2017-03-23 17:37:22 +02:00
2018-02-27 00:07:08 +02:00
//dd($this->getChartData());
2017-03-23 17:37:22 +02:00
}
}